- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.I0Itec.zkclient.ZkClient.subscribeStateChanges()
方法的一些代码示例,展示了ZkClient.subscribeStateChanges()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClient.subscribeStateChanges()
方法的具体详情如下:
包路径:org.I0Itec.zkclient.ZkClient
类名称:ZkClient
方法名:subscribeStateChanges
暂无
代码示例来源:origin: networknt/light-4j
@Override
public void subscribeStateChanges(IZkStateListener listener) {
zkClient.subscribeStateChanges(listener);
}
代码示例来源:origin: apache/incubator-dubbo
public void addListener(IZkStateListener listener) {
completableFuture.whenComplete((value, exception) -> {
this.makeClientReady(value, exception);
if (exception == null) {
client.subscribeStateChanges(listener);
}
});
}
代码示例来源:origin: apache/incubator-dubbo
public void addListener(IZkStateListener listener) {
completableFuture.whenComplete((value, exception) -> {
this.makeClientReady(value, exception);
if (exception == null) {
client.subscribeStateChanges(listener);
}
});
}
代码示例来源:origin: weibocom/motan
public ZookeeperRegistry(URL url, ZkClient client) {
super(url);
this.zkClient = client;
IZkStateListener zkStateListener = new IZkStateListener() {
@Override
public void handleStateChanged(Watcher.Event.KeeperState state) throws Exception {
// do nothing
}
@Override
public void handleNewSession() throws Exception {
LoggerUtil.info("zkRegistry get new session notify.");
reconnectService();
reconnectClient();
}
};
zkClient.subscribeStateChanges(zkStateListener);
ShutDownHook.registerShutdownHook(this);
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public ZkClientZkClient(Config config) {
String registryAddress = NodeRegistryUtils.getRealRegistryAddress(config.getRegistryAddress());
zkClient = new ZkClient(registryAddress, connectionTimeout);
zkClient.subscribeStateChanges(new IZkStateListener() {
public void handleStateChanged(Watcher.Event.KeeperState state) throws Exception {
ZkClientZkClient.this.state = state;
if (state == KeeperState.Disconnected) {
stateChanged(StateListener.DISCONNECTED);
} else if (state == KeeperState.SyncConnected) {
stateChanged(StateListener.CONNECTED);
} else if (state == KeeperState.Expired) {
stateChanged(StateListener.DISCONNECTED);
}
}
public void handleNewSession() throws Exception {
stateChanged(StateListener.RECONNECTED);
}
});
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public ZkClientZkClient(Config config) {
String registryAddress = NodeRegistryUtils.getRealRegistryAddress(config.getRegistryAddress());
zkClient = new ZkClient(registryAddress, connectionTimeout);
zkClient.subscribeStateChanges(new IZkStateListener() {
public void handleStateChanged(Watcher.Event.KeeperState state) throws Exception {
ZkClientZkClient.this.state = state;
if (state == KeeperState.Disconnected) {
stateChanged(StateListener.DISCONNECTED);
} else if (state == KeeperState.SyncConnected) {
stateChanged(StateListener.CONNECTED);
} else if (state == KeeperState.Expired) {
stateChanged(StateListener.DISCONNECTED);
}
}
public void handleNewSession() throws Exception {
stateChanged(StateListener.RECONNECTED);
}
});
}
代码示例来源:origin: javahongxi/whatsmars
public void addListener(IZkStateListener listener) {
completableFuture.whenComplete((value, exception) -> {
this.makeClientReady(value, exception);
if (exception == null) {
client.subscribeStateChanges(listener);
}
});
}
代码示例来源:origin: cris001/MyRepo
public ZookeeperRegistry(URL url, ZkClient zkClient) {
super(url);
this.zkClient = zkClient;
IZkStateListener zkStateListener = new IZkStateListener() {
@Override
public void handleStateChanged(Watcher.Event.KeeperState state) throws Exception {
// do nothing
}
@Override
public void handleNewSession() throws Exception {
logger.info("zkRegistry get new session notify.");
}
@Override
public void handleSessionEstablishmentError(Throwable throwable) throws Exception {
}
};
this.zkClient.subscribeStateChanges(zkStateListener);
}
代码示例来源:origin: org.apache.dubbo/dubbo
public void addListener(IZkStateListener listener) {
completableFuture.whenComplete((value, exception) -> {
this.makeClientReady(value, exception);
if (exception == null) {
client.subscribeStateChanges(listener);
}
});
}
代码示例来源:origin: org.apache.dubbo/dubbo-remoting-zookeeper
public void addListener(IZkStateListener listener) {
completableFuture.whenComplete((value, exception) -> {
this.makeClientReady(value, exception);
if (exception == null) {
client.subscribeStateChanges(listener);
}
});
}
代码示例来源:origin: ezbz/projectx
@Override
public void registerListener(final String path, final LeaderElectionNodeListener listener) {
zkClient.subscribeDataChanges(path, listener);
zkClient.subscribeStateChanges(listener);
}
代码示例来源:origin: com.weibo/motan-registry-zookeeper
public ZookeeperRegistry(URL url, ZkClient client) {
super(url);
this.zkClient = client;
IZkStateListener zkStateListener = new IZkStateListener() {
@Override
public void handleStateChanged(Watcher.Event.KeeperState state) throws Exception {
// do nothing
}
@Override
public void handleNewSession() throws Exception {
LoggerUtil.info("zkRegistry get new session notify.");
reconnectService();
reconnectClient();
}
};
zkClient.subscribeStateChanges(zkStateListener);
ShutDownHook.registerShutdownHook(this);
}
代码示例来源:origin: com.alibaba/dubbo
@Override
public void run() {
try {
client = listenableFutureTask.get();
client.subscribeStateChanges(listener);
} catch (InterruptedException e) {
logger.warn(Thread.currentThread().getName() + " was interrupted unexpectedly, which may cause unpredictable exception!");
} catch (ExecutionException e) {
logger.error("Got an exception when trying to create zkclient instance, can not connect to zookeeper server, please check!", e);
}
}
});
代码示例来源:origin: youtongluan/sumk
@Override
public void run() {
zkUnRegister.run();
ZkClient client = ZkClientHolder.getZkClient(zkUrl);
String zkData = createZkRouteData();
client.createEphemeral(path, zkData);
client.subscribeStateChanges(stateListener);
Log.get("sumk.rpc.zk").trace("server zk data:\n{}", zkData);
}
代码示例来源:origin: com.alibaba/dubbo-remoting-zookeeper
@Override
public void run() {
try {
client = listenableFutureTask.get();
client.subscribeStateChanges(listener);
} catch (InterruptedException e) {
logger.warn(Thread.currentThread().getName() + " was interrupted unexpectedly, which may cause unpredictable exception!");
} catch (ExecutionException e) {
logger.error("Got an exception when trying to create zkclient instance, can not connect to zookeeper server, please check!", e);
}
}
});
代码示例来源:origin: jobxhub/JobX
public ZkclientZookeeperClient(URL url) {
super(url);
client = new ZkClient(url.getBackupAddress(), Constants.ZK_CONNECTION_TIMEOUT);
client.subscribeStateChanges(new IZkStateListener() {
public void handleStateChanged(KeeperState state) throws Exception {
ZkclientZookeeperClient.this.state = state;
if (state == KeeperState.Disconnected) {
stateChanged(StateListener.DISCONNECTED);
} else if (state == KeeperState.SyncConnected) {
stateChanged(StateListener.CONNECTED);
}
}
public void handleNewSession() throws Exception {
stateChanged(StateListener.RECONNECTED);
}
@Override
public void handleSessionEstablishmentError(Throwable throwable) throws Exception {
}
});
}
代码示例来源:origin: com.github.ltsopensource/lts-core
public ZkClientZkClient(Config config) {
String registryAddress = NodeRegistryUtils.getRealRegistryAddress(config.getRegistryAddress());
zkClient = new ZkClient(registryAddress, connectionTimeout);
zkClient.subscribeStateChanges(new IZkStateListener() {
public void handleStateChanged(Watcher.Event.KeeperState state) throws Exception {
ZkClientZkClient.this.state = state;
if (state == KeeperState.Disconnected) {
stateChanged(StateListener.DISCONNECTED);
} else if (state == KeeperState.SyncConnected) {
stateChanged(StateListener.CONNECTED);
} else if (state == KeeperState.Expired) {
stateChanged(StateListener.DISCONNECTED);
}
}
public void handleNewSession() throws Exception {
stateChanged(StateListener.RECONNECTED);
}
});
}
代码示例来源:origin: org.apache.samza/samza-core
ZkJobCoordinator(Config config, MetricsRegistry metricsRegistry, ZkUtils zkUtils) {
this.config = config;
this.metrics = new ZkJobCoordinatorMetrics(metricsRegistry);
this.processorId = createProcessorId(config);
this.zkUtils = zkUtils;
// setup a listener for a session state change
// we are mostly interested in "session closed" and "new session created" events
zkUtils.getZkClient().subscribeStateChanges(new ZkSessionStateChangedListener());
leaderElector = new ZkLeaderElector(processorId, zkUtils);
leaderElector.setLeaderElectorListener(new LeaderElectorListenerImpl());
this.debounceTimeMs = new JobConfig(config).getDebounceTimeMs();
this.reporters = MetricsReporterLoader.getMetricsReporters(new MetricsConfig(config), processorId);
debounceTimer = new ScheduleAfterDebounceTime(processorId);
debounceTimer.setScheduledTaskCallback(throwable -> {
LOG.error("Received exception in debounce timer! Stopping the job coordinator", throwable);
stop();
});
this.barrier = new ZkBarrierForVersionUpgrade(zkUtils.getKeyBuilder().getJobModelVersionBarrierPrefix(), zkUtils, new ZkBarrierListenerImpl(), debounceTimer);
systemAdmins = new SystemAdmins(config);
streamMetadataCache = new StreamMetadataCache(systemAdmins, METADATA_CACHE_TTL_MS, SystemClock.instance());
}
代码示例来源:origin: org.apache.samza/samza-core_2.11
ZkJobCoordinator(Config config, MetricsRegistry metricsRegistry, ZkUtils zkUtils) {
this.config = config;
this.metrics = new ZkJobCoordinatorMetrics(metricsRegistry);
this.processorId = createProcessorId(config);
this.zkUtils = zkUtils;
// setup a listener for a session state change
// we are mostly interested in "session closed" and "new session created" events
zkUtils.getZkClient().subscribeStateChanges(new ZkSessionStateChangedListener());
leaderElector = new ZkLeaderElector(processorId, zkUtils);
leaderElector.setLeaderElectorListener(new LeaderElectorListenerImpl());
this.debounceTimeMs = new JobConfig(config).getDebounceTimeMs();
this.reporters = MetricsReporterLoader.getMetricsReporters(new MetricsConfig(config), processorId);
debounceTimer = new ScheduleAfterDebounceTime(processorId);
debounceTimer.setScheduledTaskCallback(throwable -> {
LOG.error("Received exception in debounce timer! Stopping the job coordinator", throwable);
stop();
});
this.barrier = new ZkBarrierForVersionUpgrade(zkUtils.getKeyBuilder().getJobModelVersionBarrierPrefix(), zkUtils, new ZkBarrierListenerImpl(), debounceTimer);
systemAdmins = new SystemAdmins(config);
streamMetadataCache = new StreamMetadataCache(systemAdmins, METADATA_CACHE_TTL_MS, SystemClock.instance());
}
代码示例来源:origin: apache/samza
ZkJobCoordinator(String processorId, Config config, MetricsRegistry metricsRegistry, ZkUtils zkUtils) {
this.config = config;
this.metrics = new ZkJobCoordinatorMetrics(metricsRegistry);
this.zkSessionMetrics = new ZkSessionMetrics(metricsRegistry);
this.processorId = processorId;
this.zkUtils = zkUtils;
// setup a listener for a session state change
// we are mostly interested in "session closed" and "new session created" events
zkUtils.getZkClient().subscribeStateChanges(new ZkSessionStateChangedListener());
leaderElector = new ZkLeaderElector(processorId, zkUtils);
leaderElector.setLeaderElectorListener(new LeaderElectorListenerImpl());
this.debounceTimeMs = new JobConfig(config).getDebounceTimeMs();
debounceTimer = new ScheduleAfterDebounceTime(processorId);
debounceTimer.setScheduledTaskCallback(throwable -> {
LOG.error("Received exception in debounce timer! Stopping the job coordinator", throwable);
stop();
});
this.barrier = new ZkBarrierForVersionUpgrade(zkUtils.getKeyBuilder().getJobModelVersionBarrierPrefix(), zkUtils, new ZkBarrierListenerImpl(), debounceTimer);
systemAdmins = new SystemAdmins(config);
streamMetadataCache = new StreamMetadataCache(systemAdmins, METADATA_CACHE_TTL_MS, SystemClock.instance());
LocationIdProviderFactory locationIdProviderFactory = Util.getObj(new JobConfig(config).getLocationIdProviderFactory(), LocationIdProviderFactory.class);
LocationIdProvider locationIdProvider = locationIdProviderFactory.getLocationIdProvider(config);
this.locationId = locationIdProvider.getLocationId();
}
本文整理了Java中org.I0Itec.zkclient.ZkClient.subscribeStateChanges()方法的一些代码示例,展示了ZkClient.subscribeStateCh
本文整理了Java中org.apache.helix.manager.zk.ZkClient.subscribeStateChanges()方法的一些代码示例,展示了ZkClient.subscrib
本文整理了Java中com.ucar.datalink.common.zookeeper.ZkClientX.subscribeStateChanges()方法的一些代码示例,展示了ZkClientX
我是一名优秀的程序员,十分优秀!