use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class DefaultDriverContext method buildRequestTracker.
protected RequestTracker buildRequestTracker(RequestTracker requestTrackerFromBuilder) {
List<RequestTracker> trackers = new ArrayList<>();
if (requestTrackerFromBuilder != null) {
trackers.add(requestTrackerFromBuilder);
}
for (LoadBalancingPolicy lbp : this.getLoadBalancingPolicies().values()) {
lbp.getRequestTracker().ifPresent(trackers::add);
}
DefaultDriverOption newOption = DefaultDriverOption.REQUEST_TRACKER_CLASSES;
@SuppressWarnings("deprecation") DefaultDriverOption legacyOption = DefaultDriverOption.REQUEST_TRACKER_CLASS;
DriverExecutionProfile profile = config.getDefaultProfile();
if (profile.isDefined(newOption)) {
trackers.addAll(Reflection.buildFromConfigList(this, newOption, RequestTracker.class, "com.datastax.oss.driver.internal.core.tracker"));
}
if (profile.isDefined(legacyOption)) {
LOG.warn("Option {} has been deprecated and will be removed in a future release; please use option {} instead.", legacyOption, newOption);
Reflection.buildFromConfig(this, legacyOption, RequestTracker.class, "com.datastax.oss.driver.internal.core.tracker").ifPresent(trackers::add);
}
if (trackers.isEmpty()) {
return new NoopRequestTracker(this);
} else if (trackers.size() == 1) {
return trackers.get(0);
} else {
return new MultiplexingRequestTracker(trackers);
}
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class Conversions method resolveIdempotence.
public static boolean resolveIdempotence(Request request, InternalDriverContext context) {
Boolean requestIsIdempotent = request.isIdempotent();
DriverExecutionProfile executionProfile = resolveExecutionProfile(request, context);
return (requestIsIdempotent == null) ? executionProfile.getBoolean(DefaultDriverOption.REQUEST_DEFAULT_IDEMPOTENCE) : requestIsIdempotent;
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class CqlRequestHandler method onThrottleReady.
@Override
public void onThrottleReady(boolean wasDelayed) {
DriverExecutionProfile executionProfile = Conversions.resolveExecutionProfile(initialStatement, context);
if (wasDelayed && // avoid call to nanoTime() if metric is disabled:
sessionMetricUpdater.isEnabled(DefaultSessionMetric.THROTTLING_DELAY, executionProfile.getName())) {
sessionMetricUpdater.updateTimer(DefaultSessionMetric.THROTTLING_DELAY, executionProfile.getName(), System.nanoTime() - startTimeNanos, TimeUnit.NANOSECONDS);
}
Queue<Node> queryPlan = this.initialStatement.getNode() != null ? new SimpleQueryPlan(this.initialStatement.getNode()) : context.getLoadBalancingPolicyWrapper().newQueryPlan(initialStatement, executionProfile.getName(), session);
sendRequest(initialStatement, null, queryPlan, 0, 0, true);
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class CqlRequestHandler method onThrottleFailure.
@Override
public void onThrottleFailure(@NonNull RequestThrottlingException error) {
DriverExecutionProfile executionProfile = Conversions.resolveExecutionProfile(initialStatement, context);
sessionMetricUpdater.incrementCounter(DefaultSessionMetric.THROTTLING_ERRORS, executionProfile.getName());
setFinalError(initialStatement, error, null, -1);
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class CqlRequestHandler method sendRequest.
/**
* Sends the request to the next available node.
*
* @param statement The statement to execute.
* @param retriedNode if not null, it will be attempted first before the rest of the query plan.
* @param queryPlan the list of nodes to try (shared with all other executions)
* @param currentExecutionIndex 0 for the initial execution, 1 for the first speculative one, etc.
* @param retryCount the number of times that the retry policy was invoked for this execution
* already (note that some internal retries don't go through the policy, and therefore don't
* increment this counter)
* @param scheduleNextExecution whether to schedule the next speculative execution
*/
private void sendRequest(Statement<?> statement, Node retriedNode, Queue<Node> queryPlan, int currentExecutionIndex, int retryCount, boolean scheduleNextExecution) {
if (result.isDone()) {
return;
}
Node node = retriedNode;
DriverChannel channel = null;
if (node == null || (channel = session.getChannel(node, logPrefix)) == null) {
while (!result.isDone() && (node = queryPlan.poll()) != null) {
channel = session.getChannel(node, logPrefix);
if (channel != null) {
break;
} else {
recordError(node, new NodeUnavailableException(node));
}
}
}
if (channel == null) {
// We've reached the end of the query plan without finding any node to write to
if (!result.isDone() && activeExecutionsCount.decrementAndGet() == 0) {
// We're the last execution so fail the result
setFinalError(statement, AllNodesFailedException.fromErrors(this.errors), null, -1);
}
} else {
NodeResponseCallback nodeResponseCallback = new NodeResponseCallback(statement, node, queryPlan, channel, currentExecutionIndex, retryCount, scheduleNextExecution, logPrefix);
DriverExecutionProfile executionProfile = Conversions.resolveExecutionProfile(statement, context);
Message message = Conversions.toMessage(statement, executionProfile, context);
channel.write(message, statement.isTracing(), statement.getCustomPayload(), nodeResponseCallback).addListener(nodeResponseCallback);
}
}
Aggregations