From 119c08308da9038157c2839e5de1eb26ce519fbf Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Fri, 22 Nov 2013 11:25:35 +0000 Subject: [PATCH] some code for reporting Cassansdra status --- .../cassandra/CassandraNativeConnector.java | 29 +++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/datadb/compbio/cassandra/CassandraNativeConnector.java b/datadb/compbio/cassandra/CassandraNativeConnector.java index 132611f..4b40518 100644 --- a/datadb/compbio/cassandra/CassandraNativeConnector.java +++ b/datadb/compbio/cassandra/CassandraNativeConnector.java @@ -5,12 +5,20 @@ import java.util.Calendar; import org.apache.log4j.Logger; import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.Configuration; import com.datastax.driver.core.Host; import com.datastax.driver.core.Metadata; +import com.datastax.driver.core.MetricsOptions; +import com.datastax.driver.core.PoolingOptions; +import com.datastax.driver.core.ProtocolOptions; +import com.datastax.driver.core.QueryOptions; import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Row; +import com.datastax.driver.core.SocketOptions; import com.datastax.driver.core.Session; +import com.datastax.driver.core.policies.Policies; + import compbio.engine.ProteoCachePropertyHelperManager; import compbio.util.PropertyHelper; @@ -36,7 +44,10 @@ public class CassandraNativeConnector { CASSANDRA_HOSTNAME = cassandrahostname; } - cluster = Cluster.builder().addContactPoint(CASSANDRA_HOSTNAME).build(); + Cluster.Builder builder = Cluster.builder(); + builder.addContactPoint(CASSANDRA_HOSTNAME); + //PrintClusterConfiguration( builder.getConfiguration()); + cluster = builder.build(); Metadata metadata = cluster.getMetadata(); System.out.printf("Connected to cluster: %s\n", metadata.getClusterName()); @@ -102,4 +113,20 @@ public class CassandraNativeConnector { return cal.getTimeInMillis(); } + private void PrintClusterConfiguration(Configuration cc) { + Policies policies = cc.getPolicies(); + SocketOptions sopt = cc.getSocketOptions(); + ProtocolOptions propt = cc.getProtocolOptions(); + PoolingOptions plopt = cc.getPoolingOptions(); + MetricsOptions mopt = cc.getMetricsOptions(); + QueryOptions qopt = cc.getQueryOptions(); + System.out.println("Cluster configuration:"); + System.out.println(" Policies = " + policies.toString()); + System.out.println(" Socket Options = " + sopt.toString()); + System.out.println(" Protocol Options: compression = " + propt.getCompression()); + System.out.println(" Pooling Options = " + plopt.toString()); + System.out.println(" Metrics Options = " + mopt.toString()); + System.out.println(" Query Options = " + qopt.toString()); + } + } -- 1.7.10.2