unhandledErrorListeners.forEach(new Function<UnhandledErrorListener, Void>()
private void processEvent(final CuratorEvent curatorEvent) { if ( curatorEvent.getType() == CuratorEventType.WATCHED ) { validateConnection(curatorEvent.getWatchedEvent().getState()); } listeners.forEach(new Function<CuratorListener, Void>() { @Override public Void apply(CuratorListener listener) { try { OperationTrace trace = client.startAdvancedTracer("EventListener"); listener.eventReceived(CuratorFrameworkImpl.this, curatorEvent); trace.commit(); } catch ( Exception e ) { ThreadUtils.checkInterrupted(e); logError("Event listener threw exception", e); } return null; } }); } }
if ( state.compareAndSet(CuratorFrameworkState.STARTED, CuratorFrameworkState.STOPPED) ) listeners.forEach(new Function<CuratorListener, Void>()
private void notifyListenerOfStateChanged(final ConnectionState newState) { listeners.forEach ( new Function<SharedValueListener, Void>() { @Override public Void apply(SharedValueListener listener) { listener.stateChanged(client, newState); return null; } } ); } }
void callListeners(final GroupListener.GroupEvent event) { listeners.forEach ( new Function<GroupListener<T>, Void>() { @Override public Void apply(GroupListener<T> listener) { try { listener.groupEvent(ZooKeeperGroup.this, event); } catch (Exception e) { handleException(e); } return null; } } ); }
void callListeners(final GroupListener.GroupEvent event) { listeners.forEach ( new Function<GroupListener<T>, Void>() { @Override public Void apply(GroupListener<T> listener) { try { listener.groupEvent(ZooKeeperGroup.this, event); } catch (Exception e) { handleException(e); } return null; } } ); }
void callListeners(final PathChildrenCacheEvent event) { listeners.forEach ( new Function<PathChildrenCacheListener, Void>() { @Override public Void apply(PathChildrenCacheListener listener) { try { listener.childEvent(client, event); } catch (Exception e) { handleException(e); } return null; } } ); }
void callListeners(final PathChildrenCacheEvent event) { listeners.forEach ( new Function<PathChildrenCacheListener, Void>() { @Override public Void apply(PathChildrenCacheListener listener) { try { listener.childEvent(client, event); } catch (Exception e) { handleException(e); } return null; } } ); }
private void callListeners(final TreeCacheEvent event) { listeners.forEach(new Function<TreeCacheListener, Void>() { @Override public Void apply(TreeCacheListener listener) { try { listener.childEvent(client, event); } catch ( Exception e ) { ThreadUtils.checkInterrupted(e); handleException(e); } return null; } }); }
private void accept(ModeledCacheListener.Type type, ZPath path, Stat stat, T model) { listenerContainer.forEach(l -> { l.accept(type, path, stat, model); return null; }); } }
private void postEvent(WorkflowEvent event) { listenerContainer.forEach(l -> { if ( l != null ) { l.receiveEvent(event); } return null; }); } }
private void destroyZookeeperCofigurationSource() { running = false; zooKeeperConfigurationSource.close(); zooKeeperConfigurationSource = null; //tell all the listeners that there is no more data from this source. listeners.forEach(new Function<WatchedUpdateListener, Void>() { @Nullable @Override public Void apply(@Nullable WatchedUpdateListener watchedUpdateListener) { watchedUpdateListener.updateConfiguration(WatchedUpdateResult.createFull(new HashMap<String, Object>())); return null; } }); }
private void updateToLatestVersion() { Deque<Integer> versions = new ArrayDeque<>(); versionQueue.drainTo(versions); if (!versions.isEmpty()) { int latestVersion = versions.getLast(); final Collection<BaragonServiceState> newState = stateFetcher.fetchState(latestVersion); listenerContainer.forEach(new Function<BaragonStateListener, Void>() { @Override public Void apply(BaragonStateListener listener) { listener.stateChanged(newState); return null; } }); } }
void callListeners(final GroupListener.GroupEvent event) { listeners.forEach(listener -> { try { listener.groupEvent(ZooKeeperGroup.this, event); } catch (Exception e) { handleException(e); } return null; } ); }
void callListeners(final PathChildrenCacheEvent event) { listeners.forEach ( listener -> { try { listener.childEvent(client, event); } catch (Exception e) { handleException(e); } return null; }); }
@Override public void close() throws IOException { Preconditions.checkState(state.compareAndSet(State.STARTED, State.STOPPED), "Already closed or has not been started"); listenerContainer.forEach( new Function<ServiceCacheListener<T>, Void>() { @Override public Void apply(ServiceCacheListener<T> listener) { discovery.getClient().getConnectionStateListenable().removeListener(listener); return null; } } ); listenerContainer.clear(); CloseableUtils.closeQuietly(cache); discovery.cacheClosed(this); }
private void initializeZookeeperConfigurationSource() { if (running) { LOGGER.warn("Detected creation of node {}, but zookeeper configuration source already running. This should not happen. Ignoring event...", instanceConfigPath); return; } this.zooKeeperConfigurationSource = new ZooKeeperConfigurationSource(curatorFramework, instanceConfigPath); listeners.forEach(new Function<WatchedUpdateListener, Void>() { @Nullable @Override public Void apply(@Nullable WatchedUpdateListener watchedUpdateListener) { zooKeeperConfigurationSource.addUpdateListener(watchedUpdateListener); return null; } }); try { zooKeeperConfigurationSource.start(); } catch (Exception e) { LOGGER.error("errro starting zookeeper configuration source", e); throw new BootstrapException("Error initializing zookeeper configuration source", e); } running = true; }
@Override public void childEvent(CuratorFramework client, TreeCacheEvent event) { try { internalChildEvent(event); } catch ( Exception e ) { ThreadUtils.checkInterrupted(e); listenerContainer.forEach(l -> { l.handleException(e); return null; }); } }
@Override public void close() throws IOException { Preconditions.checkState(state.compareAndSet(State.STARTED, State.STOPPED), "Already closed or has not been started"); listenerContainer.forEach ( new Function<ServiceCacheListener, Void>() { @Override public Void apply(ServiceCacheListener listener) { discovery.getClient().getConnectionStateListenable().removeListener(listener); return null; } } ); listenerContainer.clear(); CloseableUtils.closeQuietly(cache); discovery.cacheClosed(this); }