com.datastax.driver.core.policies
Class LoggingRetryPolicy

java.lang.Object
  extended by com.datastax.driver.core.policies.LoggingRetryPolicy
All Implemented Interfaces:
RetryPolicy

public class LoggingRetryPolicy
extends Object
implements RetryPolicy

A retry policy that wraps another policy, logging the decision made by its sub-policy.

Note that this policy only log the IGNORE and RETRY decisions (since RETHROW decisions are just meant to propagate the cassandra exception). The logging is done at the INFO level.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.datastax.driver.core.policies.RetryPolicy
RetryPolicy.RetryDecision
 
Constructor Summary
LoggingRetryPolicy(RetryPolicy policy)
          Creates a new RetryPolicy that logs the decision of policy.
 
Method Summary
 RetryPolicy.RetryDecision onReadTimeout(Statement statement, ConsistencyLevel cl, int requiredResponses, int receivedResponses, boolean dataRetrieved, int nbRetry)
          Defines whether to retry and at which consistency level on a read timeout.
 RetryPolicy.RetryDecision onUnavailable(Statement statement, ConsistencyLevel cl, int requiredReplica, int aliveReplica, int nbRetry)
          Defines whether to retry and at which consistency level on an unavailable exception.
 RetryPolicy.RetryDecision onWriteTimeout(Statement statement, ConsistencyLevel cl, WriteType writeType, int requiredAcks, int receivedAcks, int nbRetry)
          Defines whether to retry and at which consistency level on a write timeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingRetryPolicy

public LoggingRetryPolicy(RetryPolicy policy)
Creates a new RetryPolicy that logs the decision of policy.

Parameters:
policy - the policy to wrap. The policy created by this constructor will return the same decision than policy but will log them.
Method Detail

onReadTimeout

public RetryPolicy.RetryDecision onReadTimeout(Statement statement,
                                               ConsistencyLevel cl,
                                               int requiredResponses,
                                               int receivedResponses,
                                               boolean dataRetrieved,
                                               int nbRetry)
Description copied from interface: RetryPolicy
Defines whether to retry and at which consistency level on a read timeout.

Note that this method may be called even if requiredResponses >= receivedResponses if dataPresent is false (see ReadTimeoutException.wasDataRetrieved()).

Specified by:
onReadTimeout in interface RetryPolicy
Parameters:
statement - the original query that timeouted.
cl - the original consistency level of the read that timeouted.
requiredResponses - the number of responses that were required to achieve the requested consistency level.
receivedResponses - the number of responses that had been received by the time the timeout exception was raised.
dataRetrieved - whether actual data (by opposition to data checksum) was present in the received responses.
nbRetry - the number of retry already performed for this operation.
Returns:
the retry decision. If RetryDecision.RETHROW is returned, a ReadTimeoutException will be thrown for the operation.

onWriteTimeout

public RetryPolicy.RetryDecision onWriteTimeout(Statement statement,
                                                ConsistencyLevel cl,
                                                WriteType writeType,
                                                int requiredAcks,
                                                int receivedAcks,
                                                int nbRetry)
Description copied from interface: RetryPolicy
Defines whether to retry and at which consistency level on a write timeout.

Specified by:
onWriteTimeout in interface RetryPolicy
Parameters:
statement - the original query that timeouted.
cl - the original consistency level of the write that timeouted.
writeType - the type of the write that timeouted.
requiredAcks - the number of acknowledgments that were required to achieve the requested consistency level.
receivedAcks - the number of acknowledgments that had been received by the time the timeout exception was raised.
nbRetry - the number of retry already performed for this operation.
Returns:
the retry decision. If RetryDecision.RETHROW is returned, a WriteTimeoutException will be thrown for the operation.

onUnavailable

public RetryPolicy.RetryDecision onUnavailable(Statement statement,
                                               ConsistencyLevel cl,
                                               int requiredReplica,
                                               int aliveReplica,
                                               int nbRetry)
Description copied from interface: RetryPolicy
Defines whether to retry and at which consistency level on an unavailable exception.

Specified by:
onUnavailable in interface RetryPolicy
Parameters:
statement - the original query for which the consistency level cannot be achieved.
cl - the original consistency level for the operation.
requiredReplica - the number of replica that should have been (known) alive for the operation to be attempted.
aliveReplica - the number of replica that were know to be alive by the coordinator of the operation.
nbRetry - the number of retry already performed for this operation.
Returns:
the retry decision. If RetryDecision.RETHROW is returned, an UnavailableException will be thrown for the operation.


Copyright © 2013. All rights reserved.