本文整理汇总了Java中com.netflix.astyanax.connectionpool.SSLConnectionContext类的典型用法代码示例。如果您正苦于以下问题:Java SSLConnectionContext类的具体用法?Java SSLConnectionContext怎么用?Java SSLConnectionContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SSLConnectionContext类属于com.netflix.astyanax.connectionpool包,在下文中一共展示了SSLConnectionContext类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContextBuilder
import com.netflix.astyanax.connectionpool.SSLConnectionContext; //导入依赖的package包/类
private AstyanaxContext.Builder getContextBuilder(Configuration config, int maxConnsPerHost, String usedFor) {
final ConnectionPoolType poolType = ConnectionPoolType.valueOf(config.get(CONNECTION_POOL_TYPE));
final NodeDiscoveryType discType = NodeDiscoveryType.valueOf(config.get(NODE_DISCOVERY_TYPE));
final int maxConnections = config.get(MAX_CONNECTIONS);
final int maxOperationsPerConnection = config.get(MAX_OPERATIONS_PER_CONNECTION);
final int connectionTimeout = (int) connectionTimeoutMS.toMillis();
ConnectionPoolConfigurationImpl cpool =
new ConnectionPoolConfigurationImpl(usedFor + "TitanConnectionPool")
.setPort(port)
.setMaxOperationsPerConnection(maxOperationsPerConnection)
.setMaxConnsPerHost(maxConnsPerHost)
.setRetryDelaySlice(retryDelaySlice)
.setRetryMaxDelaySlice(retryMaxDelaySlice)
.setRetrySuspendWindow(retrySuspendWindow)
.setSocketTimeout(connectionTimeout)
.setConnectTimeout(connectionTimeout)
.setSeeds(StringUtils.join(hostnames, ","));
if (null != retryBackoffStrategy) {
cpool.setRetryBackoffStrategy(retryBackoffStrategy);
log.debug("Custom RetryBackoffStrategy {}", cpool.getRetryBackoffStrategy());
} else {
log.debug("Default RetryBackoffStrategy {}", cpool.getRetryBackoffStrategy());
}
if (StringUtils.isNotBlank(localDatacenter)) {
cpool.setLocalDatacenter(localDatacenter);
log.debug("Set local datacenter: {}", cpool.getLocalDatacenter());
}
AstyanaxConfigurationImpl aconf =
new AstyanaxConfigurationImpl()
.setConnectionPoolType(poolType)
.setDiscoveryType(discType)
.setTargetCassandraVersion("1.2")
.setMaxThriftSize(thriftFrameSizeBytes);
if (0 < maxConnections) {
cpool.setMaxConns(maxConnections);
}
if (hasAuthentication()) {
cpool.setAuthenticationCredentials(new SimpleAuthenticationCredentials(username, password));
}
if (config.get(SSL_ENABLED)) {
cpool.setSSLConnectionContext(new SSLConnectionContext(config.get(SSL_TRUSTSTORE_LOCATION), config.get(SSL_TRUSTSTORE_PASSWORD)));
}
AstyanaxContext.Builder ctxBuilder = new AstyanaxContext.Builder();
// Standard context builder options
ctxBuilder
.forCluster(clusterName)
.forKeyspace(keySpaceName)
.withAstyanaxConfiguration(aconf)
.withConnectionPoolConfiguration(cpool)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor());
// Conditional context builder option: host supplier
if (config.has(HOST_SUPPLIER)) {
String hostSupplier = config.get(HOST_SUPPLIER);
Supplier<List<Host>> supplier = null;
if (hostSupplier != null) {
try {
supplier = (Supplier<List<Host>>) Class.forName(hostSupplier).newInstance();
ctxBuilder.withHostSupplier(supplier);
} catch (Exception e) {
log.warn("Problem with host supplier class " + hostSupplier + ", going to use default.", e);
}
}
}
return ctxBuilder;
}
示例2: getContextBuilder
import com.netflix.astyanax.connectionpool.SSLConnectionContext; //导入依赖的package包/类
private AstyanaxContext.Builder getContextBuilder(Configuration config, int maxConnsPerHost, String usedFor) {
final ConnectionPoolType poolType = ConnectionPoolType.valueOf(config.get(CONNECTION_POOL_TYPE));
final NodeDiscoveryType discType = NodeDiscoveryType.valueOf(config.get(NODE_DISCOVERY_TYPE));
final int maxConnections = config.get(MAX_CONNECTIONS);
final int maxOperationsPerConnection = config.get(MAX_OPERATIONS_PER_CONNECTION);
final int connectionTimeout = (int) connectionTimeoutMS.getLength(TimeUnit.MILLISECONDS);
ConnectionPoolConfigurationImpl cpool =
new ConnectionPoolConfigurationImpl(usedFor + "TitanConnectionPool")
.setPort(port)
.setMaxOperationsPerConnection(maxOperationsPerConnection)
.setMaxConnsPerHost(maxConnsPerHost)
.setRetryDelaySlice(retryDelaySlice)
.setRetryMaxDelaySlice(retryMaxDelaySlice)
.setRetrySuspendWindow(retrySuspendWindow)
.setSocketTimeout(connectionTimeout)
.setConnectTimeout(connectionTimeout)
.setSeeds(StringUtils.join(hostnames, ","));
if (null != retryBackoffStrategy) {
cpool.setRetryBackoffStrategy(retryBackoffStrategy);
log.debug("Custom RetryBackoffStrategy {}", cpool.getRetryBackoffStrategy());
} else {
log.debug("Default RetryBackoffStrategy {}", cpool.getRetryBackoffStrategy());
}
if (StringUtils.isNotBlank(localDatacenter)) {
cpool.setLocalDatacenter(localDatacenter);
log.debug("Set local datacenter: {}", cpool.getLocalDatacenter());
}
AstyanaxConfigurationImpl aconf =
new AstyanaxConfigurationImpl()
.setConnectionPoolType(poolType)
.setDiscoveryType(discType)
.setTargetCassandraVersion("1.2");
if (0 < maxConnections) {
cpool.setMaxConns(maxConnections);
}
if (hasAuthentication()) {
cpool.setAuthenticationCredentials(new SimpleAuthenticationCredentials(username, password));
}
if (config.get(SSL_ENABLED)) {
cpool.setSSLConnectionContext(new SSLConnectionContext(config.get(SSL_TRUSTSTORE_LOCATION), config.get(SSL_TRUSTSTORE_PASSWORD)));
}
AstyanaxContext.Builder ctxBuilder = new AstyanaxContext.Builder();
// Standard context builder options
ctxBuilder
.forCluster(clusterName)
.forKeyspace(keySpaceName)
.withAstyanaxConfiguration(aconf)
.withConnectionPoolConfiguration(cpool)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor());
// Conditional context builder option: host supplier
if (config.has(HOST_SUPPLIER)) {
String hostSupplier = config.get(HOST_SUPPLIER);
Supplier<List<Host>> supplier = null;
if (hostSupplier != null) {
try {
supplier = (Supplier<List<Host>>) Class.forName(hostSupplier).newInstance();
ctxBuilder.withHostSupplier(supplier);
} catch (Exception e) {
log.warn("Problem with host supplier class " + hostSupplier + ", going to use default.", e);
}
}
}
return ctxBuilder;
}