Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class MyRetryPolicy(maxRetries: Int) extends RetryPolicy {
override def onReadTimeout(statement: Statement,
cl: ConsistencyLevel,
requiredResponses: Int,
receivedResponses: Int,
dataRetrieved: Boolean,
nbRetry: Int): RetryDecision = {
if (nbRetry < maxRetries) RetryDecision.retry(cl) else RetryDecision.rethrow()
}
override def onUnavailable(statement: Statement,
cl: ConsistencyLevel,
requiredReplica: Int,
aliveReplica: Int,
nbRetry: Int): RetryDecision = {
if (nbRetry < maxRetries) RetryDecision.retry(cl) else RetryDecision.rethrow()
}
override def onWriteTimeout(statement: Statement,
cl: ConsistencyLevel,
writeType: WriteType,
requiredAcks: Int,
receivedAcks: Int,
nbRetry: Int): RetryDecision = {
if (nbRetry < maxRetries) RetryDecision.retry(cl) else RetryDecision.rethrow()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment