Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyu85cn committed Aug 24, 2021
1 parent 3bf4802 commit 3389c8a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,6 @@ void MetaClient::getResponse(Request req,
auto&& resp = t.value();
if (resp.get_code() == nebula::cpp2::ErrorCode::SUCCEEDED) {
// succeeded
lastHeartBeatTime_ = time::TimeUtils::utcDateTime();
LOG(INFO) << "utcDateTime() : " << lastHeartBeatTime_.toString();
pro.setValue(respGen(std::move(resp)));
return;
} else if (resp.get_code() == nebula::cpp2::ErrorCode::E_LEADER_CHANGED) {
Expand Down Expand Up @@ -2325,6 +2323,7 @@ folly::Future<StatusOr<bool>> MetaClient::heartbeat() {
LOG(FATAL) << "Can't persist the clusterId in file " << FLAGS_cluster_id_path;
}
}
heartBeatTime_ = time::WallClock::fastNowInMilliSec();
metadLastUpdateTime_ = resp.get_last_update_time_in_ms();
VLOG(1) << "Metad last update time: " << metadLastUpdateTime_;
return true; // resp.code == nebula::cpp2::ErrorCode::SUCCEEDED
Expand Down
4 changes: 2 additions & 2 deletions src/clients/meta/MetaClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ class MetaClient {

HostAddr getMetaLeader() { return leader_; }

DateTime getLastHeartBeatTime() { return lastHeartBeatTime_; }
int64_t HeartBeatTime() { return heartBeatTime_; }

protected:
// Return true if load succeeded.
Expand Down Expand Up @@ -742,7 +742,7 @@ class MetaClient {
bool skipConfig_ = false;
MetaClientOptions options_;
std::vector<HostAddr> storageHosts_;
DateTime lastHeartBeatTime_;
int64_t heartBeatTime_;
};

} // namespace meta
Expand Down
10 changes: 6 additions & 4 deletions src/graph/executor/admin/ShowMetaLeaderExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ namespace graph {
folly::Future<Status> ShowMetaLeaderExecutor::execute() {
SCOPED_TIMER(&execTime_);
auto metaLeader = qctx()->getMetaClient()->getMetaLeader();
auto lastHeartBeatTime = qctx()->getMetaClient()->getLastHeartBeatTime();
auto localTime = time::TimeUtils::utcToDateTime(lastHeartBeatTime);
DataSet ds({"Meta Leader", "Last success heartbeat"});
nebula::Row r({metaLeader.toString(), localTime});
auto now = time::WallClock::fastNowInMilliSec();
auto lastHeartBeatTime = qctx()->getMetaClient()->HeartBeatTime();
auto intervalMs = now - lastHeartBeatTime;
DataSet ds({"Meta Leader", "secs from last heart beat"});
auto strLeader = folly::sformat("{}:{}", metaLeader.host, metaLeader.port);
nebula::Row r({std::move(strLeader), intervalMs / 1000});
ds.emplace_back(std::move(r));
finish(ds);
return Status::OK();
Expand Down

0 comments on commit 3389c8a

Please sign in to comment.