@Test public void firstTimeRetryOnReadTimeout_shouldRetry() throws Exception { RetryNTimes retryPolicy = new RetryNTimes(3, 3, 3); Statement mockStatement = mock( Statement.class ); RetryPolicy.RetryDecision retryResult = retryPolicy.onReadTimeout(mockStatement, ConsistencyLevel.LOCAL_ONE, 1, 0, false, 0); RetryPolicy.RetryDecision retryExpected = RetryPolicy.RetryDecision.retry(ConsistencyLevel.LOCAL_ONE); assertRetryDecisionEquals(retryExpected, retryResult); }
@Override public RetryDecision onReadTimeout(Statement stmnt, ConsistencyLevel cl, int requiredResponses, int receivedResponses, boolean dataReceived, int rTime) { if (dataReceived) { return RetryDecision.ignore(); } else if (rTime < readAttempts) { LOG.info(String.format("Retrying on ReadTimeout: stmnt %s, " + "consistency %s, requiredResponse %d, " + "receivedResponse %d, dataReceived %s, rTime %d", stmnt, cl, requiredResponses, receivedResponses, dataReceived, rTime)); return RetryDecision.retry(cl); } else { return RetryDecision.rethrow(); } }
RetryNTimes implements RetryPolicy { @Override public RetryDecision onReadTimeout(Statement stmnt, ConsistencyLevel cl, int requiredResponses, int receivedResponses, boolean dataReceived, int rTime) { if (dataReceived) { return RetryDecision.ignore(); } else if (rTime < readAttempts) { LOG.info(String.format("Retrying on ReadTimeout: stmnt %s, " + "consistency %s, requiredResponse %d, " + "receivedResponse %d, dataReceived %s, rTime %d", stmnt, cl, requiredResponses, receivedResponses, dataReceived, rTime)); return RetryDecision.retry(cl); } else { return RetryDecision.rethrow(); } } }
RetryNTimes implements RetryPolicy { @Override public RetryDecision onReadTimeout(Statement stmnt, ConsistencyLevel cl, int requiredResponses, int receivedResponses, boolean dataReceived, int rTime) { if (dataReceived) { return RetryDecision.ignore(); } else if (rTime < readAttempts) { LOG.info(String.format("Retrying on ReadTimeout: stmnt %s, " + "consistency %s, requiredResponse %d, " + "receivedResponse %d, dataReceived %s, rTime %d", stmnt, cl, requiredResponses, receivedResponses, dataReceived, rTime)); return RetryDecision.retry(cl); } else { return RetryDecision.rethrow(); } } RetryNTimes(int readAttempts, int writeAttempts, int unavailableAttempts); }
RetryNTimes implements RetryPolicy { @Override public RetryDecision onReadTimeout(Statement stmnt, ConsistencyLevel cl, int requiredResponses, int receivedResponses, boolean dataReceived, int rTime) { if (dataReceived) { return RetryDecision.ignore(); } else if (rTime < readAttempts) { LOG.info(String.format("Retrying on ReadTimeout: stmnt %s, " + "consistency %s, requiredResponse %d, " + "receivedResponse %d, dataReceived %s, rTime %d", stmnt, cl, requiredResponses, receivedResponses, dataReceived, rTime)); return RetryDecision.retry(cl); } else { return RetryDecision.rethrow(); } } RetryNTimes(int readAttempts, int writeAttempts, int unavailableAttempts); @Override RetryDecision onReadTimeout(Statement stmnt, ConsistencyLevel cl,
                                       int requiredResponses, int receivedResponses,
                                       boolean dataReceived, int rTime); @Override RetryDecision onWriteTimeout(Statement stmnt, ConsistencyLevel cl,
                                        WriteType wt, int requiredResponses,
                                        int receivedResponses, int wTime); @Override RetryDecision onUnavailable(Statement stmnt, ConsistencyLevel cl,
                                       int requiredResponses, int receivedResponses, int uTime); @Override RetryDecision onRequestError(Statement statement, ConsistencyLevel cl, DriverException e, int nbRetry); @Override void init(Cluster cluster); @Override void close(); }
RetryNTimes implements RetryPolicy { @Override public RetryDecision onReadTimeout(Statement stmnt, ConsistencyLevel cl, int requiredResponses, int receivedResponses, boolean dataReceived, int rTime) { if (dataReceived) { return RetryDecision.ignore(); } else if (rTime < readAttempts) { LOG.info(String.format("Retrying on ReadTimeout: stmnt %s, " + "consistency %s, requiredResponse %d, " + "receivedResponse %d, dataReceived %s, rTime %d", stmnt, cl, requiredResponses, receivedResponses, dataReceived, rTime)); return RetryDecision.retry(cl); } else { return RetryDecision.rethrow(); } } RetryNTimes(int readAttempts, int writeAttempts, int unavailableAttempts); @Override RetryDecision onReadTimeout(Statement stmnt, ConsistencyLevel cl,
                                       int requiredResponses, int receivedResponses,
                                       boolean dataReceived, int rTime); @Override RetryDecision onWriteTimeout(Statement stmnt, ConsistencyLevel cl,
                                        WriteType wt, int requiredResponses,
                                        int receivedResponses, int wTime); @Override RetryDecision onUnavailable(Statement stmnt, ConsistencyLevel cl,
                                       int requiredResponses, int receivedResponses, int uTime); @Override RetryDecision onRequestError(Statement statement, ConsistencyLevel cl, DriverException e, int nbRetry); @Override void init(Cluster cluster); @Override void close();  }