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


Java ListenerContainer类代码示例

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


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

示例1: ServiceCacheImplProxy

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
public ServiceCacheImplProxy(ServiceDiscoveryImpl<T> discovery, String name, ThreadFactory threadFactory) {
    this.serviceCacheImpl = new ServiceCacheImpl<T>(discovery, name, threadFactory);

    try {
        Field privateListenerContainerField = ServiceCacheImpl.class.getDeclaredField("listenerContainer");
        privateListenerContainerField.setAccessible(true);
        this.listenerContainer = (ListenerContainer)privateListenerContainerField.get(serviceCacheImpl);
    } catch (NoSuchFieldException | IllegalAccessException e) {
        log.error("Failed to construct Service Cache. Container listeners is null.");
    }

    Preconditions.checkNotNull(discovery, "discovery cannot be null");
    Preconditions.checkNotNull(name, "name cannot be null");
    Preconditions.checkNotNull(threadFactory, "threadFactory cannot be null");
    Preconditions.checkNotNull(this.listenerContainer, "container of listeners can not be null");


    this.discovery = discovery;
    this.cache = new PathChildrenCache(discovery.getClient(), discovery.pathForName(name), true, threadFactory);
    this.cache.getListenable().addListener(this);
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:22,代码来源:ServiceCacheImplProxy.java

示例2: testStoreRegistersDispatcherAndStartsItsClient

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
/**
 * This test ensures store subscribes to receive events from underlying client. Dispatcher tests ensures listeners
 * are fired on incoming events. These two sets of tests ensure observer pattern in {@code TransientStore} works fine.
 */
@Test
public void testStoreRegistersDispatcherAndStartsItsClient() throws Exception {
  final StoreWithMockClient<String> store = new StoreWithMockClient<>(config, curator);

  final PathChildrenCache cache = Mockito.mock(PathChildrenCache.class);
  final ZookeeperClient client = store.getClient();
  Mockito
      .when(client.getCache())
      .thenReturn(cache);

  final ListenerContainer<PathChildrenCacheListener> container = Mockito.mock(ListenerContainer.class);
  Mockito
      .when(cache.getListenable())
      .thenReturn(container);

  store.start();

  Mockito
      .verify(container)
      .addListener(store.dispatcher);

  Mockito
      .verify(client)
      .start();
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:30,代码来源:TestEphemeralStore.java

示例3: createPathChildrenCacheMock

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
/**
 * Create mock {@link PathChildrenCache} using given controller ID and DPIDs.
 *
 * @param controllerId Controller ID to represent current data.
 * @param paths        List of HexString indicating switch's DPID.
 * @param listener     Callback object to be set as Listenable.
 * @return Mock PathChildrenCache object
 * @throws Exception
 */
private PathChildrenCache createPathChildrenCacheMock(
            final String controllerId,
            final String[] paths,
            ListenerContainer<PathChildrenCacheListener> listener)
                throws Exception {
    PathChildrenCache pathChildrenCache = createMock(PathChildrenCache.class);

    expect(pathChildrenCache.getListenable()).andReturn(listener).anyTimes();

    pathChildrenCache.start(anyObject(StartMode.class));
    expectLastCall().anyTimes();

    List<ChildData> childs = new ArrayList<ChildData>();
    for (String path : paths) {
        childs.add(createChildDataMockForCurrentData(controllerId, path));
    }
    expect(pathChildrenCache.getCurrentData()).andReturn(childs).anyTimes();

    pathChildrenCache.rebuild();
    expectLastCall().anyTimes();

    replay(pathChildrenCache);

    return pathChildrenCache;
}
 
开发者ID:opennetworkinglab,项目名称:spring-open,代码行数:35,代码来源:ZookeeperRegistryTest.java

示例4: getListenable

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
/**
 * Return the cache listenable
 *
 * @return listenable
 */
public ListenerContainer<NodeCacheListener> getListenable()
{
    Preconditions.checkState(state.get() != State.CLOSED, "Closed");

    return listeners;
}
 
开发者ID:apache,项目名称:curator,代码行数:12,代码来源:NodeCache.java

示例5: BaragonStateWatcher

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
@Inject
public BaragonStateWatcher(final BaragonStateFetcher stateFetcher,
                           Set<BaragonStateListener> listeners,
                           @Baragon PersistentWatcher watcher) {
  this.stateFetcher = stateFetcher;
  this.listenerContainer = new ListenerContainer<>();
  this.executor = newExecutor();
  this.versionQueue = new LinkedTransferQueue<>();
  for (BaragonStateListener listener : listeners) {
    listenerContainer.addListener(listener);
  }

  watcher.getEventListenable().addListener(new EventListener() {

    @Override
    public void newEvent(Event event) {
      switch (event.getType()) {
        case NODE_UPDATED:
          int version = event.getStat().getVersion();
          versionQueue.add(version);
          executor.submit(new Runnable() {

            @Override
            public void run() {
              updateToLatestVersion();
            }
          });
          break;
        case NODE_DELETED:
          LOG.warn("Baragon state node was deleted");
          break;
        default:
          LOG.warn("Unrecognized event type {}", event.getType());
          break;
      }
    }
  }, executor);

  watcher.start();
}
 
开发者ID:HubSpot,项目名称:Baragon,代码行数:41,代码来源:BaragonStateWatcher.java

示例6: clearListener

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
public void clearListener(){
	ListenerContainer<ConnectionStateListener> list=(ListenerContainer<ConnectionStateListener>) client.getConnectionStateListenable();
	list.clear();
}
 
开发者ID:elves-project,项目名称:openapi,代码行数:5,代码来源:ZookeeperExcutor.java

示例7: CuratorFrameworkImpl

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
public CuratorFrameworkImpl(CuratorFrameworkFactory.Builder builder)
{
    ZookeeperFactory localZookeeperFactory = makeZookeeperFactory(builder.getZookeeperFactory());
    this.client = new CuratorZookeeperClient
        (
            localZookeeperFactory,
            builder.getEnsembleProvider(),
            builder.getSessionTimeoutMs(),
            builder.getConnectionTimeoutMs(),
            new Watcher()
            {
                @Override
                public void process(WatchedEvent watchedEvent)
                {
                    CuratorEvent event = new CuratorEventImpl(CuratorFrameworkImpl.this, CuratorEventType.WATCHED, watchedEvent.getState().getIntValue(), unfixForNamespace(watchedEvent.getPath()), null, null, null, null, null, watchedEvent, null, null);
                    processEvent(event);
                }
            },
            builder.getRetryPolicy(),
            builder.canBeReadOnly(),
            builder.getConnectionHandlingPolicy()
        );

    internalConnectionHandler = new StandardInternalConnectionHandler();
    listeners = new ListenerContainer<CuratorListener>();
    unhandledErrorListeners = new ListenerContainer<UnhandledErrorListener>();
    backgroundOperations = new DelayQueue<OperationAndData<?>>();
    forcedSleepOperations = new LinkedBlockingQueue<>();
    namespace = new NamespaceImpl(this, builder.getNamespace());
    threadFactory = getThreadFactory(builder);
    maxCloseWaitMs = builder.getMaxCloseWaitMs();
    connectionStateManager = new ConnectionStateManager(this, builder.getThreadFactory(), builder.getSessionTimeoutMs(), builder.getConnectionHandlingPolicy().getSimulatedSessionExpirationPercent());
    compressionProvider = builder.getCompressionProvider();
    aclProvider = builder.getAclProvider();
    state = new AtomicReference<CuratorFrameworkState>(CuratorFrameworkState.LATENT);
    useContainerParentsIfAvailable = builder.useContainerParentsIfAvailable();
    connectionStateErrorPolicy = Preconditions.checkNotNull(builder.getConnectionStateErrorPolicy(), "errorPolicy cannot be null");
    schemaSet = Preconditions.checkNotNull(builder.getSchemaSet(), "schemaSet cannot be null");
    zk34CompatibilityMode = builder.isZk34CompatibilityMode();

    byte[] builderDefaultData = builder.getDefaultData();
    defaultData = (builderDefaultData != null) ? Arrays.copyOf(builderDefaultData, builderDefaultData.length) : new byte[0];
    authInfos = buildAuths(builder);

    failedDeleteManager = new FailedDeleteManager(this);
    failedRemoveWatcherManager = new FailedRemoveWatchManager(this);
    namespaceFacadeCache = new NamespaceFacadeCache(this);

    ensembleTracker = zk34CompatibilityMode ? null : new EnsembleTracker(this, builder.getEnsembleProvider());
}
 
开发者ID:apache,项目名称:curator,代码行数:51,代码来源:CuratorFrameworkImpl.java

示例8: getPutListenerContainer

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

示例9: getPutListenerContainer

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
/**
 * Return the manager for put listeners
 *
 * @return put listener container
 */
@Override
public ListenerContainer<QueuePutListener<T>> getPutListenerContainer()
{
    return queue.getPutListenerContainer();
}
 
开发者ID:apache,项目名称:curator,代码行数:11,代码来源:DistributedDelayQueue.java

示例10: getPutListenerContainer

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
/**
 * Return the manager for put listeners
 *
 * @return put listener container
 */
@Override
public ListenerContainer<QueuePutListener<T>> getPutListenerContainer()
{
    return putListenerContainer;
}
 
开发者ID:apache,项目名称:curator,代码行数:11,代码来源:DistributedQueue.java

示例11: getListenable

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
public ListenerContainer<NodeCacheListener> getListenable() {
    return delegate().getListenable();
}
 
开发者ID:ReadyTalk,项目名称:cultivar,代码行数:4,代码来源:NodeCacheWrapper.java

示例12: getListenable

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
/**
 * Return the listenable
 *
 * @return listenable
 */
public ListenerContainer<ConnectionStateListener> getListenable()
{
    return listeners;
}
 
开发者ID:apache,项目名称:curator,代码行数:10,代码来源:ConnectionStateManager.java

示例13: getListenable

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
/**
 * Returns the listenable
 *
 * @return listenable
 */
public ListenerContainer<SharedValueListener> getListenable()
{
    return listeners;
}
 
开发者ID:apache,项目名称:curator,代码行数:10,代码来源:SharedValue.java

示例14: getListenable

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
/**
 * Returns the listenable
 *
 * @return listenable
 */
public ListenerContainer<SharedValueListener> getListenable();
 
开发者ID:apache,项目名称:curator,代码行数:7,代码来源:SharedValueReader.java

示例15: getListenable

import org.apache.curator.framework.listen.ListenerContainer; //导入依赖的package包/类
/**
 * Returns the listenable
 *
 * @return listenable
 */
public ListenerContainer<PersistentNodeListener> getListenable()
{
    return listeners;
}
 
开发者ID:apache,项目名称:curator,代码行数:10,代码来源:PersistentNode.java


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