static CassandraClient getClientInternal(InetSocketAddress addr, CassandraKeyValueServiceConfig config) throws TException { return new CassandraClientImpl(getRawClient(addr, config)); }
private <T> T executeMethodWithoutException(Supplier<T> supplier) { checkIfValidClient(); try { return supplier.get(); } catch (Exception e) { updateIsValid(e); throw e; } }
@Override public CqlPreparedResult prepare_cql3_query(ByteBuffer query, Compression compression) throws InvalidRequestException, TException { return executeHandlingExceptions(() -> client.prepare_cql3_query(query, compression)); }
@Override public List<KeySlice> get_range_slices(String kvsMethodName, TableReference tableRef, SlicePredicate predicate, KeyRange range, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { ColumnParent colFam = getColumnParent(tableRef); return executeHandlingExceptions(() -> client.get_range_slices(colFam, predicate, range, consistency_level)); }
@Override public TProtocol getInputProtocol() { return executeMethodWithoutException(() -> client.getInputProtocol()); }
@Override public Map<ByteBuffer, List<ColumnOrSuperColumn>> multiget_slice( String kvsMethodName, TableReference tableRef, List<ByteBuffer> keys, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { ColumnParent colFam = getColumnParent(tableRef); return executeHandlingExceptions(() -> client.multiget_slice(keys, colFam, predicate, consistency_level)); }
@Override public TProtocol getOutputProtocol() { return executeMethodWithoutException(() -> client.getOutputProtocol()); }
@Override public String system_add_keyspace(KsDef ks_def) throws InvalidRequestException, SchemaDisagreementException, TException { return executeHandlingExceptions(() -> client.system_add_keyspace(ks_def)); }
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; } }
@Override public Map<ByteBuffer, List<ColumnOrSuperColumn>> multiget_slice( String kvsMethodName, TableReference tableRef, List<ByteBuffer> keys, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { ColumnParent colFam = getColumnParent(tableRef); return executeHandlingExceptions(() -> client.multiget_slice(keys, colFam, predicate, consistency_level)); }
private CassandraClient instrumentClient(Client rawClient) { CassandraClient client = new CassandraClientImpl(rawClient); client = new ProfilingCassandraClient(client); client = new TracingCassandraClient(client); // TODO(ssouza): use the kvsMethodName to tag the timers. client = AtlasDbMetrics.instrument(metricsManager.getRegistry(), CassandraClient.class, client); client = new InstrumentedCassandraClient(client, metricsManager.getTaggedRegistry()); client = QosCassandraClient.instrumentWithMetrics(client, metricsManager); return client; }
@Override public TProtocol getInputProtocol() { return executeMethodWithoutException(() -> client.getInputProtocol()); }
@Override public String system_add_column_family(CfDef cf_def) throws InvalidRequestException, SchemaDisagreementException, TException { return executeHandlingExceptions(() -> client.system_add_column_family(cf_def)); }
private void executeHandlingExceptions(ThrowingVoidSupplier supplier) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException { checkIfValidClient(); try { supplier.apply(); } catch (Exception e) { updateIsValid(e); throw e; } }
@Override public List<KeySlice> get_range_slices(String kvsMethodName, TableReference tableRef, SlicePredicate predicate, KeyRange range, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { ColumnParent colFam = getColumnParent(tableRef); return executeHandlingExceptions(() -> client.get_range_slices(colFam, predicate, range, consistency_level)); }
static CassandraClient getClientInternal(InetSocketAddress addr, CassandraKeyValueServiceConfig config) throws TException { return new CassandraClientImpl(getRawClient(addr, config)); }
@Override public TProtocol getOutputProtocol() { return executeMethodWithoutException(() -> client.getOutputProtocol()); }
@Override public String system_update_keyspace(KsDef ks_def) throws InvalidRequestException, SchemaDisagreementException, TException { return executeHandlingExceptions(() -> client.system_update_keyspace(ks_def)); }
private <T> T executeMethodWithoutException(Supplier<T> supplier) { checkIfValidClient(); try { return supplier.get(); } catch (Exception e) { updateIsValid(e); throw e; } }
private CassandraClient instrumentClient(Client rawClient) { CassandraClient client = new CassandraClientImpl(rawClient); client = new ProfilingCassandraClient(client); client = new TracingCassandraClient(client); // TODO(ssouza): use the kvsMethodName to tag the timers. client = AtlasDbMetrics.instrument(metricsManager.getRegistry(), CassandraClient.class, client); client = new InstrumentedCassandraClient(client, metricsManager.getTaggedRegistry()); client = QosCassandraClient.instrumentWithMetrics(client, metricsManager); return client; }