some code for reporting Cassansdra status
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 22 Nov 2013 11:25:35 +0000 (11:25 +0000)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Fri, 22 Nov 2013 11:25:35 +0000 (11:25 +0000)
datadb/compbio/cassandra/CassandraNativeConnector.java

index 132611f..4b40518 100644 (file)
@@ -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());
+       }
+       
 }