gpt4 book ai didi

org.apache.metron.zookeeper.ZKCache类的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 19:59:31 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.metron.zookeeper.ZKCache类的一些代码示例,展示了ZKCache类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKCache类的具体详情如下:
包路径:org.apache.metron.zookeeper.ZKCache
类名称:ZKCache

ZKCache介绍

[英]A zookeeper cache that composes the Curator TreeCache. This is the basic point of abstraction to interact with metron configuration in Zookeeper.
[中]组成策展人树形图的动物园管理员缓存。这是在Zookeeper中与metron配置交互的基本抽象点。

代码示例

代码示例来源:origin: apache/metron

@Override
 public void cleanup() {
  cache.close();
  client.close();
 }
}

代码示例来源:origin: apache/metron

/**
 * Create the ZKCache object based on the config passed in the Builder.
 * @return The ZKCache
 */
public ZKCache build() {
 if(!client.isPresent()) {
  throw new IllegalArgumentException("Zookeeper client must be specified.");
 }
 if(listener.isEmpty()) {
  LOG.warn("Zookeeper listener is null or empty, which is very likely an error.");
 }
 if(zkRoot == null) {
  throw new IllegalArgumentException("Zookeeper root must not be null.");
 }
 return new ZKCache(client.get(), listener, zkRoot, ownClient);
}

代码示例来源:origin: apache/metron

/**
 * Specify your own zookeeper URL.  If you pass this in, the ZKCache will own the client
 * and it will be closed when the ZKCache is closed.
 *
 * @param zookeeperUrl The zookeeper quorum
 * @return The Builder
 */
public Builder withClient(String zookeeperUrl) {
 this.client = Optional.ofNullable(createClient(zookeeperUrl, Optional.empty()));
 ownClient = true;
 return this;
}

代码示例来源:origin: apache/metron

private void initializeCache(CuratorFramework client) {
 Lock writeLock = lock.writeLock();
 try {
  writeLock.lock();
  SimpleEventListener listener = new SimpleEventListener.Builder()
      .with(Iterables.transform(updaters, u -> u::update)
          , TreeCacheEvent.Type.NODE_ADDED
          , TreeCacheEvent.Type.NODE_UPDATED
      )
      .with(Iterables.transform(updaters, u -> u::delete)
          , TreeCacheEvent.Type.NODE_REMOVED
      )
      .build();
  cache = new ZKCache.Builder()
      .withClient(client)
      .withListener(listener)
      .withRoot(Constants.ZOOKEEPER_TOPOLOGY_ROOT)
      .build();
  for (ConfigurationsUpdater<? extends Configurations> updater : updaters) {
   updater.forceUpdate(client);
  }
  cache.start();
 } catch (Exception e) {
  LOG.error("Unable to initialize zookeeper cache: " + e.getMessage(), e);
  throw new IllegalStateException("Unable to initialize zookeeper cache: " + e.getMessage(), e);
 }
 finally {
  writeLock.unlock();
 }
}

代码示例来源:origin: apache/metron

.build();
updater.forceUpdate(zookeeperClient);
zookeeperCache.start();

代码示例来源:origin: apache/metron

@Override
public void cleanup() {
 try {
  zookeeperCache.close();
  zookeeperClient.close();
  flushExpiredExecutor.shutdown();
 } catch(Throwable e) {
  LOG.error("Exception when cleaning up", e);
 }
}

代码示例来源:origin: apache/metron

.build();
updater.forceUpdate(client);
cache.start();

代码示例来源:origin: apache/metron

/**
 * Specify your own zookeeper URL.  If you pass this in, the ZKCache will own the client
 * and it will be closed when the ZKCache is closed.
 *
 * @param zookeeperUrl The zookeeper quorum
 * @param retryPolicy The RetryPolicy to use
 * @return The Builder
 */
public Builder withClient(String zookeeperUrl, RetryPolicy retryPolicy) {
 this.client = Optional.ofNullable(createClient(zookeeperUrl, Optional.ofNullable(retryPolicy)));
 ownClient = true;
 return this;
}

代码示例来源:origin: apache/metron

@Override
public void close() {
 Lock writeLock = lock.writeLock();
 try {
  writeLock.lock();
  if (cache != null) {
   cache.close();
  }
 }
 finally{
  writeLock.unlock();
 }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com