当前位置: 首页>>代码示例>>Java>>正文


Java Listenable类代码示例

本文整理汇总了Java中org.apache.curator.framework.listen.Listenable的典型用法代码示例。如果您正苦于以下问题:Java Listenable类的具体用法?Java Listenable怎么用?Java Listenable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Listenable类属于org.apache.curator.framework.listen包,在下文中一共展示了Listenable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: before

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Before
public void before() {
    curator = mock(CuratorFramework.class);
    connectionListenable = mock(Listenable.class);

    when(curator.getConnectionStateListenable()).thenReturn(connectionListenable);
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:8,代码来源:SimpleZookeeperConnectorTest.java

示例2: assertAddConnectionStateListener

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@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);
}
 
开发者ID:artoderk,项目名称:elastic-jobx,代码行数:12,代码来源:JobNodeStorageTest.java

示例3: assertAddDataListener

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@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);
}
 
开发者ID:artoderk,项目名称:elastic-jobx,代码行数:12,代码来源:JobNodeStorageTest.java

示例4: getConnectionStateListenable

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable() {
    return listenerStateProxy;
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:5,代码来源:RedirectorCuratorFramework.java

示例5: getCuratorListenable

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<CuratorListener> getCuratorListenable() {
    return listenerProxy;
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:5,代码来源:RedirectorCuratorFramework.java

示例6: getUnhandledErrorListenable

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable() {
    return curator.getUnhandledErrorListenable();
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:5,代码来源:RedirectorCuratorFramework.java

示例7: waitForAdminURLBind

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:63,代码来源:AdminFinder.java

示例8: getConnectionStateListenable

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable() {
    return new MockListenable<>();
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:5,代码来源:MockCurator.java

示例9: getCuratorListenable

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<CuratorListener> getCuratorListenable() {
    throw new UnsupportedOperationException("Not implemented in MockCurator");
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:5,代码来源:MockCurator.java

示例10: getUnhandledErrorListenable

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable() {
    throw new UnsupportedOperationException("Not implemented in MockCurator");
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:5,代码来源:MockCurator.java

示例11: mockFramework

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
private CuratorFramework mockFramework() {
    CuratorFramework framework = mock(CuratorFramework.class);
    when(framework.getConnectionStateListenable()).thenReturn(mock(Listenable.class));
    return framework;
}
 
开发者ID:librato,项目名称:watchconf,代码行数:6,代码来源:DynamicConfigZKAdapterTest.java

示例12: getConnectionStateListenable

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable()
{
    return client.getConnectionStateListenable();
}
 
开发者ID:apache,项目名称:curator,代码行数:6,代码来源:NamespaceFacade.java

示例13: getCuratorListenable

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<CuratorListener> getCuratorListenable()
{
    throw new UnsupportedOperationException("getCuratorListenable() is only available from a non-namespaced CuratorFramework instance");
}
 
开发者ID:apache,项目名称:curator,代码行数:6,代码来源:NamespaceFacade.java

示例14: getUnhandledErrorListenable

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
{
    return client.getUnhandledErrorListenable();
}
 
开发者ID:apache,项目名称:curator,代码行数:6,代码来源:NamespaceFacade.java

示例15: getConnectionStateListenable

import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable()
{
    return connectionStateManager.getListenable();
}
 
开发者ID:apache,项目名称:curator,代码行数:6,代码来源:CuratorFrameworkImpl.java


注:本文中的org.apache.curator.framework.listen.Listenable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。