gpt4 book ai didi

com.dangdang.ddframe.job.reg.zookeeper.ZookeeperConfiguration类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 05:13:31 25 4
gpt4 key购买 nike

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

ZookeeperConfiguration介绍

[英]基于Zookeeper的注册中心配置.
[中]基于动物园管理员的注册中心配置.

代码示例

代码示例来源:origin: LuoLiangDSGA/spring-learning

@Bean
public ZookeeperConfiguration zkConfig() {
  return new ZookeeperConfiguration(serverlists, namespace);
}

代码示例来源:origin: pcbest/elastic-job-lite-starter-master

/**
 * Reg center zookeeper registry center.
 *
 * @return the zookeeper registry center
 */
@Bean(initMethod = "init")
@ConditionalOnMissingBean
public ZookeeperRegistryCenter regCenter() {
  ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(regCenterProperties.getZkAddressList(), regCenterProperties.getNamespace());
  zookeeperConfiguration.setBaseSleepTimeMilliseconds(regCenterProperties.getBaseSleepTimeMilliseconds());
  zookeeperConfiguration.setConnectionTimeoutMilliseconds(regCenterProperties.getConnectionTimeoutMilliseconds());
  zookeeperConfiguration.setMaxSleepTimeMilliseconds(regCenterProperties.getMaxSleepTimeMilliseconds());
  zookeeperConfiguration.setSessionTimeoutMilliseconds(regCenterProperties.getSessionTimeoutMilliseconds());
  zookeeperConfiguration.setMaxRetries(regCenterProperties.getMaxRetries());
  zookeeperConfiguration.setDigest(regCenterProperties.getDigest());
  return new ZookeeperRegistryCenter(zookeeperConfiguration);
}

代码示例来源:origin: com.dangdang/elastic-job-common-core

@Override
public void init() {
  log.debug("Elastic job: zookeeper registry center init, server lists is: {}.", zkConfig.getServerLists());
  CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
      .connectString(zkConfig.getServerLists())
      .retryPolicy(new ExponentialBackoffRetry(zkConfig.getBaseSleepTimeMilliseconds(), zkConfig.getMaxRetries(), zkConfig.getMaxSleepTimeMilliseconds()))
      .namespace(zkConfig.getNamespace());
  if (0 != zkConfig.getSessionTimeoutMilliseconds()) {
    builder.sessionTimeoutMs(zkConfig.getSessionTimeoutMilliseconds());
  if (0 != zkConfig.getConnectionTimeoutMilliseconds()) {
    builder.connectionTimeoutMs(zkConfig.getConnectionTimeoutMilliseconds());
  if (!Strings.isNullOrEmpty(zkConfig.getDigest())) {
    builder.authorization("digest", zkConfig.getDigest().getBytes(Charsets.UTF_8))
        .aclProvider(new ACLProvider() {
  client.start();
  try {
    if (!client.blockUntilConnected(zkConfig.getMaxSleepTimeMilliseconds() * zkConfig.getMaxRetries(), TimeUnit.MILLISECONDS)) {
      client.close();
      throw new KeeperException.OperationTimeoutException();

代码示例来源:origin: com.dangdang/elastic-job-lite-lifecycle

/**
   * 创建注册中心.
   *
   * @param connectString 注册中心连接字符串
   * @param namespace 注册中心命名空间
   * @param digest 注册中心凭证
   * @return 注册中心对象
   */
  public static CoordinatorRegistryCenter createCoordinatorRegistryCenter(final String connectString, final String namespace, final Optional<String> digest) {
    Hasher hasher =  Hashing.md5().newHasher().putString(connectString, Charsets.UTF_8).putString(namespace, Charsets.UTF_8);
    if (digest.isPresent()) {
      hasher.putString(digest.get(), Charsets.UTF_8);
    }
    HashCode hashCode = hasher.hash();
    CoordinatorRegistryCenter result = REG_CENTER_REGISTRY.get(hashCode);
    if (null != result) {
      return result;
    }
    ZookeeperConfiguration zkConfig = new ZookeeperConfiguration(connectString, namespace);
    if (digest.isPresent()) {
      zkConfig.setDigest(digest.get());
    }
    result = new ZookeeperRegistryCenter(zkConfig);
    result.init();
    REG_CENTER_REGISTRY.put(hashCode, result);
    return result;
  }
}

代码示例来源:origin: elasticjob/elastic-job-example

@Bean(initMethod = "init")
  public ZookeeperRegistryCenter regCenter(@Value("${regCenter.serverList}") final String serverList, @Value("${regCenter.namespace}") final String namespace) {
    return new ZookeeperRegistryCenter(new ZookeeperConfiguration(serverList, namespace));
  }
}

代码示例来源:origin: elasticjob/elastic-job-example

private static CoordinatorRegistryCenter setUpRegistryCenter() {
  ZookeeperConfiguration zkConfig = new ZookeeperConfiguration(ZOOKEEPER_CONNECTION_STRING, JOB_NAMESPACE);
  CoordinatorRegistryCenter result = new ZookeeperRegistryCenter(zkConfig);
  result.init();
  return result;
}

代码示例来源:origin: lord-of-code/loc-framework

private ZookeeperRegistryCenter registerCenter(LocElasticJobProperties elasticJobProperties) {
 ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(
   elasticJobProperties.getServerList(), elasticJobProperties.getNamespace());
 BeanUtils
   .copyProperties(elasticJobProperties, zookeeperConfiguration, "serverLists", "namespace");
 ZookeeperRegistryCenter registryCenter = new ZookeeperRegistryCenter(zookeeperConfiguration);
 registryCenter.init();
 return registryCenter;
}

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