From 146378633ae9d7597ffdf19c13f02f51d3bd9ab0 Mon Sep 17 00:00:00 2001 From: Pavel Kartavyy Date: Mon, 7 Jul 2014 19:55:39 +0400 Subject: [PATCH 1/2] GlobalCorrector: added program to overwrite metrics in metrage [#METR-11762] --- libs/libmysqlxx/include/mysqlxx/Date.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/libmysqlxx/include/mysqlxx/Date.h b/libs/libmysqlxx/include/mysqlxx/Date.h index c2c465474a7..6a28d55b2cd 100644 --- a/libs/libmysqlxx/include/mysqlxx/Date.h +++ b/libs/libmysqlxx/include/mysqlxx/Date.h @@ -164,11 +164,15 @@ public: return !(*this == other); } - std::string toString() + std::string toString(char separator = '-') const { std::stringstream ss; - ss << year() << '-' << (month() / 10) << (month() % 10) - << '-' << (day() / 10) << (day() % 10); + if (separator) + ss << year() << separator << (month() / 10) << (month() % 10) + << separator << (day() / 10) << (day() % 10); + else + ss << year() << (month() / 10) << (month() % 10) + << (day() / 10) << (day() % 10); return ss.str(); } }; From 039858e3f7d294e0a2c964578246b531697d6912 Mon Sep 17 00:00:00 2001 From: Michael Kolupaev Date: Tue, 8 Jul 2014 16:45:10 +0400 Subject: [PATCH 2/2] zkutil: fixed a bug, removed unused code. [#METR-10202] --- libs/libzkutil/include/zkutil/Types.h | 2 -- libs/libzkutil/include/zkutil/ZooKeeper.h | 8 +++----- libs/libzkutil/src/ZooKeeper.cpp | 21 ++++++++------------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/libs/libzkutil/include/zkutil/Types.h b/libs/libzkutil/include/zkutil/Types.h index 81ee22a6b74..e6f12ebcbb9 100644 --- a/libs/libzkutil/include/zkutil/Types.h +++ b/libs/libzkutil/include/zkutil/Types.h @@ -87,8 +87,6 @@ typedef std::vector OpResults; typedef std::shared_ptr OpResultsPtr; typedef std::vector Strings; -typedef void (*WatchFunction)(zhandle_t *zh, int type, int state, const char *path, void *watcherCtx); - namespace CreateMode { extern const int Persistent; diff --git a/libs/libzkutil/include/zkutil/ZooKeeper.h b/libs/libzkutil/include/zkutil/ZooKeeper.h index 59b7ebc60d4..ae870c1cf1e 100644 --- a/libs/libzkutil/include/zkutil/ZooKeeper.h +++ b/libs/libzkutil/include/zkutil/ZooKeeper.h @@ -29,7 +29,7 @@ class ZooKeeper public: typedef Poco::SharedPtr Ptr; - ZooKeeper(const std::string & hosts, int32_t sessionTimeoutMs = DEFAULT_SESSION_TIMEOUT, WatchFunction * watch = nullptr); + ZooKeeper(const std::string & hosts, int32_t sessionTimeoutMs = DEFAULT_SESSION_TIMEOUT); /** конфиг вида @@ -44,8 +44,7 @@ public: 30000 */ - ZooKeeper(const Poco::Util::AbstractConfiguration & config, const std::string & config_name, - WatchFunction * watch = nullptr); + ZooKeeper(const Poco::Util::AbstractConfiguration & config, const std::string & config_name); ~ZooKeeper(); @@ -169,7 +168,7 @@ public: private: friend struct WatchWithEvent; - void init(const std::string & hosts, int32_t sessionTimeoutMs, WatchFunction * watch_); + void init(const std::string & hosts, int32_t sessionTimeoutMs); void removeChildrenRecursive(const std::string & path); void tryRemoveChildrenRecursive(const std::string & path); void * watchForEvent(EventPtr event); @@ -211,7 +210,6 @@ private: AclPtr default_acl; zhandle_t * impl; - WatchFunction * state_watch; std::unordered_set watch_store; /// Количество попыток повторить операцию чтения при OperationTimeout, ConnectionLoss diff --git a/libs/libzkutil/src/ZooKeeper.cpp b/libs/libzkutil/src/ZooKeeper.cpp index 9f81f3afacf..4bb8c1268b7 100644 --- a/libs/libzkutil/src/ZooKeeper.cpp +++ b/libs/libzkutil/src/ZooKeeper.cpp @@ -32,7 +32,7 @@ struct WatchWithEvent void process(zhandle_t * zh, int32_t event_type, int32_t state, const char * path) { - if (!event) + if (event) { event->set(); event = nullptr; @@ -56,18 +56,14 @@ void ZooKeeper::processEvent(zhandle_t * zh, int type, int state, const char * p } } -void ZooKeeper::init(const std::string & hosts_, int32_t sessionTimeoutMs_, WatchFunction * watch_) +void ZooKeeper::init(const std::string & hosts_, int32_t sessionTimeoutMs_) { log = &Logger::get("ZooKeeper"); zoo_set_debug_level(ZOO_LOG_LEVEL_ERROR); hosts = hosts_; sessionTimeoutMs = sessionTimeoutMs_; - state_watch = watch_; - if (watch_) - impl = zookeeper_init(hosts.c_str(), *watch_, sessionTimeoutMs, nullptr, nullptr, 0); - else - impl = zookeeper_init(hosts.c_str(), nullptr, sessionTimeoutMs, nullptr, nullptr, 0); + impl = zookeeper_init(hosts.c_str(), nullptr, sessionTimeoutMs, nullptr, nullptr, 0); if (!impl) throw KeeperException("Fail to initialize zookeeper. Hosts are " + hosts); @@ -75,9 +71,9 @@ void ZooKeeper::init(const std::string & hosts_, int32_t sessionTimeoutMs_, Watc default_acl = &ZOO_OPEN_ACL_UNSAFE; } -ZooKeeper::ZooKeeper(const std::string & hosts, int32_t sessionTimeoutMs, WatchFunction * watch_) +ZooKeeper::ZooKeeper(const std::string & hosts, int32_t sessionTimeoutMs) { - init(hosts, sessionTimeoutMs, watch_); + init(hosts, sessionTimeoutMs); } struct ZooKeeperArgs @@ -109,11 +105,10 @@ struct ZooKeeperArgs size_t session_timeout_ms; }; -ZooKeeper::ZooKeeper(const Poco::Util::AbstractConfiguration & config, const std::string & config_name, - WatchFunction * watch) +ZooKeeper::ZooKeeper(const Poco::Util::AbstractConfiguration & config, const std::string & config_name) { ZooKeeperArgs args(config, config_name); - init(args.hosts, args.session_timeout_ms, watch); + init(args.hosts, args.session_timeout_ms); } void * ZooKeeper::watchForEvent(EventPtr event) @@ -476,7 +471,7 @@ ZooKeeper::~ZooKeeper() ZooKeeperPtr ZooKeeper::startNewSession() const { - return new ZooKeeper(hosts, sessionTimeoutMs, state_watch); + return new ZooKeeper(hosts, sessionTimeoutMs); } Op::Create::Create(const std::string & path_, const std::string & value_, AclPtr acl, int32_t flags)