@Override public CqlResult apply(CassandraClient client) throws TException { return client.execute_cql3_query(cqlQuery, Compression.NONE, consistency); }
private void createTable(TableReference tableRef, byte[] metadata, CassandraClient client) throws TException { CqlQuery query = constructQuery(tableRef, metadata); client.execute_cql3_query(query, Compression.NONE, CassandraKeyValueServiceImpl.WRITE_CONSISTENCY); }
@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); }
private CqlResult executeCqlQuery() throws TException { return profilingClient.execute_cql3_query(CQL_QUERY, Compression.NONE, ConsistencyLevel.QUORUM); }
private void verifyCqlQueryWasExecuted() throws TException { verify(delegate).execute_cql3_query(CQL_QUERY, Compression.NONE, ConsistencyLevel.QUORUM); } }
@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 void setDelegateResponseToCqlQuery(CqlResult result) throws TException { when(delegate.execute_cql3_query(CQL_QUERY, Compression.NONE, ConsistencyLevel.QUORUM)).thenReturn(result); }
@Test public void executeCqlQueryRecordsMetricsOnFailure() throws TException, LimitExceededException { when(mockClient.execute_cql3_query(any(), any(), any())).thenThrow(new RuntimeException()); QueryWeight expectedWeight = ThriftQueryWeighers.EXECUTE_CQL3_QUERY .weighFailure(new RuntimeException(), NANOS_DURATION); assertThatThrownBy(() -> client.execute_cql3_query(CQL_QUERY, Compression.NONE, ConsistencyLevel.ANY)) .isInstanceOf(RuntimeException.class); verify(mockClient, times(1)).execute_cql3_query(CQL_QUERY, Compression.NONE, ConsistencyLevel.ANY); verifyNoMoreInteractions(mockClient); verify(mockMetrics, times(1)).recordRead(expectedWeight); verifyNoMoreInteractions(mockMetrics); }
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); } }
@Test public void executeCqlQueryRecordsMetricsOnSuccess() throws TException, LimitExceededException { CqlResult emptyResult = new CqlResult(); when(mockClient.execute_cql3_query(any(), any(), any())).thenReturn(emptyResult); QueryWeight expectedWeight = ThriftQueryWeighers.EXECUTE_CQL3_QUERY.weighSuccess(emptyResult, NANOS_DURATION); client.execute_cql3_query(CQL_QUERY, Compression.NONE, ConsistencyLevel.ANY); verify(mockClient, times(1)).execute_cql3_query(CQL_QUERY, Compression.NONE, ConsistencyLevel.ANY); verifyNoMoreInteractions(mockClient); verify(mockMetrics, times(1)).recordRead(expectedWeight); verifyNoMoreInteractions(mockMetrics); }
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); } } }
@Override public CqlResult execute_cql3_query(CqlQuery cqlQuery, Compression compression, ConsistencyLevel consistency) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException { long startTime = System.currentTimeMillis(); return KvsProfilingLogger.maybeLog( (KvsProfilingLogger.CallableCheckedException<CqlResult, TException>) () -> client.execute_cql3_query(cqlQuery, compression, consistency), (logger, timer) -> cqlQuery.logSlowResult(logger, timer), (logger, cqlResult) -> { if (cqlResult.getRows() == null) { // different from an empty list logger.log("and returned null rows. The query was started at time {}", LoggingArgs.startTimeMillis(startTime)); } else { logger.log("and returned {} rows. The query was started at time {}", SafeArg.of("numRows", cqlResult.getRows().size()), LoggingArgs.startTimeMillis(startTime)); } }); } }
@Override public CqlResult apply(CassandraClient client) throws TException { return client.execute_cql3_query(cqlQuery, Compression.NONE, consistency); }
private void createTable(TableReference tableRef, byte[] metadata, CassandraClient client) throws TException { CqlQuery query = constructQuery(tableRef, metadata); client.execute_cql3_query(query, Compression.NONE, CassandraKeyValueServiceImpl.WRITE_CONSISTENCY); }
@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); }
@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 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); } }
private void putDummyValueAtCellAndTimestamp( TableReference tableReference, Cell cell, long atlasTimestamp, long cassandraTimestamp) throws TException { CassandraKeyValueServiceImpl ckvs = (CassandraKeyValueServiceImpl) keyValueService; ckvs.getClientPool().runWithRetry(input -> { CqlQuery cqlQuery = CqlQuery.builder() .safeQueryFormat("INSERT INTO \"%s\".\"%s\" (key, column1, column2, value)" + " VALUES (%s, %s, %s, %s) USING TIMESTAMP %s;") .addArgs( SafeArg.of("keyspace", CASSANDRA.getConfig().getKeyspaceOrThrow()), LoggingArgs.internalTableName(tableReference), UnsafeArg.of("row", convertBytesToHexString(cell.getRowName())), UnsafeArg.of("column", convertBytesToHexString(cell.getColumnName())), SafeArg.of("atlasTimestamp", ~atlasTimestamp), UnsafeArg.of("value", convertBytesToHexString(PtBytes.toBytes("testtesttest"))), SafeArg.of("cassandraTimestamp", cassandraTimestamp)) .build(); return input.execute_cql3_query( cqlQuery, Compression.NONE, ConsistencyLevel.QUORUM); }); }
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); } } }
@Override public CqlResult execute_cql3_query(CqlQuery cqlQuery, Compression compression, ConsistencyLevel consistency) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException { long startTime = System.currentTimeMillis(); return KvsProfilingLogger.maybeLog( (KvsProfilingLogger.CallableCheckedException<CqlResult, TException>) () -> client.execute_cql3_query(cqlQuery, compression, consistency), (logger, timer) -> cqlQuery.logSlowResult(logger, timer), (logger, cqlResult) -> { if (cqlResult.getRows() == null) { // different from an empty list logger.log("and returned null rows. The query was started at time {}", LoggingArgs.startTimeMillis(startTime)); } else { logger.log("and returned {} rows. The query was started at time {}", SafeArg.of("numRows", cqlResult.getRows().size()), LoggingArgs.startTimeMillis(startTime)); } }); } }