@Override public Void internalExecute(Client client, ConnectionContext context) throws Exception { operation.execute(null, context); return null; } }, retry);
@Override public String getKeyspace() { return next.getKeyspace(); }
@Override public Host getPinnedHost() { return next.getPinnedHost(); }
"] on keyspace [" + op.getKeyspace() + "] on pinned host[" + op.getPinnedHost() + "]");
if (op.getKeyspace() != null && (keyspaceName == null || !op.getKeyspace().equals(keyspaceName))) { CassandraOperationTracer tracer = tracerFactory.newTracer(CassandraOperationType.SET_KEYSPACE) .start(); try { cassandraClient.set_keyspace(op.getKeyspace()); if (asConfig.getCqlVersion() != null) cassandraClient.set_cql_version(asConfig.getCqlVersion()); keyspaceName = op.getKeyspace(); long now = System.nanoTime(); latency = now - startTime; R result = op.execute(cassandraClient, this); long now = System.nanoTime(); latency = now - startTime;
boolean isSorted = false; if (op.getPinnedHost() != null) { HostConnectionPool<CL> pool = hosts.get(op.getPinnedHost()); if (pool == null) { throw new NoAvailableHostsException("Host " + op.getPinnedHost() + " not active"); TokenHostConnectionPoolPartition<CL> partition = topology.getPartition(op.getRowKey()); pools = partition.getPools(); isSorted = partition.isSorted();
@Override public ByteBuffer getRowKey() { return next.getRowKey(); }
"] on keyspace [" + op.getKeyspace() + "] on pinned host[" + op.getPinnedHost() + "]");
if (op.getKeyspace() != null && (keyspaceName == null || !op.getKeyspace().equals(keyspaceName))) { CassandraOperationTracer tracer = tracerFactory.newTracer(CassandraOperationType.SET_KEYSPACE) .start(); try { cassandraClient.set_keyspace(op.getKeyspace()); if (asConfig.getCqlVersion() != null) cassandraClient.set_cql_version(asConfig.getCqlVersion()); keyspaceName = op.getKeyspace(); long now = System.nanoTime(); latency = now - startTime; R result = op.execute(cassandraClient, this); long now = System.nanoTime(); latency = now - startTime;
boolean isSorted = false; if (op.getPinnedHost() != null) { HostConnectionPool<CL> pool = hosts.get(op.getPinnedHost()); if (pool == null) { throw new NoAvailableHostsException("Host " + op.getPinnedHost() + " not active"); TokenHostConnectionPoolPartition<CL> partition = topology.getPartition(op.getRowKey()); pools = partition.getPools(); isSorted = partition.isSorted();
@Override public ByteBuffer getRowKey() { return next.getRowKey(); }
@Override public Void internalExecute(Client client, ConnectionContext context) throws Exception { operation.execute(null, context); return null; } }, retry);
@Override public Host getPinnedHost() { return next.getPinnedHost(); }
@Override public String getKeyspace() { return next.getKeyspace(); }
@Override public R execute(CL client, ConnectionContext state) throws ConnectionException { return next.execute(client, state); }
@SuppressWarnings("unchecked") public <R> ExecuteWithFailover<CL, R> newExecuteWithFailover(Operation<CL, R> operation) throws ConnectionException { try { if (operation.getPinnedHost() != null) { HostConnectionPool<CL> pool = hosts.get(operation.getPinnedHost()); if (pool == null) { throw new NoAvailableHostsException("Host " + operation.getPinnedHost() + " not active"); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, Arrays.<HostConnectionPool<CL>> asList(pool), 0); } int index = roundRobinCounter.incrementAndGet(); if (index > MAX_RR_COUNTER) { roundRobinCounter.set(0); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, topology.getAllPools().getPools(), index); } catch (ConnectionException e) { monitor.incOperationFailure(e.getHost(), e); throw e; } } }
@Override public R execute(CL client, ConnectionContext state) throws ConnectionException { return next.execute(client, state); }
@SuppressWarnings("unchecked") public <R> ExecuteWithFailover<CL, R> newExecuteWithFailover(Operation<CL, R> operation) throws ConnectionException { try { if (operation.getPinnedHost() != null) { HostConnectionPool<CL> pool = hosts.get(operation.getPinnedHost()); if (pool == null) { throw new NoAvailableHostsException("Host " + operation.getPinnedHost() + " not active"); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, Arrays.<HostConnectionPool<CL>> asList(pool), 0); } int index = roundRobinCounter.incrementAndGet(); if (index > MAX_RR_COUNTER) { roundRobinCounter.set(0); } return new RoundRobinExecuteWithFailover<CL, R>(config, monitor, topology.getAllPools().getPools(), index); } catch (ConnectionException e) { monitor.incOperationFailure(e.getHost(), e); throw e; } } }
@Override public <R> OperationResult<R> execute( HostConnectionPool<TestClient> pool, Operation<TestClient, R> op) throws ConnectionException { if (counter.incrementAndGet() > new Random().nextInt(1000)) { counter.set(0); throw new TransportException("TransportException"); } return new OperationResultImpl<R>(pool.getHost(), op.execute(null, null), 0); }
@Override public OperationResult<Void> testOperation(final Operation<?, ?> operation, RetryPolicy retry) throws ConnectionException { return executeOperation( new AbstractKeyspaceOperationImpl<Void>(tracerFactory.newTracer(CassandraOperationType.TEST), operation.getPinnedHost(), getKeyspaceName()) { @Override public Void internalExecute(Client client, ConnectionContext context) throws Exception { operation.execute(null, context); return null; } }, retry); }