Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added support to hector exceptions to display the host

  • Loading branch information...
commit 2b9bfb5e403e0664f95348802bb8c1c95e2cb01a 1 parent 7ef2306
Shaun Kalley authored shaunkalley committed
View
43 core/src/main/java/me/prettyprint/cassandra/service/ExceptionsTranslatorImpl.java
@@ -30,21 +30,22 @@ public HectorException translate(Throwable original) {
@Override
public HectorException translate(Throwable original, CassandraHost host) {
+ HectorException he;
if (original instanceof HectorException) {
- return setHost((HectorException) original, host);
+ he = (HectorException) original;
} else if (original instanceof TApplicationException) {
- return new HCassandraInternalException(((TApplicationException)original).getType(), original.getMessage());
+ he = new HCassandraInternalException(((TApplicationException)original).getType(), original.getMessage());
} else if (original instanceof TTransportException) {
// if the underlying cause is a scoket timeout, reflect that directly
// TODO this may be an issue on the Cassandra side which warrants investigation.
// I seem to remember these coming back as TimedOutException previously
if (((TTransportException) original).getCause() instanceof SocketTimeoutException) {
- return setHost(new HTimedOutException(original), host);
+ he = new HTimedOutException(original);
} else {
- return setHost(new HectorTransportException(original), host);
+ he = new HectorTransportException(original);
}
} else if (original instanceof org.apache.cassandra.thrift.TimedOutException) {
- return setHost(new HTimedOutException(original), host);
+ he = new HTimedOutException(original);
} else if (original instanceof org.apache.cassandra.thrift.InvalidRequestException) {
// See bug https://issues.apache.org/jira/browse/CASSANDRA-1862
// If a bootstrapping node is accessed it responds with IRE. It makes more sense to throw
@@ -52,35 +53,33 @@ public HectorException translate(Throwable original, CassandraHost host) {
// Hector wraps this caveat and fixes this.
String why = ((org.apache.cassandra.thrift.InvalidRequestException) original).getWhy();
if (why != null && why.contains("bootstrap")) {
- return setHost(new HUnavailableException(original), host);
+ he = new HUnavailableException(original);
+ } else {
+ HInvalidRequestException e = new HInvalidRequestException(original);
+ e.setWhy(why);
+ he = e;
}
- HInvalidRequestException e = new HInvalidRequestException(original);
- e.setWhy(why);
- return setHost(e, host);
} else if (original instanceof HPoolExhaustedException ) {
- return setHost((HPoolExhaustedException) original, host);
+ he = (HPoolExhaustedException) original;
} else if (original instanceof HPoolRecoverableException ) {
- return setHost((HPoolRecoverableException) original, host);
+ he = (HPoolRecoverableException) original;
} else if (original instanceof HInactivePoolException ) {
- return setHost((HInactivePoolException) original, host);
+ he = (HInactivePoolException) original;
} else if (original instanceof TProtocolException) {
- return setHost(new HInvalidRequestException(original), host);
+ he = new HInvalidRequestException(original);
} else if (original instanceof org.apache.cassandra.thrift.NotFoundException) {
- return setHost(new HNotFoundException(original), host);
+ he = new HNotFoundException(original);
} else if (original instanceof org.apache.cassandra.thrift.UnavailableException) {
- return setHost(new HUnavailableException(original), host);
+ he = new HUnavailableException(original);
} else if (original instanceof TException) {
- return setHost(new HectorTransportException(original), host);
+ he = new HectorTransportException(original);
} else if (original instanceof NoSuchElementException) {
- return setHost(new HPoolExhaustedException(original), host);
+ he = new HPoolExhaustedException(original);
} else if (original instanceof IllegalStateException) {
- return setHost(new PoolIllegalStateException(original), host);
+ he = new PoolIllegalStateException(original);
} else {
- return setHost(new HectorException(original), host);
+ he = new HectorException(original);
}
- }
-
- private HectorException setHost(HectorException he, CassandraHost host) {
he.setHost(host);
return he;
}

0 comments on commit 2b9bfb5

Please sign in to comment.
Something went wrong with that request. Please try again.