forked from apache/cassandra-java-driver
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JAVA-2959: Don't throw NoNodeAvailableException when all connections …
…busy (apache#1570) For cases in which there are no connections available to send requests to a Node in the query plan, collect the error rather than silently skipping over the node. The error will be thrown as part of an AllNodesFailedException if all nodes fail. This can happen when we've saturated the max in-flight requests across all nodes or when the request is directed to a particular node and it has no connections available (or all its connections are saturated). Note that in the latter case we used to throw a NoNodeAvailableException but we now throw AllNodesFailedException.
- Loading branch information
Showing
10 changed files
with
178 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
core/src/main/java/com/datastax/oss/driver/api/core/NodeUnavailableException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright DataStax, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.datastax.oss.driver.api.core; | ||
|
||
import com.datastax.oss.driver.api.core.metadata.Node; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Indicates that a {@link Node} was selected in a query plan, but it had no connection available. | ||
* | ||
* <p>A common reason to encounter this error is when the configured number of connections per node | ||
* and requests per connection is not high enough to absorb the overall request rate. This can be | ||
* mitigated by tuning the following options: | ||
* | ||
* <ul> | ||
* <li>{@code advanced.connection.pool.local.size}; | ||
* <li>{@code advanced.connection.pool.remote.size}; | ||
* <li>{@code advanced.connection.max-requests-per-connection}. | ||
* </ul> | ||
* | ||
* See {@code reference.conf} for more details. | ||
* | ||
* <p>Another possibility is when you are trying to direct a request {@linkplain | ||
* com.datastax.oss.driver.api.core.cql.Statement#setNode(Node) to a particular node}, but that node | ||
* has no connections available. | ||
*/ | ||
public class NodeUnavailableException extends DriverException { | ||
|
||
private final Node node; | ||
|
||
public NodeUnavailableException(Node node) { | ||
super("No connection was available to " + node, null, null, true); | ||
this.node = Objects.requireNonNull(node); | ||
} | ||
|
||
@NonNull | ||
public Node getNode() { | ||
return node; | ||
} | ||
|
||
@Override | ||
@NonNull | ||
public DriverException copy() { | ||
return new NodeUnavailableException(node); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters