@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; }
public static TimestampBoundStore create(CassandraKeyValueService kvs, boolean initializeAsync) { CassandraTimestampBoundStore store = new CassandraTimestampBoundStore(kvs.getClientPool(), kvs); store.wrapper.initialize(initializeAsync); return store.wrapper.isInitialized() ? store : store.wrapper; }
@Override public CqlResult execute_cql3_query(CqlQuery cqlQuery, Compression compression, ConsistencyLevel consistency) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException { try (CloseableTrace trace = startLocalTrace("cqlExecutor.execute_cql3_query(query {})", cqlQuery.getLazySafeLoggableObject())) { return client.execute_cql3_query(cqlQuery, compression, consistency); } }
private BoundData getCurrentBoundData(CassandraClient client) { checkTimestampTableExists(); CqlQuery selectQuery = CassandraTimestampUtils.constructSelectFromTimestampTableQuery(); CqlResult existingData = executeQueryUnchecked(client, selectQuery); Map<String, byte[]> columnarResults = CassandraTimestampUtils.getValuesFromSelectionResult(existingData); return ImmutableBoundData.builder() .bound(columnarResults.get(CassandraTimestampUtils.ROW_AND_COLUMN_NAME)) .backupBound(columnarResults.get(CassandraTimestampUtils.BACKUP_COLUMN_NAME)) .build(); }
private void tryInitialize() { createTable(AtlasDbConstants.DEFAULT_METADATA_TABLE, AtlasDbConstants.EMPTY_TABLE_METADATA); lowerConsistencyWhenSafe(); upgradeFromOlderInternalSchema(); CassandraKeyValueServices.warnUserInInitializationIfClusterAlreadyInInconsistentState( clientPool, config); }
public <V> V run(CassandraClient client, Set<TableReference> tableRefs, Action<V> action) throws TException { if (shouldTraceQuery(tableRefs)) { return trace(action, client, tableRefs); } else { try { return action.run(); } catch (TException e) { logFailedCall(tableRefs); throw e; } } }
private void executeAndVerifyCas(CassandraClient client, Map<String, Pair<byte[], byte[]>> casMap) { CqlQuery casQueryBuffer = CassandraTimestampUtils.constructCheckAndSetMultipleQuery(casMap); CqlResult casResult = executeQueryUnchecked(client, casQueryBuffer); CassandraTimestampUtils.verifyCompatible(casResult, casMap); }
private static boolean canCreateCassandraKeyValueService() { return CassandraKeyValueServiceImpl.createForTesting( KVS_CONFIG, LEADER_CONFIG) .isInitialized(); } }
private BoundReadability getReadability(BoundData boundData) { boolean boundReadable = boundData.bound() == null || CassandraTimestampUtils.isValidTimestampData(boundData.bound()); boolean backupBoundReadable = CassandraTimestampUtils.isValidTimestampData(boundData.backupBound()); if (boundReadable) { return backupBoundReadable ? BoundReadability.BOTH : BoundReadability.BOUND; } return backupBoundReadable ? BoundReadability.BACKUP : BoundReadability.NEITHER; }
private void truncateThenDrop(TableReference tableRef, CassandraClient client) throws TException { cassandraTableTruncator.runTruncateOnClient(ImmutableSet.of(tableRef), client); client.system_drop_column_family(CassandraKeyValueServiceImpl.internalTableName(tableRef)); } }
private Map<Cell, Value> get(String kvsMethodName, TableReference tableRef, Set<Cell> cells, long maxTimestampExclusive) { StartTsResultsCollector collector = new StartTsResultsCollector(metricsManager, maxTimestampExclusive); cellLoader.loadWithTs(kvsMethodName, tableRef, cells, maxTimestampExclusive, false, collector, readConsistency); return collector.getCollectedResults(); }
private <T> T executeHandlingExceptions(ThrowingSupplier<T> supplier) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException { checkIfValidClient(); try { return supplier.apply(); } catch (Exception e) { updateIsValid(e); throw e; } }
private void executeHandlingExceptions(ThrowingVoidSupplier supplier) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException { checkIfValidClient(); try { supplier.apply(); } catch (Exception e) { updateIsValid(e); throw e; } }
@Override public CqlResult execute_cql3_query(CqlQuery cqlQuery, Compression compression, ConsistencyLevel consistency) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException { return executeRead( () -> client.execute_cql3_query(cqlQuery, compression, consistency), ThriftQueryWeighers.EXECUTE_CQL3_QUERY); }
Multimap<Cell, Long> getAllTimestamps(TableReference tableRef, Set<Cell> cells, long ts, ConsistencyLevel consistency) { CassandraKeyValueServices.AllTimestampsCollector collector = new CassandraKeyValueServices.AllTimestampsCollector(); loadWithTs("getAllTimestamps", tableRef, cells, ts, true, collector, consistency); return collector.getCollectedResults(); }
private CassandraKeyValueService createKvs(CassandraKeyValueServiceConfig config, Logger testLogger) { // Mutation provider is needed, because deletes/sentinels are to be written after writes return CassandraKeyValueServiceImpl.create( metricsManager, config, CassandraResource.LEADER_CONFIG, CassandraTestTools.getMutationProviderWithStartingTimestamp(STARTING_ATLAS_TIMESTAMP), testLogger); }
@Override public ColumnOrSuperColumn get(TableReference tableReference, ByteBuffer key, byte[] column, ConsistencyLevel consistency_level) throws InvalidRequestException, NotFoundException, UnavailableException, TimedOutException, TException { return executeRead( () -> client.get(tableReference, key, column, consistency_level), ThriftQueryWeighers.GET); }
public static FunctionCheckedException<CassandraClient, Void, Exception> getValidatePartitioner( CassandraKeyValueServiceConfig config) { return client -> { CassandraVerifier.validatePartitioner(client.describe_partitioner(), config); return null; }; }
@Override public void remove(String kvsMethodName, TableReference tableRef, byte[] row, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { try (CloseableTrace trace = startLocalTrace( "client.remove(consistency {}) on kvs.{}", consistency_level, kvsMethodName)) { client.remove(kvsMethodName, tableRef, row, timestamp, consistency_level); } }