Java 类org.apache.curator.framework.listen.Listenable 实例源码

项目:redirector    文件:SimpleZookeeperConnectorTest.java   
@Before
public void before() {
    curator = mock(CuratorFramework.class);
    connectionListenable = mock(Listenable.class);

    when(curator.getConnectionStateListenable()).thenReturn(connectionListenable);
}
项目:elastic-jobx    文件:JobNodeStorageTest.java   
@Test
public void assertAddConnectionStateListener() {
    CuratorFramework client = mock(CuratorFramework.class);
    @SuppressWarnings("unchecked")
    Listenable<ConnectionStateListener> listeners = mock(Listenable.class);
    ConnectionStateListener listener = mock(ConnectionStateListener.class);
    when(client.getConnectionStateListenable()).thenReturn(listeners);
    when(coordinatorRegistryCenter.getRawClient()).thenReturn(client);
    jobNodeStorage.addConnectionStateListener(listener);
    verify(listeners).addListener(listener);
}
项目:elastic-jobx    文件:JobNodeStorageTest.java   
@Test
public void assertAddDataListener() {
    TreeCache treeCache = mock(TreeCache.class);
    @SuppressWarnings("unchecked")
    Listenable<TreeCacheListener> listeners = mock(Listenable.class);
    TreeCacheListener listener = mock(TreeCacheListener.class);
    when(treeCache.getListenable()).thenReturn(listeners);
    when(coordinatorRegistryCenter.getRawCache("/testJob")).thenReturn(treeCache);
    jobNodeStorage.addDataListener(listener);
    verify(listeners).addListener(listener);
}
项目:ElasticJob    文件:JobNodeStorageTest.java   
@Test
public void assertAddConnectionStateListener() {
    CuratorFramework client = mock(CuratorFramework.class);
    @SuppressWarnings("unchecked")
    Listenable<ConnectionStateListener> listeners = mock(Listenable.class);
    ConnectionStateListener listener = mock(ConnectionStateListener.class);
    when(client.getConnectionStateListenable()).thenReturn(listeners);
    when(coordinatorRegistryCenter.getRawClient()).thenReturn(client);
    jobNodeStorage.addConnectionStateListener(listener);
    verify(listeners).addListener(listener);
}
项目:ElasticJob    文件:JobNodeStorageTest.java   
@Test
public void assertAddDataListener() {
    TreeCache treeCache = mock(TreeCache.class);
    @SuppressWarnings("unchecked")
    Listenable<TreeCacheListener> listeners = mock(Listenable.class);
    TreeCacheListener listener = mock(TreeCacheListener.class);
    when(treeCache.getListenable()).thenReturn(listeners);
    when(coordinatorRegistryCenter.getRawCache("/testJob")).thenReturn(treeCache);
    jobNodeStorage.addDataListener(listener);
    verify(listeners).addListener(listener);
}
项目:redirector    文件:RedirectorCuratorFramework.java   
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable() {
    return listenerStateProxy;
}
项目:redirector    文件:RedirectorCuratorFramework.java   
@Override
public Listenable<CuratorListener> getCuratorListenable() {
    return listenerProxy;
}
项目:redirector    文件:RedirectorCuratorFramework.java   
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable() {
    return curator.getUnhandledErrorListenable();
}
项目:HeliosStreams    文件:AdminFinder.java   
/**
 * Starts an AdminURL bind event loop
 */
protected void waitForAdminURLBind() {
    final TreeCache tc = TreeCache.newBuilder(cf, ZOOKEEP_URL)
            //.setExecutor(threadFactory)
            //.setExecutor((ExecutorService)threadPool)
            //.setCacheData(true)
            .build();
    final AtomicBoolean waiting = new AtomicBoolean(true);
    final Thread waitForAdminURLThread = threadFactory.newThread(new Runnable(){
        @Override
        public void run() {
            final Thread waitThread = Thread.currentThread();
            try {                       
                final Listenable<TreeCacheListener> listen = tc.getListenable();            
                listen.addListener(new TreeCacheListener(){
                    @Override
                    public void childEvent(final CuratorFramework client, final TreeCacheEvent event) throws Exception {
                        ChildData cd = event.getData();
                        if(cd!=null) {
                            log.info("TreeCache Bound [{}]", cd.getPath());
                            final String boundPath = cd.getPath();
                            if(ZOOKEEP_URL.equals(boundPath)) {
                                updateAdminURL(cd.getData());
                                tc.close();
                                waiting.set(false);
                                waitThread.interrupt();
                            }
                        }
                    }
                });
                tc.start();
                log.debug("AdminURL TreeCache Started");            
                // Check for the data one more time in case we missed 
                // the bind event while setting up the listener
                final ZooKeeper z = cf.getZookeeperClient().getZooKeeper();
                final Stat st = z.exists(ZOOKEEP_URL, false);
                if(st!=null) {
                    updateAdminURL(z.getData(ZOOKEEP_URL, false, st));
                    tc.close();
                }
                while(true) {
                    try {
                        Thread.currentThread().join(retryPauseTime);
                        log.info("Still waiting for AdminURL....");
                    } catch (InterruptedException iex) {
                        if(Thread.interrupted()) Thread.interrupted();
                    }
                    if(!waiting.get()) break;
                }
                log.info("Ended wait for AdminURL");                    
            } catch (Exception ex) {
                log.error("Failed to wait for AdminURL bind",  ex);
                // FIXME:
            } finally {
                try { tc.close(); } catch (Exception x) {/* No Op */}
            }               
        }
    });
    waitForAdminURLThread.start();
}
项目:vespa    文件:MockCurator.java   
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable() {
    return new MockListenable<>();
}
项目:vespa    文件:MockCurator.java   
@Override
public Listenable<CuratorListener> getCuratorListenable() {
    throw new UnsupportedOperationException("Not implemented in MockCurator");
}
项目:vespa    文件:MockCurator.java   
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable() {
    throw new UnsupportedOperationException("Not implemented in MockCurator");
}
项目:watchconf    文件:DynamicConfigZKAdapterTest.java   
private CuratorFramework mockFramework() {
    CuratorFramework framework = mock(CuratorFramework.class);
    when(framework.getConnectionStateListenable()).thenReturn(mock(Listenable.class));
    return framework;
}
项目:curator    文件:NamespaceFacade.java   
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable()
{
    return client.getConnectionStateListenable();
}
项目:curator    文件:NamespaceFacade.java   
@Override
public Listenable<CuratorListener> getCuratorListenable()
{
    throw new UnsupportedOperationException("getCuratorListenable() is only available from a non-namespaced CuratorFramework instance");
}
项目:curator    文件:NamespaceFacade.java   
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
{
    return client.getUnhandledErrorListenable();
}
项目:curator    文件:CuratorFrameworkImpl.java   
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable()
{
    return connectionStateManager.getListenable();
}
项目:curator    文件:CuratorFrameworkImpl.java   
@Override
public Listenable<CuratorListener> getCuratorListenable()
{
    return listeners;
}
项目:curator    文件:CuratorFrameworkImpl.java   
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
{
    return unhandledErrorListeners;
}
项目:curator    文件:WatcherRemovalFacade.java   
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable()
{
    return client.getConnectionStateListenable();
}
项目:curator    文件:WatcherRemovalFacade.java   
@Override
public Listenable<CuratorListener> getCuratorListenable()
{
    return client.getCuratorListenable();
}
项目:curator    文件:WatcherRemovalFacade.java   
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
{
    return client.getUnhandledErrorListenable();
}
项目:curator    文件:ModeledCacheImpl.java   
public Listenable<ModeledCacheListener<T>> listenable()
{
    return listenerContainer;
}
项目:curator    文件:CachedModeledFrameworkImpl.java   
@Override
public Listenable<ModeledCacheListener<T>> listenable()
{
    return cache.listenable();
}
项目:curator    文件:TreeCache.java   
/**
 * Allows catching unhandled errors in asynchornous operations.
 *
 * TODO: consider making public.
 */
@VisibleForTesting
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
{
    return errorListeners;
}
项目:workflow    文件:WorkflowListenerManagerImpl.java   
@Override
public Listenable<WorkflowListener> getListenable()
{
    return listenerContainer;
}
项目:disco-java    文件:DiscoServiceTest.java   
@SuppressWarnings("unchecked")
private CuratorFramework mockFramework() {
    CuratorFramework framework = mock(CuratorFramework.class);
    when(framework.getConnectionStateListenable()).thenReturn(mock(Listenable.class));
    return framework;
}
项目:cultivar    文件:NamespacedCuratorFramework.java   
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable() {
    return delegateFramework.getConnectionStateListenable();
}
项目:cultivar    文件:NamespacedCuratorFramework.java   
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable() {
    return delegateFramework.getUnhandledErrorListenable();
}
项目:cultivar    文件:NamespacedCuratorFramework.java   
@Override
public Listenable<CuratorListener> getCuratorListenable() {
    return delegateFramework.getCuratorListenable();
}
项目:curator    文件:CuratorFramework.java   
/**
 * Returns the listenable interface for the Connect State
 *
 * @return listenable
 */
public Listenable<ConnectionStateListener> getConnectionStateListenable();
项目:curator    文件:CuratorFramework.java   
/**
 * Returns the listenable interface for events
 *
 * @return listenable
 */
public Listenable<CuratorListener> getCuratorListenable();
项目:curator    文件:CuratorFramework.java   
/**
 * Returns the listenable interface for unhandled errors
 *
 * @return listenable
 */
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable();
项目:curator    文件:CachedModeledFramework.java   
/**
 * Return the listener container so that you can add/remove listeners
 *
 * @return listener container
 */
Listenable<ModeledCacheListener<T>> listenable();
项目:curator    文件:TreeCache.java   
/**
 * Return the cache listenable
 *
 * @return listenable
 */
public Listenable<TreeCacheListener> getListenable()
{
    return listeners;
}
项目:workflow    文件:WorkflowListenerManager.java   
/**
 * Return the container to add/remove event listeners
 *
 * @return container
 */
Listenable<WorkflowListener> getListenable();