public class TimedLaunchConstrainer extends java.lang.Object implements LaunchConstrainer
LaunchConstrainer
that requires a minimum number of seconds to elapse between launches, for
rate-limiting purposes.Constructor and Description |
---|
TimedLaunchConstrainer(java.time.Duration minimumDelay)
Create a new constrainer with the given required minimum delay between permanent (destructive) recovery
operations.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canLaunch(RecoveryType recoveryType)
Determines whether the given
RecoveryType
can be launchHappened right now. |
protected long |
getCurrentTimeMs() |
void |
launchHappened(LaunchOfferRecommendation recommendation,
RecoveryType recoveryType)
Invoked every time a task is launchHappened.
|
public TimedLaunchConstrainer(java.time.Duration minimumDelay)
minimumDelay
- Minimum delay between each destructive launchpublic void launchHappened(LaunchOfferRecommendation recommendation, RecoveryType recoveryType)
LaunchConstrainer
We take a Operation
so that frameworks can specify additional metadata, in order to smooth the launch
rate.
launchHappened
in interface LaunchConstrainer
recommendation
- The OfferRecommendation containing the Launch Operation which occurredrecoveryType
- The type of the recovery which has been executedpublic boolean canLaunch(RecoveryType recoveryType)
LaunchConstrainer
RecoveryType
can be launchHappened right now.canLaunch
in interface LaunchConstrainer
recoveryType
- The RecoveryType
to be examinedtrue
if the offer is safe to launch immediately, false if it should waitprotected long getCurrentTimeMs()