• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IZkDataListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: processDataOrChildChange

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的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


示例2: fireDataChangedEvents

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
private void fireDataChangedEvents(final String path, Set<IZkDataListener> listeners) {
    for (final IZkDataListener listener : listeners) {
        _eventThread.send(new ZkEvent("Data of " + path + " changed sent to " + listener) {

            @Override
            public void run() throws Exception {
                // reinstall watch
                exists(path, true);
                try {
                    Object data = readData(path, null, true);
                    listener.handleDataChange(path, data);
                } catch (ZkNoNodeException e) {
                    listener.handleDataDeleted(path);
                }
            }
        });
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:19,代码来源:ZkClientx.java


示例3: doAddDataListener

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
public void doAddDataListener(String path, DataListener listener) {
	try {
		// 第一步:获取-校验-创建监听器
		IZkDataListener iZkDataListener = dataListenerMap.get(listener);
		if(iZkDataListener != null){// 已监听
			return;
		} else {
			// 添加外部监听器
			Set<DataListener> dataListenerSet = dataListenersMap.get(path);
			if(dataListenerSet == null){
				dataListenersMap.put(path, dataListenerSet = new ConcurrentHashSet<DataListener>());
			}
			dataListenerSet.add(listener);
			dataListenerMap.put(listener, iZkDataListener = new IZkDataListenerImpl(path));
		}
		
		// 第二步:启动监听
		client.subscribeDataChanges(path, iZkDataListener);
	} catch (Exception e) {
		throw new IllegalStateException(e.getMessage(), e);
	}
}
 
开发者ID:yu120,项目名称:coon,代码行数:23,代码来源:ZkclientZkTransporter.java


示例4: processDataOrChildChange

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的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


示例5: fireDataChangedEvents

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
private void fireDataChangedEvents(final String path, Set<IZkDataListener> listeners) {
  for (final IZkDataListener listener : listeners) {
    _eventThread.send(new ZkEvent("Data of " + path + " changed sent to " + listener) {

      @Override public void run() throws Exception {
        // reinstall watch
        exists(path, true);
        try {
          Object data = readData(path, null, true);
          listener.handleDataChange(path, data);
        } catch (ZkNoNodeException e) {
          listener.handleDataDeleted(path);
        }
      }
    });
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:18,代码来源:ZkClient.java


示例6: subscribeDataChanges

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
public void subscribeDataChanges(String path, IZkDataListener listener) {
    Set<IZkDataListener> listeners;
    synchronized (_dataListener) {
        listeners = _dataListener.get(path);
        if (listeners == null) {
            listeners = new CopyOnWriteArraySet<IZkDataListener>();
            _dataListener.put(path, listeners);
        }
        listeners.add(listener);
    }
    watchForData(path);
    LOG.debug("Subscribed data changes for " + path);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:14,代码来源:ZkClientx.java


示例7: unsubscribeDataChanges

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


示例8: hasListeners

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
private boolean hasListeners(String path) {
    Set<IZkDataListener> dataListeners = _dataListener.get(path);
    if (dataListeners != null && dataListeners.size() > 0) {
        return true;
    }
    Set<IZkChildListener> childListeners = _childListener.get(path);
    if (childListeners != null && childListeners.size() > 0) {
        return true;
    }
    return false;
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:12,代码来源:ZkClientx.java


示例9: numberOfListeners

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
public int numberOfListeners() {
    int listeners = 0;
    for (Set<IZkChildListener> childListeners : _childListener.values()) {
        listeners += childListeners.size();
    }
    for (Set<IZkDataListener> dataListeners : _dataListener.values()) {
        listeners += dataListeners.size();
    }
    listeners += _stateListener.size();

    return listeners;
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:13,代码来源:ZkClientx.java


示例10: doRemoveDataListener

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
public void doRemoveDataListener(String path, DataListener listener) {
	try {
		// 第一步:移除dataListenerMap中的数据
		IZkDataListener iZkDataListener = dataListenerMap.get(listener);
		if(iZkDataListener == null){
			return;
		} else {
			dataListenerMap.remove(listener);
			
			// 第二步:移除Set<DataListener>中的数据
			Set<DataListener> dataListenerSet = dataListenersMap.get(path);
			if(dataListenerSet != null && dataListenerSet.contains(listener)){
				dataListenerSet.remove(listener);
			}

			// 第三步:移除dataListenersMap和childDataMap中的数据
			if(dataListenerSet == null || dataListenerSet.isEmpty()){
				dataListenersMap.remove(path);
				childDataMap.remove(path);
			}
		}
		
		// 第四步:取消监听
		client.unsubscribeDataChanges(path, iZkDataListener);
	} catch (Exception e) {
		throw new RuntimeException(e.getMessage(), e);
	}
}
 
开发者ID:yu120,项目名称:coon,代码行数:29,代码来源:ZkclientZkTransporter.java


示例11: readAndListen

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
public static NamePairs readAndListen(String zkUrl, String path, IZkDataListener listener) {
	ZkClient client = ZkClientHolder.getZkClient(zkUrl);
	if (!client.exists(path)) {
		return null;
	}
	String data = ZkClientHolder.data2String(client.readData(path));
	if (listener != null) {
		client.subscribeDataChanges(path, listener);
	}
	return new NamePairs(data);
}
 
开发者ID:youtongluan,项目名称:sumk,代码行数:12,代码来源:ZKConfigHandler.java


示例12: ZkLeaderElector

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
@VisibleForTesting
public ZkLeaderElector(String processorIdStr,
                       ZkUtils zkUtils,
                       IZkDataListener previousProcessorChangeListener) {
  this.processorIdStr = processorIdStr;
  this.zkUtils = zkUtils;
  this.keyBuilder = zkUtils.getKeyBuilder();
  this.hostName = getHostName();
  this.previousProcessorChangeListener = previousProcessorChangeListener;
}
 
开发者ID:apache,项目名称:samza,代码行数:11,代码来源:ZkLeaderElector.java


示例13: subscribeDataChanges

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
public void subscribeDataChanges(String path, IZkDataListener listener) {
  Set<IZkDataListener> listeners;
  synchronized (_dataListener) {
    listeners = _dataListener.get(path);
    if (listeners == null) {
      listeners = new CopyOnWriteArraySet<>();
      _dataListener.put(path, listeners);
    }
    listeners.add(listener);
  }
  watchForData(path);
  LOG.debug("Subscribed data changes for " + path);
}
 
开发者ID:apache,项目名称:helix,代码行数:14,代码来源:ZkClient.java


示例14: unsubscribeDataChanges

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
public void unsubscribeDataChanges(String path, IZkDataListener dataListener) {
  synchronized (_dataListener) {
    final Set<IZkDataListener> listeners = _dataListener.get(path);
    if (listeners != null) {
      listeners.remove(dataListener);
    }
    if (listeners == null || listeners.isEmpty()) {
      _dataListener.remove(path);
    }
  }
}
 
开发者ID:apache,项目名称:helix,代码行数:12,代码来源:ZkClient.java


示例15: hasListeners

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
private boolean hasListeners(String path) {
  Set<IZkDataListener> dataListeners = _dataListener.get(path);
  if (dataListeners != null && dataListeners.size() > 0) {
    return true;
  }
  Set<IZkChildListener> childListeners = _childListener.get(path);
  if (childListeners != null && childListeners.size() > 0) {
    return true;
  }
  return false;
}
 
开发者ID:apache,项目名称:helix,代码行数:12,代码来源:ZkClient.java


示例16: numberOfListeners

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
public int numberOfListeners() {
  int listeners = 0;
  for (Set<IZkChildListener> childListeners : _childListener.values()) {
    listeners += childListeners.size();
  }
  for (Set<IZkDataListener> dataListeners : _dataListener.values()) {
    listeners += dataListeners.size();
  }
  listeners += _stateListener.size();

  return listeners;
}
 
开发者ID:apache,项目名称:helix,代码行数:13,代码来源:ZkClient.java


示例17: getZkDataListener

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
public static Map<String, Set<IZkDataListener>> getZkDataListener(ZkClient client)
    throws Exception {
  java.lang.reflect.Field field = getField(client.getClass(), "_dataListener");
  field.setAccessible(true);
  Map<String, Set<IZkDataListener>> dataListener =
      (Map<String, Set<IZkDataListener>>) field.get(client);
  return dataListener;
}
 
开发者ID:apache,项目名称:helix,代码行数:9,代码来源:ZkTestHelper.java


示例18: getDataListener

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
protected Set<IZkDataListener> getDataListener(String path) {
    return _dataListener.get(path);
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:4,代码来源:ZkClientx.java


示例19: subscribeDataChanges

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
@Override
public void subscribeDataChanges(String path, IZkDataListener listener) {
    zkClient.subscribeDataChanges(path, listener);
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:5,代码来源:ZooKeeperClientImpl.java


示例20: unsubscribeDataChanges

import org.I0Itec.zkclient.IZkDataListener; //导入依赖的package包/类
@Override
public void unsubscribeDataChanges(String path, IZkDataListener dataListener) {
    zkClient.unsubscribeDataChanges(path, dataListener);
}
 
开发者ID:networknt,项目名称:light-4j,代码行数:5,代码来源:ZooKeeperClientImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContextCapabilities类代码示例发布时间:2022-05-21
下一篇:
Java RFC2253Parser类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap