|
@@ -27,6 +27,7 @@ import org.apache.zookeeper.CreateMode;
|
|
|
import org.apache.zookeeper.KeeperException;
|
|
|
import org.apache.zookeeper.ZooDefs;
|
|
|
import org.apache.zookeeper.data.ACL;
|
|
|
+import org.apache.zookeeper.data.Stat;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
@@ -139,6 +140,16 @@ public class ZookeeperOperator implements InitializingBean {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public boolean hasChildren(final String key){
|
|
|
+ Stat stat ;
|
|
|
+ try {
|
|
|
+ stat = zkClient.checkExists().forPath(key);
|
|
|
+ return stat.getNumChildren() >= 1;
|
|
|
+ } catch (Exception ex) {
|
|
|
+ throw new IllegalStateException(ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public boolean isExisted(final String key) {
|
|
|
try {
|
|
|
return zkClient.checkExists().forPath(key) != null;
|