Skip to content

Commit 3aa45c6

Browse files
添加log日志组成形式说明
1 parent cd7b8ef commit 3aa45c6

File tree

5 files changed

+59
-37
lines changed

5 files changed

+59
-37
lines changed

demo/test.cpp

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,50 @@
3131
using namespace std;
3232

3333

34-
#include <iostream>
35-
#include <fstream>
36-
#include <filesystem>
37-
#include <string>
34+
struct ConsumptionOffset {
35+
std::map<TopicName, std::map<PatitionNo, Offset>> consumeOffsets; // 单个消费者组偏移量信息
36+
};
37+
38+
struct ConsumerInfo {
39+
std::map<TopicName, std::vector<partitionNo>> consumerTopics; // 消费主题信息
40+
uint64_t arbVersion; //< 消费者仲裁版本号
41+
}
3842

39-
enum class MyEnum : int32_t {
40-
VALUE1,
41-
VALUE2,
42-
VALUE3
43+
struct ConsumerCoordinatorInfo {
44+
std::map<ConsumerInstanceId, ConsumerInfo> consumerCoordinatorResults; //< 消费协调结果
4345
};
4446

47+
class ConsumerCoordinator {
48+
public:
49+
ConsumerCoordinator(std::string &groupId, ConsumerCoordinatorInfo &consumerCoordinatorInfo) {}
50+
// 新增消费者
51+
int32_t AddConsumer();
52+
// 减少消费者
53+
int32_t DeleteConsumer();
54+
// 网络中断
55+
int32_t NetworkDisconnected();
4556

4657

47-
void Show(int32_t data) {}
4858

49-
int main() {
59+
private:
60+
std::string m_groupId; //< 消费者组 uuid
61+
ConsumerCoordinatorInfo m_consumerInfo; //< 消费者实例id <==> 消费者实例消费分配方案
5062

51-
std::vector<char> data;
63+
};
64+
65+
66+
class ConsumerCoordinatorOffsetMng {
67+
public:
68+
uint64_t GetOffset(std::string& groupId, std::string& topicName, int32_t partitionNo) { }
69+
70+
private:
71+
std::map<GroupId, ConsumptionOffset> m_consumerrCoordinatorOffset; //< GroupId <==> ConsumerCoordinatorOffset
72+
};
5273

53-
data.reserve(1000);
54-
data.insert(data.end(),)
5574

5675

76+
int main() {
5777

5878

59-
std::cout << "All files moved successfully." << std::endl;
6079
return 0;
6180
}

doc/db/table_format.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ the BlockHandle of the metaindex and index blocks as well as a magic number.
7474
// (40==2*BlockHandle::kMaxEncodedLength)
7575
magic: fixed64; // == 0xdb4775248b80fb57 (little-endian)
7676

77-
## "filter" Meta Block
77+
=== "filter" Meta Block
7878

7979
If a `FilterPolicy` was specified when the database was opened, a
80-
filter block is stored in each table. The "metaindex" block contains
80+
filter block is stored in each table.The "metaindex" block contains
8181
an entry that maps from `filter.<N>` to the BlockHandle for the filter
8282
block where `<N>` is the string returned by the filter policy's
8383
`Name()` method.
@@ -88,7 +88,7 @@ in a block whose file offset falls within the range
8888

8989
[ i*base ... (i+1)*base-1 ]
9090

91-
Currently, "base" is 2KB. So for example, if blocks X and Y start in
91+
Currently, "base" is 2KB.So for example, if blocks X and Y start in
9292
the range `[ 0KB .. 2KB-1 ]`, all of the keys in X and Y will be
9393
converted to a filter by calling `FilterPolicy::CreateFilter()`, and the
9494
resulting filter will be stored as the first filter in the filter
@@ -114,10 +114,10 @@ The filter block is formatted as follows:
114114
The offset array at the end of the filter block allows efficient
115115
mapping from a data block offset to the corresponding filter.
116116

117-
## "stats" Meta Block
117+
=== "stats" Meta Block
118118

119-
This meta block contains a bunch of stats. The key is the name
120-
of the statistic. The value contains the statistic.
119+
This meta block contains a bunch of stats.The key is the name
120+
of the statistic.The value contains the statistic.
121121

122122
TODO(postrelease): record following stats.
123123

doc/instruction/readme.adoc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -227,21 +227,14 @@ db->Put(write_options, ...);
227227

228228
=== 并发
229229

230-
A database may only be opened by one process at a time. The leveldb
231-
implementation acquires a lock from the operating system to prevent misuse.
232-
Within a single process, the same `leveldb::DB` object may be safely shared by
233-
multiple concurrent threads. I.e., different threads may write into or fetch
234-
iterators or call Get on the same database without any external synchronization
235-
(the leveldb implementation will automatically do the required synchronization).
236-
However other objects (like Iterator and `WriteBatch`) may require external
237-
synchronization. If two threads share such an object, they must protect access
238-
to it using their own locking protocol. More details are available in the public
239-
header files.
230+
一个数据库在同一时刻只能被一个进程打开。LevelDB 通过从操作系统获取锁来防止误用。
231+
在单个进程中,同一个 `leveldb::DB` 对象可以被多个并发线程安全地共享。也就是说,不同的线程可以无需任何外部同步(LevelDB 实现将自动完成所需同步)地对同一数据库进行写入、获取迭代器或调用 Get 方法。
232+
233+
然而,其他对象(如 Iterator 和 `WriteBatch`)可能需要外部同步。如果两个线程共享这样的对象,它们必须使用自己的锁定协议来保护对该对象的访问。更多详情可在公共头文件中找到。
240234

241235
=== Iteration
242236

243-
The following example demonstrates how to print all key,value pairs in a
244-
database.
237+
下面的示例演示了如何使用迭代器打印数据库中所有的key和value
245238

246239
```c++
247240
leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions());
@@ -619,3 +612,14 @@ documents:
619612
2. [Format of an immutable Table file](table_format.md)
620613
3. [Format of a log file](log_format.md)
621614

615+
616+
617+
1. 消费组中消费实例的加入和退出
618+
2. 消费者协调器对消费实例主题分区的动态调整
619+
3. 消费偏移量的管理
620+
4. mc集群成员的变更处理
621+
622+
623+
624+
625+

doc/persistence/log_format.adoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ ifndef::rootpath[]
2323
endif::rootpath[]
2424

2525

26+
== leveldb Log format
2627

27-
leveldb Log format
28-
==================
2928
The log file contents are a sequence of 32KB blocks. The only exception is that
3029
the tail of the file may contain a partial block.
3130

@@ -80,7 +79,7 @@ bytes free in the third block, which will be left empty as the trailer.
8079

8180

8281

83-
## Some benefits over the recordio format:
82+
=== Some benefits over the recordio format:
8483

8584
1. We do not need any heuristics for resyncing - just go to next block boundary
8685
and scan. If there is a corruption, skip to the next block. As a
@@ -92,7 +91,7 @@ bytes free in the third block, which will be left empty as the trailer.
9291

9392
3. We do not need extra buffering for large records.
9493

95-
## Some downsides compared to recordio format:
94+
=== Some downsides compared to recordio format:
9695

9796
1. No packing of tiny records. This could be fixed by adding a new record type,
9897
so it is a shortcoming of the current implementation, not necessarily the

doc/utils/c++_common_knowledge.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct sql {
5959
aligned_storage是C++标准库中的一个模板类,定义在<type_traits>头文件中。它提供了一种用于按照指定对齐要求分配内存的机制。
6060

6161
aligned_storage模板类的定义如下:
62-
[souece, cpp]
62+
[source, cpp]
6363
----
6464
template <std::size_t Len, std::size_t Align>
6565
struct aligned_storage;

0 commit comments

Comments
 (0)