Skip to content

Commit

Permalink
default add hosts for standalone version (#4129)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperYoko authored and Sophie-Xie committed Apr 11, 2022
1 parent 073dafd commit 1cb6fb8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/storage/StorageServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ DEFINE_bool(local_config, false, "meta client will not retrieve latest configura
DEFINE_int32(storage_port, 44501, "Storage daemon listening port");
DEFINE_int32(storage_num_worker_threads, 32, "Number of workers");
DECLARE_bool(local_config);
DEFINE_bool(add_local_host, true, "Whether add localhost automatically");
DECLARE_string(local_ip);
#endif
DEFINE_bool(storage_kv_mode, false, "True for kv mode");
DEFINE_int32(num_io_threads, 16, "Number of IO threads");
Expand Down Expand Up @@ -168,6 +170,28 @@ bool StorageServer::start() {
options.dataPaths_ = dataPaths_;

metaClient_ = std::make_unique<meta::MetaClient>(ioThreadPool_, metaAddrs_, options);

#ifdef BUILD_STANDALONE
if (FLAGS_add_local_host) {
std::vector<HostAddr> hosts = {{FLAGS_local_ip, FLAGS_storage_port}};
folly::Baton<> baton;
bool isAdded = false;
metaClient_->addHosts(hosts).thenValue([&isAdded, &baton](StatusOr<bool> resp) {
if (!resp.ok() || !resp.value()) {
LOG(ERROR) << "Add hosts for standalone failed.";
} else {
LOG(INFO) << "Add hosts for standalone succeed.";
isAdded = true;
}
baton.post();
});
baton.wait();
if (!isAdded) {
return false;
}
}
#endif

if (!metaClient_->waitForMetadReady()) {
LOG(ERROR) << "waitForMetadReady error!";
return false;
Expand Down
1 change: 1 addition & 0 deletions tests/common/nebula_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def _make_sa_params(self, **kwargs):
self.graphd_param['password_lock_time_in_secs'] = '10'
self.graphd_param['raft_heartbeat_interval_secs'] = '30'
self.graphd_param['skip_wait_in_rate_limiter'] = 'true'
self.graphd_param['add_local_host'] = 'false'
for p in [self.metad_param, self.storaged_param, self.graphd_param]:
p.update(kwargs)

Expand Down

0 comments on commit 1cb6fb8

Please sign in to comment.