@Test void consistencyLevelShouldBeEqualToQuorum(DockerCassandra dockerCassandra) { Cluster cluster = ClusterFactory.create(dockerCassandra.configurationBuilder() .build(), CassandraConsistenciesConfiguration.DEFAULT); ConsistencyLevel consistencyLevel = cluster.getConfiguration() .getQueryOptions() .getConsistencyLevel(); assertThat(consistencyLevel).isEqualTo(ConsistencyLevel.QUORUM); }
public static Cluster create(ClusterConfiguration configuration, CassandraConsistenciesConfiguration consistenciesConfiguration) { Preconditions.checkState(configuration.getUsername().isPresent() == configuration.getPassword().isPresent(), "If you specify username, you must specify password"); Cluster.Builder clusterBuilder = Cluster.builder() .withoutJMXReporting(); configuration.getHosts().forEach(server -> clusterBuilder .addContactPoint(server.getHostName()) .withPort(server.getPort())); configuration.getUsername().ifPresent(username -> configuration.getPassword().ifPresent(password -> clusterBuilder.withCredentials(username, password))); clusterBuilder.withQueryOptions(queryOptions(consistenciesConfiguration)); SocketOptions socketOptions = new SocketOptions(); socketOptions.setReadTimeoutMillis(configuration.getReadTimeoutMillis()); socketOptions.setConnectTimeoutMillis(configuration.getConnectTimeoutMillis()); clusterBuilder.withSocketOptions(socketOptions); clusterBuilder.withRetryPolicy(new LogConsistencyAllRetryPolicy()); configuration.getPoolingOptions().ifPresent(clusterBuilder::withPoolingOptions); if (configuration.useSsl()) { clusterBuilder.withSSL(); } Cluster cluster = clusterBuilder.build(); try { configuration.getQueryLoggerConfiguration().map(queryLoggerConfiguration -> cluster.register(queryLoggerConfiguration.getQueryLogger())); ensureContactable(cluster); return cluster; } catch (Exception e) { cluster.close(); throw e; } }
ClusterFactory { public static Cluster create(ClusterConfiguration configuration, CassandraConsistenciesConfiguration consistenciesConfiguration) { Preconditions.checkState(configuration.getUsername().isPresent() == configuration.getPassword().isPresent(), "If you specify username, you must specify password"); Cluster.Builder clusterBuilder = Cluster.builder() .withoutJMXReporting(); configuration.getHosts().forEach(server -> clusterBuilder .addContactPoint(server.getHostName()) .withPort(server.getPort())); configuration.getUsername().ifPresent(username -> configuration.getPassword().ifPresent(password -> clusterBuilder.withCredentials(username, password))); clusterBuilder.withQueryOptions(queryOptions(consistenciesConfiguration)); SocketOptions socketOptions = new SocketOptions(); socketOptions.setReadTimeoutMillis(configuration.getReadTimeoutMillis()); socketOptions.setConnectTimeoutMillis(configuration.getConnectTimeoutMillis()); clusterBuilder.withSocketOptions(socketOptions); clusterBuilder.withRetryPolicy(new LogConsistencyAllRetryPolicy()); configuration.getPoolingOptions().ifPresent(clusterBuilder::withPoolingOptions); if (configuration.useSsl()) { clusterBuilder.withSSL(); } Cluster cluster = clusterBuilder.build(); try { configuration.getQueryLoggerConfiguration().map(queryLoggerConfiguration -> cluster.register(queryLoggerConfiguration.getQueryLogger())); ensureContactable(cluster); return cluster; } catch (Exception e) { cluster.close(); throw e; } } }
ClusterFactory { public static Cluster create(ClusterConfiguration configuration, CassandraConsistenciesConfiguration consistenciesConfiguration) { Preconditions.checkState(configuration.getUsername().isPresent() == configuration.getPassword().isPresent(), "If you specify username, you must specify password"); Cluster.Builder clusterBuilder = Cluster.builder() .withoutJMXReporting(); configuration.getHosts().forEach(server -> clusterBuilder .addContactPoint(server.getHostName()) .withPort(server.getPort())); configuration.getUsername().ifPresent(username -> configuration.getPassword().ifPresent(password -> clusterBuilder.withCredentials(username, password))); clusterBuilder.withQueryOptions(queryOptions(consistenciesConfiguration)); SocketOptions socketOptions = new SocketOptions(); socketOptions.setReadTimeoutMillis(configuration.getReadTimeoutMillis()); socketOptions.setConnectTimeoutMillis(configuration.getConnectTimeoutMillis()); clusterBuilder.withSocketOptions(socketOptions); clusterBuilder.withRetryPolicy(new LogConsistencyAllRetryPolicy()); configuration.getPoolingOptions().ifPresent(clusterBuilder::withPoolingOptions); if (configuration.useSsl()) { clusterBuilder.withSSL(); } Cluster cluster = clusterBuilder.build(); try { configuration.getQueryLoggerConfiguration().map(queryLoggerConfiguration -> cluster.register(queryLoggerConfiguration.getQueryLogger())); ensureContactable(cluster); return cluster; } catch (Exception e) { cluster.close(); throw e; } }  }
ClusterFactory { public static Cluster create(ClusterConfiguration configuration, CassandraConsistenciesConfiguration consistenciesConfiguration) { Preconditions.checkState(configuration.getUsername().isPresent() == configuration.getPassword().isPresent(), "If you specify username, you must specify password"); Cluster.Builder clusterBuilder = Cluster.builder() .withoutJMXReporting(); configuration.getHosts().forEach(server -> clusterBuilder .addContactPoint(server.getHostName()) .withPort(server.getPort())); configuration.getUsername().ifPresent(username -> configuration.getPassword().ifPresent(password -> clusterBuilder.withCredentials(username, password))); clusterBuilder.withQueryOptions(queryOptions(consistenciesConfiguration)); SocketOptions socketOptions = new SocketOptions(); socketOptions.setReadTimeoutMillis(configuration.getReadTimeoutMillis()); socketOptions.setConnectTimeoutMillis(configuration.getConnectTimeoutMillis()); clusterBuilder.withSocketOptions(socketOptions); clusterBuilder.withRetryPolicy(new LogConsistencyAllRetryPolicy()); configuration.getPoolingOptions().ifPresent(clusterBuilder::withPoolingOptions); if (configuration.useSsl()) { clusterBuilder.withSSL(); } Cluster cluster = clusterBuilder.build(); try { configuration.getQueryLoggerConfiguration().map(queryLoggerConfiguration -> cluster.register(queryLoggerConfiguration.getQueryLogger())); ensureContactable(cluster); return cluster; } catch (Exception e) { cluster.close(); throw e; } }  static Cluster create(ClusterConfiguration configuration, CassandraConsistenciesConfiguration consistenciesConfiguration); }
ClusterFactory { public static Cluster create(ClusterConfiguration configuration, CassandraConsistenciesConfiguration consistenciesConfiguration) { Preconditions.checkState(configuration.getUsername().isPresent() == configuration.getPassword().isPresent(), "If you specify username, you must specify password"); Cluster.Builder clusterBuilder = Cluster.builder() .withoutJMXReporting(); configuration.getHosts().forEach(server -> clusterBuilder .addContactPoint(server.getHostName()) .withPort(server.getPort())); configuration.getUsername().ifPresent(username -> configuration.getPassword().ifPresent(password -> clusterBuilder.withCredentials(username, password))); clusterBuilder.withQueryOptions(queryOptions(consistenciesConfiguration)); SocketOptions socketOptions = new SocketOptions(); socketOptions.setReadTimeoutMillis(configuration.getReadTimeoutMillis()); socketOptions.setConnectTimeoutMillis(configuration.getConnectTimeoutMillis()); clusterBuilder.withSocketOptions(socketOptions); clusterBuilder.withRetryPolicy(new LogConsistencyAllRetryPolicy()); configuration.getPoolingOptions().ifPresent(clusterBuilder::withPoolingOptions); if (configuration.useSsl()) { clusterBuilder.withSSL(); } Cluster cluster = clusterBuilder.build(); try { configuration.getQueryLoggerConfiguration().map(queryLoggerConfiguration -> cluster.register(queryLoggerConfiguration.getQueryLogger())); ensureContactable(cluster); return cluster; } catch (Exception e) { cluster.close(); throw e; } }  static Cluster create(ClusterConfiguration configuration, CassandraConsistenciesConfiguration consistenciesConfiguration);  }