Search in sources :

Example 1 with AuthProvider

use of com.datastax.driver.core.AuthProvider in project cassandra by apache.

the class CqlConfigHelper method getCluster.

public static Cluster getCluster(String[] hosts, Configuration conf, int port) {
    Optional<AuthProvider> authProvider = getAuthProvider(conf);
    Optional<SSLOptions> sslOptions = getSSLOptions(conf);
    Optional<Integer> protocolVersion = getProtocolVersion(conf);
    LoadBalancingPolicy loadBalancingPolicy = getReadLoadBalancingPolicy(hosts);
    SocketOptions socketOptions = getReadSocketOptions(conf);
    QueryOptions queryOptions = getReadQueryOptions(conf);
    PoolingOptions poolingOptions = getReadPoolingOptions(conf);
    Cluster.Builder builder = Cluster.builder().addContactPoints(hosts).withPort(port).withCompression(ProtocolOptions.Compression.NONE);
    if (authProvider.isPresent())
        builder.withAuthProvider(authProvider.get());
    if (sslOptions.isPresent())
        builder.withSSL(sslOptions.get());
    if (protocolVersion.isPresent()) {
        builder.withProtocolVersion(ProtocolVersion.fromInt(protocolVersion.get()));
    }
    builder.withLoadBalancingPolicy(loadBalancingPolicy).withSocketOptions(socketOptions).withQueryOptions(queryOptions).withPoolingOptions(poolingOptions);
    return builder.build();
}
Also used : LoadBalancingPolicy(com.datastax.driver.core.policies.LoadBalancingPolicy) SocketOptions(com.datastax.driver.core.SocketOptions) PoolingOptions(com.datastax.driver.core.PoolingOptions) Cluster(com.datastax.driver.core.Cluster) AuthProvider(com.datastax.driver.core.AuthProvider) PlainTextAuthProvider(com.datastax.driver.core.PlainTextAuthProvider) JdkSSLOptions(com.datastax.driver.core.JdkSSLOptions) SSLOptions(com.datastax.driver.core.SSLOptions) QueryOptions(com.datastax.driver.core.QueryOptions)

Aggregations

AuthProvider (com.datastax.driver.core.AuthProvider)1 Cluster (com.datastax.driver.core.Cluster)1 JdkSSLOptions (com.datastax.driver.core.JdkSSLOptions)1 PlainTextAuthProvider (com.datastax.driver.core.PlainTextAuthProvider)1 PoolingOptions (com.datastax.driver.core.PoolingOptions)1 QueryOptions (com.datastax.driver.core.QueryOptions)1 SSLOptions (com.datastax.driver.core.SSLOptions)1 SocketOptions (com.datastax.driver.core.SocketOptions)1 LoadBalancingPolicy (com.datastax.driver.core.policies.LoadBalancingPolicy)1