com.datasift.dropwizard.zookeeper.ZooKeeperFactory类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(89)

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

ZooKeeperFactory介绍

[英]A Factory for creating configured and managed ZooKeeper client instances.

A ZooKeeperHealthCheck will be registered for each ZooKeeper client instance that checks for the existence of the configured #namespace.
[中]用于创建已配置和管理的ZooKeeper客户端实例的工厂。
将为每个ZooKeeper客户端实例注册ZooKeeperHealthCheck,以检查配置的#命名空间是否存在。

代码示例

代码示例来源:origin: datasift/dropwizard-extra

@Override
public String getConnectionString() {
  return factory.getQuorumSpec();
}

代码示例来源:origin: datasift/dropwizard-extra

/**
 * Builds a default {@link ZooKeeper} instance..
 * <p/>
 * No {@link Watcher} will be configured for the built {@link ZooKeeper} instance. If you wish
 * to watch all events on the {@link ZooKeeper} client, use {@link #build(Environment, Watcher)}.
 *
 * @param environment the environment to build {@link ZooKeeper} instances for.
 *
 * @return a {@link ZooKeeper} client, managed and configured according to the {@code
 *         configuration}.
 *
 * @throws IOException if there is a network failure.
 */
public ZooKeeper build(final Environment environment) throws IOException {
  return build(environment, null, DEFAULT_NAME);
}

代码示例来源:origin: datasift/dropwizard-extra

throws IOException {
final String quorumSpec = getQuorumSpec();
final String namespace = getNamespace();
    (int) getSessionTimeout().toMilliseconds(),
    watcher,
    isReadOnly());
final Auth auth = getAuth();
if (auth != null) {
  client.addAuthInfo(auth.getScheme(), auth.getId().getBytes());

代码示例来源:origin: datasift/dropwizard-extra

zookeeper.getQuorumSpec() + zookeeper.getNamespace());
props.setProperty("zookeeper.connection.timeout.ms",
    String.valueOf(zookeeper.getConnectionTimeout().toMilliseconds()));
props.setProperty("zookeeper.session.timeout.ms",
    String.valueOf(zookeeper.getSessionTimeout().toMilliseconds()));
props.setProperty("group.id",
    factory.getGroup());

代码示例来源:origin: datasift/dropwizard-extra

final String namespace = factory.getNamespace();
final CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
    .zookeeperFactory(new DropwizardConfiguredZooKeeperFactory(environment, name))
    .ensembleProvider(new DropwizardConfiguredEnsembleProvider(factory))
    .connectionTimeoutMs((int) factory.getConnectionTimeout().toMilliseconds())
    .threadFactory(new ThreadFactoryBuilder().setNameFormat(name + "-%d").build())
    .sessionTimeoutMs((int) factory.getSessionTimeout().toMilliseconds())
    .namespace(namespace.startsWith("/") ? namespace.substring(1) : namespace)
    .compressionProvider(getCompressionProvider())
    .retryPolicy(getRetryPolicy())
    .canBeReadOnly(factory.isReadOnly());
final ZooKeeperFactory.Auth auth = factory.getAuth();
if (auth != null) {
  builder.authorization(auth.getScheme(), auth.getId().getBytes());

代码示例来源:origin: datasift/dropwizard-extra

/**
 * Builds an {@link HBaseClient} instance from the specified {@link HBaseClientFactory}
 * with the given {@code name}.
 *
 * @param environment the {@link Environment} to build {@link HBaseClient} instances for.
 * @param name the name for the {@link HBaseClient}.
 *
 * @return an {@link HBaseClient}, managed and configured according to the {@code
 *         configuration}.
 */
public HBaseClient build(final Environment environment, final String name) {
  final ZooKeeperFactory zkFactory = getZookeeper();
  final HBaseClient proxy = new HBaseClientProxy(
      new org.hbase.async.HBaseClient(zkFactory.getQuorumSpec(), zkFactory.getNamespace()));
  // optionally instrument and bound requests for the client
  final HBaseClient client = instrument(boundRequests(proxy), environment.metrics(), name);
  // configure client
  client.setFlushInterval(getFlushInterval());
  client.setIncrementBufferSize(getIncrementBufferSize());
  // add healthchecks for META and ROOT tables
  environment.healthChecks().register(name + "-meta", new HBaseHealthCheck(client, ".META."));
  environment.healthChecks().register(name + "-root", new HBaseHealthCheck(client, "-ROOT-"));
  // manage client
  environment.lifecycle().manage(new ManagedHBaseClient(
      client, getConnectionTimeout()));
  return client;
}

代码示例来源:origin: datasift/dropwizard-extra

/**
 * Builds a default {@link ZooKeeper} instance.
 * <p/>
 * The given {@link Watcher} will be assigned to watch for all events on the {@link ZooKeeper}
 * client instance. If you wish to ignore events, use {@link #build(Environment)}.
 *
 * @param environment the environment to build {@link ZooKeeper} instances for.
 * @param watcher the watcher to handle all events that occur on the {@link ZooKeeper} client.
 *
 * @return a {@link ZooKeeper} client, managed and configured according to the {@code
 *         configuration}.
 *
 * @throws IOException if there is a network failure.
 */
public ZooKeeper build(final Environment environment, final Watcher watcher)
    throws IOException {
  return build(environment, watcher, DEFAULT_NAME);
}

代码示例来源:origin: datasift/dropwizard-extra

/**
 * Builds a named {@link ZooKeeper} instance.
 * <p/>
 * No {@link Watcher} will be configured for the built {@link ZooKeeper} instance. If you wish
 * to watch all events on the {@link ZooKeeper} client, use {@link
 * #build(Environment, Watcher, String)}.
 *
 * @param environment the environment to build {@link ZooKeeper} instances for.
 * @param name the name for this {@link ZooKeeper instance}.
 *
 * @return a {@link ZooKeeper} client, managed and configured according to the {@code
 *         configuration}.
 *
 * @throws IOException if there is a network failure.
 */
public ZooKeeper build(final Environment environment, final String name)
    throws IOException {
  return build(environment, null, name);
}

相关文章