@@ -44,9 +44,9 @@ private DefaultRetryPolicy() {
4444 }
4545
4646 /**
47- * Defines whether to retry and at which consistency level on a read timeout.
47+ * {@inheritDoc}
4848 * <p/>
49- * This method triggers a maximum of one retry, and only if enough
49+ * This implementation triggers a maximum of one retry, and only if enough
5050 * replicas had responded to the read request but data was not retrieved
5151 * amongst those. Indeed, that case usually means that enough replica
5252 * are alive to satisfy the consistency but the coordinator picked a
@@ -55,15 +55,6 @@ private DefaultRetryPolicy() {
5555 * timeout the dead replica will likely have been detected as dead and
5656 * the retry has a high chance of success.
5757 *
58- * @param statement the original query that timed out.
59- * @param cl the original consistency level of the read that timed out.
60- * @param requiredResponses the number of responses that were required to
61- * achieve the requested consistency level.
62- * @param receivedResponses the number of responses that had been received
63- * by the time the timeout exception was raised.
64- * @param dataRetrieved whether actual data (by opposition to data checksum)
65- * was present in the received responses.
66- * @param nbRetry the number of retries already performed for this operation.
6758 * @return {@code RetryDecision.retry(cl)} if no retry attempt has yet been tried and
6859 * {@code receivedResponses >= requiredResponses && !dataRetrieved}, {@code RetryDecision.rethrow()} otherwise.
6960 */
@@ -76,9 +67,9 @@ public RetryDecision onReadTimeout(Statement statement, ConsistencyLevel cl, int
7667 }
7768
7869 /**
79- * Defines whether to retry and at which consistency level on a write timeout.
70+ * {@inheritDoc}
8071 * <p/>
81- * This method triggers a maximum of one retry, and only in the case of
72+ * This implementation triggers a maximum of one retry, and only in the case of
8273 * a {@code WriteType.BATCH_LOG} write. The reasoning for the retry in
8374 * that case is that write to the distributed batch log is tried by the
8475 * coordinator of the write against a small subset of all the nodes alive
@@ -88,14 +79,6 @@ public RetryDecision onReadTimeout(Statement statement, ConsistencyLevel cl, int
8879 * nodes will likely have been detected as dead and the retry has thus a
8980 * high chance of success.
9081 *
91- * @param statement the original query that timed out.
92- * @param cl the original consistency level of the write that timed out.
93- * @param writeType the type of the write that timed out.
94- * @param requiredAcks the number of acknowledgments that were required to
95- * achieve the requested consistency level.
96- * @param receivedAcks the number of acknowledgments that had been received
97- * by the time the timeout exception was raised.
98- * @param nbRetry the number of retry already performed for this operation.
9982 * @return {@code RetryDecision.retry(cl)} if no retry attempt has yet been tried and
10083 * {@code writeType == WriteType.BATCH_LOG}, {@code RetryDecision.rethrow()} otherwise.
10184 */
@@ -105,37 +88,27 @@ public RetryDecision onWriteTimeout(Statement statement, ConsistencyLevel cl, Wr
10588 return RetryDecision .rethrow ();
10689
10790 // If the batch log write failed, retry the operation as this might just be we were unlucky at picking candidates
91+ // JAVA-764: testing the write type automatically filters out serial consistency levels as these have always WriteType.CAS.
10892 return writeType == WriteType .BATCH_LOG ? RetryDecision .retry (cl ) : RetryDecision .rethrow ();
10993 }
11094
11195 /**
112- * Defines whether to retry and at which consistency level on an
113- * unavailable exception.
96+ * {@inheritDoc}
11497 * <p/>
115- * This method triggers a retry iff no retry has been executed before
116- * (nbRetry == 0), with
117- * {@link RetryPolicy.RetryDecision#tryNextHost(ConsistencyLevel) RetryDecision.tryNextHost(cl)},
118- * otherwise it throws an exception. The retry will be processed on the next host
119- * in the query plan according to the current Load Balancing Policy.
120- * Where retrying on the same host in the event of an Unavailable exception
121- * has almost no chance of success, if the first replica tried happens to
122- * be "network" isolated from all the other nodes but can still answer to
123- * the client, it makes sense to retry the query on another node.
124- *
125- * @param statement the original query for which the consistency level cannot
126- * be achieved.
127- * @param cl the original consistency level for the operation.
128- * @param requiredReplica the number of replica that should have been
129- * (known) alive for the operation to be attempted.
130- * @param aliveReplica the number of replica that were know to be alive by
131- * the coordinator of the operation.
132- * @param nbRetry the number of retry already performed for this operation.
133- * @return {@code RetryDecision.rethrow()}.
98+ * This implementation does the following:
99+ * <ul>
100+ * <li>if this is the first retry ({@code nbRetry == 0}), it triggers a retry on the next host in the query plan
101+ * with the same consistency level ({@link RetryPolicy.RetryDecision#tryNextHost(ConsistencyLevel) RetryDecision#tryNextHost(null)}.
102+ * The rationale is that the first coordinator might have been network-isolated from all other nodes (thinking
103+ * they're down), but still able to communicate with the client; in that case, retrying on the same host has almost
104+ * no chance of success, but moving to the next host might solve the issue.</li>
105+ * <li>otherwise, the exception is rethrow.</li>
106+ * </ul>
134107 */
135108 @ Override
136109 public RetryDecision onUnavailable (Statement statement , ConsistencyLevel cl , int requiredReplica , int aliveReplica , int nbRetry ) {
137110 return (nbRetry == 0 )
138- ? RetryDecision .tryNextHost (cl )
111+ ? RetryDecision .tryNextHost (null )
139112 : RetryDecision .rethrow ();
140113 }
141114
0 commit comments