Esempio n. 1
0
        /// <summary>
        /// Gets the retry decision based on the exception from Cassandra
        /// </summary>
        public RetryDecision GetRetryDecision(Exception ex)
        {
            RetryDecision decision = RetryDecision.Rethrow();

            if (ex is SocketException)
            {
                decision = RetryDecision.Retry(null);
            }
            else if (ex is OverloadedException || ex is IsBootstrappingException || ex is TruncateException)
            {
                decision = RetryDecision.Retry(null);
            }
            else if (ex is ReadTimeoutException)
            {
                var e = ex as ReadTimeoutException;
                decision = _retryPolicy.OnReadTimeout(_statement, e.ConsistencyLevel, e.RequiredAcknowledgements, e.ReceivedAcknowledgements, e.WasDataRetrieved, _retryCount);
            }
            else if (ex is WriteTimeoutException)
            {
                var e = ex as WriteTimeoutException;
                decision = _retryPolicy.OnWriteTimeout(_statement, e.ConsistencyLevel, e.WriteType, e.RequiredAcknowledgements, e.ReceivedAcknowledgements, _retryCount);
            }
            else if (ex is UnavailableException)
            {
                var e = ex as UnavailableException;
                decision = _retryPolicy.OnUnavailable(_statement, e.Consistency, e.RequiredReplicas, e.AliveReplicas, _retryCount);
            }
            return(decision);
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the retry decision based on the exception from Cassandra
        /// </summary>
        public static RetryDecision GetRetryDecision(Exception ex, IRetryPolicy policy, IStatement statement, int retryCount)
        {
            var decision = RetryDecision.Rethrow();

            if (ex is SocketException)
            {
                decision = RetryDecision.Retry(null, false);
            }
            else if (ex is OverloadedException || ex is IsBootstrappingException || ex is TruncateException)
            {
                decision = RetryDecision.Retry(null, false);
            }
            else if (ex is ReadTimeoutException)
            {
                var e = (ReadTimeoutException)ex;
                decision = policy.OnReadTimeout(statement, e.ConsistencyLevel, e.RequiredAcknowledgements, e.ReceivedAcknowledgements, e.WasDataRetrieved, retryCount);
            }
            else if (ex is WriteTimeoutException)
            {
                var e = (WriteTimeoutException)ex;
                decision = policy.OnWriteTimeout(statement, e.ConsistencyLevel, e.WriteType, e.RequiredAcknowledgements, e.ReceivedAcknowledgements, retryCount);
            }
            else if (ex is UnavailableException)
            {
                var e = (UnavailableException)ex;
                decision = policy.OnUnavailable(statement, e.Consistency, e.RequiredReplicas, e.AliveReplicas, retryCount);
            }
            return(decision);
        }
        public RetryDecision OnUnavailable(Query query, ConsistencyLevel cl, int requiredReplica, int aliveReplica, int nbRetry)
        {
            RetryDecision decision = _policy.OnUnavailable(query, cl, requiredReplica, aliveReplica, nbRetry);

            switch (decision.DecisionType)
            {
            case RetryDecision.RetryDecisionType.Ignore:
                _logger.Info(string.Format("Ignoring unavailable exception (initial consistency: {0}, required replica: {1}, alive replica: {2}, retries: {3})", cl, requiredReplica, aliveReplica, nbRetry));
                break;

            case RetryDecision.RetryDecisionType.Retry:
                _logger.Info(string.Format("Retrying on unavailable exception at consistency {0} (initial consistency: {1}, required replica: {2}, alive replica: {3}, retries: {4})", CL(cl, decision), cl, requiredReplica, aliveReplica, nbRetry));
                break;
            }
            return(decision);
        }
Esempio n. 4
0
 /// <inheritdoc />
 public RetryDecision OnUnavailable(IStatement stmt, ConsistencyLevel cl, int requiredReplica, int aliveReplica, int nbRetry)
 {
     return(_childPolicy.OnUnavailable(stmt, cl, requiredReplica, aliveReplica, nbRetry));
 }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
 public RetryDecision OnUnavailable(IStatement query, ConsistencyLevel cl, int requiredReplica,
                                    int aliveReplica, int nbRetry)
 {
     return(_policy.OnUnavailable(query, cl, requiredReplica, aliveReplica, nbRetry));
 }