Automatic failover

If a Cassandra node fails or becomes unreachable, the Java driver automatically and transparently tries other nodes in the cluster and schedules reconnections to the dead nodes in the background.

Description

How the driver handles failover is determined by which retry and reconnection policies are used when building a cluster object.

Examples

This code illustrates building a cluster instance with a retry policy which sometimes retries with a lower consistency level than the one specified for the query.

public RollYourOwnCluster() {
   Cluster cluster = Cluster.builder()
         .addContactPoints("127.0.0.1", "127.0.0.2")
         .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
         .withReconnectionPolicy(new ConstantReconnectionPolicy(100L))
         .build();
   session = cluster.connect();
}