Skip to content

Commit

Permalink
feat: add zookeeper client config resolve_delay_ms
Browse files Browse the repository at this point in the history
  • Loading branch information
GehaFearless committed Aug 4, 2022
1 parent b57669e commit 6d2c1e0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/rdsn/src/zookeeper/zookeeper_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
}
dassert(_handle != nullptr, "zookeeper session init failed");
}
int ret = zoo_set_servers_resolution_delay(_handle, zookeeper_session_mgr::instance().resolve_delay_ms());
dassert(ret == ZOK, "zookeeper set resolve_delay_ms failed.");

_watchers.push_back(watcher_object());
_watchers.back().watcher_path = "";
Expand Down
2 changes: 2 additions & 0 deletions src/rdsn/src/zookeeper/zookeeper_session_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ zookeeper_session_mgr::zookeeper_session_mgr()
_timeout_ms = dsn_config_get_value_uint64(
"zookeeper", "timeout_ms", 30000, "zookeeper_timeout_milliseconds");
_zoo_logfile = dsn_config_get_value_string("zookeeper", "logfile", "", "zookeeper logfile");
_resolve_delay_ms = dsn_config_get_value_uint64(
"zookeeper", "resolve_delay_ms", 0, "zookeeper_resolve_delay_ms");

FILE *fp = fopen(_zoo_logfile.c_str(), "a");
if (fp != nullptr)
Expand Down
2 changes: 2 additions & 0 deletions src/rdsn/src/zookeeper/zookeeper_session_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class zookeeper_session_mgr : public utils::singleton<zookeeper_session_mgr>
const char *zoo_hosts() const { return _zoo_hosts.c_str(); }
int timeout() const { return _timeout_ms; }
const char *zoo_logfile() const { return _zoo_logfile.c_str(); }
int resolve_delay_ms() const { return _resolve_delay_ms; }

private:
zookeeper_session_mgr();
Expand All @@ -59,6 +60,7 @@ class zookeeper_session_mgr : public utils::singleton<zookeeper_session_mgr>
std::string _zoo_hosts;
int _timeout_ms;
std::string _zoo_logfile;
int _resolve_delay_ms;

friend class utils::singleton<zookeeper_session_mgr>;
};
Expand Down
1 change: 1 addition & 0 deletions src/server/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@
hosts_list = %{zk.server.list}
timeout_ms = 10000
logfile = zoo.log
resolve_delay_ms = 0

[task..default]
is_trace = false
Expand Down

0 comments on commit 6d2c1e0

Please sign in to comment.