diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathNode.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathNode.java index e13fc41f7df23204b7ff138765570c3763e8f6d0..d46a4651ab3e864c6f506c6df491059d199aad17 100644 --- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathNode.java +++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathNode.java @@ -34,8 +34,10 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public final class PathNode { + @Getter private final Map children = new ConcurrentHashMap<>(); + @Getter private final String nodeKey; @Getter(value = AccessLevel.PACKAGE) @@ -56,32 +58,14 @@ public final class PathNode { this.path = key; } - /** - * Get children. - * - * @return children - */ - public Map getChildren() { - return children; - } - - /** - * Get key. - * - * @return node key - */ - public String getKey() { - return this.nodeKey; - } - /** * Attach child node. * * @param node node */ - public void attachChild(final PathNode node) { + void attachChild(final PathNode node) { this.children.put(node.nodeKey, node); - node.setPath(PathUtil.getRealPath(path, node.getKey())); + node.setPath(PathUtil.getRealPath(path, node.getNodeKey())); } PathNode set(final PathResolve pathResolve, final String value) { diff --git a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathTree.java b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathTree.java index 10f54af0627c0afe6fd4e6a523e76616a3c9c178..31d81ce77ef5e9f90b5f4027ed3fcc9f6d787661 100644 --- a/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathTree.java +++ b/sharding-jdbc-orchestration/src/main/java/io/shardingsphere/jdbc/orchestration/reg/newzk/client/cache/PathTree.java @@ -92,8 +92,8 @@ public final class PathTree { log.debug("loading status:{}", status); status = PathStatus.CHANGING; - final PathNode newRoot = new PathNode(rootNode.get().getKey()); - final List children = provider.getChildren(PathUtil.checkPath(rootNode.get().getKey())); + final PathNode newRoot = new PathNode(rootNode.get().getNodeKey()); + final List children = provider.getChildren(PathUtil.checkPath(rootNode.get().getNodeKey())); children.remove(ZookeeperConstants.CHANGING_KEY); attachIntoNode(children, newRoot); rootNode.set(newRoot); @@ -190,7 +190,7 @@ public final class PathTree { * Watch data change. */ public void watch() { - watch(new ZookeeperEventListener(rootNode.get().getKey()) { + watch(new ZookeeperEventListener(rootNode.get().getNodeKey()) { @Override public void process(final WatchedEvent event) { String path = event.getPath(); @@ -222,7 +222,7 @@ public final class PathTree { } final String key = zookeeperEventListener.getKey(); log.debug("PathTree Watch:{}", key); - client.registerWatch(rootNode.get().getKey(), zookeeperEventListener); + client.registerWatch(rootNode.get().getNodeKey(), zookeeperEventListener); watcherKeys.add(key); }