public class KafkaSpoutRetryExponentialBackoff extends Object implements KafkaSpoutRetryService
Implementation of KafkaSpoutRetryService
using the exponential backoff formula. The time of the nextRetry is set as follows: nextRetry = failCount == 1 ? currentTime + initialDelay : currentTime + delayPeriod^(failCount-1) where failCount = 1, 2, 3, … nextRetry = Min(nextRetry, currentTime + maxDelay)
Modifier and Type | Class and Description |
---|---|
static class |
KafkaSpoutRetryExponentialBackoff.TimeInterval |
Constructor and Description |
---|
KafkaSpoutRetryExponentialBackoff(KafkaSpoutRetryExponentialBackoff.TimeInterval initialDelay,
KafkaSpoutRetryExponentialBackoff.TimeInterval delayPeriod,
int maxRetries,
KafkaSpoutRetryExponentialBackoff.TimeInterval maxDelay)
The time stamp of the next retry is scheduled according to the exponential backoff formula ( geometric progression): nextRetry = failCount == 1 ? currentTime + initialDelay : currentTime + delayPeriod^(failCount-1) where failCount = 1, 2, 3, … nextRetry = Min(nextRetry, currentTime + maxDelay)
|
Modifier and Type | Method and Description |
---|---|
boolean |
isReady(KafkaSpoutMessageId msgId)
Checks if a specific failed
KafkaSpoutMessageId is is ready to be retried, i.e is scheduled and has retry time that is less than current time. |
boolean |
isScheduled(KafkaSpoutMessageId msgId)
Checks if a specific failed
KafkaSpoutMessageId is scheduled to be retried. |
boolean |
remove(KafkaSpoutMessageId msgId)
Removes a message from the list of messages scheduled for retrial
|
boolean |
retainAll(Collection<org.apache.kafka.common.TopicPartition> topicPartitions)
Retains all the messages whose
TopicPartition belongs to the specified Collection<TopicPartition> . |
Set<org.apache.kafka.common.TopicPartition> |
retriableTopicPartitions() |
void |
schedule(KafkaSpoutMessageId msgId)
Schedules this
KafkaSpoutMessageId if not yet scheduled, or updates retry time if it has already been scheduled. |
String |
toString() |
public KafkaSpoutRetryExponentialBackoff(KafkaSpoutRetryExponentialBackoff.TimeInterval initialDelay, KafkaSpoutRetryExponentialBackoff.TimeInterval delayPeriod, int maxRetries, KafkaSpoutRetryExponentialBackoff.TimeInterval maxDelay)
The time stamp of the next retry is scheduled according to the exponential backoff formula ( geometric progression): nextRetry = failCount == 1 ? currentTime + initialDelay : currentTime + delayPeriod^(failCount-1) where failCount = 1, 2, 3, … nextRetry = Min(nextRetry, currentTime + maxDelay)
initialDelay
- initial delay of the first retrydelayPeriod
- the time interval that is the ratio of the exponential backoff formula (geometric progression)maxRetries
- maximum number of times a tuple is retried before being acked and scheduled for commitmaxDelay
- maximum amount of time waiting before retryingpublic Set<org.apache.kafka.common.TopicPartition> retriableTopicPartitions()
retriableTopicPartitions
in interface KafkaSpoutRetryService
public boolean isReady(KafkaSpoutMessageId msgId)
KafkaSpoutRetryService
Checks if a specific failed KafkaSpoutMessageId
is is ready to be retried, i.e is scheduled and has retry time that is less than current time.
isReady
in interface KafkaSpoutRetryService
public boolean isScheduled(KafkaSpoutMessageId msgId)
KafkaSpoutRetryService
Checks if a specific failed KafkaSpoutMessageId
is scheduled to be retried. The message may or may not be ready to be retried yet.
isScheduled
in interface KafkaSpoutRetryService
public boolean remove(KafkaSpoutMessageId msgId)
KafkaSpoutRetryService
Removes a message from the list of messages scheduled for retrial
remove
in interface KafkaSpoutRetryService
msgId
- message to remove from retrialpublic boolean retainAll(Collection<org.apache.kafka.common.TopicPartition> topicPartitions)
KafkaSpoutRetryService
Retains all the messages whose TopicPartition
belongs to the specified Collection<TopicPartition>
. All messages that come from a TopicPartition
NOT existing in the collection will be removed. This method is useful to cleanup state following partition rebalance.
retainAll
in interface KafkaSpoutRetryService
topicPartitions
- Collection of TopicPartition
for which to keep messagespublic void schedule(KafkaSpoutMessageId msgId)
KafkaSpoutRetryService
Schedules this KafkaSpoutMessageId
if not yet scheduled, or updates retry time if it has already been scheduled.
schedule
in interface KafkaSpoutRetryService
msgId
- message to schedule for retrialCopyright © 2016 The Apache Software Foundation. All Rights Reserved.