Search in sources :

Example 16 with SocketOptions

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

the class CqlConfigHelper method getReadSocketOptions.

private static SocketOptions getReadSocketOptions(Configuration conf) {
    SocketOptions socketOptions = new SocketOptions();
    Optional<Integer> connectTimeoutMillis = getInputNativeConnectionTimeout(conf);
    Optional<Integer> readTimeoutMillis = getInputNativeReadConnectionTimeout(conf);
    Optional<Integer> receiveBufferSize = getInputNativeReceiveBufferSize(conf);
    Optional<Integer> sendBufferSize = getInputNativeSendBufferSize(conf);
    Optional<Integer> soLinger = getInputNativeSolinger(conf);
    Optional<Boolean> tcpNoDelay = getInputNativeTcpNodelay(conf);
    Optional<Boolean> reuseAddress = getInputNativeReuseAddress(conf);
    Optional<Boolean> keepAlive = getInputNativeKeepAlive(conf);
    if (connectTimeoutMillis.isPresent())
        socketOptions.setConnectTimeoutMillis(connectTimeoutMillis.get());
    if (readTimeoutMillis.isPresent())
        socketOptions.setReadTimeoutMillis(readTimeoutMillis.get());
    if (receiveBufferSize.isPresent())
        socketOptions.setReceiveBufferSize(receiveBufferSize.get());
    if (sendBufferSize.isPresent())
        socketOptions.setSendBufferSize(sendBufferSize.get());
    if (soLinger.isPresent())
        socketOptions.setSoLinger(soLinger.get());
    if (tcpNoDelay.isPresent())
        socketOptions.setTcpNoDelay(tcpNoDelay.get());
    if (reuseAddress.isPresent())
        socketOptions.setReuseAddress(reuseAddress.get());
    if (keepAlive.isPresent())
        socketOptions.setKeepAlive(keepAlive.get());
    return socketOptions;
}
Also used : SocketOptions(com.datastax.driver.core.SocketOptions)

Aggregations

SocketOptions (com.datastax.driver.core.SocketOptions)16 Cluster (com.datastax.driver.core.Cluster)7 QueryOptions (com.datastax.driver.core.QueryOptions)6 PoolingOptions (com.datastax.driver.core.PoolingOptions)4 TokenAwarePolicy (com.datastax.driver.core.policies.TokenAwarePolicy)4 DCAwareRoundRobinPolicy (com.datastax.driver.core.policies.DCAwareRoundRobinPolicy)3 LoadBalancingPolicy (com.datastax.driver.core.policies.LoadBalancingPolicy)3 RoundRobinPolicy (com.datastax.driver.core.policies.RoundRobinPolicy)3 PlainTextAuthProvider (com.datastax.driver.core.PlainTextAuthProvider)2 SSLOptions (com.datastax.driver.core.SSLOptions)2 WhiteListPolicy (com.datastax.driver.core.policies.WhiteListPolicy)2 InetSocketAddress (java.net.InetSocketAddress)2 PostConstruct (javax.annotation.PostConstruct)2 BeforeClass (org.junit.BeforeClass)2 AuthProvider (com.datastax.driver.core.AuthProvider)1 Configuration (com.datastax.driver.core.Configuration)1 Host (com.datastax.driver.core.Host)1 JdkSSLOptions (com.datastax.driver.core.JdkSSLOptions)1 Metadata (com.datastax.driver.core.Metadata)1 NoHostAvailableException (com.datastax.driver.core.exceptions.NoHostAvailableException)1