Search in sources :

Example 1 with CassandraKeyValueService

use of com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueService 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 2 with CassandraKeyValueService

use of com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueService in project atlasdb by palantir.

the class NodesDownTestSetup method setupTestTable.

private static void setupTestTable() {
    CassandraKeyValueService setupDb = createCassandraKvs();
    setupDb.createTable(TEST_TABLE, AtlasDbConstants.GENERIC_TABLE_METADATA);
    setupDb.put(TEST_TABLE, ImmutableMap.of(CELL_1_1, PtBytes.toBytes("old_value")), OLD_TIMESTAMP);
    setupDb.put(TEST_TABLE, ImmutableMap.of(CELL_1_1, DEFAULT_CONTENTS), DEFAULT_TIMESTAMP);
    setupDb.put(TEST_TABLE, ImmutableMap.of(CELL_1_2, DEFAULT_CONTENTS), DEFAULT_TIMESTAMP);
    setupDb.put(TEST_TABLE, ImmutableMap.of(CELL_2_1, DEFAULT_CONTENTS), DEFAULT_TIMESTAMP);
    setupDb.createTable(TEST_TABLE_TO_DROP, AtlasDbConstants.GENERIC_TABLE_METADATA);
    setupDb.createTable(TEST_TABLE_TO_DROP_2, AtlasDbConstants.GENERIC_TABLE_METADATA);
    setupDb.close();
}
Also used : CassandraKeyValueService(com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueService)

Aggregations

CassandraKeyValueService (com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueService)2 CassandraKeyValueServiceConfig (com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig)1 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)1 File (java.io.File)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 Test (org.junit.Test)1