Search in sources :

Example 6 with InsufficientConsistencyException

use of com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException in project atlasdb by palantir.

the class CqlKeyValueService method dropTables.

@Override
public void dropTables(final Set<TableReference> tablesToDrop) {
    // full table name (ks.cf)
    String dropQuery = "DROP TABLE IF EXISTS %s";
    for (TableReference tableRef : tablesToDrop) {
        BoundStatement dropStatement = getPreparedStatement(tableRef, String.format(dropQuery, getFullTableName(tableRef)), longRunningQuerySession).setConsistencyLevel(ConsistencyLevel.ALL).bind();
        try {
            ResultSet resultSet = longRunningQuerySession.execute(dropStatement);
            cqlKeyValueServices.logTracedQuery(dropQuery, resultSet, session, cqlStatementCache.normalQuery);
        } catch (com.datastax.driver.core.exceptions.UnavailableException e) {
            throw new InsufficientConsistencyException("Dropping tables requires all Cassandra" + " nodes to be up and available.", e);
        }
    }
    CqlKeyValueServices.waitForSchemaVersionsToCoalesce("dropTables(" + tablesToDrop.size() + " tables)", this);
    put(AtlasDbConstants.DEFAULT_METADATA_TABLE, Maps.toMap(Lists.transform(Lists.newArrayList(tablesToDrop), CqlKeyValueServices::getMetadataCell), Functions.constant(PtBytes.EMPTY_BYTE_ARRAY)), System.currentTimeMillis());
}
Also used : InsufficientConsistencyException(com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) UnavailableException(com.datastax.driver.core.exceptions.UnavailableException) ResultSet(com.datastax.driver.core.ResultSet) BoundStatement(com.datastax.driver.core.BoundStatement)

Example 7 with InsufficientConsistencyException

use of com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException in project atlasdb by palantir.

the class CqlKeyValueService method truncateTables.

@Override
public void truncateTables(final Set<TableReference> tablesToTruncate) {
    // full table name (ks.cf)
    String truncateQuery = "TRUNCATE %s";
    for (TableReference tableRef : tablesToTruncate) {
        BoundStatement truncateStatement = getPreparedStatement(tableRef, String.format(truncateQuery, getFullTableName(tableRef)), longRunningQuerySession).setConsistencyLevel(ConsistencyLevel.ALL).bind();
        try {
            ResultSet resultSet = longRunningQuerySession.execute(truncateStatement);
            cqlKeyValueServices.logTracedQuery(truncateQuery, resultSet, session, cqlStatementCache.normalQuery);
        } catch (com.datastax.driver.core.exceptions.UnavailableException e) {
            throw new InsufficientConsistencyException("Truncating tables requires all Cassandra" + " nodes to be up and available.", e);
        }
    }
    CqlKeyValueServices.waitForSchemaVersionsToCoalesce("truncateTables(" + tablesToTruncate.size() + " tables)", this);
}
Also used : InsufficientConsistencyException(com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) UnavailableException(com.datastax.driver.core.exceptions.UnavailableException) ResultSet(com.datastax.driver.core.ResultSet) BoundStatement(com.datastax.driver.core.BoundStatement)

Aggregations

InsufficientConsistencyException (com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException)7 BoundStatement (com.datastax.driver.core.BoundStatement)5 ResultSet (com.datastax.driver.core.ResultSet)5 UnavailableException (com.datastax.driver.core.exceptions.UnavailableException)5 TableReference (com.palantir.atlasdb.keyvalue.api.TableReference)5 Row (com.datastax.driver.core.Row)2 InvalidQueryException (com.datastax.driver.core.exceptions.InvalidQueryException)2 NoHostAvailableException (com.datastax.driver.core.exceptions.NoHostAvailableException)2 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)2 Column (org.apache.cassandra.thrift.Column)2 ColumnOrSuperColumn (org.apache.cassandra.thrift.ColumnOrSuperColumn)2 UnavailableException (org.apache.cassandra.thrift.UnavailableException)2 BatchStatement (com.datastax.driver.core.BatchStatement)1 Cluster (com.datastax.driver.core.Cluster)1 ConsistencyLevel (com.datastax.driver.core.ConsistencyLevel)1 Host (com.datastax.driver.core.Host)1 HostDistance (com.datastax.driver.core.HostDistance)1 Metadata (com.datastax.driver.core.Metadata)1 PoolingOptions (com.datastax.driver.core.PoolingOptions)1 PreparedStatement (com.datastax.driver.core.PreparedStatement)1