use of com.datastax.oss.driver.api.core.NodeUnavailableException in project java-driver by datastax.
the class CqlPrepareHandler method sendRequest.
private void sendRequest(PrepareRequest request, Node node, int retryCount) {
if (result.isDone()) {
return;
}
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) {
setFinalError(AllNodesFailedException.fromErrors(this.errors));
} else {
InitialPrepareCallback initialPrepareCallback = new InitialPrepareCallback(request, node, channel, retryCount);
Prepare message = toPrepareMessage(request);
channel.write(message, false, request.getCustomPayload(), initialPrepareCallback).addListener(initialPrepareCallback);
}
}
use of com.datastax.oss.driver.api.core.NodeUnavailableException 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);
}
}
use of com.datastax.oss.driver.api.core.NodeUnavailableException in project java-driver by datastax.
the class GraphRequestHandler method sendRequest.
/**
* Sends the request to the next available node.
*
* @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(GraphStatement<?> 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, NO_SUCCESSFUL_EXECUTION);
}
} else {
NodeResponseCallback nodeResponseCallback = new NodeResponseCallback(statement, node, queryPlan, channel, currentExecutionIndex, retryCount, scheduleNextExecution, logPrefix);
DriverExecutionProfile executionProfile = Conversions.resolveExecutionProfile(statement, context);
GraphProtocol graphSubProtocol = GraphConversions.resolveGraphSubProtocol(statement, graphSupportChecker, context);
Message message = GraphConversions.createMessageFromGraphStatement(statement, graphSubProtocol, executionProfile, context, graphBinaryModule);
Map<String, ByteBuffer> customPayload = GraphConversions.createCustomPayload(statement, graphSubProtocol, executionProfile, context, graphBinaryModule);
channel.write(message, statement.isTracing(), customPayload, nodeResponseCallback).addListener(nodeResponseCallback);
}
}
Aggregations