Merge pull request #9961 from ClickHouse/fix_zookeeper_implementation

Fix bug with wrong implementation in ZooKeeper API
This commit is contained in:
alexey-milovidov 2020-03-31 23:08:11 +03:00 committed by GitHub
commit 576936f4e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -45,7 +45,7 @@ static void check(int32_t code, const std::string & path)
} }
void ZooKeeper::init(const std::string & implementation, const std::string & hosts_, const std::string & identity_, void ZooKeeper::init(const std::string & implementation_, const std::string & hosts_, const std::string & identity_,
int32_t session_timeout_ms_, int32_t operation_timeout_ms_, const std::string & chroot_) int32_t session_timeout_ms_, int32_t operation_timeout_ms_, const std::string & chroot_)
{ {
log = &Logger::get("ZooKeeper"); log = &Logger::get("ZooKeeper");
@ -54,6 +54,7 @@ void ZooKeeper::init(const std::string & implementation, const std::string & hos
session_timeout_ms = session_timeout_ms_; session_timeout_ms = session_timeout_ms_;
operation_timeout_ms = operation_timeout_ms_; operation_timeout_ms = operation_timeout_ms_;
chroot = chroot_; chroot = chroot_;
implementation = implementation_;
if (implementation == "zookeeper") if (implementation == "zookeeper")
{ {
@ -65,13 +66,13 @@ void ZooKeeper::init(const std::string & implementation, const std::string & hos
Coordination::ZooKeeper::Addresses addresses; Coordination::ZooKeeper::Addresses addresses;
addresses.reserve(addresses_strings.size()); addresses.reserve(addresses_strings.size());
for (const auto &address_string : addresses_strings) for (const auto & address_string : addresses_strings)
{ {
try try
{ {
addresses.emplace_back(address_string); addresses.emplace_back(address_string);
} }
catch (const Poco::Net::DNSException &e) catch (const Poco::Net::DNSException & e)
{ {
LOG_ERROR(log, "Cannot use ZooKeeper address " << address_string << ", reason: " << e.displayText()); LOG_ERROR(log, "Cannot use ZooKeeper address " << address_string << ", reason: " << e.displayText());
} }
@ -107,9 +108,9 @@ void ZooKeeper::init(const std::string & implementation, const std::string & hos
} }
ZooKeeper::ZooKeeper(const std::string & hosts_, const std::string & identity_, int32_t session_timeout_ms_, ZooKeeper::ZooKeeper(const std::string & hosts_, const std::string & identity_, int32_t session_timeout_ms_,
int32_t operation_timeout_ms_, const std::string & chroot_, const std::string & implementation) int32_t operation_timeout_ms_, const std::string & chroot_, const std::string & implementation_)
{ {
init(implementation, hosts_, identity_, session_timeout_ms_, operation_timeout_ms_, chroot_); init(implementation_, hosts_, identity_, session_timeout_ms_, operation_timeout_ms_, chroot_);
} }
struct ZooKeeperArgs struct ZooKeeperArgs
@ -671,7 +672,7 @@ void ZooKeeper::waitForDisappear(const std::string & path)
ZooKeeperPtr ZooKeeper::startNewSession() const ZooKeeperPtr ZooKeeper::startNewSession() const
{ {
return std::make_shared<ZooKeeper>(hosts, identity, session_timeout_ms, operation_timeout_ms, chroot); return std::make_shared<ZooKeeper>(hosts, identity, session_timeout_ms, operation_timeout_ms, chroot, implementation);
} }

View File

@ -258,6 +258,7 @@ private:
int32_t session_timeout_ms; int32_t session_timeout_ms;
int32_t operation_timeout_ms; int32_t operation_timeout_ms;
std::string chroot; std::string chroot;
std::string implementation;
std::mutex mutex; std::mutex mutex;