Exemplo n.º 1
0
        /// <summary>
        ///  Defines whether to retry and at which consistency level on a write timeout.
        ///  <p> This method triggers a maximum of one retry. If <code>writeType ==
        ///  WriteType.BATCH_LOG</code>, the write is retried with the initial consistency
        ///  level. If <code>writeType == WriteType.UNLOGGED_BATCH</code> and at least one
        ///  replica acknowleged, the write is retried with a lower consistency level
        ///  (with unlogged batch, a write timeout can <b>always</b> mean that part of the
        ///  batch haven't been persisted at' all, even if <code>receivedAcks > 0</code>).
        ///  For other <code>writeType</code>, if we know the write has been persisted on
        ///  at least one replica, we ignore the exception. Otherwise, an exception is
        ///  thrown.</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>a RetryDecision as defined above.</returns>
        public RetryDecision OnWriteTimeout(Query query, ConsistencyLevel cl, string writeType, int requiredAcks, int receivedAcks, int nbRetry)
        {
            if (nbRetry != 0)
            {
                return(RetryDecision.Rethrow());
            }

            switch (writeType)
            {
            case "SIMPLE":
            case "BATCH":
                // Since we provide atomicity there is no point in retrying
                return(RetryDecision.Ignore());

            case "COUNTER":
                // We should not retry counters, period!
                return(RetryDecision.Ignore());

            case "UNLOGGED_BATCH":
                // Since only part of the batch could have been persisted,
                // retry with whatever consistency should allow to persist all
                return(MaxLikelyToWorkCl(receivedAcks));

            case "BATCH_LOG":
                return(RetryDecision.Retry(cl));
            }
            return(RetryDecision.Rethrow());
        }
Exemplo n.º 2
0
 public RetryDecision OnUnavailable(IStatement query, ConsistencyLevel cl, int requiredReplica, int aliveReplica, int nbRetry)
 {
     return(RetryDecision.Ignore());
 }
Exemplo n.º 3
0
 public RetryDecision OnWriteTimeout(IStatement query, ConsistencyLevel cl, string writeType, int requiredAcks, int receivedAcks, int nbRetry)
 {
     return(RetryDecision.Ignore());
 }
Exemplo n.º 4
0
 public RetryDecision OnReadTimeout(IStatement query, ConsistencyLevel cl, int requiredResponses, int receivedResponses, bool dataRetrieved,
                                    int nbRetry)
 {
     return(RetryDecision.Ignore());
 }
Exemplo n.º 5
0
 public RetryDecision OnRequestError(IStatement statement, Configuration config, Exception ex, int nbRetry)
 {
     return(RetryDecision.Ignore());
 }