A retry policy that avoids retrying non-idempotent statements.

In case of write timeouts or unexpected errors, this policy will always return rethrowResult() if the statement is deemed non-idempotent (see QueryOptions.isIdempotent).

For all other cases, this policy delegates the decision to the child policy.

Augments

Constructor

new

IdempotenceAwareRetryPolicy

([RetryPolicy childPolicy])

Creates a new instance of IdempotenceAwareRetryPolicy.

Parameters:
Name Type Description
childPolicy optional RetryPolicy

The child retry policy to wrap. When not defined, it will use an instance of RetryPolicy as child policy.

Methods

onReadTimeout

(OperationInfo info, Number consistency, Number received, Number blockFor, Boolean isDataPresent)

Determines what to do when the driver gets a ReadTimeoutException response from a Cassandra node.

Parameters:
Name Type Description
info OperationInfo
consistency Number

The consistency level of the query that triggered the exception.

received Number

The number of nodes having answered the request.

blockFor Number

The number of replicas whose response is required to achieve the required consistency.

isDataPresent Boolean

When false, it means the replica that was asked for data has not responded.

Returns:
Type Description
DecisionInfo

onRequestError

()

If the query is not idempotent, it returns a rethrow decision. Otherwise, it relies on the child policy to decide.

onUnavailable

(OperationInfo info, Number consistency, Number required, Number alive)

Determines what to do when the driver gets an UnavailableException response from a Cassandra node.

Parameters:
Name Type Description
info OperationInfo
consistency Number

The consistency level of the query that triggered the exception.

required Number

The number of replicas whose response is required to achieve the required consistency.

alive Number

The number of replicas that were known to be alive when the request had been processed (since an unavailable exception has been triggered, there will be alive < required)

Returns:
Type Description
DecisionInfo

onWriteTimeout

()

If the query is not idempotent, it return a rethrow decision. Otherwise, it relies on the child policy to decide.

rethrowResult

()

Returns a DecisionInfo to callback in error when a err is obtained for a given request.

Returns:
Type Description
DecisionInfo

retryResult

([Number or undefined consistency], [Boolean useCurrentHost])

Returns a DecisionInfo to retry the request with the given consistency.

Parameters:
Name Type Description
consistency optional Number or undefined

When specified, it retries the request with the given consistency.

useCurrentHost optional Boolean

When specified, determines if the retry should be made using the same coordinator. Default: true.

Returns:
Type Description
DecisionInfo