Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cvictory committed May 23, 2019
1 parent 2cbbd45 commit 4eca5fd
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.apache.dubbo.remoting.zookeeper.curator;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.remoting.zookeeper.ChildListener;
import org.apache.dubbo.remoting.zookeeper.DataListener;
Expand Down Expand Up @@ -49,6 +51,8 @@

public class CuratorZookeeperClient extends AbstractZookeeperClient<CuratorZookeeperClient.CuratorWatcherImpl, CuratorZookeeperClient.CuratorWatcherImpl> {

protected static final Logger logger = LoggerFactory.getLogger(CuratorZookeeperClient.class);

static final Charset CHARSET = Charset.forName("UTF-8");
private final CuratorFramework client;
private Map<String, TreeCache> treeCacheMap = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -288,6 +292,9 @@ public void process(WatchedEvent event) throws Exception {
@Override
public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exception {
if (dataListener != null) {
if (logger.isInfoEnabled()) {
logger.info("listen the zookeeper changed. The changed data:" + event.getData());
}
TreeCacheEvent.Type type = event.getType();
EventType eventType = null;
String content = null;
Expand All @@ -296,12 +303,12 @@ public void childEvent(CuratorFramework client, TreeCacheEvent event) throws Exc
case NODE_ADDED:
eventType = EventType.NodeCreated;
path = event.getData().getPath();
content = new String(event.getData().getData(), CHARSET);
content = event.getData().getData() == null ? "" : new String(event.getData().getData(), CHARSET);
break;
case NODE_UPDATED:
eventType = EventType.NodeDataChanged;
path = event.getData().getPath();
content = new String(event.getData().getData(), CHARSET);
content = event.getData().getData() == null ? "" : new String(event.getData().getData(), CHARSET);
break;
case NODE_REMOVED:
path = event.getData().getPath();
Expand Down

0 comments on commit 4eca5fd

Please sign in to comment.