gpt4 book ai didi

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

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

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

ZookeeperRegistryCenter介绍

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

代码示例

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

@Bean(initMethod = "init")
public ZookeeperRegistryCenter regCenter(ZookeeperConfiguration config) {
  return new ZookeeperRegistryCenter(config);
}

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

@Override
public String get(final String key) {
  TreeCache cache = findTreeCache(key);
  if (null == cache) {
    return getDirectly(key);
  }
  ChildData resultInCache = cache.getCurrentData(key);
  if (null != resultInCache) {
    return null == resultInCache.getData() ? null : new String(resultInCache.getData(), Charsets.UTF_8);
  }
  return getDirectly(key);
}

代码示例来源: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;
}

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

@Override
public void persist(final String key, final String value) {
  try {
    if (!isExisted(key)) {
      client.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(key, value.getBytes(Charsets.UTF_8));
    } else {
      update(key, value);
    }
  //CHECKSTYLE:OFF
  } catch (final Exception ex) {
  //CHECKSTYLE:ON
    RegExceptionHandler.handleException(ex);
  }
}

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

@Override
public long getRegistryCenterTime(final String key) {
  long result = 0L;
  try {
    persist(key, "");
    result = client.checkExists().forPath(key).getMtime();
  //CHECKSTYLE:OFF
  } catch (final Exception ex) {
  //CHECKSTYLE:ON
    RegExceptionHandler.handleException(ex);
  }
  Preconditions.checkState(0L != result, "Cannot get registry center time.");
  return result;
}

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

@Override
public void persistEphemeral(final String key, final String value) {
  try {
    if (isExisted(key)) {
      client.delete().deletingChildrenIfNeeded().forPath(key);
    }
    client.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(key, value.getBytes(Charsets.UTF_8));
  //CHECKSTYLE:OFF
  } catch (final Exception ex) {
  //CHECKSTYLE:ON
    RegExceptionHandler.handleException(ex);
  }
}

代码示例来源: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: 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: 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);
}

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