gpt4 book ai didi

io.pravega.common.auth.ZKTLSUtils类的使用及代码示例

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

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

ZKTLSUtils介绍

暂无

代码示例

代码示例来源:origin: pravega/pravega

private void cleanUpZK() {
  String[] pathsTobeCleaned = {"/pravega", "/hostIndex", "/store", "/taskIndex"};
  RetryPolicy rp = new ExponentialBackoffRetry(1000, 3);
  CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
      .connectString(zkUrl)
      .connectionTimeoutMs(5000)
      .sessionTimeoutMs(5000)
      .retryPolicy(rp);
  if (secureZK) {
    ZKTLSUtils.setSecureZKClientProperties(jksTrustFile, "1111_aaaa");
  }
  @Cleanup
  CuratorFramework zclient = builder.build();
  zclient.start();
  for ( String path : pathsTobeCleaned ) {
    try {
      zclient.delete().guaranteed().deletingChildrenIfNeeded()
          .forPath(path);
    } catch (Exception e) {
      log.warn("Not able to delete path {} . Exception {}", path, e.getMessage());
    }
  }
  zclient.close();
}

代码示例来源:origin: pravega/pravega

public void shutdown() {
  if (!this.closed) {
    this.serviceBuilder.close();
    log.info("StreamSegmentService shut down.");
    if (this.listener != null) {
      this.listener.close();
      log.info("PravegaConnectionListener closed.");
    }
    if (this.statsProvider != null) {
      statsProvider.close();
      statsProvider = null;
      log.info("Metrics statsProvider is now closed.");
    }
    if (this.zkClient != null) {
      this.zkClient.close();
      this.zkClient = null;
      log.info("ZooKeeper Client shut down.");
    }
    if (this.segmentStatsFactory != null) {
      segmentStatsFactory.close();
    }
    if (this.serviceConfig.isSecureZK()) {
      ZKTLSUtils.unsetSecureZKClientProperties();
    }
    this.closed = true;
  }
}

代码示例来源:origin: pravega/pravega

private void initializeZookeeper() throws Exception {
  log.info("Formatting ZooKeeper ...");
  if (this.secureZK) {
    ZKTLSUtils.setSecureZKClientProperties(this.tlsTrustStore, JKSHelper.loadPasswordFrom(this.tLSKeyStorePasswordPath));
  }
  @Cleanup
  val zkc = ZooKeeperClient.newBuilder()
               .connectString(LOOPBACK_ADDRESS.getHostAddress() + ":" + this.zkPort)
               .sessionTimeoutMs(10000)
               .build();
  String znode;
  StringBuilder znodePath = new StringBuilder();
  for (String z : this.ledgersPath.split("/")) {
    znodePath.append(z);
    znode = znodePath.toString();
    if (!znode.isEmpty()) {
      zkc.create(znode, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    }
    znodePath.append("/");
  }
  znodePath.append("available");
  zkc.create(znodePath.toString(), new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
}

代码示例来源:origin: pravega/pravega

@VisibleForTesting
static CuratorFramework createZKClient(ZKClientConfig zkClientConfig, Supplier<Boolean> canRetry, Consumer<Void> expiryHandler) {
  if (zkClientConfig.isSecureConnectionToZooKeeper()) {
    ZKTLSUtils.setSecureZKClientProperties(zkClientConfig.getTrustStorePath(), JKSHelper.loadPasswordFrom(zkClientConfig.getTrustStorePasswordPath()));
  }
  RetryWrapper retryPolicy = new RetryWrapper(new ExponentialBackoffRetry(zkClientConfig.getInitialSleepInterval(),
      zkClientConfig.getMaxRetries(), CURATOR_MAX_SLEEP_MS), canRetry);
  //Create and initialize the curator client framework.
  CuratorFramework zkClient = CuratorFrameworkFactory.builder()
      .connectString(zkClientConfig.getConnectionString())
      .namespace(zkClientConfig.getNamespace())
      .zookeeperFactory(new ZKClientFactory())
      .retryPolicy(retryPolicy)
      .sessionTimeoutMs(zkClientConfig.getSessionTimeoutMs())
      .build();
  zkClient.start();
  zkClient.getConnectionStateListenable().addListener((client1, newState) -> {
    if (newState.equals(ConnectionState.LOST)) {
      expiryHandler.accept(null);
    }
  });
  return zkClient;
}

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