ArunM
ArunM

Reputation: 2314

Determine replication strategy for Cassandra cluster at run time

I need to set the consistency level of a query depending on the replication strategy. A replication strategy of NetworkTopologyStrategy will mean that the insert will execute at EACH_QUORUM. A replication strategy of SimpleStrategy will mean that the insert will execute at LOCAL_QUORUM.

The session seems to have a getCluster(). Is there anyway to know the replication strategy for the Cluster object or through any other method.

Upvotes: 1

Views: 140

Answers (1)

Adam Holmberg
Adam Holmberg

Reputation: 7365

You're on the right track. From cluster, you can getMetadata(), then Metadata.getKeyspace(String), KeyspaceMetadata.getReplication() will get you a map of replication options for a given keyspace.

Upvotes: 2

Related Questions