Skip to content

Instantly share code, notes, and snippets.

@kluyg
Created July 13, 2015 22:26
Show Gist options
  • Save kluyg/46ae3dee9000a358edf9 to your computer and use it in GitHub Desktop.
Save kluyg/46ae3dee9000a358edf9 to your computer and use it in GitHub Desktop.
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