org.apache.curator.ensemble.fixed.FixedEnsembleProvider类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(125)

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

FixedEnsembleProvider介绍

[英]Standard ensemble provider that wraps a fixed connection string
[中]包装固定连接字符串的标准集成提供程序

代码示例

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

private static void checkRootAcls(Configuration conf, String path, String user) {
 int stime = conf.getInt(ZK_DTSM_ZK_SESSION_TIMEOUT, ZK_DTSM_ZK_SESSION_TIMEOUT_DEFAULT),
   ctime = conf.getInt(ZK_DTSM_ZK_CONNECTION_TIMEOUT, ZK_DTSM_ZK_CONNECTION_TIMEOUT_DEFAULT);
 CuratorFramework zkClient = CuratorFrameworkFactory.builder().namespace(null)
   .retryPolicy(new RetryOneTime(10)).sessionTimeoutMs(stime).connectionTimeoutMs(ctime)
   .ensembleProvider(new FixedEnsembleProvider(conf.get(ZK_DTSM_ZK_CONNECTION_STRING)))
   .build();
 // Hardcoded from a private field in ZKDelegationTokenSecretManager.
 // We need to check the path under what it sets for namespace, since the namespace is
 // created with world ACLs.
 String nsPath = "/" + path + "/ZKDTSMRoot";
 Id currentUser = new Id("sasl", user);
 try {
  zkClient.start();
  List<String> children = zkClient.getChildren().forPath(nsPath);
  for (String child : children) {
   String childPath = nsPath + "/" + child;
   checkAcls(zkClient, currentUser, childPath);
  }
 } catch (Exception e) {
  throw new RuntimeException(e);
 } finally {
  zkClient.close();
 }
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

throw new RuntimeException("Could not Load ZK acls or auth");
zkClient = builder.ensembleProvider(new FixedEnsembleProvider(connString))
  .build();
isExternalClient = false;

代码示例来源:origin: apache/incubator-druid

@Provides
@LazySingleton
public EnsembleProvider makeEnsembleProvider(CuratorConfig config, ExhibitorConfig exConfig)
{
 if (exConfig.getHosts().isEmpty()) {
  return new FixedEnsembleProvider(config.getZkHosts());
 }
 return new ExhibitorEnsembleProvider(
   new Exhibitors(
     exConfig.getHosts(),
     exConfig.getRestPort(),
     newBackupProvider(config.getZkHosts())
   ),
   new DefaultExhibitorRestClient(exConfig.getUseSsl()),
   exConfig.getRestUriPath(),
   exConfig.getPollingMs(),
   new BoundedExponentialBackoffRetry(BASE_SLEEP_TIME_MS, MAX_SLEEP_TIME_MS, MAX_RETRIES)
 )
 {
  @Override
  public void start() throws Exception
  {
   log.info("Poll the list of zookeeper servers for initial ensemble");
   this.pollForInitialEnsemble();
   super.start();
  }
 };
}

代码示例来源:origin: org.apache.curator/curator-framework

/**
 * Set the list of servers to connect to. IMPORTANT: use either this or {@link #ensembleProvider(EnsembleProvider)}
 * but not both.
 *
 * @param connectString list of servers to connect to
 * @return this
 */
public Builder connectString(String connectString)
{
  ensembleProvider = new FixedEnsembleProvider(connectString);
  return this;
}

代码示例来源:origin: info.xiancloud/xian-curator-framework

/**
 * Set the list of servers to connect to. IMPORTANT: use either this or {@link #ensembleProvider(EnsembleProvider)}
 * but not both.
 *
 * @param connectString list of servers to connect to
 * @return this
 */
public Builder connectString(String connectString)
{
  ensembleProvider = new FixedEnsembleProvider(connectString);
  return this;
}

代码示例来源:origin: xiancloud/xian

/**
 *
 * @param connectString list of servers to connect to
 * @param sessionTimeoutMs session timeout
 * @param connectionTimeoutMs connection timeout
 * @param watcher default watcher or null
 * @param retryPolicy the retry policy to use
 */
public CuratorZookeeperClient(String connectString, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy)
{
  this(new DefaultZookeeperFactory(), new FixedEnsembleProvider(connectString), sessionTimeoutMs, connectionTimeoutMs, watcher, retryPolicy, false);
}

代码示例来源:origin: io.fabric8/fabric-zookeeper

/**
 *
 * @param connectString list of servers to connect to
 * @param sessionTimeoutMs session timeout
 * @param connectionTimeoutMs connection timeout
 * @param watcher default watcher or null
 * @param retryPolicy the retry policy to use
 */
public CuratorZookeeperClient(String connectString, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy)
{
  this(new DefaultZookeeperFactory(), new FixedEnsembleProvider(connectString), sessionTimeoutMs, connectionTimeoutMs, watcher, retryPolicy, false);
}

代码示例来源:origin: jboss-fuse/fabric8

/**
 *
 * @param connectString list of servers to connect to
 * @param sessionTimeoutMs session timeout
 * @param connectionTimeoutMs connection timeout
 * @param watcher default watcher or null
 * @param retryPolicy the retry policy to use
 */
public CuratorZookeeperClient(String connectString, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy)
{
  this(new DefaultZookeeperFactory(), new FixedEnsembleProvider(connectString), sessionTimeoutMs, connectionTimeoutMs, watcher, retryPolicy, false);
}

代码示例来源:origin: org.apache.curator/curator-client

/**
 *
 * @param connectString list of servers to connect to
 * @param sessionTimeoutMs session timeout
 * @param connectionTimeoutMs connection timeout
 * @param watcher default watcher or null
 * @param retryPolicy the retry policy to use
 */
public CuratorZookeeperClient(String connectString, int sessionTimeoutMs, int connectionTimeoutMs, Watcher watcher, RetryPolicy retryPolicy)
{
  this(new DefaultZookeeperFactory(), new FixedEnsembleProvider(connectString), sessionTimeoutMs, connectionTimeoutMs, watcher, retryPolicy, false, new StandardConnectionHandlingPolicy());
}

代码示例来源:origin: com.haulmont.addon.zookeeper/cubazk-global

protected void connect() {
  log.info("Connecting to ZooKeeper at {}", connection);
  if (connection == null || connection.trim().isEmpty()) {
    throw new IllegalArgumentException("Cannot connect to ZooKeeper: missing connection property");
  }
  CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
      .ensembleProvider(new FixedEnsembleProvider(connection))
      .connectionTimeoutMs(connectionTimeout)
      .sessionTimeoutMs(sessionTimeout)
      .retryPolicy(new RetryNTimes(maxRetry, retryInterval));
  if (password != null && password.length() > 0) {
    builder = builder.authorization("digest", password.getBytes());
  }
  curator = builder.build();
  curator.start();
}

代码示例来源:origin: org.zalando.paradox/paradox-nakadi-consumer-partitioned-zk

public void init() throws Exception {
  Preconditions.checkArgument(StringUtils.isNotEmpty(zookeeperBrokers), "zookeeperBrokers must not be empty");
  final RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
  final EnsembleProvider ensembleProvider;
  if (StringUtils.isNotEmpty(exhibitorAddresses)) {
    final Collection<String> exhibitorHosts = Arrays.asList(exhibitorAddresses.split("\\s*,\\s*"));
    final Exhibitors exhibitors = new Exhibitors(exhibitorHosts, exhibitorPort, () -> zookeeperBrokers);
    final ExhibitorRestClient exhibitorRestClient = new DefaultExhibitorRestClient();
    ensembleProvider = new ExhibitorEnsembleProvider(exhibitors, exhibitorRestClient,
        "/exhibitor/v1/cluster/list", 300000, retryPolicy);
    ((ExhibitorEnsembleProvider) ensembleProvider).pollForInitialEnsemble();
  } else {
    ensembleProvider = new FixedEnsembleProvider(zookeeperBrokers);
  }
  curator = CuratorFrameworkFactory.builder().ensembleProvider(ensembleProvider).retryPolicy(retryPolicy).build();
  curator.start();
}

代码示例来源:origin: io.hops/hadoop-yarn-registry

/**
 * Supply the binding information.
 * This implementation returns a fixed ensemble bonded to
 * the quorum supplied by {@link #buildConnectionString()}
 * @return the binding information
 */
@Override
public BindingInformation supplyBindingInformation() {
 BindingInformation binding = new BindingInformation();
 String connectString = buildConnectionString();
 binding.ensembleProvider = new FixedEnsembleProvider(connectString);
 binding.description =
   "fixed ZK quorum \"" + connectString + "\"";
 return binding;
}

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

/**
 * Supply the binding information.
 * This implementation returns a fixed ensemble bonded to
 * the quorum supplied by {@link #buildConnectionString()}.
 *
 * @return the binding information
 */
@Override
public BindingInformation supplyBindingInformation() {
 BindingInformation binding = new BindingInformation();
 String connectString = buildConnectionString();
 binding.ensembleProvider = new FixedEnsembleProvider(connectString);
 binding.description =
   "fixed ZK quorum \"" + connectString + "\"";
 return binding;
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

throw new RuntimeException("Could not Load ZK acls or auth");
zkClient = builder.ensembleProvider(new FixedEnsembleProvider(connString))
  .build();
isExternalClient = false;

代码示例来源:origin: ch.cern.hadoop/hadoop-common

throw new RuntimeException("Could not Load ZK acls or auth");
zkClient = builder.ensembleProvider(new FixedEnsembleProvider(connString))
  .build();
isExternalClient = false;

代码示例来源:origin: jboss-fuse/fabric8

protected CuratorFramework createCurator() throws KeeperException {
  log.info(String.format("Creating curator [%s], mode: %s", connection, getCreateMode()));
  CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
    .ensembleProvider(new FixedEnsembleProvider(connection))
    .connectionTimeoutMs(connectionTimeout)
    .sessionTimeoutMs(sessionTimeout)
    .retryPolicy(new RetryNTimes(maxRetry, retryInterval));
  if (password != null && password.length() > 0) {
    builder = builder.authorization(getScheme(), getAuth()).aclProvider(aclProvider);
  }
  return builder.build();
}

代码示例来源:origin: io.hops/hadoop-common

throw new RuntimeException("Could not Load ZK acls or auth");
zkClient = builder.ensembleProvider(new FixedEnsembleProvider(connString))
  .build();
isExternalClient = false;

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

throw new RuntimeException("Could not Load ZK acls or auth");
zkClient = builder.ensembleProvider(new FixedEnsembleProvider(connString))
  .build();
isExternalClient = false;

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

binding.ensembleProvider = new FixedEnsembleProvider(connectString);
binding.description =
  getName() + " reachable at \"" + connectString + "\"";

代码示例来源:origin: io.hops/hadoop-yarn-registry

binding.ensembleProvider = new FixedEnsembleProvider(connectString);
binding.description =
  getName() + " reachable at \"" + connectString + "\"";

相关文章

微信公众号

最新文章

更多

FixedEnsembleProvider类方法