@Override public void subscribeStateChanges(IZkStateListener listener) { zkClient.subscribeStateChanges(listener); }
public void addListener(IZkStateListener listener) { completableFuture.whenComplete((value, exception) -> { this.makeClientReady(value, exception); if (exception == null) { client.subscribeStateChanges(listener); } }); }
public void addListener(IZkStateListener listener) { completableFuture.whenComplete((value, exception) -> { this.makeClientReady(value, exception); if (exception == null) { client.subscribeStateChanges(listener); } }); }
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); }
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); } }); }
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); } }); }
public void addListener(IZkStateListener listener) { completableFuture.whenComplete((value, exception) -> { this.makeClientReady(value, exception); if (exception == null) { client.subscribeStateChanges(listener); } }); }
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); }
public void addListener(IZkStateListener listener) { completableFuture.whenComplete((value, exception) -> { this.makeClientReady(value, exception); if (exception == null) { client.subscribeStateChanges(listener); } }); }
public void addListener(IZkStateListener listener) { completableFuture.whenComplete((value, exception) -> { this.makeClientReady(value, exception); if (exception == null) { client.subscribeStateChanges(listener); } }); }
@Override public void registerListener(final String path, final LeaderElectionNodeListener listener) { zkClient.subscribeDataChanges(path, listener); zkClient.subscribeStateChanges(listener); }
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); }
@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); } } });
@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); }
@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); } } });
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 { } }); }
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); } }); }
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()); }
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()); }
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(); }