gpt4 book ai didi

com.twitter.distributedlog.ZooKeeperClientBuilder.zkAclId()方法的使用及代码示例

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

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

ZooKeeperClientBuilder.zkAclId介绍

[英]* Build zookeeper client with given zk acl digest id zkAclId.
[中]*使用给定的zk acl摘要id zkAclId构建zookeeper客户端。

代码示例

代码示例来源:origin: twitter/distributedlog

public void create(URI uri) throws IOException {
  DistributedLogConfiguration conf = new DistributedLogConfiguration();
  ZooKeeperClient zkc = ZooKeeperClientBuilder.newBuilder()
      .sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds())
      .retryThreadCount(conf.getZKClientNumberRetryThreads())
      .requestRateLimit(conf.getZKRequestRateLimit())
      .zkAclId(conf.getZkAclId())
      .uri(uri)
      .build();
  byte[] data = serialize();
  try {
    Utils.zkCreateFullPathOptimistic(zkc, uri.getPath(), data,
        zkc.getDefaultACL(), CreateMode.PERSISTENT);
  } catch (KeeperException e) {
    throw new IOException("Fail to write dl metadata " + new String(data, UTF_8)
        +  " to uri " + uri, e);
  } catch (InterruptedException e) {
    throw new IOException("Interrupted when writing dl metadata " + new String(data, UTF_8)
        + " to uri " + uri, e);
  } finally {
    zkc.close();
  }
}

代码示例来源:origin: twitter/distributedlog

private ZooKeeperClient buildClient() throws Exception {
  return clientBuilder().zkAclId(null).build();
}

代码示例来源:origin: twitter/distributedlog

private ZooKeeperClient buildAuthdClient(String id) throws Exception {
  return clientBuilder().zkAclId(id).build();
}

代码示例来源:origin: twitter/distributedlog

public void update(URI uri) throws IOException {
  DistributedLogConfiguration conf = new DistributedLogConfiguration();
  ZooKeeperClient zkc = ZooKeeperClientBuilder.newBuilder()
      .sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds())
      .retryThreadCount(conf.getZKClientNumberRetryThreads())
      .requestRateLimit(conf.getZKRequestRateLimit())
      .zkAclId(conf.getZkAclId())
      .uri(uri)
      .build();
  byte[] data = serialize();
  try {
    zkc.get().setData(uri.getPath(), data, -1);
  } catch (KeeperException e) {
    throw new IOException("Fail to update dl metadata " + new String(data, UTF_8)
        + " to uri " + uri, e);
  } catch (InterruptedException e) {
    throw new IOException("Interrupted when updating dl metadata "
        + new String(data, UTF_8) + " to uri " + uri, e);
  } finally {
    zkc.close();
  }
}

代码示例来源:origin: twitter/distributedlog

public static void unbind(URI uri) throws IOException {
  DistributedLogConfiguration conf = new DistributedLogConfiguration();
  ZooKeeperClient zkc = ZooKeeperClientBuilder.newBuilder()
      .sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds())
      .retryThreadCount(conf.getZKClientNumberRetryThreads())
      .requestRateLimit(conf.getZKRequestRateLimit())
      .zkAclId(conf.getZkAclId())
      .uri(uri)
      .build();
  byte[] data = new byte[0];
  try {
    zkc.get().setData(uri.getPath(), data, -1);
  } catch (KeeperException ke) {
    throw new IOException("Fail to unbound dl metadata on uri " + uri, ke);
  } catch (InterruptedException ie) {
    throw new IOException("Interrupted when unbinding dl metadata on uri " + uri, ie);
  } finally {
    zkc.close();
  }
}

代码示例来源:origin: twitter/distributedlog

.name("benchmark-zkc")
    .sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds())
    .zkAclId(null)
    .build();
BKDLConfig bkdlConfig;

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
public void testZooKeeperReconnectionBlockingRetryThread() throws Exception {
  int sessionTimeoutMs = 100;
  ZooKeeperClient zkc = clientBuilder(sessionTimeoutMs).zkAclId(null).build();
  ZooKeeper zk = zkc.get();
  assertTrue(zk instanceof org.apache.bookkeeper.zookeeper.ZooKeeperClient);

代码示例来源:origin: twitter/distributedlog

.sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds())
    .retryPolicy(retryPolicy)
    .zkAclId(conf.getZkAclId())
    .build();
ExecutorService executorService = Executors.newCachedThreadPool();

代码示例来源:origin: twitter/distributedlog

/**
 * Return a zookeeper client builder for testing.
 *
 * @return a zookeeper client builder
 */
public static ZooKeeperClientBuilder newBuilder() {
  return ZooKeeperClientBuilder.newBuilder()
      .retryPolicy(RetryPolicyUtils.DEFAULT_INFINITE_RETRY_POLICY)
      .connectionTimeoutMs(10000)
      .sessionTimeoutMs(60000)
      .zkAclId(null)
      .statsLogger(NullStatsLogger.INSTANCE);
}

代码示例来源:origin: twitter/distributedlog

/**
 * Run given <i>handler</i> by providing an available new zookeeper client
 *
 * @param handler
 *          Handler to process with provided zookeeper client.
 * @param conf
 *          Distributedlog Configuration.
 * @param namespace
 *          Distributedlog Namespace.
 */
private static <T> T withZooKeeperClient(ZooKeeperClientHandler<T> handler,
                     DistributedLogConfiguration conf,
                     URI namespace) throws IOException {
  ZooKeeperClient zkc = ZooKeeperClientBuilder.newBuilder()
      .name(String.format("dlzk:%s:factory_static", namespace))
      .sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds())
      .uri(namespace)
      .retryThreadCount(conf.getZKClientNumberRetryThreads())
      .requestRateLimit(conf.getZKRequestRateLimit())
      .zkAclId(conf.getZkAclId())
      .build();
  try {
    return handler.handle(zkc);
  } finally {
    zkc.close();
  }
}

代码示例来源:origin: twitter/distributedlog

/**
 * {@link https://issues.apache.org/jira/browse/DL-34}
 */
@DistributedLogAnnotations.FlakyTest
@Ignore
@Test(timeout = 60000)
public void testAclAuthSpansExpirationNonRetryableClient() throws Exception {
  ZooKeeperClient zkcAuth = clientBuilder().retryPolicy(null).zkAclId("test").build();
  zkcAuth.get().create("/test", new byte[0], DistributedLogConstants.EVERYONE_READ_CREATOR_ALL, CreateMode.PERSISTENT);
  CountDownLatch expired = awaitConnectionEvent(KeeperState.Expired, zkcAuth);
  CountDownLatch connected = awaitConnectionEvent(KeeperState.SyncConnected, zkcAuth);
  expireZooKeeperSession(zkcAuth.get(), 2000);
  expired.await(2, TimeUnit.SECONDS);
  connected.await(2, TimeUnit.SECONDS);
  zkcAuth.get().create("/test/key1", new byte[0], DistributedLogConstants.EVERYONE_READ_CREATOR_ALL, CreateMode.PERSISTENT);
  rmAll(zkcAuth, "/test");
}

代码示例来源:origin: twitter/distributedlog

.sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds())
    .retryPolicy(retryPolicy)
    .zkAclId(conf.getZkAclId())
    .build();
ExecutorService executorService = Executors.newCachedThreadPool();

代码示例来源:origin: twitter/distributedlog

.retryThreadCount(conf.getZKClientNumberRetryThreads())
  .requestRateLimit(conf.getZKRequestRateLimit())
  .zkAclId(conf.getZkAclId())
  .uri(uri)
  .retryPolicy(retryPolicy)
    .zkServers(zkServersForReader)
    .retryPolicy(retryPolicy)
    .zkAclId(conf.getZkAclId())
    .statsLogger(statsLogger.scope("dlzk_dlm_reader_shared"));
this.ownReaderZKC = true;

代码示例来源:origin: twitter/distributedlog

@Test(timeout = 60000)
public void testZooKeeperReconnection() throws Exception {
  int sessionTimeoutMs = 100;
  ZooKeeperClient zkc = clientBuilder(sessionTimeoutMs).zkAclId(null).build();
  ZooKeeper zk = zkc.get();
  long sessionId = zk.getSessionId();
  ZooKeeperClientUtils.expireSession(zkc, zkServers, 2 * sessionTimeoutMs);
  ZooKeeper newZk = zkc.get();
  while (!ZooKeeper.States.CONNECTED.equals(newZk.getState())) {
    TimeUnit.MILLISECONDS.sleep(sessionTimeoutMs / 2);
  }
  long newSessionId = newZk.getSessionId();
  assertTrue(newZk == zk);
  assertFalse(sessionId == newSessionId);
}

代码示例来源:origin: twitter/distributedlog

public SimpleBookKeeperClient(DistributedLogConfiguration conf, URI uri) {
  try {
    zkc = ZooKeeperClientBuilder.newBuilder()
      .sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds())
      .zkAclId(conf.getZkAclId())
      .uri(uri)
      .build();
    BKDLConfig bkdlConfig = BKDLConfig.resolveDLConfig(zkc, uri);
    BKDLConfig.propagateConfiguration(bkdlConfig, conf);
    bkc = BookKeeperClientBuilder.newBuilder()
        .zkc(zkc)
        .dlConfig(conf)
        .ledgersPath(bkdlConfig.getBkLedgersPath())
        .name("dlog")
        .build();
  } catch (Exception e) {
    close();
  }
}
public BookKeeperClient client() {

代码示例来源:origin: twitter/distributedlog

private static ZooKeeperClientBuilder createDLZKClientBuilder(String zkcName,
                              DistributedLogConfiguration conf,
                              String zkServers,
                              StatsLogger statsLogger) {
  RetryPolicy retryPolicy = null;
  if (conf.getZKNumRetries() > 0) {
    retryPolicy = new BoundExponentialBackoffRetryPolicy(
      conf.getZKRetryBackoffStartMillis(),
      conf.getZKRetryBackoffMaxMillis(), conf.getZKNumRetries());
  }
  ZooKeeperClientBuilder builder = ZooKeeperClientBuilder.newBuilder()
    .name(zkcName)
    .sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds())
    .retryThreadCount(conf.getZKClientNumberRetryThreads())
    .requestRateLimit(conf.getZKRequestRateLimit())
    .zkServers(zkServers)
    .retryPolicy(retryPolicy)
    .statsLogger(statsLogger)
    .zkAclId(conf.getZkAclId());
  LOG.info("Created shared zooKeeper client builder {}: zkServers = {}, numRetries = {}, sessionTimeout = {}, retryBackoff = {},"
       + " maxRetryBackoff = {}, zkAclId = {}.", new Object[] { zkcName, zkServers, conf.getZKNumRetries(),
      conf.getZKSessionTimeoutMilliseconds(), conf.getZKRetryBackoffStartMillis(),
      conf.getZKRetryBackoffMaxMillis(), conf.getZkAclId() });
  return builder;
}

代码示例来源:origin: twitter/distributedlog

private static ZooKeeperClientBuilder createBKZKClientBuilder(String zkcName,
                               DistributedLogConfiguration conf,
                               String zkServers,
                               StatsLogger statsLogger) {
  RetryPolicy retryPolicy = null;
  if (conf.getZKNumRetries() > 0) {
    retryPolicy = new BoundExponentialBackoffRetryPolicy(
        conf.getBKClientZKRetryBackoffStartMillis(),
        conf.getBKClientZKRetryBackoffMaxMillis(),
        conf.getBKClientZKNumRetries());
  }
  ZooKeeperClientBuilder builder = ZooKeeperClientBuilder.newBuilder()
      .name(zkcName)
      .sessionTimeoutMs(conf.getBKClientZKSessionTimeoutMilliSeconds())
      .retryThreadCount(conf.getZKClientNumberRetryThreads())
      .requestRateLimit(conf.getBKClientZKRequestRateLimit())
      .zkServers(zkServers)
      .retryPolicy(retryPolicy)
      .statsLogger(statsLogger)
      .zkAclId(conf.getZkAclId());
  LOG.info("Created shared zooKeeper client builder {}: zkServers = {}, numRetries = {}, sessionTimeout = {}, retryBackoff = {},"
      + " maxRetryBackoff = {}, zkAclId = {}.", new Object[] { zkcName, zkServers, conf.getBKClientZKNumRetries(),
      conf.getBKClientZKSessionTimeoutMilliSeconds(), conf.getBKClientZKRetryBackoffStartMillis(),
      conf.getBKClientZKRetryBackoffMaxMillis(), conf.getZkAclId() });
  return builder;
}

代码示例来源:origin: twitter/distributedlog

@Before
public void setup() throws Exception {
  zkc = ZooKeeperClientBuilder.newBuilder()
      .name("zkc")
      .uri(createDLMURI("/"))
      .sessionTimeoutMs(sessionTimeoutMs)
      .zkAclId(null)
      .build();
  zkc0 = ZooKeeperClientBuilder.newBuilder()
      .name("zkc0")
      .uri(createDLMURI("/"))
      .sessionTimeoutMs(sessionTimeoutMs)
      .zkAclId(null)
      .build();
  lockStateExecutor = OrderedScheduler.newBuilder()
      .name("test-scheduer")
      .corePoolSize(1)
      .build();
}

代码示例来源:origin: twitter/distributedlog

@Before
public void setup() throws Exception {
  zkc = ZooKeeperClientBuilder.newBuilder()
      .name("zkc")
      .uri(DLMTestUtil.createDLMURI(zkPort, "/"))
      .sessionTimeoutMs(sessionTimeoutMs)
      .zkServers(zkServers)
      .zkAclId(null)
      .build();
  zkc0 = ZooKeeperClientBuilder.newBuilder()
      .name("zkc0")
      .uri(DLMTestUtil.createDLMURI(zkPort, "/"))
      .sessionTimeoutMs(sessionTimeoutMs)
      .zkServers(zkServers)
      .zkAclId(null)
      .build();
  lockStateExecutor = OrderedScheduler.newBuilder()
      .corePoolSize(1)
      .build();
}

代码示例来源:origin: twitter/distributedlog

/**
   * Create a zookeeper client builder with provided <i>conf</i> for testing.
   *
   * @param conf distributedlog configuration
   * @return zookeeper client builder
   */
  public static ZooKeeperClientBuilder newBuilder(DistributedLogConfiguration conf) {
    return ZooKeeperClientBuilder.newBuilder()
        .retryPolicy(RetryPolicyUtils.DEFAULT_INFINITE_RETRY_POLICY)
        .sessionTimeoutMs(conf.getZKSessionTimeoutMilliseconds())
        .zkAclId(conf.getZkAclId())
        .retryThreadCount(conf.getZKClientNumberRetryThreads())
        .requestRateLimit(conf.getZKRequestRateLimit())
        .statsLogger(NullStatsLogger.INSTANCE);
  }
}

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