本文整理了Java中org.apache.helix.manager.zk.ZkClient.subscribeDataChanges()
方法的一些代码示例,展示了ZkClient.subscribeDataChanges()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClient.subscribeDataChanges()
方法的具体详情如下:
包路径:org.apache.helix.manager.zk.ZkClient
类名称:ZkClient
方法名:subscribeDataChanges
暂无
代码示例来源:origin: apache/incubator-pinot
public void start(ControllerMetrics controllerMetrics) {
_controllerMetrics = controllerMetrics;
LOGGER.info("Starting realtime segments manager, adding a listener on the property store table configs path.");
String zkUrl = _pinotHelixResourceManager.getHelixZkURL();
_zkClient = new ZkClient(zkUrl, ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT);
_zkClient.setZkSerializer(new ZNRecordSerializer());
_zkClient.waitUntilConnected(CommonConstants.Helix.ZkClient.DEFAULT_CONNECT_TIMEOUT_SEC, TimeUnit.SECONDS);
// Subscribe to any data/child changes to property
_zkClient.subscribeChildChanges(_tableConfigPath, this);
_zkClient.subscribeDataChanges(_tableConfigPath, this);
// Subscribe to leadership changes
ControllerLeadershipManager.getInstance().subscribe(PinotLLCRealtimeSegmentManager.class.getName(), this);
// Setup change listeners for already existing tables, if any.
processPropertyStoreChange(_tableConfigPath);
}
代码示例来源:origin: apache/incubator-pinot
_zkClient.subscribeDataChanges(realtimeSegmentsPathForTable, this);
_zkClient.subscribeChildChanges(realtimeSegmentsPathForTable, this);
LOGGER.info("Setting data change watch for real-time segment currently being consumed: {}",
segmentPath);
_zkClient.subscribeDataChanges(segmentPath, this);
} else {
_zkClient.unsubscribeDataChanges(segmentPath, this);
代码示例来源:origin: org.apache.helix/helix-core
/**
* Subscribe to zookeeper data changes
*/
@Override
public void subscribeDataChanges(String path, IZkDataListener listener) {
_zkClient.subscribeDataChanges(path, listener);
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
for (String child : currentChilds) {
String childPath = parentPath.equals("/") ? parentPath + child : parentPath + "/" + child;
_zkClient.subscribeDataChanges(childPath, this);
}
boolean result = _verifier.verify();
if (result == true) {
_countDown.countDown();
}
}
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
for (String child : currentChilds) {
String childPath = String.format("%s/%s", parentPath, child);
_zkclient.subscribeDataChanges(childPath, this);
}
boolean success = verify();
if (success) {
_countdown.countDown();
}
}
代码示例来源:origin: org.apache.helix/helix-core
@Override
public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception {
for (String child : currentChilds) {
String childPath = String.format("%s/%s", parentPath, child);
_zkClient.subscribeDataChanges(childPath, this);
}
if (!_verifyTaskThreadPool.isShutdown()) {
_verifyTaskThreadPool.submit(new VerifyStateCallbackTask());
}
}
代码示例来源:origin: org.apache.helix/helix-core
private void subscribeDataChange(String path, NotificationContext.Type callbackType) {
if (callbackType == NotificationContext.Type.INIT
|| callbackType == NotificationContext.Type.CALLBACK) {
if (logger.isDebugEnabled()) {
logger.debug(
_manager.getInstanceName() + " subscribe data-change. path: " + path + ", listener: "
+ _listener);
}
_zkClient.subscribeDataChanges(path, this);
} else if (callbackType == NotificationContext.Type.FINALIZE) {
logger.info(
_manager.getInstanceName() + " unsubscribe data-change. path: " + path + ", listener: "
+ _listener);
_zkClient.unsubscribeDataChanges(path, this);
}
}
代码示例来源:origin: org.apache.helix/helix-core
private void subscribeTrigger(ClusterVerifyTrigger trigger) {
String path = trigger.getTriggerKey().getPath();
if (trigger.isTriggerOnDataChange()) {
_zkClient.subscribeDataChanges(path, this);
}
if (trigger.isTriggerOnChildChange()) {
_zkClient.subscribeChildChanges(path, this);
}
if (trigger.isTriggerOnChildDataChange()) {
List<String> childs = _zkClient.getChildren(path);
for (String child : childs) {
String childPath = String.format("%s/%s", path, child);
_zkClient.subscribeDataChanges(childPath, this);
}
}
}
代码示例来源:origin: org.apache.helix/helix-core
public boolean verifyByCallback(long timeout, List<ClusterVerifyTrigger> triggers) {
_countdown = new CountDownLatch(1);
for (ClusterVerifyTrigger trigger : triggers) {
String path = trigger._triggerKey.getPath();
_zkclient.subscribeChildChanges(path, this);
if (trigger._triggerOnChildDataChange) {
List<String> childs = _zkclient.getChildren(path);
for (String child : childs) {
String childPath = String.format("%s/%s", path, child);
_zkclient.subscribeDataChanges(childPath, this);
}
}
}
boolean success = false;
try {
success = verify();
if (!success) {
success = _countdown.await(timeout, TimeUnit.MILLISECONDS);
if (!success) {
// make a final try if timeout
success = verify();
}
}
} catch (Exception e) {
LOG.error("Exception in verifier", e);
}
// clean up
_zkclient.unsubscribeAll();
return success;
}
代码示例来源:origin: org.apache.helix/helix-core
for (String child : zkClient.getChildren(extViewPath)) {
String childPath = extViewPath.equals("/") ? extViewPath + child : extViewPath + "/" + child;
zkClient.subscribeDataChanges(childPath, listener);
代码示例来源:origin: apache/helix
@Test
public void testCloseZkClientInZkClientEventThread() throws Exception {
String className = TestHelper.getTestClassName();
String methodName = TestHelper.getTestMethodName();
String clusterName = className + "_" + methodName;
System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
final CountDownLatch waitCallback = new CountDownLatch(1);
final ZkClient client =
new ZkClient(ZK_ADDR, HelixZkClient.DEFAULT_SESSION_TIMEOUT,
HelixZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
String path = String.format("/%s", clusterName);
client.createEphemeral(path);
client.subscribeDataChanges(path, new IZkDataListener() {
@Override
public void handleDataDeleted(String dataPath) throws Exception {
}
@Override
public void handleDataChange(String dataPath, Object data) throws Exception {
client.close();
waitCallback.countDown();
}
});
client.writeData(path, new ZNRecord("test"));
waitCallback.await();
Assert.assertFalse(_gZkClient.exists(path), "Ephemeral node: " + path
+ " should be removed after ZkClient#close() in its own event-thread");
System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
代码示例来源:origin: apache/helix
zkClient.subscribeDataChanges(TEST_PATH, new IZkDataListener() {
@Override
public void handleDataChange(String dataPath, Object data) throws Exception {
代码示例来源:origin: apache/helix
client.subscribeDataChanges(path, listener);
client.subscribeChildChanges(path, listener);
代码示例来源:origin: apache/helix
client.subscribeDataChanges(path, listener);
client.subscribeChildChanges(path, listener);
内容来源于网络,如有侵权,请联系作者删除!