Skip to content

Instantly share code, notes, and snippets.

@rbramwell
Forked from kluyg/MyRetryPolicy.scala
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbramwell/e1bbe38c2a9768f5d24f to your computer and use it in GitHub Desktop.
Save rbramwell/e1bbe38c2a9768f5d24f 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