Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Huang Wei committed Dec 5, 2023
1 parent 5eb5d6c commit d4341ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
17 changes: 8 additions & 9 deletions src/zk/zk_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ void ItemWatcher(zhandle_t* zh, int type, int state, const char* path, void* wat
}

ZkClient::ZkClient(const std::string& hosts, const std::string& real_endpoint, int32_t session_timeout,
const std::string& endpoint, const std::string& zk_root_path,
const std::string& auth_schema, const std::string& cert)
const std::string& endpoint, const std::string& zk_root_path, const std::string& auth_schema,
const std::string& cert)
: hosts_(hosts),
session_timeout_(session_timeout),
endpoint_(endpoint),
Expand All @@ -92,8 +92,8 @@ ZkClient::ZkClient(const std::string& hosts, const std::string& real_endpoint, i
}

ZkClient::ZkClient(const std::string& hosts, int32_t session_timeout, const std::string& endpoint,
const std::string& zk_root_path, const std::string& zone_path,
const std::string& auth_schema, const std::string& cert)
const std::string& zk_root_path, const std::string& zone_path, const std::string& auth_schema,
const std::string& cert)
: hosts_(hosts),
session_timeout_(session_timeout),
endpoint_(endpoint),
Expand Down Expand Up @@ -296,8 +296,7 @@ bool ZkClient::CreateNode(const std::string& node, const std::string& value, int
}
uint32_t size = node.size() + 11;
char path_buffer[size]; // NOLINT
int ret =
zoo_create(zk_, node.c_str(), value.c_str(), value.size(), &acl_vector_, flags, path_buffer, size);
int ret = zoo_create(zk_, node.c_str(), value.c_str(), value.size(), &acl_vector_, flags, path_buffer, size);
if (ret == ZOK) {
assigned_path_name.assign(path_buffer, size - 1);
PDLOG(INFO, "create node %s ok and real node name %s", node.c_str(), assigned_path_name.c_str());
Expand Down Expand Up @@ -583,8 +582,8 @@ void ZkClient::LogEvent(int type, int state, const char* path) {
if (type == ZOO_SESSION_EVENT) {
if (state == ZOO_CONNECTED_STATE) {
Connected();
} else if(state == ZOO_CONNECTING_STATE || state == ZOO_ASSOCIATING_STATE) {
//just wait
} else if (state == ZOO_CONNECTING_STATE || state == ZOO_ASSOCIATING_STATE) {

Check warning on line 585 in src/zk/zk_client.cc

View check run for this annotation

Codecov / codecov/patch

src/zk/zk_client.cc#L585

Added line #L585 was not covered by tests
// just wait
} else if (state == ZOO_EXPIRED_SESSION_STATE) {
connected_ = false;
} else {
Expand Down Expand Up @@ -635,7 +634,7 @@ bool ZkClient::Mkdir(const std::string& path) {
return MkdirNoLock(path);
}

bool ZkClient::EnsureConnected() {
bool ZkClient::EnsureConnected() {
if (!IsConnected()) {
LOG(WARNING) << "reconnect zk";
if (Reconnect()) {
Expand Down
16 changes: 8 additions & 8 deletions src/zk/zk_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class ZkClient {
// session_timeout, the session timeout
// endpoint, the client endpoint
ZkClient(const std::string& hosts, const std::string& real_endpoint, int32_t session_timeout,
const std::string& endpoint, const std::string& zk_root_path,
const std::string& auth_schema, const std::string& cert);
const std::string& endpoint, const std::string& zk_root_path, const std::string& auth_schema,
const std::string& cert);

ZkClient(const std::string& hosts, int32_t session_timeout, const std::string& endpoint,
const std::string& zk_root_path, const std::string& zone_path,
const std::string& auth_schema, const std::string& cert);
const std::string& zk_root_path, const std::string& zone_path, const std::string& auth_schema,
const std::string& cert);
~ZkClient();

// init zookeeper connections
Expand Down Expand Up @@ -138,10 +138,10 @@ class ZkClient {
// when reconnect, need Register and Watchnodes again
bool Reconnect();

// ensure that zk client is connected:
// if not, try to reconnect, return false if reconnect failed
// DON'T use zk client if this function return false
bool EnsureConnected();
// ensure that zk client is connected:
// if not, try to reconnect, return false if reconnect failed
// DON'T use zk client if this function return false
bool EnsureConnected();

private:
void Connected();
Expand Down

0 comments on commit d4341ab

Please sign in to comment.