public <T> ExecutionResult<T> doExecuteOperation(Operation<T> operation) throws HectorException { operation.applyConnectionParams(keyspace, consistencyLevelPolicy, failoverPolicy, credentials); connectionManager.operateWithFailover(operation); return operation.getExecutionResult(); }
@Override public void executeAndSetResult(Client cassandra, CassandraHost cassandraHost) throws Exception { operation.executeAndSetResult(new VirtualKeyspaceCassandraClient(cassandra, prefixBytes), cassandraHost); }
@Override public SuperColumn getSuperColumn(final ByteBuffer key, final ColumnPath columnPath) throws HectorException { Operation<SuperColumn> op = new Operation<SuperColumn>(OperationType.READ, failoverPolicy, keyspaceName, credentials) { @Override public SuperColumn execute(Cassandra.Client cassandra) throws HectorException { ColumnOrSuperColumn cosc; try { cosc = cassandra.get(key, columnPath, getThriftCl(OperationType.READ)); } catch (NotFoundException e) { setException(xtrans.translate(e)); return null; } catch (Exception e) { throw xtrans.translate(e); } return cosc == null ? null : cosc.getSuper_column(); } }; operateWithFailover(op); if (op.hasException()) { throw op.getException(); } return op.getResult(); }
@Override public T getResult() { return operation.getResult(); }
@Override public CassandraHost getCassandraHost() { return operation.getCassandraHost(); }
@Override public void applyConnectionParams(String keyspace, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy, Map<String, String> credentials) { operation.applyConnectionParams(keyspace, consistencyLevelPolicy, failoverPolicy, credentials); }
@Override public T execute(Client cassandra) throws Exception { return operation.execute(new VirtualKeyspaceCassandraClient(cassandra, prefixBytes)); }
@Override public void setResult(T executionResult) { operation.setResult(executionResult); }
@Override public void setException(HectorException e) { operation.setException(e); }
@Override public boolean hasException() { return operation.hasException(); }
@Override public ExecutionResult<T> getExecutionResult() { return operation.getExecutionResult(); }
@Override public HectorException getException() { return operation.getException(); }
@Override public CounterColumn getCounter(final ByteBuffer key, final ColumnPath columnPath) throws HectorException { Operation<CounterColumn> op = new Operation<CounterColumn>(OperationType.READ, failoverPolicy, keyspaceName, credentials) { @Override public CounterColumn execute(Cassandra.Client cassandra) throws HectorException { ColumnOrSuperColumn cosc; try { cosc = cassandra.get(key, columnPath, getThriftCl(OperationType.READ)); } catch (NotFoundException e) { setException(xtrans.translate(e)); return null; } catch (Exception e) { throw xtrans.translate(e); } return cosc.getCounter_column(); } }; operateWithFailover(op); if (op.hasException()) { throw op.getException(); } return op.getResult(); }
@Override public int getCount(final ByteBuffer key, final ColumnParent columnParent, final SlicePredicate predicate) throws HectorException { Operation<Integer> op = new Operation<Integer>(OperationType.READ, failoverPolicy, keyspaceName, credentials) { @Override public Integer execute(Cassandra.Client cassandra) throws HectorException { try { return cassandra.get_count(key, columnParent, predicate, getThriftCl(OperationType.READ)); } catch (Exception e) { throw xtrans.translate(e); } } }; operateWithFailover(op); return op.getResult(); }
private void operateWithFailover(Operation<?> op) throws HectorException { connectionManager.operateWithFailover(op); this.cassandraHost = op.getCassandraHost(); }
@Override public void applyConnectionParams(String keyspace, ConsistencyLevelPolicy consistencyLevelPolicy, FailoverPolicy failoverPolicy, Map<String, String> credentials) { operation.applyConnectionParams(keyspace, consistencyLevelPolicy, failoverPolicy, credentials); }
@Override public T execute(Client cassandra) throws Exception { return operation.execute(new VirtualKeyspaceCassandraClient(cassandra, prefixBytes)); }
@Override public void setResult(T executionResult) { operation.setResult(executionResult); }
@Override public void setException(HectorException e) { operation.setException(e); }