当前位置: 首页>>代码示例>>Java>>正文


Java IZkChildListener类代码示例

本文整理汇总了Java中org.I0Itec.zkclient.IZkChildListener的典型用法代码示例。如果您正苦于以下问题:Java IZkChildListener类的具体用法?Java IZkChildListener怎么用?Java IZkChildListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IZkChildListener类属于org.I0Itec.zkclient包,在下文中一共展示了IZkChildListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ProcessMonitor

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
public ProcessMonitor(Long pipelineId){
    super(pipelineId);
    processListener = new IZkChildListener() {

        public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
            if (currentChilds != null) {
                initProcess(currentChilds);
            }
        }
    };

    String path = StagePathUtils.getProcessRoot(getPipelineId());
    List<String> childs = zookeeper.subscribeChildChanges(path, processListener);
    initProcess(childs);
    // syncStage();
    MonitorScheduler.register(this);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:18,代码来源:ProcessMonitor.java

示例2: StageMonitor

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
public StageMonitor(Long pipelineId){
    super(pipelineId);

    processListener = new IZkChildListener() {

        public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
            if (currentChilds != null) {
                initStage(currentChilds);
            }
        }
    };

    String path = StagePathUtils.getProcessRoot(getPipelineId());
    List<String> childs = zookeeper.subscribeChildChanges(path, processListener);
    initStage(childs);
    // syncStage();
    MonitorScheduler.register(this);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:19,代码来源:StageMonitor.java

示例3: TerminMonitor

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
public TerminMonitor(Long pipelineId){
    super(pipelineId);
    childListener = new IZkChildListener() {

        public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
            if (currentChilds != null) {
                initTermin(currentChilds);
            }
        }
    };

    String path = StagePathUtils.getTerminRoot(getPipelineId());
    List<String> childs = zookeeper.subscribeChildChanges(path, childListener);
    initTermin(childs);
    MonitorScheduler.register(this);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:17,代码来源:TerminMonitor.java

示例4: NodeMonitor

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
public NodeMonitor(){
    childListener = new IZkChildListener() {

        public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
            if (currentChilds != null) {
                initNodes(currentChilds);
            }
        }
    };
    List<String> childs = zookeeper.subscribeChildChanges(ArbitrateConstants.NODE_NID_ROOT, childListener);
    if (childs == null) {//如果为null,代表系统节点为初始化
        try {
            zookeeper.createPersistent(ArbitrateConstants.NODE_NID_ROOT, true);
        } catch (ZkNodeExistsException e) {
            //ignore 
        }

        childs = zookeeper.getChildren(ArbitrateConstants.NODE_NID_ROOT);
    }

    initNodes(childs);
    // syncNodes();// 开始监视node节点的变化
    MonitorScheduler.register(this);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:25,代码来源:NodeMonitor.java

示例5: processDataOrChildChange

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
private void processDataOrChildChange(WatchedEvent event) {
    final String path = event.getPath();

    if (event.getType() == EventType.NodeChildrenChanged || event.getType() == EventType.NodeCreated
        || event.getType() == EventType.NodeDeleted) {
        Set<IZkChildListener> childListeners = _childListener.get(path);
        if (childListeners != null && !childListeners.isEmpty()) {
            fireChildChangedEvents(path, childListeners);
        }
    }

    if (event.getType() == EventType.NodeDataChanged || event.getType() == EventType.NodeDeleted
        || event.getType() == EventType.NodeCreated) {
        Set<IZkDataListener> listeners = _dataListener.get(path);
        if (listeners != null && !listeners.isEmpty()) {
            fireDataChangedEvents(event.getPath(), listeners);
        }
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:20,代码来源:ZkClientx.java

示例6: doSubscribe

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
@Override
protected void doSubscribe(final URL url, final NotifyListener listener) {
    try {
        clientLock.lock();

        ConcurrentHashMap<NotifyListener, IZkChildListener> childChangeListeners = serviceListeners.get(url);
        if (childChangeListeners == null) {
            serviceListeners.putIfAbsent(url, new ConcurrentHashMap<NotifyListener, IZkChildListener>());
            childChangeListeners = serviceListeners.get(url);
        }
        IZkChildListener zkChildListener = childChangeListeners.get(listener);
        if (zkChildListener == null) {
            childChangeListeners.putIfAbsent(listener, new IZkChildListener() {
                @Override
                public void handleChildChange(String parentPath, List<String> currentChilds) {

                    listener.notify(getUrl(), childrenNodeToUrls(parentPath, currentChilds));
                    logger.info(String.format("[ZookeeperRegistry] service list change: path=%s, currentChilds=%s", parentPath, currentChilds.toString()));
                }
            });
            zkChildListener = childChangeListeners.get(listener);
        }

        // 防止旧节点未正常注销
        removeNode(url, ZkNodeType.CLIENT);
        createNode(url, ZkNodeType.CLIENT);

        String serverTypePath = ZkUtils.toNodeTypePath(url, ZkNodeType.SERVER);
        zkClient.subscribeChildChanges(serverTypePath, zkChildListener);
        logger.info(String.format("[ZookeeperRegistry] subscribe service: path=%s, info=%s", ZkUtils.toNodePath(url, ZkNodeType.SERVER), url.toFullUri()));
    } catch (Throwable e) {
        throw new RpcFrameworkException(String.format("Failed to subscribe %s to zookeeper(%s), cause: %s", url, getUrl(), e.getMessage()), e);
    } finally {
        clientLock.unlock();
    }
}
 
开发者ID:TFdream,项目名称:mango,代码行数:37,代码来源:ZookeeperRegistry.java

示例7: doUnsubscribe

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
@Override
protected void doUnsubscribe(URL url, NotifyListener listener) {
    try {
        clientLock.lock();
        Map<NotifyListener, IZkChildListener> childChangeListeners = serviceListeners.get(url);
        if (childChangeListeners != null) {
            IZkChildListener zkChildListener = childChangeListeners.get(listener);
            if (zkChildListener != null) {
                zkClient.unsubscribeChildChanges(ZkUtils.toNodeTypePath(url, ZkNodeType.CLIENT), zkChildListener);
                childChangeListeners.remove(listener);
            }
        }
    } catch (Throwable e) {
        throw new RpcFrameworkException(String.format("Failed to unsubscribe service %s to zookeeper(%s), cause: %s", url, getUrl(), e.getMessage()), e);
    } finally {
        clientLock.unlock();
    }
}
 
开发者ID:TFdream,项目名称:mango,代码行数:19,代码来源:ZookeeperRegistry.java

示例8: startListener

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
public void startListener() {
	LOG.info("Starting Kafka ZK node listener...");
	exec.execute(new Runnable() {

		@Override
		public void run() {
			ZKUtils.getZKClient().subscribeChildChanges(ZkUtils.BrokerIdsPath(), new IZkChildListener() {

				@Override
				public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
					
				}
				
			});
		}

	});
}
 
开发者ID:chickling,项目名称:kmanager,代码行数:19,代码来源:KafkaNodeListener.java

示例9: unsubscribeService

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
@Override
protected void unsubscribeService(URL url, ServiceListener serviceListener) {
    try {
        clientLock.lock();
        Map<ServiceListener, IZkChildListener> childChangeListeners = serviceListeners.get(url);
        if (childChangeListeners != null) {
            IZkChildListener zkChildListener = childChangeListeners.get(serviceListener);
            if (zkChildListener != null) {
                client.unsubscribeChildChanges(ZkUtils.toNodeTypePath(url, ZkNodeType.CLIENT), zkChildListener);
                childChangeListeners.remove(serviceListener);
            }
        }
    } catch (Throwable e) {
        throw new FrameworkException(new Status(UNSUBSCRIBE_ZOOKEEPER_SERVICE_ERROR, url, getUrl(), e.getMessage()), e);
    } finally {
        clientLock.unlock();
    }
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:19,代码来源:ZooKeeperRegistry.java

示例10: monitor

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
private static void monitor() {
    ZkClient zc=new ZkClient("localhost:2181",1000);
    //创建监控节点
    if(!zc.exists("/monitor"))
    zc.create("/monitor",null, CreateMode.PERSISTENT);

    if(!zc.exists("/monitor/client"))
    zc.create("/monitor/client",null, CreateMode.PERSISTENT);

    zc.subscribeChildChanges("/monitor/client",new IZkChildListener(){
        @Override
        public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
            System.out.println("------------客户端发生变化---------childPath="+parentPath );
            currentChilds.forEach((String childPath)->{
                System.out.println("parentPath = [" + parentPath + "], currentChilds = [" + currentChilds + "]");
            });
        }
    });



}
 
开发者ID:ggj2010,项目名称:javabase,代码行数:23,代码来源:ServerManagerMonitor.java

示例11: processDataOrChildChange

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
private void processDataOrChildChange(WatchedEvent event) {
  final String path = event.getPath();

  if (event.getType() == EventType.NodeChildrenChanged || event.getType() == EventType.NodeCreated
      || event.getType() == EventType.NodeDeleted) {
    Set<IZkChildListener> childListeners = _childListener.get(path);
    if (childListeners != null && !childListeners.isEmpty()) {
      fireChildChangedEvents(path, childListeners);
    }
  }

  if (event.getType() == EventType.NodeDataChanged || event.getType() == EventType.NodeDeleted
      || event.getType() == EventType.NodeCreated) {
    Set<IZkDataListener> listeners = _dataListener.get(path);
    if (listeners != null && !listeners.isEmpty()) {
      fireDataChangedEvents(event.getPath(), listeners);
    }
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:20,代码来源:ZkClient.java

示例12: subscribe

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
@Override
public void subscribe() {
    List<String> children = zkClient.subscribeChildChanges(rootPath, new IZkChildListener() {
        @Override
        public void handleChildChange(String parentPath, List<String> currentChildren) throws Exception {
            directory.notify(currentChildren);
        }
    });
    directory.notify(children);
}
 
开发者ID:justice-code,项目名称:star-map,代码行数:11,代码来源:ZookeeperRegistry.java

示例13: createTargetChildListener

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
public IZkChildListener createTargetChildListener(String path, final ChildListener listener) {
	return new IZkChildListener() {
		public void handleChildChange(String parentPath, List<String> currentChilds)
				throws Exception {
			listener.childChanged(parentPath, currentChilds);
		}
	};
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:9,代码来源:ZkclientZookeeperClient.java

示例14: subscribeChildChanges

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
public List<String> subscribeChildChanges(String path, IZkChildListener listener) {
    synchronized (_childListener) {
        Set<IZkChildListener> listeners = _childListener.get(path);
        if (listeners == null) {
            listeners = new CopyOnWriteArraySet<IZkChildListener>();
            _childListener.put(path, listeners);
        }
        listeners.add(listener);
    }
    return watchForChilds(path);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:12,代码来源:ZkClientx.java

示例15: unsubscribeChildChanges

import org.I0Itec.zkclient.IZkChildListener; //导入依赖的package包/类
public void unsubscribeChildChanges(String path, IZkChildListener childListener) {
    synchronized (_childListener) {
        final Set<IZkChildListener> listeners = _childListener.get(path);
        if (listeners != null) {
            listeners.remove(childListener);
        }
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:9,代码来源:ZkClientx.java


注:本文中的org.I0Itec.zkclient.IZkChildListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。