mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
add zookeeper tryRemoveChildren method
This commit is contained in:
parent
34f74ff785
commit
1f03839830
@ -579,6 +579,23 @@ void ZooKeeper::removeChildren(const std::string & path)
|
||||
}
|
||||
|
||||
|
||||
void ZooKeeper::tryRemoveChildren(const std::string & path)
|
||||
{
|
||||
Strings children;
|
||||
if (tryGetChildren(path, children) != Coordination::ZOK)
|
||||
return;
|
||||
while (!children.empty())
|
||||
{
|
||||
Coordination::Requests ops;
|
||||
for (size_t i = 0; i < MULTI_BATCH_SIZE && !children.empty(); ++i)
|
||||
{
|
||||
ops.emplace_back(makeRemoveRequest(path + "/" + children.back(), -1));
|
||||
children.pop_back();
|
||||
}
|
||||
multi(ops);
|
||||
}
|
||||
}
|
||||
|
||||
void ZooKeeper::removeChildrenRecursive(const std::string & path)
|
||||
{
|
||||
Strings children = getChildren(path);
|
||||
|
@ -187,7 +187,12 @@ public:
|
||||
/// Remove all children nodes (non recursive).
|
||||
void removeChildren(const std::string & path);
|
||||
|
||||
/// Remove all children nodes (non recursive).
|
||||
/// If there're no children, this method doesn't throw an exception
|
||||
void tryRemoveChildren(const std::string & path);
|
||||
|
||||
using WaitCondition = std::function<bool()>;
|
||||
|
||||
/// Wait for the node to disappear or return immediately if it doesn't exist.
|
||||
/// If condition is speficied, it is used to return early (when condition returns false)
|
||||
/// The function returns true if waited and false if waiting was interrupted by condition.
|
||||
|
Loading…
Reference in New Issue
Block a user