com.datastax.oss.driver.api.core.ConsistencyLevel Java Examples
The following examples show how to use
com.datastax.oss.driver.api.core.ConsistencyLevel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InterpreterLogicTest.java From zeppelin with Apache License 2.0 | 6 votes |
@Test public void should_generate_simple_statement() throws Exception { //Given String input = "SELECT * FROM users LIMIT 10;"; CassandraQueryOptions options = new CassandraQueryOptions(Option.apply(QUORUM), Option.<ConsistencyLevel>empty(), Option.empty(), Option.empty(), Option.empty()); //When final SimpleStatement actual = helper.generateSimpleStatement(new SimpleStm(input), options, intrContext); //Then assertThat(actual).isNotNull(); assertThat(actual.getQuery()).isEqualTo("SELECT * FROM users LIMIT 10;"); assertThat(actual.getConsistencyLevel()).isSameAs(QUORUM); }
Example #2
Source File: QueryOptions.java From casquatch with Apache License 2.0 | 5 votes |
/** * Query Consistency Level as Object * @return object of consistencyLevel */ public ConsistencyLevel getConsistencyLevel() { if(this.consistency!=null) { return DefaultConsistencyLevel.valueOf(this.consistency); } return null; }
Example #3
Source File: InterpreterLogicTest.java From zeppelin with Apache License 2.0 | 5 votes |
@Test public void should_generate_batch_statement() throws Exception { //Given SimpleStatement st1 = SimpleStatement.newInstance("SELECT * FROM users LIMIT 10;"); SimpleStatement st2 = SimpleStatement.newInstance("INSERT INTO users(id) VALUES(10);"); SimpleStatement st3 = SimpleStatement.newInstance( "UPDATE users SET name = 'John DOE' WHERE id=10;"); CassandraQueryOptions options = new CassandraQueryOptions(Option.apply(QUORUM), Option.<ConsistencyLevel>empty(), Option.empty(), Option.empty(), Option.empty()); //When BatchStatement actual = helper.generateBatchStatement(UNLOGGED, options, toScalaList(asList(st1, st2, st3))); //Then assertThat(actual).isNotNull(); List<BatchableStatement> statements = new ArrayList<BatchableStatement>(); for (BatchableStatement b: actual) { statements.add(b); } assertThat(statements).hasSize(3); assertThat(statements.get(0)).isSameAs(st1); assertThat(statements.get(1)).isSameAs(st2); assertThat(statements.get(2)).isSameAs(st3); assertThat(actual.getConsistencyLevel()).isSameAs(QUORUM); }
Example #4
Source File: BackplaneConfiguration.java From elasticactors with Apache License 2.0 | 5 votes |
@PostConstruct public void initialize() { String cassandraHosts = env.getProperty("ea.cassandra.hosts","localhost:9042"); String cassandraKeyspaceName = env.getProperty("ea.cassandra.keyspace","\"ElasticActors\""); Integer cassandraPort = env.getProperty("ea.cassandra.port", Integer.class, 9042); Set<String> hostSet = StringUtils.commaDelimitedListToSet(cassandraHosts); String[] contactPoints = new String[hostSet.size()]; int i=0; for (String host : hostSet) { if(host.contains(":")) { contactPoints[i] = host.substring(0,host.indexOf(":")); } else { contactPoints[i] = host; } i+=1; } List<InetSocketAddress> contactPointAddresses = Arrays.stream(contactPoints) .map(host -> new InetSocketAddress(host, cassandraPort)) .collect(Collectors.toList()); DriverConfigLoader driverConfigLoader = DriverConfigLoader.programmaticBuilder() .withDuration(DefaultDriverOption.HEARTBEAT_INTERVAL, Duration.ofSeconds(60)) .withString(DefaultDriverOption.REQUEST_CONSISTENCY, ConsistencyLevel.QUORUM.name()) .withString(DefaultDriverOption.RETRY_POLICY_CLASS, "DefaultRetryPolicy") .withString(DefaultDriverOption.RECONNECTION_POLICY_CLASS, "ConstantReconnectionPolicy") .withDuration(DefaultDriverOption.RECONNECTION_BASE_DELAY, Duration.ofSeconds(env.getProperty("ea.cassandra.retryDownedHostsDelayInSeconds",Integer.class,1))) .withString(DefaultDriverOption.LOAD_BALANCING_POLICY_CLASS, "DcInferringLoadBalancingPolicy") .build(); cassandraSession = CqlSession.builder() .addContactPoints(contactPointAddresses) .withConfigLoader(driverConfigLoader) .withKeyspace(cassandraKeyspaceName) .build(); }
Example #5
Source File: CassandraTransactionManager.java From jstarcraft-core with Apache License 2.0 | 4 votes |
public CassandraTransactionManager(CqlSession cqlSession, ConsistencyLevel consistencyLevel) { this.cqlSession = cqlSession; this.consistencyLevel = consistencyLevel; }
Example #6
Source File: CassandraTransactionManagerTestCase.java From jstarcraft-core with Apache License 2.0 | 4 votes |
@Before public void testBefore() { manager = new CassandraTransactionManager(cqlSession, ConsistencyLevel.QUORUM); manager.create(name); }
Example #7
Source File: CQLTransaction.java From grakn with GNU Affero General Public License v3.0 | 4 votes |
ConsistencyLevel getReadConsistencyLevel() { return this.readConsistencyLevel; }
Example #8
Source File: CQLTransaction.java From grakn with GNU Affero General Public License v3.0 | 4 votes |
ConsistencyLevel getWriteConsistencyLevel() { return this.writeConsistencyLevel; }
Example #9
Source File: CassandraStorageAccessor.java From ShedLock with Apache License 2.0 | 4 votes |
CassandraStorageAccessor(@NonNull CqlSession cqlSession, @NonNull String table, @NonNull ConsistencyLevel consistencyLevel) { this.hostname = Utils.getHostname(); this.table = table; this.cqlSession = cqlSession; this.consistencyLevel = consistencyLevel; }
Example #10
Source File: CassandraLockProvider.java From ShedLock with Apache License 2.0 | 4 votes |
public CassandraLockProvider(@NonNull CqlSession cqlSession) { super(new CassandraStorageAccessor(cqlSession, DEFAULT_TABLE, ConsistencyLevel.QUORUM)); }
Example #11
Source File: CassandraLockProvider.java From ShedLock with Apache License 2.0 | 4 votes |
public CassandraLockProvider(@NonNull CqlSession cqlSession, @NonNull String table, @NonNull ConsistencyLevel consistencyLevel) { super(new CassandraStorageAccessor(cqlSession, table, consistencyLevel)); }
Example #12
Source File: CassandraLockProviderIntegrationTest.java From ShedLock with Apache License 2.0 | 4 votes |
private Lock findLock(String lockName) { CassandraStorageAccessor cassandraStorageAccessor = new CassandraStorageAccessor(cqlSession, CassandraLockProvider.DEFAULT_TABLE, ConsistencyLevel.QUORUM); return cassandraStorageAccessor.find(lockName).get(); }