operationCounter.incrementAndGet();
// Set a new keyspace, if it changed
lastException = null;
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;
pool.addLatencySample(latency, now);
tracer.success();
}
catch (Exception e) {
long now = System.nanoTime();
latency = now - startTime;
lastException = ThriftConverter.ToConnectionPoolException(e).setLatency(latency);
if (e instanceof IsTimeoutException) {
pool.addLatencySample(TimeUnit.NANOSECONDS.convert(cpConfig.getSocketTimeout(), TimeUnit.MILLISECONDS), now);
}
tracer.failure(lastException);
throw lastException;
}
startTime = System.nanoTime(); // We don't want to include
// the set_keyspace in our
// latency calculation