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

Adjust meta client ctor && implement heartbeat logic inside. #379

Closed
wants to merge 2 commits into from
Closed

Conversation

dangleptr
Copy link
Contributor

@dangleptr dangleptr commented May 15, 2019

  1. Force meta client to reuse IOThreadPool outside.
  2. Move meta_server_addrs flag outside, so we don't check the flag in MetaClient ctor any more.
  3. Implement heartbeat logic.

Subtask of #283

@dangleptr dangleptr requested review from laura-ding, dutor and darionyaphet and removed request for laura-ding and dutor May 15, 2019 05:32
@dangleptr dangleptr added the ready-for-testing PR: ready for the CI test label May 15, 2019
@dangleptr
Copy link
Contributor Author

Jenkins go

@nebula-community-bot
Copy link
Member

Unit testing passed.

mClient->init();
auto r = mClient->addHosts({HostAddr(localIp, localDataPort)}).get();

auto r = mClient->addHosts({HostAddr(localIp, localDataPort)}).get();
Copy link
Contributor

Choose a reason for hiding this comment

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

alignment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch

LOG(ERROR) << "meta_server_addrs flag should be set!";
return -1;
}
auto ioThreadPool = std::make_shared<folly::IOThreadPoolExecutor>(FLAGS_io_handlers);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we share the same pool with the hosting service?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hosting service? If it means the thrift service, yes of course. Please note line 143.

@@ -114,7 +125,10 @@ int main(int argc, char *argv[]) {

auto handler = std::make_shared<StorageServiceHandler>(kvstore.get(), std::move(schemaMan));
gServer = std::make_unique<apache::thrift::ThriftServer>();
CHECK(!!gServer) << "Failed to create the thrift server";
if (!!gServer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

By default, make_unique could never return a nullptr, instead it will throw bad_alloc on memory allocation failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your reminding. Good point. 👍

DEFINE_string(meta_server_addrs, "", "list of meta server addresses,"
"the format looks like ip1:port1, ip2:port2, ip3:port3");
DEFINE_int32(meta_client_io_threads, 3, "meta client io threads");
DEFINE_int32(heartbeat_interval_sec, 10, "Heartbeat interval, unit: second");
Copy link
Contributor

Choose a reason for hiding this comment

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

secs or seconds? Maybe we should unify them, e.g. the above line.

req.set_host(std::move(thriftHost));
return getResponse(std::move(req), [] (auto client, auto request) {
return client->future_heartBeat(request);
}, [] (cpp2::HBResp&& resp) -> decltype(auto) {
Copy link
Contributor

@dutor dutor May 15, 2019

Choose a reason for hiding this comment

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

FYI. I sincerely suggest not to use decltype(auto) if not necessary while auto suffices, because you may return a reference to local storage by accident. Consider this:

decltype(auto) get() {
    int var = 0;
    int &ref = var;
    return ref;
    // or return (var);
    // or return (var &= 0xF)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. We should be careful about it.

@dangleptr
Copy link
Contributor Author

Please refer #383

@dangleptr dangleptr closed this May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants