/// <summary> /// The default implementation triggers a retry on the next host in the query plan with the same consistency level, /// regardless of the statement's idempotence, for historical reasons. /// </summary> public RetryDecision OnRequestError(IStatement statement, Configuration config, Exception ex, int nbRetry) { if (ex is OperationTimedOutException && !config.QueryOptions.RetryOnTimeout) { return(RetryDecision.Rethrow()); } return(RetryDecision.Retry(null, false)); }
/// <inheritdoc /> public RetryDecision OnWriteTimeout(IStatement stmt, ConsistencyLevel cl, string writeType, int requiredAcks, int receivedAcks, int nbRetry) { if (stmt != null && stmt.IsIdempotent == true) { return(_childPolicy.OnWriteTimeout(stmt, cl, writeType, requiredAcks, receivedAcks, nbRetry)); } return(RetryDecision.Rethrow()); }
/// <summary> /// Defines whether to retry and at which consistency level on a write timeout. /// <p> This method triggers a maximum of one retry, and only in the case of a /// <c>WriteType.BATCH_LOG</c> write. The reasoning for the retry in that /// case is that write to the distributed batch log is tried by the coordinator /// of the write against a small subset of all the node alive in the local /// datacenter. Hence, a timeout usually means that none of the nodes in that /// subset were alive but the coordinator hasn't' detected them as dead. By the /// time we get the timeout the dead nodes will likely have been detected as dead /// and the retry has thus a high change of success.</p> /// </summary> /// <param name="query"> the original query that timeouted. </param> /// <param name="cl"> the original consistency level of the write that timeouted. /// </param> /// <param name="writeType"> the type of the write that timeouted. </param> /// <param name="requiredAcks"> the number of acknowledgments that were required /// to achieve the requested consistency level. </param> /// <param name="receivedAcks"> the number of acknowledgments that had been /// received by the time the timeout exception was raised. </param> /// <param name="nbRetry"> the number of retry already performed for this /// operation. </param> /// /// <returns><c>RetryDecision.retry(cl)</c> if no retry attempt has yet /// been tried and <c>writeType == WriteType.BATCH_LOG</c>, /// <c>RetryDecision.rethrow()</c> otherwise.</returns> public RetryDecision OnWriteTimeout(IStatement query, ConsistencyLevel cl, string 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 candidtes return(writeType == "BATCH_LOG" ? RetryDecision.Retry(cl) : RetryDecision.Rethrow()); }
/// <summary> /// Defines whether to retry and at which consistency level on a read timeout. /// <p> This method triggers a maximum of one retry, and only if enough replica /// had responded to the read request but data was not retrieved amongst those. /// Indeed, that case usually means that enough replica are alive to satisfy the /// consistency but the coordinator picked a dead one for data retrieval, not /// having detected that replica as dead yet. The reasoning for retrying then is /// that by the time we get the timeout the dead replica will likely have been /// detected as dead and the retry has a high change of success.</p> /// </summary> /// <param name="query"> the original query that timed out. </param> /// <param name="cl"> the original consistency level of the read that timed out. /// </param> /// <param name="requiredResponses"> the number of responses that were required /// to achieve the requested consistency level. </param> /// <param name="receivedResponses"> the number of responses that had been /// received by the time the timeout exception was raised. </param> /// <param name="dataRetrieved"> whether actual data (by opposition to data /// checksum) was present in the received responses. </param> /// <param name="nbRetry"> the number of retry already performed for this /// operation. </param> /// /// <returns><c>RetryDecision.Retry(cl)</c> if no retry attempt has yet /// been tried and <c>receivedResponses >= requiredResponses && /// !dataRetrieved</c>, <c>RetryDecision.Rethrow()</c> /// otherwise.</returns> public RetryDecision OnReadTimeout(IStatement query, ConsistencyLevel cl, int requiredResponses, int receivedResponses, bool dataRetrieved, int nbRetry) { if (nbRetry != 0) { return(RetryDecision.Rethrow()); } return(receivedResponses >= requiredResponses && !dataRetrieved ? RetryDecision.Retry(cl) : RetryDecision.Rethrow()); }
/// <inheritdoc /> public RetryDecision OnRequestError(IStatement stmt, Configuration config, Exception ex, int nbRetry) { if (stmt != null && stmt.IsIdempotent == true) { if (_extendedChildPolicy != null) { return(_extendedChildPolicy.OnRequestError(stmt, config, ex, nbRetry)); } return(RetryDecision.Retry(null, false)); } return(RetryDecision.Rethrow()); }
/// <summary> /// Defines whether to retry and at which consistency level on an unavailable /// exception. <p> This method never retries as a retry on an unavailable /// exception using the same consistency level has almost no change of success.</p> /// </summary> /// <param name="query"> the original query for which the consistency level /// cannot be achieved. </param> /// <param name="cl"> the original consistency level for the operation. </param> /// <param name="requiredReplica"> the number of replica that should have been /// (known) alive for the operation to be attempted. </param> /// <param name="aliveReplica"> the number of replica that were know to be alive /// by the coordinator of the operation. </param> /// <param name="nbRetry"> the number of retry already performed for this /// operation. </param> /// <returns><c>RetryDecision.rethrow()</c>.</returns> public RetryDecision OnUnavailable(IStatement query, ConsistencyLevel cl, int requiredReplica, int aliveReplica, int nbRetry) { return(RetryDecision.Rethrow()); }
/// <inheritdoc /> public RetryDecision OnRequestError(IStatement statement, Configuration config, Exception ex, int nbRetry) { return(RetryDecision.Rethrow()); }
/// <summary> /// Defines whether to retry and at which consistency level on a write timeout. /// </summary> /// <param name="query"> the original query that timeouted. </param> /// <param name="cl"> the original consistency level of the write that timeouted. /// </param> /// <param name="writeType"> the type of the write that timeouted. </param> /// <param name="requiredAcks"> the number of acknowledgments that were required /// to achieve the requested consistency level. </param> /// <param name="receivedAcks"> the number of acknowledgments that had been /// received by the time the timeout exception was raised. </param> /// <param name="nbRetry"> the number of retry already performed for this /// operation. </param> /// /// <returns><c>RetryDecision.rethrow()</c>.</returns> public RetryDecision OnWriteTimeout(IStatement query, ConsistencyLevel cl, string writeType, int requiredAcks, int receivedAcks, int nbRetry) { return(RetryDecision.Rethrow()); }