Search in sources :

Example 6 with NoopRequestTracker

use of com.datastax.oss.driver.internal.core.tracker.NoopRequestTracker in project java-driver by datastax.

the class CqlRequestHandler method setFinalResult.

private void setFinalResult(Result resultMessage, Frame responseFrame, boolean schemaInAgreement, NodeResponseCallback callback) {
    try {
        ExecutionInfo executionInfo = buildExecutionInfo(callback, resultMessage, responseFrame, schemaInAgreement);
        AsyncResultSet resultSet = Conversions.toResultSet(resultMessage, executionInfo, session, context);
        if (result.complete(resultSet)) {
            cancelScheduledTasks();
            throttler.signalSuccess(this);
            // Only call nanoTime() if we're actually going to use it
            long completionTimeNanos = NANOTIME_NOT_MEASURED_YET, totalLatencyNanos = NANOTIME_NOT_MEASURED_YET;
            if (!(requestTracker instanceof NoopRequestTracker)) {
                completionTimeNanos = System.nanoTime();
                totalLatencyNanos = completionTimeNanos - startTimeNanos;
                long nodeLatencyNanos = completionTimeNanos - callback.nodeStartTimeNanos;
                requestTracker.onNodeSuccess(callback.statement, nodeLatencyNanos, callback.executionProfile, callback.node, logPrefix);
                requestTracker.onSuccess(callback.statement, totalLatencyNanos, callback.executionProfile, callback.node, logPrefix);
            }
            if (sessionMetricUpdater.isEnabled(DefaultSessionMetric.CQL_REQUESTS, callback.executionProfile.getName())) {
                if (completionTimeNanos == NANOTIME_NOT_MEASURED_YET) {
                    completionTimeNanos = System.nanoTime();
                    totalLatencyNanos = completionTimeNanos - startTimeNanos;
                }
                sessionMetricUpdater.updateTimer(DefaultSessionMetric.CQL_REQUESTS, callback.executionProfile.getName(), totalLatencyNanos, TimeUnit.NANOSECONDS);
            }
        }
        // log the warnings if they have NOT been disabled
        if (!executionInfo.getWarnings().isEmpty() && callback.executionProfile.getBoolean(DefaultDriverOption.REQUEST_LOG_WARNINGS) && LOG.isWarnEnabled()) {
            logServerWarnings(callback.statement, callback.executionProfile, executionInfo.getWarnings());
        }
    } catch (Throwable error) {
        setFinalError(callback.statement, error, callback.node, -1);
    }
}
Also used : AsyncResultSet(com.datastax.oss.driver.api.core.cql.AsyncResultSet) NoopRequestTracker(com.datastax.oss.driver.internal.core.tracker.NoopRequestTracker) ExecutionInfo(com.datastax.oss.driver.api.core.cql.ExecutionInfo)

Aggregations

NoopRequestTracker (com.datastax.oss.driver.internal.core.tracker.NoopRequestTracker)6 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)4 DriverException (com.datastax.oss.driver.api.core.DriverException)2 DriverTimeoutException (com.datastax.oss.driver.api.core.DriverTimeoutException)2 RequestThrottlingException (com.datastax.oss.driver.api.core.RequestThrottlingException)2 AsyncResultSet (com.datastax.oss.driver.api.core.cql.AsyncResultSet)2 ExecutionInfo (com.datastax.oss.driver.api.core.cql.ExecutionInfo)2 RequestTracker (com.datastax.oss.driver.api.core.tracker.RequestTracker)2 DefaultExecutionInfo (com.datastax.oss.driver.internal.core.cql.DefaultExecutionInfo)2 GraphNode (com.datastax.dse.driver.api.core.graph.GraphNode)1 DefaultDriverOption (com.datastax.oss.driver.api.core.config.DefaultDriverOption)1 LoadBalancingPolicy (com.datastax.oss.driver.api.core.loadbalancing.LoadBalancingPolicy)1 MultiplexingRequestTracker (com.datastax.oss.driver.internal.core.tracker.MultiplexingRequestTracker)1 Error (com.datastax.oss.protocol.internal.response.Error)1 Rows (com.datastax.oss.protocol.internal.response.result.Rows)1 ByteBuffer (java.nio.ByteBuffer)1 ArrayDeque (java.util.ArrayDeque)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1