本文整理汇总了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);
}
示例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);
}
示例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);
}
示例4: getConnectionStateListenable
import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable() {
return listenerStateProxy;
}
示例5: getCuratorListenable
import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<CuratorListener> getCuratorListenable() {
return listenerProxy;
}
示例6: getUnhandledErrorListenable
import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable() {
return curator.getUnhandledErrorListenable();
}
示例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();
}
示例8: getConnectionStateListenable
import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable() {
return new MockListenable<>();
}
示例9: getCuratorListenable
import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<CuratorListener> getCuratorListenable() {
throw new UnsupportedOperationException("Not implemented in MockCurator");
}
示例10: getUnhandledErrorListenable
import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable() {
throw new UnsupportedOperationException("Not implemented in MockCurator");
}
示例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;
}
示例12: getConnectionStateListenable
import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable()
{
return client.getConnectionStateListenable();
}
示例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");
}
示例14: getUnhandledErrorListenable
import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<UnhandledErrorListener> getUnhandledErrorListenable()
{
return client.getUnhandledErrorListenable();
}
示例15: getConnectionStateListenable
import org.apache.curator.framework.listen.Listenable; //导入依赖的package包/类
@Override
public Listenable<ConnectionStateListener> getConnectionStateListenable()
{
return connectionStateManager.getListenable();
}