예제 #1
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);
            }
        }
예제 #2
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;
        }