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());
}
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);
}
Aggregations