@Test public void testShouldAdaptWriteTypes() { assertThat(adapt(WriteType.SIMPLE)).isSameAs(SIMPLE); assertThat(adapt(WriteType.BATCH)).isSameAs(BATCH); assertThat(adapt(WriteType.UNLOGGED_BATCH)).isSameAs(UNLOGGED_BATCH); assertThat(adapt(WriteType.COUNTER)).isSameAs(COUNTER); assertThat(adapt(WriteType.BATCH_LOG)).isSameAs(BATCH_LOG); assertThat(adapt(WriteType.CAS)).isSameAs(CAS); }
@Test public void testShouldExtractWriteTypes() { assertThat(extract(SIMPLE)).isSameAs(WriteType.SIMPLE); assertThat(extract(BATCH)).isSameAs(WriteType.BATCH); assertThat(extract(UNLOGGED_BATCH)).isSameAs(WriteType.UNLOGGED_BATCH); assertThat(extract(COUNTER)).isSameAs(WriteType.COUNTER); assertThat(extract(BATCH_LOG)).isSameAs(WriteType.BATCH_LOG); assertThat(extract(CAS)).isSameAs(WriteType.CAS); }
@Override public RetryDecision onWriteTimeout(Statement stmnt, ConsistencyLevel cl, WriteType wt, int requiredResponses, int receivedResponses, int wTime) { if (wTime < writeAttempts) { return RetryDecision.retry(cl); } return RetryDecision.rethrow(); }
@Override public RetryDecision onWriteTimeout( Statement stmt, ConsistencyLevel cl, WriteType type, int required, int received, int retry) { return null != stmt && stmt.isIdempotent() ? RetryDecision.retry(cl) : DefaultRetryPolicy.INSTANCE.onWriteTimeout(stmt, cl, type, required, received, retry); }
@Override public RetryDecision onWriteTimeout(Statement statement, ConsistencyLevel cl, WriteType writeType, int requiredAcks, int receivedAcks, int nbRetry) { final RetryDecision decision = policy.onWriteTimeout(statement, cl, writeType, requiredAcks, receivedAcks, nbRetry); this.decision = decision; return decision; }
@Override public RetryDecision onWriteTimeout( Statement statement, ConsistencyLevel cl, WriteType writeType, int requiredAcks, int receivedAcks, int nbRetry ) { if (nbRetry != 0) { return RetryDecision.rethrow(); } // If the batch log write failed, retry the operation as this might just be we were // unlucky at picking candidates return writeType == WriteType.BATCH_LOG ? RetryDecision.retry(cl) : RetryDecision.rethrow(); }
public RetryDecision onWriteTimeout(Statement statement, ConsistencyLevel cl, WriteType writeType, int requiredAcks, int receivedAcks, int nbRetry) { if (nbRetry >= numRetries) return RetryDecision.rethrow(); return RetryDecision.retry(cl); }
@Override public RetryDecision onWriteTimeout(Statement stmnt, ConsistencyLevel cl, WriteType wt, int requiredResponses, int receivedResponses, int wTime) { if (wTime >= writeAttempts) return RetryDecision.rethrow(); return RetryDecision.retry(cl); }
@Override public RetryDecision onWriteTimeout(final Statement statement, final ConsistencyLevel cl, final WriteType writeType, final int requiredAcks, final int receivedAcks, final int nbRetry) { final RetryDecision decision = delegate.onWriteTimeout(statement, cl, writeType, requiredAcks, receivedAcks, nbRetry); for (final TagMetrics c : tagMetrics) { c.writeTimeouts.inc(); } return decision; }
@Override public RetryDecision onWriteTimeout(Statement stmnt, ConsistencyLevel cl, WriteType wt, int requiredResponses, int receivedResponses, int wTime) { if (wTime < writeAttempts) { LOG.info(String.format("Retrying on WriteTimeout: stmnt %s, " + "consistency %s, writeType %s, requiredResponse %d, " + "receivedResponse %d, rTime %d", stmnt, cl, wt.toString(), requiredResponses, receivedResponses, wTime)); return RetryDecision.retry(cl); } return RetryDecision.rethrow(); }
@Test public void firstTimeRetryOnWriteTimeout_shouldRetry() throws Exception { RetryNTimes retryPolicy = new RetryNTimes(3, 3, 3); Statement mockStatement = mock( Statement.class ); RetryPolicy.RetryDecision retryResult = retryPolicy.onWriteTimeout(mockStatement, ConsistencyLevel.LOCAL_ONE, WriteType.BATCH, 1, 0, 0); RetryPolicy.RetryDecision retryExpected = RetryPolicy.RetryDecision.retry(ConsistencyLevel.LOCAL_ONE); assertRetryDecisionEquals(retryExpected, retryResult); }
@Test public void maxTimeRetryOnWriteTimeout_shouldRethrow() throws Exception { RetryNTimes retryPolicy = new RetryNTimes(3, 3, 3); Statement mockStatement = mock( Statement.class ); RetryPolicy.RetryDecision retryResult = retryPolicy.onWriteTimeout(mockStatement, ConsistencyLevel.LOCAL_ONE, WriteType.BATCH, 1, 0, 3); RetryPolicy.RetryDecision retryExpected = RetryPolicy.RetryDecision.rethrow(); assertRetryDecisionEquals(retryExpected, retryResult); }
@Test public void testShouldAdaptExtractWriteTypes() { for (WriteType w : WriteType.values()) { assertThat(extract(adapt(w))).isSameAs(w); } }
@Override public RetryDecision onWriteTimeout(Statement statement, ConsistencyLevel cl, WriteType writeType, int requiredAcks, int receivedAcks, int nbRetry) { return RetryDecision.retry(ConsistencyLevel.ONE); }
@Override public RetryDecision onWriteTimeout(Statement statement, ConsistencyLevel cl, WriteType writeType, int requiredAcks, int receivedAcks, int nbRetry) { return DefaultRetryPolicy.INSTANCE.onWriteTimeout(statement, cl, writeType, requiredAcks, receivedAcks, nbRetry); }
@Override public RetryDecision onWriteTimeout(Statement statement, ConsistencyLevel cl, WriteType writeType, int requiredAcks, int receivedAcks, int nbRetry) { return RetryDecision.retry(cl); }