Class RetryPolicy.RetryDecision
- java.lang.Object
-
- com.datastax.driver.core.policies.RetryPolicy.RetryDecision
-
- Enclosing interface:
- RetryPolicy
public static class RetryPolicy.RetryDecision extends Object
A retry decision to adopt on a Cassandra exception (read/write timeout or unavailable exception).There are three possible decisions:
- RETHROW: no retry should be attempted and an exception should be thrown.
- RETRY: the operation will be retried. The consistency level of the retry should be specified.
- IGNORE: no retry should be attempted and the exception should be ignored. In that case, the operation that triggered the Cassandra exception will return an empty result set.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRetryPolicy.RetryDecision.TypeThe types of retry decisions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConsistencyLevelgetRetryConsistencyLevel()The consistency level for this retry decision.RetryPolicy.RetryDecision.TypegetType()The type of this retry decision.static RetryPolicy.RetryDecisionignore()Creates anRetryPolicy.RetryDecision.Type.IGNOREretry decision.booleanisRetryCurrent()Whether this decision is to retry the same host.static RetryPolicy.RetryDecisionrethrow()Creates aRetryPolicy.RetryDecision.Type.RETHROWretry decision.static RetryPolicy.RetryDecisionretry(ConsistencyLevel consistency)Creates aRetryPolicy.RetryDecision.Type.RETRYretry decision using the same host and the provided consistency level.StringtoString()static RetryPolicy.RetryDecisiontryNextHost(ConsistencyLevel consistency)Creates aRetryPolicy.RetryDecision.Type.RETRYretry decision using the next host in the query plan, and using the provided consistency level.
-
-
-
Method Detail
-
getType
public RetryPolicy.RetryDecision.Type getType()
The type of this retry decision.- Returns:
- the type of this retry decision.
-
getRetryConsistencyLevel
public ConsistencyLevel getRetryConsistencyLevel()
The consistency level for this retry decision. This is only meaningful forRETRYdecisions. The consistency level is alwaysnullfor anIGNOREor aRETHROWdecision; for aRETRYdecision, the consistency level can benull, in which case the retry is done at the same consistency level as in the previous attempt.- Returns:
- the consistency level for a retry decision.
-
isRetryCurrent
public boolean isRetryCurrent()
Whether this decision is to retry the same host. This is only meaningful forRETRYdecisions.- Returns:
trueif the decision is to retry the same host,falseotherwise. Default isfalse.
-
rethrow
public static RetryPolicy.RetryDecision rethrow()
Creates aRetryPolicy.RetryDecision.Type.RETHROWretry decision.- Returns:
- a
RetryPolicy.RetryDecision.Type.RETHROWretry decision.
-
retry
public static RetryPolicy.RetryDecision retry(ConsistencyLevel consistency)
Creates aRetryPolicy.RetryDecision.Type.RETRYretry decision using the same host and the provided consistency level.If the provided consistency level is
null, the retry will be done at the same consistency level as the previous attempt.Beware that
serialconsistency levels should never be passed to this method; attempting to do so would trigger anInvalidQueryException.- Parameters:
consistency- the consistency level to use for the retry; ifnull, the same level as the previous attempt will be used.- Returns:
- a
RetryPolicy.RetryDecision.Type.RETRYdecision using the same host and the provided consistency level
-
ignore
public static RetryPolicy.RetryDecision ignore()
Creates anRetryPolicy.RetryDecision.Type.IGNOREretry decision.- Returns:
- an
RetryPolicy.RetryDecision.Type.IGNOREretry decision.
-
tryNextHost
public static RetryPolicy.RetryDecision tryNextHost(ConsistencyLevel consistency)
Creates aRetryPolicy.RetryDecision.Type.RETRYretry decision using the next host in the query plan, and using the provided consistency level.If the provided consistency level is
null, the retry will be done at the same consistency level as the previous attempt.Beware that
serialconsistency levels should never be passed to this method; attempting to do so would trigger anInvalidQueryException.- Parameters:
consistency- the consistency level to use for the retry; ifnull, the same level as the previous attempt will be used.- Returns:
- a
RetryPolicy.RetryDecision.Type.RETRYretry decision using the next host in the query plan, and using the provided consistency level.
-
-