kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 68ee5447be2a928e7e1359ef665d22123ad7fb7ad04c7a41f2e7b1954d53e5a2 |
|---|---|
| Author | Alexandre Dutra <alexandre.dutra@datastax.com> · 2015-12-01 15:25 +01:00 |
| Committer | Alexandre Dutra <alexandre.dutra@datastax.com> · 2015-12-03 18:44 +01:00 |
| Parents | b4554bb54c38 |
48 files changed
modified driver-core/src/main/java/com/datastax/driver/core/AbstractReconnectionHandler.java +5 −3
| @@ -25,6 +25,8 @@ | ||
| 25 | 25 | import org.slf4j.LoggerFactory; |
| 26 | 26 | |
| 27 | 27 | import com.datastax.driver.core.exceptions.AuthenticationException; |
| 28 | +import com.datastax.driver.core.exceptions.ConnectionException; | |
| 29 | +import com.datastax.driver.core.exceptions.UnsupportedProtocolVersionException; | |
| 28 | 30 | import com.datastax.driver.core.policies.ReconnectionPolicy; |
| 29 | 31 | |
| 30 | 32 | /** |
| @@ -140,7 +142,7 @@ | ||
| 140 | 142 | if (onAuthenticationException(e, nextDelay)) { |
| 141 | 143 | reschedule(nextDelay); |
| 142 | 144 | } else { |
| 143 | - logger.error("Retry against {} have been suspended. It won't be retried unless the node is restarted.", e.getHost()); | |
| 145 | + logger.error("Retries against {} have been suspended. It won't be retried unless the node is restarted.", e.getHost()); | |
| 144 | 146 | currentAttempt.compareAndSet(handlerFuture, null); |
| 145 | 147 | } |
| 146 | 148 | } catch (InterruptedException e) { |
| @@ -151,7 +153,7 @@ | ||
| 151 | 153 | if (onUnsupportedProtocolVersionException(e, nextDelay)) { |
| 152 | 154 | reschedule(nextDelay); |
| 153 | 155 | } else { |
| 154 | - logger.error("Retry against {} have been suspended. It won't be retried unless the node is restarted.", e.address); | |
| 156 | + logger.error("Retries against {} have been suspended. It won't be retried unless the node is restarted.", e.getHost()); | |
| 155 | 157 | currentAttempt.compareAndSet(handlerFuture, null); |
| 156 | 158 | } |
| 157 | 159 | } catch (ClusterNameMismatchException e) { |
| @@ -160,7 +162,7 @@ | ||
| 160 | 162 | if (onClusterNameMismatchException(e, nextDelay)) { |
| 161 | 163 | reschedule(nextDelay); |
| 162 | 164 | } else { |
| 163 | - logger.error("Retry against {} have been suspended. It won't be retried unless the node is restarted.", e.address); | |
| 165 | + logger.error("Retries against {} have been suspended. It won't be retried unless the node is restarted.", e.address.getAddress()); | |
| 164 | 166 | currentAttempt.compareAndSet(handlerFuture, null); |
| 165 | 167 | } |
| 166 | 168 | } catch (Exception e) { |
modified driver-core/src/main/java/com/datastax/driver/core/ArrayBackedResultSet.java +1 −0
| @@ -28,6 +28,7 @@ | ||
| 28 | 28 | import org.slf4j.Logger; |
| 29 | 29 | import org.slf4j.LoggerFactory; |
| 30 | 30 | |
| 31 | +import com.datastax.driver.core.exceptions.ConnectionException; | |
| 31 | 32 | import com.datastax.driver.core.exceptions.DriverInternalError; |
| 32 | 33 | |
| 33 | 34 | /** |
deleted driver-core/src/main/java/com/datastax/driver/core/BusyConnectionException.java +0 −25
| @@ -1,25 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | - * | |
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | - * you may not use this file except in compliance with the License. | |
| 6 | - * You may obtain a copy of the License at | |
| 7 | - * | |
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | - * | |
| 10 | - * Unless required by applicable law or agreed to in writing, software | |
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | - * See the License for the specific language governing permissions and | |
| 14 | - * limitations under the License. | |
| 15 | - */ | |
| 16 | -package com.datastax.driver.core; | |
| 17 | - | |
| 18 | -class BusyConnectionException extends Exception | |
| 19 | -{ | |
| 20 | - private static final long serialVersionUID = 0; | |
| 21 | - | |
| 22 | - public BusyConnectionException() { | |
| 23 | - super(); | |
| 24 | - } | |
| 25 | -} |
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +5 −8
| @@ -34,10 +34,7 @@ | ||
| 34 | 34 | import org.slf4j.Logger; |
| 35 | 35 | import org.slf4j.LoggerFactory; |
| 36 | 36 | |
| 37 | -import com.datastax.driver.core.exceptions.AuthenticationException; | |
| 38 | -import com.datastax.driver.core.exceptions.DriverInternalError; | |
| 39 | -import com.datastax.driver.core.exceptions.InvalidQueryException; | |
| 40 | -import com.datastax.driver.core.exceptions.NoHostAvailableException; | |
| 37 | +import com.datastax.driver.core.exceptions.*; | |
| 41 | 38 | import com.datastax.driver.core.policies.*; |
| 42 | 39 | import com.datastax.driver.core.utils.MoreFutures; |
| 43 | 40 | |
| @@ -1404,9 +1401,9 @@ | ||
| 1404 | 1401 | try { |
| 1405 | 1402 | controlConnection.connect(); |
| 1406 | 1403 | } catch (UnsupportedProtocolVersionException e) { |
| 1407 | - logger.debug("Cannot connect with protocol {}, trying {}", e.unsupportedVersion, e.serverVersion); | |
| 1404 | + logger.debug("Cannot connect with protocol {}, trying {}", e.getUnsupportedVersion(), e.getServerVersion()); | |
| 1408 | 1405 | |
| 1409 | - connectionFactory.protocolVersion = e.serverVersion; | |
| 1406 | + connectionFactory.protocolVersion = e.getServerVersion(); | |
| 1410 | 1407 | try { |
| 1411 | 1408 | controlConnection.connect(); |
| 1412 | 1409 | } catch (UnsupportedProtocolVersionException e1) { |
| @@ -1682,7 +1679,7 @@ | ||
| 1682 | 1679 | Thread.currentThread().interrupt(); |
| 1683 | 1680 | // Don't propagate because we don't want to prevent other listener to run |
| 1684 | 1681 | } catch (UnsupportedProtocolVersionException e) { |
| 1685 | - logUnsupportedVersionProtocol(host, e.unsupportedVersion); | |
| 1682 | + logUnsupportedVersionProtocol(host, e.getUnsupportedVersion()); | |
| 1686 | 1683 | return; |
| 1687 | 1684 | } catch (ClusterNameMismatchException e) { |
| 1688 | 1685 | logClusterNameMismatch(host, e.expectedClusterName, e.actualClusterName); |
| @@ -1969,7 +1966,7 @@ | ||
| 1969 | 1966 | Thread.currentThread().interrupt(); |
| 1970 | 1967 | // Don't propagate because we don't want to prevent other listener to run |
| 1971 | 1968 | } catch (UnsupportedProtocolVersionException e) { |
| 1972 | - logUnsupportedVersionProtocol(host, e.unsupportedVersion); | |
| 1969 | + logUnsupportedVersionProtocol(host, e.getUnsupportedVersion()); | |
| 1973 | 1970 | return; |
| 1974 | 1971 | } catch (ClusterNameMismatchException e) { |
| 1975 | 1972 | logClusterNameMismatch(host, e.expectedClusterName, e.actualClusterName); |
modified driver-core/src/main/java/com/datastax/driver/core/Connection.java +3 −3
| @@ -47,9 +47,7 @@ | ||
| 47 | 47 | import static io.netty.handler.timeout.IdleState.ALL_IDLE; |
| 48 | 48 | |
| 49 | 49 | import com.datastax.driver.core.Responses.Result.SetKeyspace; |
| 50 | -import com.datastax.driver.core.exceptions.AuthenticationException; | |
| 51 | -import com.datastax.driver.core.exceptions.DriverException; | |
| 52 | -import com.datastax.driver.core.exceptions.DriverInternalError; | |
| 50 | +import com.datastax.driver.core.exceptions.*; | |
| 53 | 51 | import com.datastax.driver.core.utils.MoreFutures; |
| 54 | 52 | |
| 55 | 53 | import static com.datastax.driver.core.Message.Response.Type.ERROR; |
| @@ -1225,6 +1223,8 @@ | ||
| 1225 | 1223 | public ResponseHandler(Connection connection, ResponseCallback callback) throws BusyConnectionException { |
| 1226 | 1224 | this.connection = connection; |
| 1227 | 1225 | this.streamId = connection.dispatcher.streamIdHandler.next(); |
| 1226 | + if (streamId == -1) | |
| 1227 | + throw new BusyConnectionException(connection.address); | |
| 1228 | 1228 | this.callback = callback; |
| 1229 | 1229 | this.retryCount = callback.retryCount(); |
| 1230 | 1230 |
deleted driver-core/src/main/java/com/datastax/driver/core/ConnectionException.java +0 −42
| @@ -1,42 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | - * | |
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | - * you may not use this file except in compliance with the License. | |
| 6 | - * You may obtain a copy of the License at | |
| 7 | - * | |
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | - * | |
| 10 | - * Unless required by applicable law or agreed to in writing, software | |
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | - * See the License for the specific language governing permissions and | |
| 14 | - * limitations under the License. | |
| 15 | - */ | |
| 16 | -package com.datastax.driver.core; | |
| 17 | - | |
| 18 | -import java.net.InetSocketAddress; | |
| 19 | - | |
| 20 | -class ConnectionException extends Exception { | |
| 21 | - | |
| 22 | - private static final long serialVersionUID = 0; | |
| 23 | - | |
| 24 | - public final InetSocketAddress address; | |
| 25 | - | |
| 26 | - public ConnectionException(InetSocketAddress address, String msg, Throwable cause) | |
| 27 | - { | |
| 28 | - super(msg, cause); | |
| 29 | - this.address = address; | |
| 30 | - } | |
| 31 | - | |
| 32 | - public ConnectionException(InetSocketAddress address, String msg) | |
| 33 | - { | |
| 34 | - super(msg); | |
| 35 | - this.address = address; | |
| 36 | - } | |
| 37 | - | |
| 38 | - @Override | |
| 39 | - public String getMessage() { | |
| 40 | - return String.format("[%s] %s", address, super.getMessage()); | |
| 41 | - } | |
| 42 | -} |
modified driver-core/src/main/java/com/datastax/driver/core/ControlConnection.java +1 −3
| @@ -28,9 +28,7 @@ | ||
| 28 | 28 | import org.slf4j.Logger; |
| 29 | 29 | import org.slf4j.LoggerFactory; |
| 30 | 30 | |
| 31 | -import com.datastax.driver.core.exceptions.DriverException; | |
| 32 | -import com.datastax.driver.core.exceptions.DriverInternalError; | |
| 33 | -import com.datastax.driver.core.exceptions.NoHostAvailableException; | |
| 31 | +import com.datastax.driver.core.exceptions.*; | |
| 34 | 32 | |
| 35 | 33 | import static com.datastax.driver.core.SchemaElement.*; |
| 36 | 34 |
modified driver-core/src/main/java/com/datastax/driver/core/HostConnectionPool.java +2 −0
| @@ -34,6 +34,8 @@ | ||
| 34 | 34 | import org.slf4j.LoggerFactory; |
| 35 | 35 | |
| 36 | 36 | import com.datastax.driver.core.exceptions.AuthenticationException; |
| 37 | +import com.datastax.driver.core.exceptions.ConnectionException; | |
| 38 | +import com.datastax.driver.core.exceptions.UnsupportedProtocolVersionException; | |
| 37 | 39 | import com.datastax.driver.core.utils.MoreFutures; |
| 38 | 40 | |
| 39 | 41 | import static com.datastax.driver.core.Connection.State.GONE; |
deleted driver-core/src/main/java/com/datastax/driver/core/OperationTimedOutException.java +0 −28
| @@ -1,28 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | - * | |
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | - * you may not use this file except in compliance with the License. | |
| 6 | - * You may obtain a copy of the License at | |
| 7 | - * | |
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | - * | |
| 10 | - * Unless required by applicable law or agreed to in writing, software | |
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | - * See the License for the specific language governing permissions and | |
| 14 | - * limitations under the License. | |
| 15 | - */ | |
| 16 | -package com.datastax.driver.core; | |
| 17 | - | |
| 18 | -import java.net.InetSocketAddress; | |
| 19 | - | |
| 20 | -/** | |
| 21 | - * Thrown on a client-side timeout, i.e. when the client didn't hear back from the server within | |
| 22 | - * {@link SocketOptions#getReadTimeoutMillis()}. | |
| 23 | - */ | |
| 24 | -class OperationTimedOutException extends ConnectionException { | |
| 25 | - public OperationTimedOutException(InetSocketAddress address) { | |
| 26 | - super(address, "Operation timed out"); | |
| 27 | - } | |
| 28 | -} |
modified driver-core/src/main/java/com/datastax/driver/core/RegularStatement.java +1 −0
| @@ -18,6 +18,7 @@ | ||
| 18 | 18 | import java.nio.ByteBuffer; |
| 19 | 19 | |
| 20 | 20 | import com.datastax.driver.core.exceptions.InvalidTypeException; |
| 21 | +import com.datastax.driver.core.exceptions.UnsupportedProtocolVersionException; | |
| 21 | 22 | |
| 22 | 23 | /** |
| 23 | 24 | * A regular (non-prepared and non batched) CQL statement. |
modified driver-core/src/main/java/com/datastax/driver/core/RequestHandler.java +5 −8
| @@ -505,8 +505,7 @@ | ||
| 505 | 505 | connection.release(); |
| 506 | 506 | // Try another node |
| 507 | 507 | logger.warn("Host {} is overloaded, trying next host.", connection.address); |
| 508 | - DriverException overloaded = new DriverException("Host overloaded"); | |
| 509 | - logError(connection.address, overloaded); | |
| 508 | + logError(connection.address, exceptionToReport); | |
| 510 | 509 | if (metricsEnabled()) |
| 511 | 510 | metrics().getErrorMetrics().getOthers().inc(); |
| 512 | 511 | retry(false, null); |
| @@ -515,9 +514,8 @@ | ||
| 515 | 514 | connection.release(); |
| 516 | 515 | // Defunct connection and try another node |
| 517 | 516 | logger.warn("{} replied with server error ({}), trying next host.", connection.address, err.message); |
| 518 | - DriverException exception = new DriverException("Host replied with server error: " + err.message); | |
| 519 | - logError(connection.address, exception); | |
| 520 | - connection.defunct(exception); | |
| 517 | + logError(connection.address, exceptionToReport); | |
| 518 | + connection.defunct(exceptionToReport); | |
| 521 | 519 | if (metricsEnabled()) |
| 522 | 520 | metrics().getErrorMetrics().getOthers().inc(); |
| 523 | 521 | retry(false, null); |
| @@ -526,8 +524,7 @@ | ||
| 526 | 524 | connection.release(); |
| 527 | 525 | // Try another node |
| 528 | 526 | logger.error("Query sent to {} but it is bootstrapping. This shouldn't happen but trying next host.", connection.address); |
| 529 | - DriverException bootstrapping = new DriverException("Host is bootstrapping"); | |
| 530 | - logError(connection.address, bootstrapping); | |
| 527 | + logError(connection.address, exceptionToReport); | |
| 531 | 528 | if (metricsEnabled()) |
| 532 | 529 | metrics().getErrorMetrics().getOthers().inc(); |
| 533 | 530 | retry(false, null); |
| @@ -678,7 +675,7 @@ | ||
| 678 | 675 | return false; |
| 679 | 676 | } |
| 680 | 677 | connection.release(); |
| 681 | - logError(connection.address, new DriverException("Timeout waiting for response to prepare message")); | |
| 678 | + logError(connection.address, new OperationTimedOutException(connection.address, "Timeout waiting for response to prepare message")); | |
| 682 | 679 | retry(false, null); |
| 683 | 680 | return true; |
| 684 | 681 | } |
modified driver-core/src/main/java/com/datastax/driver/core/SchemaParser.java +3 −0
| @@ -23,6 +23,9 @@ | ||
| 23 | 23 | import org.slf4j.Logger; |
| 24 | 24 | import org.slf4j.LoggerFactory; |
| 25 | 25 | |
| 26 | +import com.datastax.driver.core.exceptions.BusyConnectionException; | |
| 27 | +import com.datastax.driver.core.exceptions.ConnectionException; | |
| 28 | + | |
| 26 | 29 | import static com.datastax.driver.core.SchemaElement.*; |
| 27 | 30 | |
| 28 | 31 | abstract class SchemaParser { |
modified driver-core/src/main/java/com/datastax/driver/core/SessionManager.java +2 −1
| @@ -32,6 +32,7 @@ | ||
| 32 | 32 | import com.datastax.driver.core.exceptions.DriverInternalError; |
| 33 | 33 | import com.datastax.driver.core.exceptions.InvalidQueryException; |
| 34 | 34 | import com.datastax.driver.core.exceptions.UnsupportedFeatureException; |
| 35 | +import com.datastax.driver.core.exceptions.UnsupportedProtocolVersionException; | |
| 35 | 36 | import com.datastax.driver.core.policies.LoadBalancingPolicy; |
| 36 | 37 | import com.datastax.driver.core.policies.ReconnectionPolicy; |
| 37 | 38 | import com.datastax.driver.core.policies.SpeculativeExecutionPolicy; |
| @@ -357,7 +358,7 @@ | ||
| 357 | 358 | @Override |
| 358 | 359 | public void onFailure(Throwable t) { |
| 359 | 360 | if (t instanceof UnsupportedProtocolVersionException) { |
| 360 | - cluster.manager.logUnsupportedVersionProtocol(host, ((UnsupportedProtocolVersionException)t).unsupportedVersion); | |
| 361 | + cluster.manager.logUnsupportedVersionProtocol(host, ((UnsupportedProtocolVersionException)t).getUnsupportedVersion()); | |
| 361 | 362 | cluster.manager.triggerOnDown(host, false); |
| 362 | 363 | } else if (t instanceof ClusterNameMismatchException) { |
| 363 | 364 | ClusterNameMismatchException e = (ClusterNameMismatchException)t; |
modified driver-core/src/main/java/com/datastax/driver/core/Statement.java +1 −0
| @@ -21,6 +21,7 @@ | ||
| 21 | 21 | import com.google.common.collect.ImmutableMap; |
| 22 | 22 | |
| 23 | 23 | import com.datastax.driver.core.exceptions.PagingStateException; |
| 24 | +import com.datastax.driver.core.exceptions.UnsupportedProtocolVersionException; | |
| 24 | 25 | import com.datastax.driver.core.policies.RetryPolicy; |
| 25 | 26 | import com.datastax.driver.core.querybuilder.BuiltStatement; |
| 26 | 27 |
modified driver-core/src/main/java/com/datastax/driver/core/StreamIdGenerator.java +2 −2
| @@ -81,7 +81,7 @@ | ||
| 81 | 81 | offset = new AtomicInteger(bits.length() - 1); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - public int next() throws BusyConnectionException { | |
| 84 | + public int next() { | |
| 85 | 85 | int previousOffset, myOffset; |
| 86 | 86 | do { |
| 87 | 87 | previousOffset = offset.get(); |
| @@ -95,7 +95,7 @@ | ||
| 95 | 95 | if (id >= 0) |
| 96 | 96 | return id + (64 * j); |
| 97 | 97 | } |
| 98 | - throw new BusyConnectionException(); | |
| 98 | + return -1; | |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | public void release(int streamId) { |
deleted driver-core/src/main/java/com/datastax/driver/core/TransportException.java +0 −37
| @@ -1,37 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | - * | |
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | - * you may not use this file except in compliance with the License. | |
| 6 | - * You may obtain a copy of the License at | |
| 7 | - * | |
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | - * | |
| 10 | - * Unless required by applicable law or agreed to in writing, software | |
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | - * See the License for the specific language governing permissions and | |
| 14 | - * limitations under the License. | |
| 15 | - */ | |
| 16 | -package com.datastax.driver.core; | |
| 17 | - | |
| 18 | -import java.net.InetSocketAddress; | |
| 19 | - | |
| 20 | -/** | |
| 21 | - * A connection exception that has to do with the transport itself, i.e. that | |
| 22 | - * suggests the node is down. | |
| 23 | - */ | |
| 24 | -class TransportException extends ConnectionException | |
| 25 | -{ | |
| 26 | - private static final long serialVersionUID = 0; | |
| 27 | - | |
| 28 | - public TransportException(InetSocketAddress address, String msg, Throwable cause) | |
| 29 | - { | |
| 30 | - super(address, msg, cause); | |
| 31 | - } | |
| 32 | - | |
| 33 | - public TransportException(InetSocketAddress address, String msg) | |
| 34 | - { | |
| 35 | - super(address, msg); | |
| 36 | - } | |
| 37 | -} |
deleted driver-core/src/main/java/com/datastax/driver/core/UnsupportedProtocolVersionException.java +0 −39
| @@ -1,39 +0,0 @@ | ||
| 1 | -/* | |
| 2 | - * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | - * | |
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | - * you may not use this file except in compliance with the License. | |
| 6 | - * You may obtain a copy of the License at | |
| 7 | - * | |
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | - * | |
| 10 | - * Unless required by applicable law or agreed to in writing, software | |
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | - * See the License for the specific language governing permissions and | |
| 14 | - * limitations under the License. | |
| 15 | - */ | |
| 16 | -package com.datastax.driver.core; | |
| 17 | - | |
| 18 | -import java.net.InetSocketAddress; | |
| 19 | - | |
| 20 | -/** | |
| 21 | - * Indicates that we've attempted to connect to a 1.2 C* node with version 2 of | |
| 22 | - * the protocol. | |
| 23 | - */ | |
| 24 | -class UnsupportedProtocolVersionException extends Exception { | |
| 25 | - | |
| 26 | - private static final long serialVersionUID = 0; | |
| 27 | - | |
| 28 | - public final InetSocketAddress address; | |
| 29 | - public final ProtocolVersion unsupportedVersion; | |
| 30 | - public final ProtocolVersion serverVersion; | |
| 31 | - | |
| 32 | - public UnsupportedProtocolVersionException(InetSocketAddress address, ProtocolVersion unsupportedVersion, ProtocolVersion serverVersion) | |
| 33 | - { | |
| 34 | - super(String.format("[%s] Host %s does not support protocol version %s but %s", address, address, unsupportedVersion, serverVersion)); | |
| 35 | - this.address = address; | |
| 36 | - this.unsupportedVersion = unsupportedVersion; | |
| 37 | - this.serverVersion = serverVersion; | |
| 38 | - } | |
| 39 | -} |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/BootstrappingException.java +2 −6
| @@ -19,13 +19,9 @@ | ||
| 19 | 19 | import java.net.InetSocketAddress; |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | - * Indicates that the contacted host was bootstrapping. | |
| 23 | - * This class is mainly intended for internal use; | |
| 24 | - * client applications are not expected to deal with this exception directly, | |
| 25 | - * because the driver would transparently retry the same query on another host; | |
| 26 | - * but such exceptions are likely to appear occasionally in the driver logs. | |
| 22 | + * Indicates that the contacted host was bootstrapping when it received a read query. | |
| 27 | 23 | */ |
| 28 | -public class BootstrappingException extends DriverInternalError implements CoordinatorException { | |
| 24 | +public class BootstrappingException extends QueryExecutionException implements CoordinatorException { | |
| 29 | 25 | |
| 30 | 26 | private static final long serialVersionUID = 0; |
| 31 | 27 |
added driver-core/src/main/java/com/datastax/driver/core/exceptions/BusyConnectionException.java +55 −0
| @@ -0,0 +1,55 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + */ | |
| 16 | +package com.datastax.driver.core.exceptions; | |
| 17 | + | |
| 18 | +import java.net.InetAddress; | |
| 19 | +import java.net.InetSocketAddress; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * Indicates that a connection has run out of stream IDs. | |
| 23 | + */ | |
| 24 | +public class BusyConnectionException extends DriverException implements CoordinatorException { | |
| 25 | + | |
| 26 | + private static final long serialVersionUID = 0; | |
| 27 | + | |
| 28 | + private final InetSocketAddress address; | |
| 29 | + | |
| 30 | + public BusyConnectionException(InetSocketAddress address) { | |
| 31 | + super(String.format("[%s] Connection has run out of stream IDs", address.getAddress())); | |
| 32 | + this.address = address; | |
| 33 | + } | |
| 34 | + | |
| 35 | + public BusyConnectionException(InetSocketAddress address, Throwable cause) { | |
| 36 | + super(String.format("[%s] Connection has run out of stream IDs", address.getAddress()), cause); | |
| 37 | + this.address = address; | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public InetAddress getHost() { | |
| 42 | + return address.getAddress(); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + public InetSocketAddress getAddress() { | |
| 47 | + return address; | |
| 48 | + } | |
| 49 | + | |
| 50 | + @Override | |
| 51 | + public BusyConnectionException copy() { | |
| 52 | + return new BusyConnectionException(address, this); | |
| 53 | + } | |
| 54 | + | |
| 55 | +} |
added driver-core/src/main/java/com/datastax/driver/core/exceptions/ConnectionException.java +65 −0
| @@ -0,0 +1,65 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + */ | |
| 16 | +package com.datastax.driver.core.exceptions; | |
| 17 | + | |
| 18 | +import java.net.InetAddress; | |
| 19 | +import java.net.InetSocketAddress; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * Indicates that a connection to a host has encountered a problem | |
| 23 | + * and that it should be closed. | |
| 24 | + */ | |
| 25 | +public class ConnectionException extends DriverException implements CoordinatorException { | |
| 26 | + | |
| 27 | + private static final long serialVersionUID = 0; | |
| 28 | + | |
| 29 | + public final InetSocketAddress address; | |
| 30 | + | |
| 31 | + public ConnectionException(InetSocketAddress address, String msg, Throwable cause) { | |
| 32 | + super(msg, cause); | |
| 33 | + this.address = address; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public ConnectionException(InetSocketAddress address, String msg) { | |
| 37 | + super(msg); | |
| 38 | + this.address = address; | |
| 39 | + } | |
| 40 | + | |
| 41 | + @Override | |
| 42 | + public InetAddress getHost() { | |
| 43 | + return address.getAddress(); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @Override | |
| 47 | + public InetSocketAddress getAddress() { | |
| 48 | + return address; | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public String getMessage() { | |
| 53 | + return String.format("[%s] %s", getHost(), getRawMessage()); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @Override | |
| 57 | + public ConnectionException copy() { | |
| 58 | + return new ConnectionException(address, getRawMessage(), this); | |
| 59 | + } | |
| 60 | + | |
| 61 | + String getRawMessage() { | |
| 62 | + return super.getMessage(); | |
| 63 | + } | |
| 64 | + | |
| 65 | +} |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/CoordinatorException.java +5 −5
| @@ -20,25 +20,25 @@ | ||
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * An interface for exceptions that are able to report the address of the coordinator host |
| 23 | - * that triggered the response error which caused the exception to be raised. | |
| 23 | + * that was contacted. | |
| 24 | 24 | */ |
| 25 | 25 | public interface CoordinatorException { |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | - * The coordinator host that caused this exception to be raised. | |
| 28 | + * The coordinator host that was contacted. | |
| 29 | 29 | * <p> |
| 30 | 30 | * This is a shortcut for {@link InetSocketAddress#getAddress() getAddress().getAddress()}. |
| 31 | 31 | * |
| 32 | - * @return The coordinator host that caused this exception to be raised; | |
| 32 | + * @return The coordinator host that was contacted; | |
| 33 | 33 | * may be {@code null} if the coordinator is not known. |
| 34 | 34 | * |
| 35 | 35 | */ |
| 36 | 36 | InetAddress getHost(); |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * The full address of the coordinator host that caused this exception to be raised. | |
| 39 | + * The full address of the coordinator host that was contacted. | |
| 40 | 40 | * |
| 41 | - * @return the full address of the coordinator host that caused this exception to be raised; | |
| 41 | + * @return the full address of the coordinator host that was contacted; | |
| 42 | 42 | * may be {@code null} if the coordinator is not known. |
| 43 | 43 | */ |
| 44 | 44 | InetSocketAddress getAddress(); |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/DriverException.java +1 −5
| @@ -22,10 +22,6 @@ | ||
| 22 | 22 | |
| 23 | 23 | private static final long serialVersionUID = 0; |
| 24 | 24 | |
| 25 | - DriverException() { | |
| 26 | - super(); | |
| 27 | - } | |
| 28 | - | |
| 29 | 25 | public DriverException(String message) { |
| 30 | 26 | super(message); |
| 31 | 27 | } |
| @@ -41,7 +37,7 @@ | ||
| 41 | 37 | /** |
| 42 | 38 | * Copy the exception. |
| 43 | 39 | * <p> |
| 44 | - * This return a new exception, equivalent to the original one, except that | |
| 40 | + * This returns a new exception, equivalent to the original one, except that | |
| 45 | 41 | * because a new object is created in the current thread, the top-most |
| 46 | 42 | * element in the stacktrace of the exception will refer to the current |
| 47 | 43 | * thread (this is mainly intended for internal use by the driver). The cause of |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/DriverInternalError.java +1 −1
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | /** |
| 19 | 19 | * An unexpected error happened internally. |
| 20 | 20 | * |
| 21 | - * This should never be raise and indicates a bug (either in the driver or in | |
| 21 | + * This should never be raised and indicates a bug (either in the driver or in | |
| 22 | 22 | * Cassandra). |
| 23 | 23 | */ |
| 24 | 24 | public class DriverInternalError extends DriverException { |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/InvalidTypeException.java +8 −1
| @@ -15,6 +15,13 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core.exceptions; |
| 17 | 17 | |
| 18 | +/** | |
| 19 | + * Thrown when a {@link com.datastax.driver.core.TypeCodec} | |
| 20 | + * is unable to perform the requested operation (serialization, | |
| 21 | + * deserialization, parsing or formatting) because the | |
| 22 | + * object or the byte buffer content being processed does not | |
| 23 | + * comply with the expected Java and/or CQL type. | |
| 24 | + */ | |
| 18 | 25 | public class InvalidTypeException extends DriverException { |
| 19 | 26 | |
| 20 | 27 | private static final long serialVersionUID = 0; |
| @@ -28,7 +35,7 @@ | ||
| 28 | 35 | } |
| 29 | 36 | |
| 30 | 37 | @Override |
| 31 | - public DriverException copy() { | |
| 38 | + public InvalidTypeException copy() { | |
| 32 | 39 | return new InvalidTypeException(getMessage(), this); |
| 33 | 40 | } |
| 34 | 41 | } |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/NoHostAvailableException.java +8 −8
| @@ -22,17 +22,17 @@ | ||
| 22 | 22 | import java.util.Map; |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * Exception thrown when a query cannot be performed because no host are | |
| 25 | + * Exception thrown when a query cannot be performed because no host is | |
| 26 | 26 | * available. |
| 27 | - * | |
| 28 | - * This exception is thrown if | |
| 27 | + * <p> | |
| 28 | + * This exception is thrown if either: | |
| 29 | 29 | * <ul> |
| 30 | - * <li>either there is no host live in the cluster at the moment of the query</li> | |
| 31 | - * <li>all host that have been tried have failed due to a connection problem</li> | |
| 30 | + * <li>there is no host live in the cluster at the moment of the query;</li> | |
| 31 | + * <li>all hosts that have been tried have failed.</li> | |
| 32 | 32 | * </ul> |
| 33 | 33 | * |
| 34 | - * For debugging purpose, the list of hosts that have been tried along with the | |
| 35 | - * failure cause can be retrieved using the {@link #errors} method. | |
| 34 | + * For debugging purposes, the list of hosts that have been tried along with the | |
| 35 | + * failure cause can be retrieved using the {@link #getErrors()} method. | |
| 36 | 36 | */ |
| 37 | 37 | public class NoHostAvailableException extends DriverException { |
| 38 | 38 | |
| @@ -80,7 +80,7 @@ | ||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | @Override |
| 83 | - public DriverException copy() { | |
| 83 | + public NoHostAvailableException copy() { | |
| 84 | 84 | return new NoHostAvailableException(getMessage(), this, errors); |
| 85 | 85 | } |
| 86 | 86 |
added driver-core/src/main/java/com/datastax/driver/core/exceptions/OperationTimedOutException.java +47 −0
| @@ -0,0 +1,47 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + */ | |
| 16 | +package com.datastax.driver.core.exceptions; | |
| 17 | + | |
| 18 | +import java.net.InetSocketAddress; | |
| 19 | + | |
| 20 | +import com.datastax.driver.core.SocketOptions; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * Thrown on a client-side timeout, i.e. when the client didn't hear back from the server within | |
| 24 | + * {@link SocketOptions#getReadTimeoutMillis()}. | |
| 25 | + */ | |
| 26 | +public class OperationTimedOutException extends ConnectionException { | |
| 27 | + | |
| 28 | + private static final long serialVersionUID = 0; | |
| 29 | + | |
| 30 | + public OperationTimedOutException(InetSocketAddress address) { | |
| 31 | + super(address, "Operation timed out"); | |
| 32 | + } | |
| 33 | + | |
| 34 | + public OperationTimedOutException(InetSocketAddress address, String msg) { | |
| 35 | + super(address, msg); | |
| 36 | + } | |
| 37 | + | |
| 38 | + public OperationTimedOutException(InetSocketAddress address, String msg, Throwable cause) { | |
| 39 | + super(address, msg, cause); | |
| 40 | + } | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public OperationTimedOutException copy() { | |
| 44 | + return new OperationTimedOutException(address, getRawMessage(), this); | |
| 45 | + } | |
| 46 | + | |
| 47 | +} |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/OverloadedException.java +1 −5
| @@ -20,12 +20,8 @@ | ||
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Indicates that the contacted host reported itself being overloaded. |
| 23 | - * This class is mainly intended for internal use; | |
| 24 | - * client applications are not expected to deal with this exception directly, | |
| 25 | - * because the driver would transparently retry the same query on another host; | |
| 26 | - * but such exceptions are likely to appear occasionally in the driver logs. | |
| 27 | 23 | */ |
| 28 | -public class OverloadedException extends DriverInternalError implements CoordinatorException { | |
| 24 | +public class OverloadedException extends QueryExecutionException implements CoordinatorException { | |
| 29 | 25 | |
| 30 | 26 | private static final long serialVersionUID = 0; |
| 31 | 27 |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/PagingStateException.java +8 −1
| @@ -15,6 +15,13 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core.exceptions; |
| 17 | 17 | |
| 18 | +/** | |
| 19 | + * Indicates an error while deserializing a (previously serialized) | |
| 20 | + * {@link com.datastax.driver.core.PagingState} object, | |
| 21 | + * or when a paging state does not match the statement being executed. | |
| 22 | + * | |
| 23 | + * @see com.datastax.driver.core.PagingState | |
| 24 | + */ | |
| 18 | 25 | public class PagingStateException extends DriverException { |
| 19 | 26 | |
| 20 | 27 | private static final long serialVersionUID = 0; |
| @@ -27,4 +34,4 @@ | ||
| 27 | 34 | super(msg, cause); |
| 28 | 35 | } |
| 29 | 36 | |
| 30 | -} | |
| No newline at the end of the file | ||
| 37 | +} |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/QueryExecutionException.java +2 −2
| @@ -17,8 +17,8 @@ | ||
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Exception related to the execution of a query. |
| 20 | - * | |
| 21 | - * This correspond to the exception that Cassandra throw when a (valid) query | |
| 20 | + * <p> | |
| 21 | + * This corresponds to the exception that Cassandra throws when a (valid) query | |
| 22 | 22 | * cannot be executed (TimeoutException, UnavailableException, ...). |
| 23 | 23 | */ |
| 24 | 24 | @SuppressWarnings("serial") |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/ReadFailureException.java +3 −3
| @@ -80,12 +80,12 @@ | ||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | @Override |
| 83 | - public DriverException copy() { | |
| 83 | + public ReadFailureException copy() { | |
| 84 | 84 | return new ReadFailureException(getAddress(), getMessage(), this, getConsistencyLevel(), getReceivedAcknowledgements(), |
| 85 | 85 | getRequiredAcknowledgements(), getFailures(), wasDataRetrieved()); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public DriverException copy(InetSocketAddress address) { | |
| 88 | + public ReadFailureException copy(InetSocketAddress address) { | |
| 89 | 89 | return new ReadFailureException( |
| 90 | 90 | address, |
| 91 | 91 | getMessage(), |
| @@ -96,4 +96,4 @@ | ||
| 96 | 96 | failed, |
| 97 | 97 | dataPresent); |
| 98 | 98 | } |
| 99 | -} | |
| No newline at the end of the file | ||
| 99 | +} |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/ReadTimeoutException.java +1 −1
| @@ -77,7 +77,7 @@ | ||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | @Override |
| 80 | - public DriverException copy() { | |
| 80 | + public ReadTimeoutException copy() { | |
| 81 | 81 | return new ReadTimeoutException( |
| 82 | 82 | getAddress(), |
| 83 | 83 | getMessage(), |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/ServerError.java +2 −1
| @@ -19,7 +19,8 @@ | ||
| 19 | 19 | import java.net.InetSocketAddress; |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | - * Indicates that the contacted host reported un expected error. | |
| 22 | + * Indicates that the contacted host reported an internal error. | |
| 23 | + * This should be considered as a bug in Cassandra and reported as such. | |
| 23 | 24 | */ |
| 24 | 25 | public class ServerError extends DriverInternalError implements CoordinatorException { |
| 25 | 26 |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/SyntaxError.java +1 −1
| @@ -62,7 +62,7 @@ | ||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | @Override |
| 65 | - public DriverException copy() { | |
| 65 | + public SyntaxError copy() { | |
| 66 | 66 | return new SyntaxError(getAddress(), getMessage(), this); |
| 67 | 67 | } |
| 68 | 68 | } |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/TraceRetrievalException.java +1 −1
| @@ -33,7 +33,7 @@ | ||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | @Override |
| 36 | - public DriverException copy() { | |
| 36 | + public TraceRetrievalException copy() { | |
| 37 | 37 | return new TraceRetrievalException(getMessage(), this); |
| 38 | 38 | } |
| 39 | 39 | } |
added driver-core/src/main/java/com/datastax/driver/core/exceptions/TransportException.java +41 −0
| @@ -0,0 +1,41 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + */ | |
| 16 | +package com.datastax.driver.core.exceptions; | |
| 17 | + | |
| 18 | +import java.net.InetSocketAddress; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * A connection exception that has to do with the transport itself, i.e. that | |
| 22 | + * suggests the node is down. | |
| 23 | + */ | |
| 24 | +public class TransportException extends ConnectionException { | |
| 25 | + | |
| 26 | + private static final long serialVersionUID = 0; | |
| 27 | + | |
| 28 | + public TransportException(InetSocketAddress address, String msg, Throwable cause) { | |
| 29 | + super(address, msg, cause); | |
| 30 | + } | |
| 31 | + | |
| 32 | + public TransportException(InetSocketAddress address, String msg) { | |
| 33 | + super(address, msg); | |
| 34 | + } | |
| 35 | + | |
| 36 | + @Override | |
| 37 | + public TransportException copy() { | |
| 38 | + return new TransportException(address, getRawMessage(), this); | |
| 39 | + } | |
| 40 | + | |
| 41 | +} |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/TruncateException.java +1 −1
| @@ -62,7 +62,7 @@ | ||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | @Override |
| 65 | - public DriverException copy() { | |
| 65 | + public TruncateException copy() { | |
| 66 | 66 | return new TruncateException(getAddress(), getMessage(), this); |
| 67 | 67 | } |
| 68 | 68 | } |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/UnauthorizedException.java +1 −1
| @@ -63,7 +63,7 @@ | ||
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | @Override |
| 66 | - public DriverException copy() { | |
| 66 | + public UnauthorizedException copy() { | |
| 67 | 67 | return new UnauthorizedException(getAddress(), getMessage(), this); |
| 68 | 68 | } |
| 69 | 69 | } |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/UnavailableException.java +4 −4
| @@ -21,7 +21,7 @@ | ||
| 21 | 21 | import com.datastax.driver.core.ConsistencyLevel; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | - * Exception thrown when the coordinator knows there is not enough replica | |
| 24 | + * Exception thrown when the coordinator knows there is not enough replicas | |
| 25 | 25 | * alive to perform a query with the requested consistency level. |
| 26 | 26 | */ |
| 27 | 27 | public class UnavailableException extends QueryExecutionException implements CoordinatorException { |
| @@ -78,10 +78,10 @@ | ||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | - * The number of replica that were known to be alive by the Cassandra | |
| 81 | + * The number of replicas that were known to be alive by the Cassandra | |
| 82 | 82 | * coordinator node when it tried to execute the operation. |
| 83 | 83 | * |
| 84 | - * @return The number of replica that were known to be alive by the Cassandra | |
| 84 | + * @return The number of replicas that were known to be alive by the Cassandra | |
| 85 | 85 | * coordinator node when it tried to execute the operation. |
| 86 | 86 | */ |
| 87 | 87 | public int getAliveReplicas() { |
| @@ -105,7 +105,7 @@ | ||
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | @Override |
| 108 | - public DriverException copy() { | |
| 108 | + public UnavailableException copy() { | |
| 109 | 109 | return new UnavailableException(getAddress(), getMessage(), this, consistency, required, alive); |
| 110 | 110 | } |
| 111 | 111 |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/UnpreparedException.java +1 −5
| @@ -20,12 +20,8 @@ | ||
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Indicates that the contacted host replied with an UNPREPARED error code. |
| 23 | - * This class is mainly intended for internal use; | |
| 24 | - * client applications are not expected to deal with this exception directly, | |
| 25 | - * because the driver would transparently prepare the query and execute it again; | |
| 26 | - * but such exceptions are likely to appear occasionally in the driver logs. | |
| 27 | 23 | */ |
| 28 | -public class UnpreparedException extends DriverInternalError implements CoordinatorException { | |
| 24 | +public class UnpreparedException extends QueryValidationException implements CoordinatorException { | |
| 29 | 25 | |
| 30 | 26 | private static final long serialVersionUID = 0; |
| 31 | 27 |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/UnresolvedUserTypeException.java +9 −2
| @@ -17,8 +17,15 @@ | ||
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Thrown when a user type cannot be resolved. |
| 20 | + * <p> | |
| 21 | + * This exception can be raised when the driver is rebuilding | |
| 22 | + * its schema metadata, and a user-defined type cannot be completely | |
| 23 | + * constructed due to some missing information. | |
| 24 | + * It should only appear in the driver logs, never in client code. | |
| 25 | + * It shouldn't be considered as a severe error as long as it only | |
| 26 | + * appears occasionally. | |
| 20 | 27 | */ |
| 21 | -public class UnresolvedUserTypeException extends InvalidTypeException { | |
| 28 | +public class UnresolvedUserTypeException extends DriverException { | |
| 22 | 29 | |
| 23 | 30 | private final String keyspaceName; |
| 24 | 31 | |
| @@ -45,7 +52,7 @@ | ||
| 45 | 52 | } |
| 46 | 53 | |
| 47 | 54 | @Override |
| 48 | - public DriverException copy() { | |
| 55 | + public UnresolvedUserTypeException copy() { | |
| 49 | 56 | return new UnresolvedUserTypeException(keyspaceName, name, this); |
| 50 | 57 | } |
| 51 | 58 |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/UnsupportedFeatureException.java +8 −0
| @@ -25,7 +25,15 @@ | ||
| 25 | 25 | |
| 26 | 26 | private static final long serialVersionUID = 0; |
| 27 | 27 | |
| 28 | + private final ProtocolVersion currentVersion; | |
| 29 | + | |
| 28 | 30 | public UnsupportedFeatureException(ProtocolVersion currentVersion, String msg) { |
| 29 | 31 | super("Unsupported feature with the native protocol " + currentVersion + " (which is currently in use): " + msg); |
| 32 | + this.currentVersion = currentVersion; | |
| 30 | 33 | } |
| 34 | + | |
| 35 | + public ProtocolVersion getCurrentVersion() { | |
| 36 | + return currentVersion; | |
| 37 | + } | |
| 38 | + | |
| 31 | 39 | } |
added driver-core/src/main/java/com/datastax/driver/core/exceptions/UnsupportedProtocolVersionException.java +75 −0
| @@ -0,0 +1,75 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (C) 2012-2015 DataStax Inc. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + */ | |
| 16 | +package com.datastax.driver.core.exceptions; | |
| 17 | + | |
| 18 | +import java.net.InetAddress; | |
| 19 | +import java.net.InetSocketAddress; | |
| 20 | + | |
| 21 | +import com.datastax.driver.core.ProtocolVersion; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * Indicates that we've attempted to connect to a Cassandra node with a protocol version | |
| 25 | + * that it cannot handle (e.g., connecting to a C* 1.2 node with protocol version 2). | |
| 26 | + */ | |
| 27 | +public class UnsupportedProtocolVersionException extends DriverException implements CoordinatorException { | |
| 28 | + | |
| 29 | + private static final long serialVersionUID = 0; | |
| 30 | + | |
| 31 | + private final InetSocketAddress address; | |
| 32 | + | |
| 33 | + private final ProtocolVersion unsupportedVersion; | |
| 34 | + | |
| 35 | + private final ProtocolVersion serverVersion; | |
| 36 | + | |
| 37 | + public UnsupportedProtocolVersionException(InetSocketAddress address, ProtocolVersion unsupportedVersion, ProtocolVersion serverVersion) { | |
| 38 | + super(String.format("[%s] Host does not support protocol version %s but %s", address, unsupportedVersion, serverVersion)); | |
| 39 | + this.address = address; | |
| 40 | + this.unsupportedVersion = unsupportedVersion; | |
| 41 | + this.serverVersion = serverVersion; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public UnsupportedProtocolVersionException(InetSocketAddress address, ProtocolVersion unsupportedVersion, ProtocolVersion serverVersion, Throwable cause) { | |
| 45 | + super(String.format("[%s] Host does not support protocol version %s but %s", address, unsupportedVersion, serverVersion), cause); | |
| 46 | + this.address = address; | |
| 47 | + this.unsupportedVersion = unsupportedVersion; | |
| 48 | + this.serverVersion = serverVersion; | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public InetAddress getHost() { | |
| 53 | + return address.getAddress(); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @Override | |
| 57 | + public InetSocketAddress getAddress() { | |
| 58 | + return address; | |
| 59 | + } | |
| 60 | + | |
| 61 | + public ProtocolVersion getServerVersion() { | |
| 62 | + return serverVersion; | |
| 63 | + } | |
| 64 | + | |
| 65 | + public ProtocolVersion getUnsupportedVersion() { | |
| 66 | + return unsupportedVersion; | |
| 67 | + } | |
| 68 | + | |
| 69 | + @Override | |
| 70 | + public UnsupportedProtocolVersionException copy() { | |
| 71 | + return new UnsupportedProtocolVersionException(address, unsupportedVersion, serverVersion, this); | |
| 72 | + } | |
| 73 | + | |
| 74 | + | |
| 75 | +} |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/WriteFailureException.java +2 −2
| @@ -75,12 +75,12 @@ | ||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | @Override |
| 78 | - public DriverException copy() { | |
| 78 | + public WriteFailureException copy() { | |
| 79 | 79 | return new WriteFailureException(getAddress(), getMessage(), this, getConsistencyLevel(), getWriteType(), |
| 80 | 80 | getReceivedAcknowledgements(), getRequiredAcknowledgements(), getFailures()); |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - public DriverException copy(InetSocketAddress address) { | |
| 83 | + public WriteFailureException copy(InetSocketAddress address) { | |
| 84 | 84 | return new WriteFailureException( |
| 85 | 85 | address, |
| 86 | 86 | getMessage(), |
modified driver-core/src/main/java/com/datastax/driver/core/exceptions/WriteTimeoutException.java +1 −1
| @@ -62,7 +62,7 @@ | ||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | @Override |
| 65 | - public DriverException copy() { | |
| 65 | + public WriteTimeoutException copy() { | |
| 66 | 66 | return new WriteTimeoutException( |
| 67 | 67 | getAddress(), |
| 68 | 68 | getMessage(), |
modified driver-core/src/test/java/com/datastax/driver/core/AbstractReconnectionHandlerTest.java +2 −0
| @@ -40,6 +40,8 @@ | ||
| 40 | 40 | |
| 41 | 41 | import com.datastax.driver.core.AbstractReconnectionHandler.HandlerFuture; |
| 42 | 42 | import com.datastax.driver.core.AbstractReconnectionHandlerTest.MockReconnectionWork.ReconnectBehavior; |
| 43 | +import com.datastax.driver.core.exceptions.ConnectionException; | |
| 44 | +import com.datastax.driver.core.exceptions.UnsupportedProtocolVersionException; | |
| 43 | 45 | import com.datastax.driver.core.policies.ReconnectionPolicy.ReconnectionSchedule; |
| 44 | 46 | |
| 45 | 47 | public class AbstractReconnectionHandlerTest { |
modified driver-core/src/test/java/com/datastax/driver/core/HostConnectionPoolTest.java +2 −0
| @@ -38,6 +38,8 @@ | ||
| 38 | 38 | import static org.scassandra.http.client.PrimingRequest.then; |
| 39 | 39 | import static org.testng.Assert.fail; |
| 40 | 40 | |
| 41 | +import com.datastax.driver.core.exceptions.BusyConnectionException; | |
| 42 | +import com.datastax.driver.core.exceptions.ConnectionException; | |
| 41 | 43 | import com.datastax.driver.core.policies.ConstantReconnectionPolicy; |
| 42 | 44 | |
| 43 | 45 | import static com.datastax.driver.core.Assertions.assertThat; |
modified driver-core/src/test/java/com/datastax/driver/core/QueryLoggerErrorsTest.java +2 −7
| @@ -176,12 +176,7 @@ | ||
| 176 | 176 | assertThat(expectedException).isEqualTo(NoHostAvailableException.class); |
| 177 | 177 | // ok |
| 178 | 178 | Throwable error = ((NoHostAvailableException)e).getErrors().get(hostAddress); |
| 179 | - assertThat(error).isNotNull(); | |
| 180 | - if(loggedException.getSuperclass() == DriverInternalError.class) { | |
| 181 | - assertThat(error).isOfAnyClassIn(DriverException.class); | |
| 182 | - } else { | |
| 183 | - assertThat(error).isOfAnyClassIn(loggedException); | |
| 184 | - } | |
| 179 | + assertThat(error).isNotNull().isOfAnyClassIn(loggedException); | |
| 185 | 180 | } else { |
| 186 | 181 | assertThat(e).isInstanceOf(expectedException); |
| 187 | 182 | } |
| @@ -196,4 +191,4 @@ | ||
| 196 | 191 | .contains(loggedException.getName()); |
| 197 | 192 | } |
| 198 | 193 | |
| 199 | -} | |
| No newline at the end of the file | ||
| 194 | +} |
modified driver-core/src/test/java/com/datastax/driver/core/StreamIdGeneratorTest.java +3 −6
| @@ -19,6 +19,8 @@ | ||
| 19 | 19 | import static org.testng.Assert.assertEquals; |
| 20 | 20 | import static org.testng.Assert.fail; |
| 21 | 21 | |
| 22 | +import com.datastax.driver.core.exceptions.BusyConnectionException; | |
| 23 | + | |
| 22 | 24 | public class StreamIdGeneratorTest { |
| 23 | 25 | |
| 24 | 26 | @Test(groups = "unit") |
| @@ -42,11 +44,6 @@ | ||
| 42 | 44 | generator.release(100); |
| 43 | 45 | assertEquals(generator.next(), 100); |
| 44 | 46 | |
| 45 | - try { | |
| 46 | - generator.next(); | |
| 47 | - fail("No more streamId should be available"); | |
| 48 | - } catch (BusyConnectionException e) { | |
| 49 | - // Ok, expected | |
| 50 | - } | |
| 47 | + assertEquals(generator.next(), -1); | |
| 51 | 48 | } |
| 52 | 49 | } |