Search in sources :

Example 1 with TracingPrefsConfig

use of com.palantir.atlasdb.keyvalue.impl.TracingPrefsConfig in project atlasdb by palantir.

the class OneNodeDownTableManipulationTest method canCleanUpSchemaMutationLockTablesState.

@Test
public void canCleanUpSchemaMutationLockTablesState() throws Exception {
    ImmutableCassandraKeyValueServiceConfig config = OneNodeDownTestSuite.CONFIG;
    CassandraClientPool clientPool = OneNodeDownTestSuite.kvs.getClientPool();
    SchemaMutationLockTables lockTables = new SchemaMutationLockTables(clientPool, config);
    TracingQueryRunner queryRunner = new TracingQueryRunner(LoggerFactory.getLogger(TracingQueryRunner.class), new TracingPrefsConfig());
    CassandraSchemaLockCleaner cleaner = CassandraSchemaLockCleaner.create(config, clientPool, lockTables, queryRunner);
    cleaner.cleanLocksState();
}
Also used : TracingQueryRunner(com.palantir.atlasdb.keyvalue.cassandra.TracingQueryRunner) CassandraSchemaLockCleaner(com.palantir.atlasdb.keyvalue.cassandra.CassandraSchemaLockCleaner) CassandraClientPool(com.palantir.atlasdb.keyvalue.cassandra.CassandraClientPool) TracingPrefsConfig(com.palantir.atlasdb.keyvalue.impl.TracingPrefsConfig) ImmutableCassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.ImmutableCassandraKeyValueServiceConfig) SchemaMutationLockTables(com.palantir.atlasdb.keyvalue.cassandra.SchemaMutationLockTables) Test(org.junit.Test)

Example 2 with TracingPrefsConfig

use of com.palantir.atlasdb.keyvalue.impl.TracingPrefsConfig in project atlasdb by palantir.

the class CleanCassLocksStateCommand method runWithConfig.

@VisibleForTesting
public Integer runWithConfig(CassandraKeyValueServiceConfig config) throws TException {
    CassandraClientPool clientPool = CassandraClientPoolImpl.create(config);
    SchemaMutationLockTables lockTables = new SchemaMutationLockTables(clientPool, config);
    TracingQueryRunner tracingQueryRunner = new TracingQueryRunner(log, new TracingPrefsConfig());
    CassandraSchemaLockCleaner.create(config, clientPool, lockTables, tracingQueryRunner).cleanLocksState();
    printer.info("Schema mutation lock cli completed successfully.");
    return 0;
}
Also used : TracingQueryRunner(com.palantir.atlasdb.keyvalue.cassandra.TracingQueryRunner) CassandraClientPool(com.palantir.atlasdb.keyvalue.cassandra.CassandraClientPool) TracingPrefsConfig(com.palantir.atlasdb.keyvalue.impl.TracingPrefsConfig) SchemaMutationLockTables(com.palantir.atlasdb.keyvalue.cassandra.SchemaMutationLockTables) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with TracingPrefsConfig

use of com.palantir.atlasdb.keyvalue.impl.TracingPrefsConfig in project atlasdb by palantir.

the class CassandraKeyValueServiceIntegrationTest method testLockTablesStateCleanUp.

@Test
public void testLockTablesStateCleanUp() throws Exception {
    CassandraKeyValueServiceImpl ckvs = (CassandraKeyValueServiceImpl) keyValueService;
    SchemaMutationLockTables lockTables = new SchemaMutationLockTables(ckvs.getClientPool(), CassandraContainer.KVS_CONFIG);
    SchemaMutationLockTestTools lockTestTools = new SchemaMutationLockTestTools(ckvs.getClientPool(), new UniqueSchemaMutationLockTable(lockTables, LockLeader.I_AM_THE_LOCK_LEADER));
    grabLock(lockTestTools);
    createExtraLocksTable(lockTables);
    TracingQueryRunner queryRunner = new TracingQueryRunner(LoggerFactory.getLogger(CassandraKeyValueServiceIntegrationTest.class), new TracingPrefsConfig());
    CassandraSchemaLockCleaner cleaner = CassandraSchemaLockCleaner.create(CassandraContainer.KVS_CONFIG, ckvs.getClientPool(), lockTables, queryRunner);
    cleaner.cleanLocksState();
    // depending on which table we pick when running cleanup on multiple lock tables, we might have a table with
    // no rows or a table with a single row containing the cleared lock value (both are valid clean states).
    List<CqlRow> resultRows = lockTestTools.readLocksTable().getRows();
    assertThat(resultRows, either(is(empty())).or(hasSize(1)));
    if (resultRows.size() == 1) {
        Column resultColumn = Iterables.getOnlyElement(Iterables.getOnlyElement(resultRows).getColumns());
        long lockId = SchemaMutationLock.getLockIdFromColumn(resultColumn);
        assertThat(lockId, is(SchemaMutationLock.GLOBAL_DDL_LOCK_CLEARED_ID));
    }
}
Also used : CqlRow(org.apache.cassandra.thrift.CqlRow) TracingPrefsConfig(com.palantir.atlasdb.keyvalue.impl.TracingPrefsConfig) Column(org.apache.cassandra.thrift.Column) AbstractKeyValueServiceTest(com.palantir.atlasdb.keyvalue.impl.AbstractKeyValueServiceTest) Test(org.junit.Test)

Aggregations

TracingPrefsConfig (com.palantir.atlasdb.keyvalue.impl.TracingPrefsConfig)3 CassandraClientPool (com.palantir.atlasdb.keyvalue.cassandra.CassandraClientPool)2 SchemaMutationLockTables (com.palantir.atlasdb.keyvalue.cassandra.SchemaMutationLockTables)2 TracingQueryRunner (com.palantir.atlasdb.keyvalue.cassandra.TracingQueryRunner)2 Test (org.junit.Test)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableCassandraKeyValueServiceConfig (com.palantir.atlasdb.cassandra.ImmutableCassandraKeyValueServiceConfig)1 CassandraSchemaLockCleaner (com.palantir.atlasdb.keyvalue.cassandra.CassandraSchemaLockCleaner)1 AbstractKeyValueServiceTest (com.palantir.atlasdb.keyvalue.impl.AbstractKeyValueServiceTest)1 Column (org.apache.cassandra.thrift.Column)1 CqlRow (org.apache.cassandra.thrift.CqlRow)1