gpt4 book ai didi

com.uber.marmaray.common.configuration.ZookeeperConfiguration类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 11:08:16 26 4
gpt4 key购买 nike

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

ZookeeperConfiguration介绍

[英]ZookeeperConfiguration defines zookeeper related configuration All properties start with #ZK_PROPERTY_PREFIX.
[中]ZookePerConfiguration定义与zookeeper相关的配置所有属性都以#ZK_PROPERTY_前缀开头。

代码示例

代码示例来源:origin: uber/marmaray

public ZookeeperConfiguration(@NonNull final Configuration conf) {
  this.conf = conf;
  ConfigUtil.checkMandatoryProperties(this.getConf(), getMandatoryProperties());
  this.zkQuorum = this.getConf().getProperty(ZK_QUORUM).get();
  this.zkPort = this.getConf().getProperty(ZK_PORT).get();
}

代码示例来源:origin: uber/marmaray

public LockManager(@NonNull final Configuration conf) {
  this.lockConf = new LockManagerConfiguration(conf);
  this.isEnabled = lockConf.isEnabled();
  this.lockMap = new ConcurrentHashMap();
  if (this.isEnabled) {
    final ZookeeperConfiguration zkConf = new ZookeeperConfiguration(conf);
    this.client = Optional.of(CuratorFrameworkFactory.builder()
        .connectString(zkConf.getZkQuorum())
        .retryPolicy(new BoundedExponentialBackoffRetry(1000, 5000, 3))
        .namespace(lockConf.getZkBasePath())
        .sessionTimeoutMs(lockConf.getZkSessionTimeoutMs())
        .connectionTimeoutMs(lockConf.getZkConnectionTimeoutMs())
        .build());
    this.client.get().start();
  } else {
    this.client = Optional.absent();
  }
}

代码示例来源:origin: uber/marmaray

@Test
public void testLockInfo() throws Exception {
  final String LOCK_INFO = "This is the information in the lock";
  final String key1 = LockManager.getLockKey("test_lock", "key1");
  try (final LockManager lockManager = new LockManager(conf)) {
    assertTrue(lockManager.lock(key1, LOCK_INFO));
    final LockManagerConfiguration lockConf = new LockManagerConfiguration(conf);
    final ZookeeperConfiguration zkConf = new ZookeeperConfiguration(conf);
    final CuratorFramework client = CuratorFrameworkFactory.builder()
        .connectString(zkConf.getZkQuorum())
        .retryPolicy(new BoundedExponentialBackoffRetry(1000, 5000, 3))
        .namespace(lockConf.getZkBasePath())
        .sessionTimeoutMs(lockConf.getZkSessionTimeoutMs())
        .connectionTimeoutMs(lockConf.getZkConnectionTimeoutMs())
        .build();
    client.start();
    final String node = client.getChildren().forPath(key1).get(0);
    final String data = new String(client.getData().forPath(key1 + "/" + node));
    assertEquals(LOCK_INFO, data);
    client.close();
    lockManager.unlock(key1);
  }
}

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