/** * Create new cassandra cluster using builder. */ @PostConstruct public void init() { Cluster.Builder builder = Cluster.builder() .addContactPointsWithPorts(parseNodeList(nodeList)) .withClusterName(clusterName) .withSocketOptions(clientOptions.getSocketOptions()); if (!useJmx) { builder.withoutJMXReporting(); } if (disableMetrics) { builder.withoutMetrics(); } if (useCredentials) { builder.withCredentials(username, password); } if (useSsl) { builder.withSSL(); } builder.withQueryOptions(clientOptions.getQueryOptions()); builder.withCompression(parseCompression(compression)); cluster = builder.build(); }
builder = builder.withoutMetrics();
.withoutMetrics() .addContactPoints(cassandraConf.getNodes()) .withPort(cassandraConf.getPort())
if (mOpt != null) { if (!mOpt.isEnabled()) { builder.withoutMetrics();
clusterBuilder.withoutMetrics();
builder.withoutMetrics(); } else if (!config.getMetricsOptions().isJMXReportingEnabled()) { builder.withoutJMXReporting();
if (enableMetricsProp != null) { if (!Boolean.parseBoolean(enableMetricsProp)) { builder = builder.withoutMetrics();
builder = builder.withoutMetrics();
builder = builder.withoutMetrics();
.withoutMetrics() .addContactPoints(cassandraConf.getNodes()) .withPort(cassandraConf.getPort())
builder.withoutMetrics(); } else if (!config.getMetricsOptions().isJMXReportingEnabled()) { builder.withoutJMXReporting();
/** * Validates that when metrics are disabled using {@link Cluster.Builder#withoutMetrics()} that * {@link Cluster#getMetrics()} returns null and 'clusterName-metrics:name=connected-to' MBean is * not present. * * @test_category metrics */ @Test(groups = "short", expectedExceptions = InstanceNotFoundException.class) public void metrics_should_be_null_when_metrics_disabled() throws Exception { Cluster cluster = register( Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .withoutMetrics() .build()); try { cluster.init(); assertThat(cluster.getMetrics()).isNull(); assertThat(cluster.getConfiguration().getMetricsOptions().isEnabled()).isFalse(); ObjectName clusterMetricsON = ObjectName.getInstance(cluster.getClusterName() + "-metrics:name=connected-to"); server.getMBeanInfo(clusterMetricsON); } finally { cluster.close(); } }
public static Cluster setupCassandraClient(String []nodes) { return Cluster.builder() .withoutJMXReporting() .withoutMetrics() .addContactPoints(nodes) .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE) .withReconnectionPolicy(new ExponentialReconnectionPolicy(100L, TimeUnit.MINUTES.toMillis(5))) .withLoadBalancingPolicy(new TokenAwarePolicy(new RoundRobinPolicy())) .build(); }
/** * Validates that when metrics are disabled using {@link Cluster.Builder#withoutMetrics()} that * {@link Cluster#getMetrics()} returns null and 'clusterName-metrics:name=connected-to' MBean is * not present. * * @test_category metrics */ @Test(groups = "short", expectedExceptions = InstanceNotFoundException.class) public void metrics_should_be_null_when_metrics_disabled() throws Exception { Cluster cluster = register( Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .withoutMetrics() .build()); try { cluster.init(); assertThat(cluster.getMetrics()).isNull(); assertThat(cluster.getConfiguration().getMetricsOptions().isEnabled()).isFalse(); ObjectName clusterMetricsON = ObjectName.getInstance(cluster.getClusterName() + "-metrics:name=connected-to"); server.getMBeanInfo(clusterMetricsON); } finally { cluster.close(); } }