Book Image

Cassandra High Availability

By : Robbie Strickland
Book Image

Cassandra High Availability

By: Robbie Strickland

Overview of this book

Table of Contents (16 chapters)
Cassandra High Availability
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Tying it all together


In attempting to develop a comprehensive approach to handling failure, we will start by assuming that you prefer consistency when possible but want your application to remain available even if the desired consistency level cannot be satisfied; you are also willing to experience slower client response rather than denying requests.

With these ideas in mind, we can tie the concepts you have learned throughout this chapter together in a policy that answers this demand. Take a look at the following example, which makes use of the previously discussed features:

// defined at class level
String localDC = "DC1";
ConsistencyLevel defaultCL = ConsistencyLevel.LOCAL_QUORUM;
private Cluster cluster;

// initialized once per application
cluster = cluster.builder()
  .addContactPoints("10.10.10.1", "10.10.10.2", "10.10.10.3")
  .withRetryPolicy(new LoggingRetryPolicy(
    DowngradingConsistencyRetryPolicy.INSTANCE))
  .withLoadBalancingPolicy(new TokenAwarePolicy(
    new DCAwareRoundRobinPolicy...