MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / getStatus

Method getStatus

src/Databases/DatabaseReplicated.cpp:246–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246void DatabaseReplicated::getStatus(ReplicatedStatus & response, const bool with_zk_fields) const
247{
248 auto component_guard = Coordination::setCurrentComponent("DatabaseReplicated::getStatus");
249 auto zookeeper = getZooKeeper();
250
251 response.is_readonly = is_readonly;
252 response.is_session_expired = !zookeeper || zookeeper->expired();
253 response.max_log_ptr = 0;
254
255 response.replica_name = replica_name;
256 response.replica_path = replica_path;
257 response.shard_name = shard_name;
258 response.zookeeper_path = zookeeper_path;
259
260 response.total_replicas = 0;
261
262 if (!with_zk_fields || response.is_session_expired)
263 return;
264
265 try
266 {
267 std::vector<std::string> paths;
268
269 paths.push_back(zookeeper_path + "/max_log_ptr");
270 paths.push_back(fs::path(replica_path) / "log_ptr");
271
272 auto get_result = zookeeper->tryGet(paths);
273 chassert(get_result.size() == paths.size());
274
275 const auto & max_log_pointer_str = get_result[0].data;
276 if (get_result[0].error == Coordination::Error::ZNONODE)
277 throw zkutil::KeeperException(get_result[0].error);
278
279 response.max_log_ptr = max_log_pointer_str.empty() ? 0 : parse<UInt32>(max_log_pointer_str);
280
281 const auto & log_ptr_str = get_result[1].data;
282 if (get_result[1].error == Coordination::Error::ZNONODE)
283 throw zkutil::KeeperException(get_result[1].error);
284
285 response.log_ptr = log_ptr_str.empty() ? 0 : parse<UInt32>(log_ptr_str);
286
287 paths.clear();
288
289 const Strings all_replicas = zookeeper->getChildren(fs::path(zookeeper_path) / "replicas");
290 response.total_replicas = static_cast<UInt32>(all_replicas.size());
291 }
292 catch (const Coordination::Exception &)
293 {
294 response.zookeeper_exception = getCurrentExceptionMessage(false);
295 }
296}
297
298String DatabaseReplicated::getFullReplicaName() const
299{

Callers 15

assertResponseIsOkFunction · 0.45
fetchGCPOAuthTokenFunction · 0.45
getUriAfterRedirectFunction · 0.45
callWithRedirectsMethod · 0.45
initializeMethod · 0.45
readBigAtMethod · 0.45
parseFileInfoMethod · 0.45
requestBearerTokenMethod · 0.45

Calls 10

setCurrentComponentFunction · 0.85
KeeperExceptionClass · 0.85
expiredMethod · 0.45
push_backMethod · 0.45
tryGetMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45
getChildrenMethod · 0.45

Tested by

no test coverage detected