org.apache.zookeeper.client.ZKClientConfig Java Examples

The following examples show how to use org.apache.zookeeper.client.ZKClientConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZookeeperScaler.java    From strimzi-kafka-operator with Apache License 2.0 5 votes vote down vote up
/**
 * Generates the TLS configuration for Zookeeper.
 *
 * @return
 */
private ZKClientConfig getClientConfig()  {
    ZKClientConfig clientConfig = new ZKClientConfig();

    clientConfig.setProperty("zookeeper.clientCnxnSocket", "org.apache.zookeeper.ClientCnxnSocketNetty");
    clientConfig.setProperty("zookeeper.client.secure", "true");
    clientConfig.setProperty("zookeeper.ssl.trustStore.location", trustStoreFile.getAbsolutePath());
    clientConfig.setProperty("zookeeper.ssl.trustStore.password", trustStorePassword);
    clientConfig.setProperty("zookeeper.ssl.trustStore.type", "PKCS12");
    clientConfig.setProperty("zookeeper.ssl.keyStore.location", keyStoreFile.getAbsolutePath());
    clientConfig.setProperty("zookeeper.ssl.keyStore.password", keyStorePassword);
    clientConfig.setProperty("zookeeper.ssl.keyStore.type", "PKCS12");

    return clientConfig;
}
 
Example #2
Source File: Curator.java    From vespa with Apache License 2.0 5 votes vote down vote up
private static ZKClientConfig createClientConfig(Optional<File> clientConfigFile) {
    if (clientConfigFile.isPresent()) {
        boolean useSecureClient = Boolean.parseBoolean(getEnvironmentVariable("VESPA_USE_TLS_FOR_ZOOKEEPER_CLIENT").orElse("false"));
        String config = "zookeeper.client.secure=" + useSecureClient + "\n";
        clientConfigFile.get().getParentFile().mkdirs();
        IOUtils.writeFile(clientConfigFile.get(), Utf8.toBytes(config));
        try {
            return new ZKClientConfig(clientConfigFile.get());
        } catch (QuorumPeerConfig.ConfigException e) {
            throw new RuntimeException("Unable to create ZooKeeper client config file " + clientConfigFile.get());
        }
    } else {
        return new ZKClientConfig();
    }
}
 
Example #3
Source File: ZkTestClientCnxnSocketNIO.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @throws IOException If failed.
 */
public ZkTestClientCnxnSocketNIO(ZKClientConfig clientCfg) throws IOException {
    super(clientCfg);

    String threadName = Thread.currentThread().getName();

    nodeName = threadName.substring(threadName.indexOf('-') + 1);

    if (DEBUG)
        log.info("ZkTestClientCnxnSocketNIO created for node: " + nodeName);
}
 
Example #4
Source File: VespaZooKeeperFactory.java    From vespa with Apache License 2.0 4 votes vote down vote up
VespaZooKeeperFactory(ZKClientConfig zkClientConfig) {
    this.zkClientConfig = zkClientConfig;
}
 
Example #5
Source File: ZooKeeperAdminProvider.java    From strimzi-kafka-operator with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an instance of ZooKeeperAdmin
 *
 * @throws      IOException might be thrown
 *
 * @param connectString     Connection String used to connect to Zookeeper
 * @param sessionTimeout    Session timeout
 * @param watcher           Watcher which will be notified about watches and connection changes
 * @param conf              Zookeeper client configuration
 *
 * @return  ZooKeeperAdmin instance
 */
ZooKeeperAdmin createZookeeperAdmin(String connectString, int sessionTimeout, Watcher watcher, ZKClientConfig conf) throws IOException;
 
Example #6
Source File: DefaultZooKeeperAdminProvider.java    From strimzi-kafka-operator with Apache License 2.0 2 votes vote down vote up
/**
 * Creates an instance of ZooKeeperAdmin
 *
 * @param connectString     Connection String used to connect to Zookeeper
 * @param sessionTimeout    Session timeout
 * @param watcher           Watcher which will be notified about watches and connection changes
 * @param conf              Zookeeper client configuration
 *
 * @return  ZooKeeperAdmin instance
 */
@Override
public ZooKeeperAdmin createZookeeperAdmin(String connectString, int sessionTimeout, Watcher watcher, ZKClientConfig conf) throws IOException {
    return new ZooKeeperAdmin(connectString, sessionTimeout, watcher, conf);
}