com.netflix.astyanax.connectionpool.impl.SimpleAuthenticationCredentials Java Examples
The following examples show how to use
com.netflix.astyanax.connectionpool.impl.SimpleAuthenticationCredentials.
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: CassandraClusterImpl.java From usergrid with Apache License 2.0 | 5 votes |
private ConnectionPoolConfiguration getConnectionPoolConfig ( final String poolName, final int poolSize ){ ConnectionPoolConfiguration config; final String username = cassandraFig.getUsername(); final String password = cassandraFig.getPassword(); if ( username != null && !username.isEmpty() && password != null && !password.isEmpty() ){ config = new ConnectionPoolConfigurationImpl( poolName ) .setPort( cassandraFig.getThriftPort() ) .setLocalDatacenter( cassandraFig.getLocalDataCenter() ) .setMaxConnsPerHost( poolSize ) .setSeeds( cassandraFig.getHosts() ) .setConnectTimeout( cassandraFig.getTimeout() ) .setSocketTimeout( cassandraFig.getTimeout() ) .setAuthenticationCredentials(new SimpleAuthenticationCredentials( username, password)); } else { // create instance of the connection pool without credential if they are not set config = new ConnectionPoolConfigurationImpl( poolName ) .setPort( cassandraFig.getThriftPort() ) .setLocalDatacenter( cassandraFig.getLocalDataCenter() ) .setMaxConnsPerHost( poolSize ) .setSeeds( cassandraFig.getHosts() ) .setSocketTimeout( cassandraFig.getTimeout() ) .setConnectTimeout( cassandraFig.getTimeout() ); } return config; }
Example #2
Source File: CassandraConfiguration.java From emodb with Apache License 2.0 | 4 votes |
public SimpleAuthenticationCredentials getAuthenticationCredentials() { return _authenticationCredentials; }
Example #3
Source File: CassandraConfiguration.java From emodb with Apache License 2.0 | 4 votes |
public CassandraConfiguration setAuthenticationCredentials(SimpleAuthenticationCredentials authenticationCredentials) { _authenticationCredentials = authenticationCredentials; return this; }
Example #4
Source File: AstyanaxStoreManager.java From titan1withtp3.1 with Apache License 2.0 | 4 votes |
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; }