private static Cluster createCluster(CentralConfiguration centralConfig, TimestampGenerator defaultTimestampGenerator) { Cluster.Builder builder = Cluster.builder() .addContactPoints( centralConfig.cassandraContactPoint().toArray(new String[0])) // aggressive reconnect policy seems ok since not many clients .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) // let driver know that only idempotent queries are used so it will retry on timeout .withQueryOptions(new QueryOptions() .setDefaultIdempotence(true) .setConsistencyLevel(centralConfig.cassandraConsistencyLevel())) // central runs lots of parallel async queries and is very spiky since all // aggregates come in right after each minute marker .withPoolingOptions( new PoolingOptions().setMaxQueueSize(Session.MAX_CONCURRENT_QUERIES)) .withTimestampGenerator(defaultTimestampGenerator); String cassandraUsername = centralConfig.cassandraUsername(); if (!cassandraUsername.isEmpty()) { // empty password is strange but valid builder.withCredentials(cassandraUsername, centralConfig.cassandraPassword()); } return builder.build(); }
@Bean public TimestampGenerator getTimestampGenerator() { return new AtomicMonotonicTimestampGenerator(); }
/** * @return the timestampGenerator */ public TimestampGenerator getTimestampGenerator() { return timestampGenerator; }
/** * @param timestampGenerator * the timestampGenerator to set */ public void setTimestampGenerator(TimestampGenerator timestampGenerator) { this.timestampGenerator = timestampGenerator; }