-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
Jenkins go |
Unit testing passed. |
mClient->init(); | ||
auto r = mClient->addHosts({HostAddr(localIp, localDataPort)}).get(); | ||
|
||
auto r = mClient->addHosts({HostAddr(localIp, localDataPort)}).get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alignment
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)
}
There was a problem hiding this comment.
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.
Please refer #383 |
Subtask of #283