mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-11 10:04:06 +00:00
Merge
This commit is contained in:
commit
5cd9ceaffd
@ -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();
|
||||
}
|
||||
};
|
||||
|
@ -87,8 +87,6 @@ typedef std::vector<OpResult> OpResults;
|
||||
typedef std::shared_ptr<OpResults> OpResultsPtr;
|
||||
typedef std::vector<std::string> Strings;
|
||||
|
||||
typedef void (*WatchFunction)(zhandle_t *zh, int type, int state, const char *path, void *watcherCtx);
|
||||
|
||||
namespace CreateMode
|
||||
{
|
||||
extern const int Persistent;
|
||||
|
@ -29,7 +29,7 @@ class ZooKeeper
|
||||
public:
|
||||
typedef Poco::SharedPtr<ZooKeeper> 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);
|
||||
|
||||
/** конфиг вида
|
||||
<zookeeper>
|
||||
@ -44,8 +44,7 @@ public:
|
||||
<session_timeout_ms>30000</session_timeout_ms>
|
||||
</zookeeper>
|
||||
*/
|
||||
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<WatchWithEvent *> watch_store;
|
||||
|
||||
/// Количество попыток повторить операцию чтения при OperationTimeout, ConnectionLoss
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user