Interface AutoScaling.Trigger
-
- All Superinterfaces:
AutoCloseable
,Closeable
,Runnable
- All Known Implementing Classes:
IndexSizeTrigger
,MetricTrigger
,NodeAddedTrigger
,NodeLostTrigger
,ScheduledTrigger
,SearchRateTrigger
,TriggerBase
- Enclosing class:
- AutoScaling
public static interface AutoScaling.Trigger extends Closeable, Runnable
Interface for a Solr trigger. Each trigger implements Runnable and Closeable interface. A trigger is scheduled using aScheduledExecutorService
so it is executed as per a configured schedule to check whether the trigger is ready to fire. ThesetProcessor(AutoScaling.TriggerEventProcessor)
method should be used to set a processor which is used by implementation of this class whenever ready.As per the guarantees made by the
ScheduledExecutorService
a trigger implementation is only ever called sequentially and therefore need not be thread safe. However, it is encouraged that implementations be immutable with the exception of the associated listener which can be get/set by a different thread than the one executing the trigger. Therefore, implementations should use appropriate synchronization around the listener.When a trigger is ready to fire, it calls the
AutoScaling.TriggerEventProcessor.process(TriggerEvent)
event with the proper trigger event object. If that method returns false then it should be interpreted to mean that Solr is not ready to process this trigger event and therefore we should retain the state and fire at the next invocation of the run() method.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
configure(SolrResourceLoader loader, SolrCloudManager cloudManager, Map<String,Object> properties)
Called when trigger is created but before it's initialized or scheduled for use.List<TriggerAction>
getActions()
Actions to execute when event is fired.TriggerEventType
getEventType()
Event type generated by this trigger.String
getName()
Trigger name.AutoScaling.TriggerEventProcessor
getProcessor()
Get event processor.Map<String,Object>
getProperties()
Trigger properties.int
getWaitForSecond()
Number of seconds to wait between fired events ("waitFor" property).void
init()
Called before a trigger is scheduled.boolean
isClosed()
Return true when this trigger is closed and cannot be used.boolean
isEnabled()
Returns true if this trigger is enabled.void
restoreState()
Restore internal state of this trigger from ZooKeeper.void
restoreState(AutoScaling.Trigger old)
Set internal state of this trigger from another instance.void
saveState()
Save internal state of this trigger in ZooKeeper.void
setProcessor(AutoScaling.TriggerEventProcessor processor)
Set event processor to call when event is fired.
-
-
-
Method Detail
-
getName
String getName()
Trigger name.
-
getEventType
TriggerEventType getEventType()
Event type generated by this trigger.
-
isEnabled
boolean isEnabled()
Returns true if this trigger is enabled.
-
getWaitForSecond
int getWaitForSecond()
Number of seconds to wait between fired events ("waitFor" property).
-
getActions
List<TriggerAction> getActions()
Actions to execute when event is fired.
-
setProcessor
void setProcessor(AutoScaling.TriggerEventProcessor processor)
Set event processor to call when event is fired.
-
getProcessor
AutoScaling.TriggerEventProcessor getProcessor()
Get event processor.
-
isClosed
boolean isClosed()
Return true when this trigger is closed and cannot be used.
-
restoreState
void restoreState(AutoScaling.Trigger old)
Set internal state of this trigger from another instance.
-
saveState
void saveState()
Save internal state of this trigger in ZooKeeper.
-
restoreState
void restoreState()
Restore internal state of this trigger from ZooKeeper.
-
configure
void configure(SolrResourceLoader loader, SolrCloudManager cloudManager, Map<String,Object> properties) throws TriggerValidationException
Called when trigger is created but before it's initialized or scheduled for use. This method should also verify that the trigger configuration parameters are correct. It may be called multiple times.- Parameters:
properties
- configuration properties- Throws:
TriggerValidationException
- contains details of invalid configuration parameters.
-
-