Search in sources :

Example 1 with CassandraKeyValueServiceConfig

use of com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig in project atlasdb by palantir.

the class HeartbeatServiceIntegrationTest method setUp.

@Before
public void setUp() throws TException {
    queryRunner = new TracingQueryRunner(log, TracingPrefsConfig.create());
    CassandraKeyValueServiceConfig config = CassandraContainer.KVS_CONFIG;
    writeConsistency = ConsistencyLevel.EACH_QUORUM;
    clientPool = CassandraClientPoolImpl.create(config);
    lockTable = new UniqueSchemaMutationLockTable(new SchemaMutationLockTables(clientPool, config), LockLeader.I_AM_THE_LOCK_LEADER);
    heartbeatService = new HeartbeatService(clientPool, queryRunner, heartbeatTimePeriodMillis, lockTable.getOnlyTable(), writeConsistency);
    lockTestTools = new SchemaMutationLockTestTools(clientPool, lockTable);
    lockTestTools.setLocksTableValue(lockId, 0);
}
Also used : CassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig) Before(org.junit.Before)

Example 2 with CassandraKeyValueServiceConfig

use of com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig in project atlasdb by palantir.

the class CassandraSchemaLockTest method shouldCreateTablesConsistentlyWithMultipleCassandraNodes.

@Test
public void shouldCreateTablesConsistentlyWithMultipleCassandraNodes() throws Exception {
    TableReference table1 = TableReference.createFromFullyQualifiedName("ns.table1");
    CassandraKeyValueServiceConfig config = ThreeNodeCassandraCluster.KVS_CONFIG;
    try {
        CyclicBarrier barrier = new CyclicBarrier(THREAD_COUNT);
        for (int i = 0; i < THREAD_COUNT; i++) {
            async(() -> {
                CassandraKeyValueService keyValueService = CassandraKeyValueServiceImpl.create(config, Optional.empty());
                barrier.await();
                keyValueService.createTable(table1, AtlasDbConstants.GENERIC_TABLE_METADATA);
                return null;
            });
        }
    } finally {
        executorService.shutdown();
        assertTrue(executorService.awaitTermination(4, TimeUnit.MINUTES));
    }
    CassandraKeyValueService kvs = CassandraKeyValueServiceImpl.create(config, Optional.empty());
    assertThat(kvs.getAllTableNames(), hasItem(table1));
    assertThat(new File(CONTAINERS.getLogDirectory()), containsFiles(everyItem(doesNotContainTheColumnFamilyIdMismatchError())));
}
Also used : TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) CassandraKeyValueService(com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueService) File(java.io.File) CassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig) CyclicBarrier(java.util.concurrent.CyclicBarrier) Test(org.junit.Test)

Example 3 with CassandraKeyValueServiceConfig

use of com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig in project atlasdb by palantir.

the class QosCassandraEteTestSetup method getAtlasDbConfig.

private static AtlasDbConfig getAtlasDbConfig() {
    DockerPort cassandraPort = docker.containers().container("cassandra").port(CASSANDRA_PORT_NUMBER);
    InetSocketAddress cassandraAddress = new InetSocketAddress(cassandraPort.getIp(), cassandraPort.getExternalPort());
    CassandraKeyValueServiceConfig kvsConfig = ImmutableCassandraKeyValueServiceConfig.builder().servers(ImmutableList.of(cassandraAddress)).credentials(ImmutableCassandraCredentialsConfig.builder().username("cassandra").password("cassandra").build()).ssl(false).replicationFactor(1).autoRefreshNodes(false).build();
    return ImmutableAtlasDbConfig.builder().namespace("qosete").keyValueService(kvsConfig).initializeAsync(true).build();
}
Also used : DockerPort(com.palantir.docker.compose.connection.DockerPort) InetSocketAddress(java.net.InetSocketAddress) CassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig) ImmutableCassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.ImmutableCassandraKeyValueServiceConfig)

Example 4 with CassandraKeyValueServiceConfig

use of com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig in project atlasdb by palantir.

the class CleanCassLocksStateCommand method getCassandraKvsConfig.

private CassandraKeyValueServiceConfig getCassandraKvsConfig() {
    KeyValueServiceConfig kvsConfig = getAtlasDbConfig().keyValueService();
    if (!kvsConfig.type().equals(CassandraKeyValueServiceConfig.TYPE)) {
        throw new IllegalStateException(String.format("KeyValueService must be of type %s, but yours is %s", CassandraKeyValueServiceConfig.TYPE, kvsConfig.type()));
    }
    CassandraKeyValueServiceConfig cassandraConfig = (CassandraKeyValueServiceConfig) kvsConfig;
    Optional<String> namespace = getAtlasDbConfig().namespace();
    String desiredKeyspace = OptionalResolver.resolve(namespace, cassandraConfig.keyspace());
    return CassandraKeyValueServiceConfigs.copyWithKeyspace(cassandraConfig, desiredKeyspace);
}
Also used : CassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig) KeyValueServiceConfig(com.palantir.atlasdb.spi.KeyValueServiceConfig) CassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig)

Example 5 with CassandraKeyValueServiceConfig

use of com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig in project atlasdb by palantir.

the class CleanCassLocksStateCommand method call.

@Override
public Integer call() throws Exception {
    Preconditions.checkState(isOffline(), "This CLI can only be run offline");
    CassandraKeyValueServiceConfig config = getCassandraKvsConfig();
    return runWithConfig(config);
}
Also used : CassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig)

Aggregations

CassandraKeyValueServiceConfig (com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig)5 ImmutableCassandraKeyValueServiceConfig (com.palantir.atlasdb.cassandra.ImmutableCassandraKeyValueServiceConfig)1 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)1 CassandraKeyValueService (com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueService)1 KeyValueServiceConfig (com.palantir.atlasdb.spi.KeyValueServiceConfig)1 DockerPort (com.palantir.docker.compose.connection.DockerPort)1 File (java.io.File)1 InetSocketAddress (java.net.InetSocketAddress)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 Before (org.junit.Before)1 Test (org.junit.Test)1