本文整理了Java中io.pravega.common.auth.ZKTLSUtils
类的一些代码示例,展示了ZKTLSUtils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKTLSUtils
类的具体详情如下:
包路径:io.pravega.common.auth.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;
}
内容来源于网络,如有侵权,请联系作者删除!