MCPcopy Create free account
hub / github.com/Tencent/phxsql / InitCheckPointDataFile

Method InitCheckPointDataFile

phxbinlogsvr/core/storage/event_storage.cpp:94–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94int EventStorage::InitCheckPointDataFile(const string &checkpointfile) {
95 if (checkpointfile.size() == 0) {
96 event_file_manager_->SwitchNewWriteFile(0);
97 return 0;
98 }
99 EventDataInfo info;
100 info.set_file_name(checkpointfile);
101 info.set_offset(0);
102
103 int ret = event_file_manager_->SetReadPos(info);
104 if (ret) {
105 return ret;
106 }
107
108 vector < pair<string, EventDataInfo> > data_list;
109 int num = 0;
110 LockManager lock(&mutex_);
111 checkpoint_data_.clear();
112 EventDataInfo last_data_info;
113 EventDataInfo last_info;
114 while (true) {
115 EventDataInfo data_info;
116 EventData data;
117 int ret = event_file_manager_->ReadData(&data, &data_info);
118 data_list.push_back(make_pair(data.gtid(), data_info));
119 if (ret) {
120 ColorLogInfo("%s read done gtid %s read offset %u file offset %u ", __func__,
121 last_data_info.gtid().c_str(), last_data_info.offset(), data_info.offset());
122 if (last_data_info.offset() == 0) {
123 if (ret == DATA_EMPTY) {
124 //only header exists
125 event_file_manager_->SetWritePos(data_info, true);
126 } else {
127 return ret;
128 }
129 } else {
130 event_file_manager_->SetWritePos(last_data_info, true);
131 }
132 break;
133 }
134 ++num;
135 if (ret == OK) {
136 if (last_data_info.gtid().size()) {
137 checkpoint_data_[last_data_info.gtid()] = last_data_info;
138 }
139 last_data_info = data_info;
140 continue;
141 }
142 return ret;
143 }
144
145 ColorLogInfo("%s get check point data size %zu, real size %u, set last gtid %s, gtid size %zu", __func__,
146 checkpoint_data_.size(), num, last_data_info.gtid().c_str(), data_list.size());
147
148 return OK;
149}
150
151int EventStorage::LoadFromCheckPoint(const EventData &checkpoint_data, const string &checkpoint_file) {

Callers

nothing calls this directly

Calls 5

ColorLogInfoFunction · 0.85
SwitchNewWriteFileMethod · 0.80
SetReadPosMethod · 0.80
SetWritePosMethod · 0.80
ReadDataMethod · 0.45

Tested by

no test coverage detected