Class AbstractSourceTask.Backoff
java.lang.Object
io.aiven.kafka.connect.common.source.AbstractSourceTask.Backoff
- Enclosing class:
- AbstractSourceTask
Performs a delay based on the number of successive
delay()
or cleanDelay()
calls without a
reset()
. Delay increases exponentially but never exceeds the time remaining by more than 0.512 seconds.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AbstractSourceTask.AbortTrigger
A function to call to abort the timer.static final int
static final int
The maximum jitter random number.protected final AbstractSourceTask.SupplierOfLong
A supplier of the time remaining (in milliseconds) on the overriding timer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Likedelay()
but swallows theInterruptedException
.void
delay()
Delay execution based on the number of times this method has been called.long
Calculates the delay without jitter.int
Calculates the range of jitter in milliseconds.final void
reset()
Reset the backoff time so that delay is again at the minimum.toString()
-
Field Details
-
MAX_JITTER
public static final int MAX_JITTERThe maximum jitter random number. Should be a power of 2 for speed.- See Also:
-
JITTER_SUBTRAHEND
public static final int JITTER_SUBTRAHEND- See Also:
-
timeRemaining
A supplier of the time remaining (in milliseconds) on the overriding timer. -
abortTrigger
A function to call to abort the timer.
-
-
Constructor Details
-
Backoff
Constructor.- Parameters:
config
- The configuration for the backoff.
-
-
Method Details
-
reset
public final void reset()Reset the backoff time so that delay is again at the minimum. -
estimatedDelay
public long estimatedDelay()Calculates the delay without jitter.- Returns:
- the number of milliseconds the delay will be.
-
getMaxJitter
public int getMaxJitter()Calculates the range of jitter in milliseconds.- Returns:
- the maximum jitter in milliseconds. jitter is +/- maximum jitter.
-
delay
Delay execution based on the number of times this method has been called.- Throws:
InterruptedException
- If any thread interrupts this thread.
-
cleanDelay
public void cleanDelay()Likedelay()
but swallows theInterruptedException
. -
toString
-