static RetryDecision GetRetryDecision(Query query, QueryValidationException exc, IRetryPolicy policy, int queryRetries) { if (exc is OverloadedException) { return(RetryDecision.Retry(null)); } else if (exc is IsBootstrappingException) { return(RetryDecision.Retry(null)); } else if (exc is TruncateException) { return(RetryDecision.Retry(null)); } else if (exc is ReadTimeoutException) { var e = exc as ReadTimeoutException; return(policy.OnReadTimeout(query, e.ConsistencyLevel, e.RequiredAcknowledgements, e.ReceivedAcknowledgements, e.WasDataRetrieved, queryRetries)); } else if (exc is WriteTimeoutException) { var e = exc as WriteTimeoutException; return(policy.OnWriteTimeout(query, e.ConsistencyLevel, e.WriteType, e.RequiredAcknowledgements, e.ReceivedAcknowledgements, queryRetries)); } else if (exc is UnavailableException) { var e = exc as UnavailableException; return(policy.OnUnavailable(query, e.Consistency, e.RequiredReplicas, e.AliveReplicas, queryRetries)); } else if (exc is AlreadyExistsException) { return(RetryDecision.Rethrow()); } else if (exc is InvalidConfigurationInQueryException) { return(RetryDecision.Rethrow()); } else if (exc is PreparedQueryNotFoundException) { return(RetryDecision.Rethrow()); } else if (exc is ProtocolErrorException) { return(RetryDecision.Rethrow()); } else if (exc is InvalidQueryException) { return(RetryDecision.Rethrow()); } else if (exc is UnauthorizedException) { return(RetryDecision.Rethrow()); } else if (exc is SyntaxError) { return(RetryDecision.Rethrow()); } else if (exc is ServerErrorException) { return(null); } else { return(null); } }
private static ConsistencyLevel CL(ConsistencyLevel cl, RetryDecision decision) { return(decision.RetryConsistencyLevel ?? cl); }
/// <summary> /// Defines whether to retry and at which consistency level on an unavailable /// exception. <p> This method triggers a maximum of one retry. If at least one /// replica is know to be alive, the operation is retried at a lower consistency /// level.</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>a RetryDecision as defined above.</returns> public RetryDecision OnUnavailable(IStatement query, ConsistencyLevel cl, int requiredReplica, int aliveReplica, int nbRetry) { return(nbRetry != 0 ? RetryDecision.Rethrow() : MaxLikelyToWorkCl(aliveReplica)); // Tries the biggest CL that is expected to work }
private static ConsistencyLevel CL(ConsistencyLevel cl, RetryDecision decision) { return decision.RetryConsistencyLevel ?? cl; }
/// <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()); }
/// <summary> /// Defines whether to retry and at which consistency level on a read timeout. /// </summary> /// <param name="query"> the original query that timeouted. </param> /// <param name="cl"> the original consistency level of the read that timeouted. /// </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.rethrow()</c>.</returns> public RetryDecision OnReadTimeout(IStatement query, ConsistencyLevel cl, int requiredResponses, int receivedResponses, bool dataRetrieved, int nbRetry) { return(RetryDecision.Rethrow()); }