gpt4 book ai didi

com.uber.marmaray.common.configuration.ZookeeperConfiguration.()方法的使用及代码示例

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

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

ZookeeperConfiguration.<init>介绍

暂无

代码示例

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