Skip to content

Commit

Permalink
add notifyStop() for metaClient
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyu85cn committed Jan 4, 2022
1 parent fb0fb5f commit ad46f18
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ MetaClient::MetaClient(std::shared_ptr<folly::IOThreadPoolExecutor> ioThreadPool
}

MetaClient::~MetaClient() {
notifyStop();
stop();
delete sessionMap_.load();
delete killedPlans_.load();
Expand Down Expand Up @@ -142,13 +143,18 @@ bool MetaClient::waitForMetadReady(int count, int retryIntervalSecs) {
return ready_;
}

void MetaClient::stop() {
void MetaClient::notifyStop() {
if (bgThread_ != nullptr) {
bgThread_->stop();
}
isRunning_ = false;
}

void MetaClient::stop() {
if (bgThread_ != nullptr) {
bgThread_->wait();
bgThread_.reset();
}
isRunning_ = false;
}

void MetaClient::heartBeatThreadFunc() {
Expand Down
2 changes: 2 additions & 0 deletions src/clients/meta/MetaClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ class MetaClient {

bool waitForMetadReady(int count = -1, int retryIntervalSecs = FLAGS_heartbeat_interval_secs);

void notifyStop();

void stop();

void registerListener(MetaChangedListener* listener) {
Expand Down
2 changes: 2 additions & 0 deletions src/mock/MockCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ class MockCluster {

void stop() {
if (metaClient_) {
metaClient_->notifyStop();
metaClient_->stop();
}
if (lMetaClient_) {
metaClient_->notifyStop();
lMetaClient_->stop();
}
if (metaKV_) {
Expand Down
6 changes: 5 additions & 1 deletion src/storage/StorageServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ void StorageServer::notifyStop() {
serverStatus_ = STATUS_STOPPED;
cvStop_.notify_one();
}
if (metaClient_) {
metaClient_->notifyStop();
}
}

void StorageServer::stop() {
Expand Down Expand Up @@ -396,7 +399,8 @@ void StorageServer::stop() {
taskMgr_->shutdown();
}
if (metaClient_) {
metaClient_->stop();
metaClient_->notifyStop();
// metaClient_->stop();
}
if (kvstore_) {
kvstore_.reset();
Expand Down
1 change: 1 addition & 0 deletions src/tools/storage-perf/StoragePerfTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class Perf {
t.join();
}

mClient_->notifyStop();
mClient_->stop();
threadPool_->stop();
LOG(INFO) << "Total time cost " << duration.elapsedInMSec() << "ms, "
Expand Down

0 comments on commit ad46f18

Please sign in to comment.