Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add notifyStop() for metaClient #3621

Merged
merged 4 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}

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