Class: RetryPolicy

policies/retry~ RetryPolicy

Constructor

new RetryPolicy()

Base and default RetryPolicy. Determines what to do when the drivers runs into an specific Cassandra exception

Members

(static) retryDecision :Object

Determines the retry decision for the retry policies.
Type:
  • Object

Methods

onReadTimeout(requestInfo, consistency, received, blockFor, isDataPresent) → {DecisionInfo}

Determines what to do when the driver gets a ReadTimeoutException response from a Cassandra node.
Parameters:
Name Type Description
requestInfo Object
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
DecisionInfo

onRequestError(requestInfo, consistency, err) → {DecisionInfo}

Defines whether to retry and at which consistency level on an unexpected error.

This method might be invoked in the following situations:

  1. On a client timeout, while waiting for the server response (see socketOptions.readTimeout), being the error an instance of OperationTimedOutError.
  2. On a connection error (socket closed, etc.).
  3. When the contacted host replies with an error, such as overloaded, isBootstrapping, serverError, etc. In this case, the error is instance of ResponseError.

Note that when this method is invoked, the driver cannot guarantee that the mutation has been effectively applied server-side; a retry should only be attempted if the request is known to be idempotent.

Parameters:
Name Type Description
requestInfo Object
consistency Number | undefined The consistency level of the query that triggered the exception.
err Error The error that caused this request to fail.
Returns:
Type
DecisionInfo

onUnavailable(requestInfo, consistency, required, alive) → {DecisionInfo}

Determines what to do when the driver gets an UnavailableException response from a Cassandra node.
Parameters:
Name Type Description
requestInfo Object
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
DecisionInfo

onWriteTimeout(requestInfo, consistency, received, blockFor, writeType) → {DecisionInfo}

Determines what to do when the driver gets a WriteTimeoutException response from a Cassandra node.
Parameters:
Name Type Description
requestInfo Object
consistency Number The consistency level of the query that triggered the exception.
received Number The number of nodes having acknowledged the request.
blockFor Number The number of replicas whose acknowledgement is required to achieve the required consistency.
writeType String A string that describes the type of the write that timed out ("SIMPLE" / "BATCH" / "BATCH_LOG" / "UNLOGGED_BATCH" / "COUNTER").
Returns:
Type
DecisionInfo

rethrowResult() → {DecisionInfo}

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

retryResult(consistencyopt, useCurrentHostopt) → {DecisionInfo}

Returns a DecisionInfo to retry the request with the given consistency.
Parameters:
Name Type Attributes Description
consistency Number | undefined <optional>
When specified, it retries the request with the given consistency.
useCurrentHost Boolean <optional>
When specified, determines if the retry should be made using the same coordinator. Default: true.
Returns:
Type
DecisionInfo