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.AbortTriggerA function to call to abort the timer.static final intstatic final intThe maximum jitter random number.protected final AbstractSourceTask.SupplierOfLongA supplier of the time remaining (in milliseconds) on the overriding timer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidLikedelay()but swallows theInterruptedException.voiddelay()Delay execution based on the number of times this method has been called.longCalculates the delay without jitter.intCalculates the range of jitter in milliseconds.final voidreset()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
-