MCPcopy Create free account
hub / github.com/OpenAtomFoundation/pikiwidb / HandleMetaRsyncRequest

Method HandleMetaRsyncRequest

src/rsync_server.cc:114–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void RsyncServerConn::HandleMetaRsyncRequest(void* arg) {
115 std::unique_ptr<RsyncServerTaskArg> task_arg(static_cast<RsyncServerTaskArg*>(arg));
116 const std::shared_ptr<RsyncService::RsyncRequest> req = task_arg->req;
117 std::shared_ptr<net::PbConn> conn = task_arg->conn;
118 std::string db_name = req->db_name();
119 std::shared_ptr<DB> db = g_pika_server->GetDB(db_name);
120
121 RsyncService::RsyncResponse response;
122 response.set_reader_index(req->reader_index());
123 response.set_code(RsyncService::kOk);
124 response.set_type(RsyncService::kRsyncMeta);
125 response.set_db_name(db_name);
126 /*
127 * Since the slot field is written in protobuffer,
128 * slot_id is set to the default value 0 for compatibility
129 * with older versions, but slot_id is not used
130 */
131 response.set_slot_id(0);
132
133 std::string snapshot_uuid;
134 if (!db || db->IsBgSaving()) {
135 LOG(WARNING) << "waiting bgsave done...";
136 response.set_snapshot_uuid(snapshot_uuid);
137 response.set_code(RsyncService::kErr);
138 RsyncWriteResp(response, conn);
139 return;
140 }
141
142 std::vector<std::string> filenames;
143 g_pika_server->GetDumpMeta(db_name, &filenames, &snapshot_uuid);
144 response.set_snapshot_uuid(snapshot_uuid);
145
146 LOG(INFO) << "Rsync Meta request, snapshot_uuid: " << snapshot_uuid
147 << " files count: " << filenames.size() << " file list: ";
148 std::for_each(filenames.begin(), filenames.end(), [](auto& file) {
149 LOG(INFO) << "rsync snapshot file: " << file;
150 });
151
152 RsyncService::MetaResponse* meta_resp = response.mutable_meta_resp();
153 for (const auto& filename : filenames) {
154 meta_resp->add_filenames(filename);
155 }
156 RsyncWriteResp(response, conn);
157}
158
159void RsyncServerConn::HandleFileRsyncRequest(void* arg) {
160 std::unique_ptr<RsyncServerTaskArg> task_arg(static_cast<RsyncServerTaskArg*>(arg));

Callers

nothing calls this directly

Calls 6

RsyncWriteRespFunction · 0.70
db_nameMethod · 0.45
GetDBMethod · 0.45
IsBgSavingMethod · 0.45
GetDumpMetaMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected