public <V> V run(CassandraClient client, TableReference tableRef, Action<V> action) throws TException { return run(client, ImmutableSet.of(tableRef), action); }
@Override public Void apply(CassandraClient client) throws TException { for (TableReference tableRef : tablesToTruncate) { queryRunner.run(client, tableRef, () -> { client.truncate(CassandraKeyValueServiceImpl.internalTableName(tableRef)); return true; }); } return null; }
Map<ByteBuffer, List<ColumnOrSuperColumn>> multiget( String kvsMethodName, CassandraClient client, TableReference tableRef, List<ByteBuffer> rowNames, SlicePredicate pred, ConsistencyLevel consistency) throws TException { try { return queryRunner.run(client, tableRef, () -> client.multiget_slice(kvsMethodName, tableRef, rowNames, pred, consistency)); } catch (UnavailableException e) { throw new InsufficientConsistencyException( "This get operation requires " + consistency + " Cassandra nodes to be up and available.", e); } } }
private CqlResult executeQueryUnchecked(CassandraClient client, CqlQuery query) { try { return queryRunner().run(client, AtlasDbConstants.TIMESTAMP_TABLE, () -> client.execute_cql3_query(query, Compression.NONE, ConsistencyLevel.QUORUM)); } catch (TException e) { throw Throwables.rewrapAndThrowUncheckedException(e); } }
Void batchMutate(String kvsMethodName, CassandraClient client, Set<TableReference> tableRefs, MutationMap map, ConsistencyLevel consistency) throws TException { try { return queryRunner.run(client, tableRefs, () -> { client.batch_mutate(kvsMethodName, map.toMap(), consistency); return null; }); } catch (UnavailableException e) { throw new InsufficientConsistencyException( "This batch mutate operation requires " + consistency + " Cassandra nodes to be up and available.", e); } }
@Override public List<KeySlice> apply(CassandraClient client) { try { return queryRunner.run(client, tableRef, () -> client.get_range_slices(kvsMethodName, tableRef, slicePredicate, keyRange, consistency)); } catch (UnavailableException e) { throw new InsufficientConsistencyException("get_range_slices requires " + consistency + " Cassandra nodes to be up and available.", e); } catch (Exception e) { throw Throwables.unwrapAndThrowAtlasDbDependencyException(e); } }
public CheckAndSetResult<ByteString> executeCheckAndSet(CassandraClient client, CheckAndSetRequest request) throws TException { try { TableReference table = request.table(); CqlResult result = queryRunner.run( client, table, () -> client.execute_cql3_query( CheckAndSetQueries.getQueryForRequest(request), Compression.NONE, writeConsistency)); return CheckAndSetResponseDecoder.decodeCqlResult(result); } catch (UnavailableException e) { throw new InsufficientConsistencyException( "Check-and-set requires " + writeConsistency + " Cassandra nodes to be up and available.", e); } } }
public <V> V run(CassandraClient client, TableReference tableRef, Action<V> action) throws TException { return run(client, ImmutableSet.of(tableRef), action); }
@Override public Void apply(CassandraClient client) throws TException { for (TableReference tableRef : tablesToTruncate) { queryRunner.run(client, tableRef, () -> { client.truncate(CassandraKeyValueServiceImpl.internalTableName(tableRef)); return true; }); } return null; }
Map<ByteBuffer, List<ColumnOrSuperColumn>> multiget( String kvsMethodName, CassandraClient client, TableReference tableRef, List<ByteBuffer> rowNames, SlicePredicate pred, ConsistencyLevel consistency) throws TException { try { return queryRunner.run(client, tableRef, () -> client.multiget_slice(kvsMethodName, tableRef, rowNames, pred, consistency)); } catch (UnavailableException e) { throw new InsufficientConsistencyException( "This get operation requires " + consistency + " Cassandra nodes to be up and available.", e); } } }
private CqlResult executeQueryUnchecked(CassandraClient client, CqlQuery query) { try { return queryRunner().run(client, AtlasDbConstants.TIMESTAMP_TABLE, () -> client.execute_cql3_query(query, Compression.NONE, ConsistencyLevel.QUORUM)); } catch (TException e) { throw Throwables.rewrapAndThrowUncheckedException(e); } }
@Override public List<KeySlice> apply(CassandraClient client) { try { return queryRunner.run(client, tableRef, () -> client.get_range_slices(kvsMethodName, tableRef, slicePredicate, keyRange, consistency)); } catch (UnavailableException e) { throw new InsufficientConsistencyException("get_range_slices requires " + consistency + " Cassandra nodes to be up and available.", e); } catch (Exception e) { throw Throwables.unwrapAndThrowAtlasDbDependencyException(e); } }
Void batchMutate(String kvsMethodName, CassandraClient client, Set<TableReference> tableRefs, MutationMap map, ConsistencyLevel consistency) throws TException { try { return queryRunner.run(client, tableRefs, () -> { client.batch_mutate(kvsMethodName, map.toMap(), consistency); return null; }); } catch (UnavailableException e) { throw new InsufficientConsistencyException( "This batch mutate operation requires " + consistency + " Cassandra nodes to be up and available.", e); } }
public CheckAndSetResult<ByteString> executeCheckAndSet(CassandraClient client, CheckAndSetRequest request) throws TException { try { TableReference table = request.table(); CqlResult result = queryRunner.run( client, table, () -> client.execute_cql3_query( CheckAndSetQueries.getQueryForRequest(request), Compression.NONE, writeConsistency)); return CheckAndSetResponseDecoder.decodeCqlResult(result); } catch (UnavailableException e) { throw new InsufficientConsistencyException( "Check-and-set requires " + writeConsistency + " Cassandra nodes to be up and available.", e); } } }