Skip to content

Commit

Permalink
add notifyStop() for metaClient (#3621)
Browse files Browse the repository at this point in the history
* add notifyStop() for metaClient

* do clean
  • Loading branch information
liuyu85cn committed Jan 6, 2022
1 parent fd3f925 commit 848d50f
Show file tree
Hide file tree
Showing 5 changed files with 17 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 @@ -240,6 +240,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 @@ -95,9 +95,11 @@ class MockCluster {

void stop() {
if (metaClient_) {
metaClient_->notifyStop();
metaClient_->stop();
}
if (lMetaClient_) {
metaClient_->notifyStop();
lMetaClient_->stop();
}
if (metaKV_) {
Expand Down
5 changes: 4 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,7 @@ void StorageServer::stop() {
taskMgr_->shutdown();
}
if (metaClient_) {
metaClient_->stop();
metaClient_->notifyStop();
}
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 848d50f

Please sign in to comment.