use of com.couchbase.client.core.env.LoggerConfig in project couchbase-jdbc-driver by couchbaselabs.
the class ConnectionManager method clusterForCoordinate.
private Cluster clusterForCoordinate(final ConnectionCoordinate coordinate) {
synchronized (this) {
if (environment == null) {
// This logger config makes sure the SDK also uses java.util.Logging.
LoggerConfig.Builder loggerConfig = LoggerConfig.builder().disableSlf4J(true).fallbackToConsole(false);
SecurityConfig.Builder securityConfig = SecurityConfig.builder();
if (Boolean.parseBoolean(CouchbaseDriverProperty.SSL.get(coordinate.properties()))) {
securityConfig = securityConfig.enableTls(true);
if ("no-verify".equals(CouchbaseDriverProperty.SSL_MODE.get(coordinate.properties()))) {
securityConfig = securityConfig.trustManagerFactory(InsecureTrustManagerFactory.INSTANCE);
} else {
if ("verify-ca".equals(CouchbaseDriverProperty.SSL_MODE.get(coordinate.properties()))) {
securityConfig = securityConfig.enableHostnameVerification(false);
}
String certPath = CouchbaseDriverProperty.SSL_CERT_PATH.get(coordinate.properties());
if (!isNullOrEmpty(certPath)) {
securityConfig.trustCertificate(Paths.get(certPath));
}
String keyStorePath = CouchbaseDriverProperty.SSL_KEYSTORE_PATH.get(coordinate.properties());
if (!isNullOrEmpty(keyStorePath)) {
String keyStorePassword = CouchbaseDriverProperty.SSL_KEYSTORE_PASSWORD.get(coordinate.properties());
if (isNull(keyStorePassword)) {
throw new IllegalArgumentException("If a keystore is provided, the password also needs to be provided");
}
securityConfig.trustStore(Paths.get(keyStorePath), keyStorePassword, Optional.empty());
}
}
}
environment = ClusterEnvironment.builder().load((PropertyLoader<CoreEnvironment.Builder>) builder -> new SystemPropertyPropertyLoader(coordinate.properties()).load(builder)).loggerConfig(loggerConfig).securityConfig(securityConfig).retryStrategy(new InterceptingRetryStrategy()).build();
}
long newHandleCount = openHandles.compute(coordinate, (k, v) -> {
if (v == null) {
return 1L;
} else {
return v + 1;
}
});
LOGGER.fine("Incrementing Handle Count to " + newHandleCount + " for Coordinate " + coordinate);
return clusterCache.computeIfAbsent(coordinate, s -> {
Cluster c = Cluster.connect(coordinate.connectionString(), clusterOptions(coordinate.authenticator()).environment(environment));
maybeWaitUntilReady(coordinate, c);
return c;
});
}
}
Aggregations