gpt4 book ai didi

org.apache.twill.zookeeper.ZKClients类的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 15:26:40 26 4
gpt4 key购买 nike

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

ZKClients介绍

[英]Utility class to create ZKClient instances.
[中]用于创建客户端实例的实用程序类。

代码示例

代码示例来源:origin: co.cask.cdap/cdap-data-fabric

private ZKClient getCoordinatorZKClient() {
  return ZKClients.namespace(zkClient, Constants.Stream.STREAM_ZK_COORDINATION_NAMESPACE);
 }
}

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

ZKClients.reWatchOnExpire(
  ZKClients.retryOnFailure(
     new TephraZKClientService(zkQuorumServersString, timeOut, null,
         ArrayListMultimap.<String, byte[]>create()),

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

/**
 * Creates a {@link ZKClientService}.
 */
protected final ZKClientService createZKClient() {
 TwillRuntimeSpecification twillRuntimeSpec = getTwillRuntimeSpecification();
 return ZKClientServices.delegate(
  ZKClients.namespace(
   ZKClients.reWatchOnExpire(
    ZKClients.retryOnFailure(
     ZKClientService.Builder.of(twillRuntimeSpec.getZkConnectStr()).build(),
     RetryStrategies.fixDelay(1, TimeUnit.SECONDS)
    )
   ), "/" + twillRuntimeSpec.getTwillAppName()
  )
 );
}

代码示例来源:origin: caskdata/coopr

private ZKClientService getZKService(String connectString) {
  return ZKClientServices.delegate(
   ZKClients.namespace(
    ZKClients.reWatchOnExpire(
     ZKClients.retryOnFailure(
      ZKClientService.Builder.of(connectString)
       .setSessionTimeout(conf.getInt(Constants.ZOOKEEPER_SESSION_TIMEOUT_MILLIS))
       .build(),
      RetryStrategies.fixDelay(2, TimeUnit.SECONDS)
     )
    ), conf.get(Constants.ZOOKEEPER_NAMESPACE)
   )
  );
 }
}

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

@Override
public PhoenixTransactionService getTransactionService(Configuration config, ConnectionInfo connInfo, int port) {
  config.setInt(TxConstants.Service.CFG_DATA_TX_BIND_PORT, port);
  int retryTimeOut = config.getInt(TxConstants.Service.CFG_DATA_TX_CLIENT_DISCOVERY_TIMEOUT_SEC, 
      TxConstants.Service.DEFAULT_DATA_TX_CLIENT_DISCOVERY_TIMEOUT_SEC);
  ZKClientService zkClient = ZKClientServices.delegate(
   ZKClients.reWatchOnExpire(
    ZKClients.retryOnFailure(
     ZKClientService.Builder.of(connInfo.getZookeeperConnectionString())
      .setSessionTimeout(config.getInt(HConstants.ZK_SESSION_TIMEOUT,
          HConstants.DEFAULT_ZK_SESSION_TIMEOUT))
      .build(),
     RetryStrategies.exponentialDelay(500, retryTimeOut, TimeUnit.MILLISECONDS)
    )
   )
  );
  DiscoveryService discovery = new ZKDiscoveryService(zkClient);
  TransactionManager txManager = new TransactionManager(config, new HDFSTransactionStateStorage(config, 
      new SnapshotCodecProvider(config), new TxMetricsCollector()), new TxMetricsCollector());
  TransactionService txService = new TransactionService(config, zkClient, discovery, Providers.of(txManager));
  TephraTransactionService service = new TephraTransactionService(zkClient, txService);
  service.start();
  return service;
}

代码示例来源:origin: org.apache.twill/twill-yarn

/**
 * Creates a {@link ZKClientService}.
 */
protected final ZKClientService createZKClient() {
 TwillRuntimeSpecification twillRuntimeSpec = getTwillRuntimeSpecification();
 return ZKClientServices.delegate(
  ZKClients.namespace(
   ZKClients.reWatchOnExpire(
    ZKClients.retryOnFailure(
     ZKClientService.Builder.of(twillRuntimeSpec.getZkConnectStr()).build(),
     RetryStrategies.fixDelay(1, TimeUnit.SECONDS)
    )
   ), "/" + twillRuntimeSpec.getTwillAppName()
  )
 );
}

代码示例来源:origin: co.cask.cdap/cdap-data-fabric

private ZKClient getCoordinatorZKClient() {
 return ZKClients.namespace(zkClient, Constants.Stream.STREAM_ZK_COORDINATION_NAMESPACE);
}

代码示例来源:origin: co.cask.tephra/tephra-core

@Provides
 @Singleton
 private ZKClientService provideZKClientService(Configuration conf) {
  String zkStr = conf.get(TxConstants.Service.CFG_DATA_TX_ZOOKEEPER_QUORUM);
  if (zkStr == null) {
   // Default to HBase one.
   zkStr = conf.get(TxConstants.HBase.ZOOKEEPER_QUORUM);
  }

  int timeOut = conf.getInt(TxConstants.HBase.ZK_SESSION_TIMEOUT, TxConstants.HBase.DEFAULT_ZK_SESSION_TIMEOUT);
  ZKClientService zkClientService = new TephraZKClientService(zkStr, timeOut, null,
                                ArrayListMultimap.<String, byte[]>create());
  return ZKClientServices.delegate(
   ZKClients.reWatchOnExpire(
    ZKClients.retryOnFailure(zkClientService, RetryStrategies.exponentialDelay(500, 2000, TimeUnit.MILLISECONDS)
    )
   )
  );
 }
}

代码示例来源:origin: co.cask.cdap/cdap-common

kafkaNamespace = "/" + kafkaNamespace;
zkClientService = ZKClientServices.delegate(ZKClients.namespace(zkClientService, kafkaNamespace));
ZKClients.reWatchOnExpire(
 ZKClients.retryOnFailure(
  ZKClientService.Builder.of(kafkaZKQuorum)
   .setSessionTimeout(cConf.getInt(Constants.Zookeeper.CFG_SESSION_TIMEOUT_MILLIS,

代码示例来源:origin: caskdata/coopr

public SynchronizedZKMap(ZKClient zkClient, String namespace, Serializer<T> serializer) {
 this(namespace == null ? zkClient : ZKClients.namespace(zkClient, namespace), serializer);
}

代码示例来源:origin: caskdata/tephra

@Provides
 @Singleton
 private ZKClientService provideZKClientService(Configuration conf) {
  String zkStr = conf.get(TxConstants.Service.CFG_DATA_TX_ZOOKEEPER_QUORUM);
  if (zkStr == null) {
   // Default to HBase one.
   zkStr = conf.get(TxConstants.HBase.ZOOKEEPER_QUORUM);
  }

  int timeOut = conf.getInt(TxConstants.HBase.ZK_SESSION_TIMEOUT, TxConstants.HBase.DEFAULT_ZK_SESSION_TIMEOUT);
  ZKClientService zkClientService = new TephraZKClientService(zkStr, timeOut, null,
                                ArrayListMultimap.<String, byte[]>create());
  return ZKClientServices.delegate(
   ZKClients.reWatchOnExpire(
    ZKClients.retryOnFailure(zkClientService, RetryStrategies.exponentialDelay(500, 2000, TimeUnit.MILLISECONDS)
    )
   )
  );
 }
}

代码示例来源:origin: caskdata/cdap

kafkaNamespace = "/" + kafkaNamespace;
zkClientService = ZKClientServices.delegate(ZKClients.namespace(zkClientService, kafkaNamespace));
ZKClients.reWatchOnExpire(
 ZKClients.retryOnFailure(
  ZKClientService.Builder.of(kafkaZKQuorum)
   .setSessionTimeout(cConf.getInt(Constants.Zookeeper.CFG_SESSION_TIMEOUT_MILLIS,

代码示例来源:origin: org.apache.twill/twill-yarn

/**
 * Returns a {@link ZKClient} that namespaced under the given run id.
 */
private static ZKClient getAppRunZKClient(ZKClient zkClient, RunId appRunId) {
 return ZKClients.namespace(zkClient, String.format("/%s", appRunId));
}

代码示例来源:origin: org.apache.tephra/tephra-core

@Provides
 @Singleton
 private ZKClientService provideZKClientService(Configuration conf) {
  String zkStr = conf.get(TxConstants.Service.CFG_DATA_TX_ZOOKEEPER_QUORUM);
  if (zkStr == null) {
   // Default to HBase one.
   zkStr = conf.get(TxConstants.HBase.ZOOKEEPER_QUORUM);
  }

  int timeOut = conf.getInt(TxConstants.HBase.ZK_SESSION_TIMEOUT, TxConstants.HBase.DEFAULT_ZK_SESSION_TIMEOUT);
  ZKClientService zkClientService = new TephraZKClientService(zkStr, timeOut, null,
                                ArrayListMultimap.<String, byte[]>create());
  return ZKClientServices.delegate(
   ZKClients.reWatchOnExpire(
    ZKClients.retryOnFailure(zkClientService, RetryStrategies.exponentialDelay(500, 2000, TimeUnit.MILLISECONDS)
    )
   )
  );
 }
}

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

/**
 * Returns a {@link ZKClient} that namespaced under the given run id.
 */
private static ZKClient getAppRunZKClient(ZKClient zkClient, RunId appRunId) {
 return ZKClients.namespace(zkClient, String.format("/%s", appRunId));
}

代码示例来源:origin: org.apache.twill/twill-yarn

private ZKClientService getZKClientService(String zkConnect) {
 return ZKClientServices.delegate(
  ZKClients.reWatchOnExpire(
   ZKClients.retryOnFailure(ZKClientService.Builder.of(zkConnect)
                 .setSessionTimeout(ZK_TIMEOUT)
                 .build(), RetryStrategies.exponentialDelay(100, 2000, TimeUnit.MILLISECONDS))));
}

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

private static ZKClient getContainerZKClient(ZKClient zkClient, RunId appRunId, String runnableName) {
 return ZKClients.namespace(zkClient, String.format("/%s/runnables/%s", appRunId, runnableName));
}

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

private ZKClientService getZKClientService(String zkConnect) {
 return ZKClientServices.delegate(
  ZKClients.reWatchOnExpire(
   ZKClients.retryOnFailure(ZKClientService.Builder.of(zkConnect)
                 .setSessionTimeout(ZK_TIMEOUT)
                 .build(), RetryStrategies.exponentialDelay(100, 2000, TimeUnit.MILLISECONDS))));
}

代码示例来源:origin: org.apache.twill/twill-yarn

private static ZKClient getContainerZKClient(ZKClient zkClient, RunId appRunId, String runnableName) {
 return ZKClients.namespace(zkClient, String.format("/%s/runnables/%s", appRunId, runnableName));
}

代码示例来源:origin: caskdata/cdap

@Provides
 @Singleton
 private ZKClientService provideZKClientService(CConfiguration cConf) {
  String zookeeper = cConf.get(Constants.Zookeeper.QUORUM);
  Preconditions.checkNotNull(zookeeper, "Missing ZooKeeper configuration '%s'", Constants.Zookeeper.QUORUM);

  return ZKClientServices.delegate(
   ZKClients.reWatchOnExpire(
    ZKClients.retryOnFailure(
     ZKClientService.Builder.of(cConf.get(Constants.Zookeeper.QUORUM))
      .setSessionTimeout(cConf.getInt(Constants.Zookeeper.CFG_SESSION_TIMEOUT_MILLIS,
                      Constants.Zookeeper.DEFAULT_SESSION_TIMEOUT_MILLIS))
      .build(),
     RetryStrategies.exponentialDelay(500, 2000, TimeUnit.MILLISECONDS)
    )
   )
  );
 }
}

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