.withLoadBalancingPolicy(new SelectiveLoadBalancingPolicy(readLoadBalancePolicy, m_writeLoadBalancingPolicy)) .withCompression(ProtocolOptions.Compression.LZ4) .withoutJMXReporting() .withQueryOptions(new QueryOptions().setConsistencyLevel(m_clusterConfiguration.getReadConsistencyLevel())) .withTimestampGenerator(new TimestampGenerator() //todo need to remove this and put it only on the datapoints call
/** * 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.withoutJMXReporting();
private Session createSession() { Cluster.Builder clusterBuilder = new Cluster.Builder(); clusterBuilder.addContactPoints(cassandraNodes.toArray(new String[] {})); if (useSSL) { SSLOptions sslOptions = null; try { String[] defaultCipherSuites = {"TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_256_CBC_SHA"}; sslOptions = JdkSSLOptions.builder().withSSLContext(SSLContext.getDefault()) .withCipherSuites(defaultCipherSuites).build(); clusterBuilder.withSSL(sslOptions); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("SSL support is required but is not available in the JVM.", e); } } clusterBuilder.withoutJMXReporting(); Cluster cluster = clusterBuilder.build(); cluster.init(); Session createdSession = null; try { createdSession = cluster.connect("system"); return createdSession; } finally { if (createdSession == null) { cluster.close(); } } }
/** * Validates that when metrics are enabled but JMX reporting is disabled via {@link * Cluster.Builder#withoutJMXReporting()} that {@link Cluster#getMetrics()} is not null and * 'clusterName-metrics:name=connected-to' MBean is present. * * @test_category metrics */ @Test(groups = "short", expectedExceptions = InstanceNotFoundException.class) public void should_be_no_jmx_mbean_when_jmx_is_disabled() throws Exception { Cluster cluster = register( Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .withoutJMXReporting() .build()); try { cluster.init(); assertThat(cluster.getMetrics()).isNotNull(); assertThat(cluster.getConfiguration().getMetricsOptions().isEnabled()).isTrue(); assertThat(cluster.getConfiguration().getMetricsOptions().isJMXReportingEnabled()).isFalse(); ObjectName clusterMetricsON = ObjectName.getInstance(cluster.getClusterName() + "-metrics:name=connected-to"); server.getMBeanInfo(clusterMetricsON); } finally { cluster.close(); } } }
static Cluster buildCluster(CassandraStorage cassandra) { Cluster.Builder builder = Cluster.builder().withoutJMXReporting(); List<InetSocketAddress> contactPoints = parseContactPoints(cassandra); int defaultPort = findConnectPort(contactPoints); builder.addContactPointsWithPorts(contactPoints); builder.withPort(defaultPort); // This ends up protocolOptions.port if (cassandra.username != null && cassandra.password != null) { builder.withCredentials(cassandra.username, cassandra.password); } builder.withRetryPolicy(ZipkinRetryPolicy.INSTANCE); builder.withLoadBalancingPolicy( new TokenAwarePolicy( new LatencyAwarePolicy.Builder( cassandra.localDc != null ? DCAwareRoundRobinPolicy.builder().withLocalDc(cassandra.localDc).build() : new RoundRobinPolicy() // This can select remote, but LatencyAwarePolicy will prefer local ) .build())); builder.withPoolingOptions( new PoolingOptions() .setMaxConnectionsPerHost(HostDistance.LOCAL, cassandra.maxConnections)); if (cassandra.useSsl) { builder = builder.withSSL(); } return builder.build(); }
@Override public Session call() throws Exception { try { return new Cluster.Builder() .addContactPoints(nodes.split(",")) .withPort(new Integer(cqlPort)) .withProtocolVersion(ProtocolVersion.V3) .withoutJMXReporting() .build().connect(); } catch (Exception e) { if (attempts != 0) { logger.attemptToConnectToCassandraFailed(attempts, e); attempts--; Thread.sleep(interval); return call(); } else { logger.cannotConnectToCassandra(e); return null; } } } }
private static synchronized void initCluster() { if (cluster == null) { QueryOptions queryOptions = new QueryOptions(); queryOptions.setRefreshSchemaIntervalMillis(0); queryOptions.setRefreshNodeIntervalMillis(0); queryOptions.setRefreshNodeListIntervalMillis(0); cluster = com.datastax.driver.core.Cluster.builder() .addContactPoints(EmbeddedCassandraServerHelper.getHost()) .withPort(EmbeddedCassandraServerHelper.getNativeTransportPort()) .withoutJMXReporting() .withQueryOptions(queryOptions) .build(); } }
private static synchronized void initCluster() { if (cluster == null) { QueryOptions queryOptions = new QueryOptions(); queryOptions.setRefreshSchemaIntervalMillis(0); queryOptions.setRefreshNodeIntervalMillis(0); queryOptions.setRefreshNodeListIntervalMillis(0); cluster = com.datastax.driver.core.Cluster.builder() .addContactPoints(EmbeddedCassandraServerHelper.getHost()) .withPort(EmbeddedCassandraServerHelper.getNativeTransportPort()) .withoutJMXReporting() .withQueryOptions(queryOptions) .build(); } }
private static synchronized void initCluster() { if (cluster == null) { QueryOptions queryOptions = new QueryOptions(); queryOptions.setRefreshSchemaIntervalMillis(0); queryOptions.setRefreshNodeIntervalMillis(0); queryOptions.setRefreshNodeListIntervalMillis(0); cluster = com.datastax.driver.core.Cluster.builder() .addContactPoints(EmbeddedCassandraServerHelper.getHost()) .withPort(EmbeddedCassandraServerHelper.getNativeTransportPort()) .withoutJMXReporting() .withQueryOptions(queryOptions) .build(); } }
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(); }
private static void dataSetLoad(String host, String port, String file) { Cluster cluster = Cluster.builder() .addContactPoints(host) .withoutJMXReporting() .withPort(Integer.parseInt(port)) .build(); CQLDataLoader dataLoader = new CQLDataLoader(cluster.connect()); dataLoader.load(new FileCQLDataSet(file)); System.out.println("Loading completed"); }
private static void otherTypeOfDataSetLoad(String host, String port, String file) { Cluster cluster = com.datastax.driver.core.Cluster.builder() .addContactPoints(host) .withoutJMXReporting() .withPort(Integer.parseInt(port)) .build(); CQLDataLoader dataLoader = new CQLDataLoader(cluster.connect()); dataLoader.load(new FileCQLDataSet(file)); }
private static void dataSetLoad(String host, String port, String file) { Cluster cluster = Cluster.builder() .addContactPoints(host) .withoutJMXReporting() .withPort(Integer.parseInt(port)) .build(); CQLDataLoader dataLoader = new CQLDataLoader(cluster.connect()); dataLoader.load(new FileCQLDataSet(file)); System.out.println("Loading completed"); }
private static void otherTypeOfDataSetLoad(String host, String port, String file) { Cluster cluster = com.datastax.driver.core.Cluster.builder() .addContactPoints(host) .withoutJMXReporting() .withPort(Integer.parseInt(port)) .build(); CQLDataLoader dataLoader = new CQLDataLoader(cluster.connect()); dataLoader.load(new FileCQLDataSet(file)); }
private static void dataSetLoad(String host, String port, String file) { Cluster cluster = Cluster.builder() .addContactPoints(host) .withoutJMXReporting() .withPort(Integer.parseInt(port)) .build(); CQLDataLoader dataLoader = new CQLDataLoader(cluster.connect()); dataLoader.load(new FileCQLDataSet(file)); System.out.println("Loading completed"); }
private static void otherTypeOfDataSetLoad(String host, String port, String file) { Cluster cluster = com.datastax.driver.core.Cluster.builder() .addContactPoints(host) .withoutJMXReporting() .withPort(Integer.parseInt(port)) .build(); CQLDataLoader dataLoader = new CQLDataLoader(cluster.connect()); dataLoader.load(new FileCQLDataSet(file)); }
/** * Validates that when metrics are enabled but JMX reporting is disabled via {@link * Cluster.Builder#withoutJMXReporting()} that {@link Cluster#getMetrics()} is not null and * 'clusterName-metrics:name=connected-to' MBean is present. * * @test_category metrics */ @Test(groups = "short", expectedExceptions = InstanceNotFoundException.class) public void should_be_no_jmx_mbean_when_jmx_is_disabled() throws Exception { Cluster cluster = register( Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .withoutJMXReporting() .build()); try { cluster.init(); assertThat(cluster.getMetrics()).isNotNull(); assertThat(cluster.getConfiguration().getMetricsOptions().isEnabled()).isTrue(); assertThat(cluster.getConfiguration().getMetricsOptions().isJMXReportingEnabled()).isFalse(); ObjectName clusterMetricsON = ObjectName.getInstance(cluster.getClusterName() + "-metrics:name=connected-to"); server.getMBeanInfo(clusterMetricsON); } finally { cluster.close(); } } }
.withoutJMXReporting() .withoutMetrics() .addContactPoints(cassandraConf.getNodes())