@Override public Void apply(ConnectionStateListener listener) { listener.stateChanged(client, newState); return null; } }
@Override public void stateChanged(CuratorFramework client, ConnectionState newState) { connectionStateListener.stateChanged(client, newState); } }
@Override public Void apply(ConnectionStateListener listener) { listener.stateChanged(client, newState); return null; } }
@Override public void stateChanged(CuratorFramework client, ConnectionState newState) { connectionStateListener.stateChanged(client, newState); }
void bindConnectionStateListener(ConnectionStateListener connectionStateListener) { connectionStateListeners.add(connectionStateListener); State curr = state.get(); CuratorFramework curator = curr != null ? curr.curator : null; if (curator != null && curator.getZookeeperClient().isConnected()) { connectionStateListener.stateChanged(curator, ConnectionState.CONNECTED); } }
@Override public void stateChanged(CuratorFramework client, ConnectionState newState) { if (newState == ConnectionState.CONNECTED || newState == ConnectionState.READ_ONLY || newState == ConnectionState.RECONNECTED) { retryCount.set(0); if (registration == null) { registration = bundleContext.registerService(CuratorFramework.class, curator, null); } } for (ConnectionStateListener listener : connectionStateListeners) { listener.stateChanged(client, newState); } if (newState == ConnectionState.LOST) { try { run(); } catch (Exception e){ // this should never occurr LOGGER.debug("Error starting Zookeeper Client", e); } } }
void bindConnectionStateListener(ConnectionStateListener connectionStateListener) { connectionStateListeners.add(connectionStateListener); State curr = state.get(); CuratorFramework curator = curr != null ? curr.curator : null; if (curator != null && curator.getZookeeperClient().isConnected()) { connectionStateListener.stateChanged(curator, ConnectionState.CONNECTED); } }
public void close() { closed.set(true); CuratorFramework curator = this.curator; if (curator != null) { for (ConnectionStateListener listener : connectionStateListeners) { listener.stateChanged(curator, ConnectionState.LOST); } curator.getZookeeperClient().stop(); } try { executor.submit(this).get(); } catch (Exception e) { LOGGER.warn("Error while closing curator", e); } }
public void close(State next) { closed.set(true); CuratorFramework curator = this.curator; if (curator != null) { for (ConnectionStateListener listener : connectionStateListeners) { listener.stateChanged(curator, ConnectionState.LOST); } curator.getZookeeperClient().stop(); } try { executor.submit(this).get(); if (next != null) { executor.submit(next); } } catch (Exception e) { LOGGER.warn("Error while closing curator", e); } }
@Override public void stateChanged(CuratorFramework client, ConnectionState newState) { if (newState == ConnectionState.CONNECTED || newState == ConnectionState.READ_ONLY || newState == ConnectionState.RECONNECTED) { retryCount.set(0); if (registration == null) { CuratorFrameworkLocator.bindCurator(curator); // this is where the magic happens... registration = bundleContext.registerService(CuratorFramework.class, curator, null); // 12 (at least) seconds passed, >100 SCR components were activated curatorCompleteRegistration = bundleContext.registerService(CuratorComplete.class, new CuratorCompleteService(), null); } } for (ConnectionStateListener listener : connectionStateListeners) { listener.stateChanged(client, newState); } if (newState == ConnectionState.LOST) { try { run(); } catch (Exception e){ // this should never occurr LOGGER.debug("Error starting Zookeeper Client", e); } } }