static boolean isConnectionException(Throwable ex) { return ex != null // tcp socket timeout, possibly indicating network flake, long GC, or restarting server. && (ex instanceof SocketTimeoutException || ex instanceof CassandraClientFactory.ClientCreationFailedException || isConnectionException(ex.getCause())); }
@VisibleForTesting boolean shouldBlacklist(Exception ex, int numberOfAttempts) { return isConnectionException(ex) && numberOfAttempts >= maxTriesSameHost.get(); }
@Override public boolean shouldBackoff(Exception ex) { return isConnectionException(ex) || isIndicativeOfCassandraLoad(ex); }
@VisibleForTesting static boolean isRetryable(Exception ex) { return isConnectionException(ex) || isTransientException(ex) || isIndicativeOfCassandraLoad(ex) || isFastFailoverException(ex); }
private <V, K extends Exception> V runWithPooledResourceRecordingMetrics( CassandraClientPoolingContainer hostPool, FunctionCheckedException<CassandraClient, V, K> fn) throws K { metrics.recordRequestOnHost(hostPool); try { return hostPool.runWithPooledResource(fn); } catch (Exception e) { metrics.recordExceptionOnHost(hostPool); if (CassandraRequestExceptionHandler.isConnectionException(e)) { metrics.recordConnectionExceptionOnHost(hostPool); } throw e; } }
static boolean isConnectionException(Throwable ex) { return ex != null // tcp socket timeout, possibly indicating network flake, long GC, or restarting server. && (ex instanceof SocketTimeoutException || ex instanceof CassandraClientFactory.ClientCreationFailedException || isConnectionException(ex.getCause())); }
@VisibleForTesting boolean shouldBlacklist(Exception ex, int numberOfAttempts) { return isConnectionException(ex) && numberOfAttempts >= maxTriesSameHost.get(); }
@Override public boolean shouldBackoff(Exception ex) { return isConnectionException(ex) || isIndicativeOfCassandraLoad(ex); }
@VisibleForTesting static boolean isRetryable(Exception ex) { return isConnectionException(ex) || isTransientException(ex) || isIndicativeOfCassandraLoad(ex) || isFastFailoverException(ex); }
private <V, K extends Exception> V runWithPooledResourceRecordingMetrics( CassandraClientPoolingContainer hostPool, FunctionCheckedException<CassandraClient, V, K> fn) throws K { metrics.recordRequestOnHost(hostPool); try { return hostPool.runWithPooledResource(fn); } catch (Exception e) { metrics.recordExceptionOnHost(hostPool); if (CassandraRequestExceptionHandler.isConnectionException(e)) { metrics.recordConnectionExceptionOnHost(hostPool); } throw e; } }