Class ScheduledTriggers
- java.lang.Object
-
- org.apache.solr.cloud.autoscaling.ScheduledTriggers
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class ScheduledTriggers extends Object implements Closeable
Responsible for scheduling active triggers, starting and stopping them and performing actions when they fire
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_ACTION_THROTTLE_PERIOD_SECONDS
static int
DEFAULT_COOLDOWN_PERIOD_SECONDS
static int
DEFAULT_SCHEDULED_TRIGGER_DELAY_SECONDS
static int
DEFAULT_TRIGGER_CORE_POOL_SIZE
protected static Random
RANDOM
-
Constructor Summary
Constructors Constructor Description ScheduledTriggers(SolrResourceLoader loader, SolrCloudManager cloudManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(AutoScaling.Trigger newTrigger)
Adds a new trigger or replaces an existing one.void
addAdditionalListener(TriggerListener listener)
Add a temporary listener for internal use (tests, simulation).void
close()
Set<String>
getScheduledTriggerNames()
AutoScaling.Trigger
getTrigger(String name)
For use in white/grey box testing: The Trigger returned may be inspected, but should not be modified in any way.void
pauseTriggers()
Pauses all scheduled trigger invocations without interrupting any that are in progressvoid
remove(String triggerName)
Removes and stops the trigger with the given name.void
removeAdditionalListener(TriggerListener listener)
Remove a temporary listener for internal use (tests, simulation).void
removeAll()
Remove and stop all triggers.void
resumeTriggers(long afterDelayMillis)
Resumes all previously cancelled triggers to be scheduled after the given initial delayvoid
setAutoScalingConfig(AutoScalingConfig autoScalingConfig)
Set the current autoscaling config.
-
-
-
Field Detail
-
DEFAULT_SCHEDULED_TRIGGER_DELAY_SECONDS
public static final int DEFAULT_SCHEDULED_TRIGGER_DELAY_SECONDS
- See Also:
- Constant Field Values
-
DEFAULT_ACTION_THROTTLE_PERIOD_SECONDS
public static final int DEFAULT_ACTION_THROTTLE_PERIOD_SECONDS
- See Also:
- Constant Field Values
-
DEFAULT_COOLDOWN_PERIOD_SECONDS
public static final int DEFAULT_COOLDOWN_PERIOD_SECONDS
- See Also:
- Constant Field Values
-
DEFAULT_TRIGGER_CORE_POOL_SIZE
public static final int DEFAULT_TRIGGER_CORE_POOL_SIZE
- See Also:
- Constant Field Values
-
RANDOM
protected static final Random RANDOM
-
-
Constructor Detail
-
ScheduledTriggers
public ScheduledTriggers(SolrResourceLoader loader, SolrCloudManager cloudManager)
-
-
Method Detail
-
setAutoScalingConfig
public void setAutoScalingConfig(AutoScalingConfig autoScalingConfig)
Set the current autoscaling config. This is invoked byOverseerTriggerThread
when autoscaling.json is updated, and it re-initializes trigger listeners and other properties used by the framework- Parameters:
autoScalingConfig
- current autoscaling.json
-
add
public void add(AutoScaling.Trigger newTrigger) throws Exception
Adds a new trigger or replaces an existing one. The replaced trigger, if any, is closed before the new trigger is run. If a trigger is replaced with itself then this operation becomes a no-op.- Parameters:
newTrigger
- the trigger to be managed- Throws:
AlreadyClosedException
- if this class has already been closedException
-
pauseTriggers
public void pauseTriggers()
Pauses all scheduled trigger invocations without interrupting any that are in progress- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
resumeTriggers
public void resumeTriggers(long afterDelayMillis)
Resumes all previously cancelled triggers to be scheduled after the given initial delay- Parameters:
afterDelayMillis
- the initial delay in milliseconds after which triggers should be resumed- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
removeAll
public void removeAll()
Remove and stop all triggers. Also cleans up any leftover state / events in ZK.
-
remove
public void remove(String triggerName)
Removes and stops the trigger with the given name. Also cleans up any leftover state / events in ZK.- Parameters:
triggerName
- the name of the trigger to be removed
-
getScheduledTriggerNames
public Set<String> getScheduledTriggerNames()
- Returns:
- an unmodifiable set of names of all triggers being managed by this class
-
getTrigger
public AutoScaling.Trigger getTrigger(String name)
For use in white/grey box testing: The Trigger returned may be inspected, but should not be modified in any way.- Parameters:
name
- the name of an existing trigger- Returns:
- the current scheduled trigger with that name, or null if none exists
- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
addAdditionalListener
public void addAdditionalListener(TriggerListener listener)
Add a temporary listener for internal use (tests, simulation).- Parameters:
listener
- listener instance
-
removeAdditionalListener
public void removeAdditionalListener(TriggerListener listener)
Remove a temporary listener for internal use (tests, simulation).- Parameters:
listener
- listener instance
-
-