public abstract class TriggerBase extends Object implements AutoScaling.Trigger
AutoScaling.Trigger implementations.
It handles state snapshot / restore in ZK.| Modifier and Type | Field and Description |
|---|---|
protected List<TriggerAction> |
actions |
protected SolrCloudManager |
cloudManager |
protected boolean |
enabled |
protected TriggerEventType |
eventType |
protected boolean |
isClosed |
protected Map<String,Object> |
lastState |
protected SolrResourceLoader |
loader |
protected String |
name |
protected AtomicReference<AutoScaling.TriggerEventProcessor> |
processorRef |
protected Map<String,Object> |
properties |
protected Set<String> |
requiredProperties
Set of required property names.
|
protected DistribStateManager |
stateManager |
protected Set<String> |
validProperties
Set of valid property names.
|
protected int |
waitForSecond |
| Modifier | Constructor and Description |
|---|---|
protected |
TriggerBase(TriggerEventType eventType,
String name) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
configure(SolrResourceLoader loader,
SolrCloudManager cloudManager,
Map<String,Object> properties)
Called when trigger is created but before it's initialized or scheduled for use.
|
Map<String,Object> |
deepCopyState()
Returns an immutable deep copy of this trigger's state, suitible for saving.
|
boolean |
equals(Object obj) |
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.
|
protected abstract Map<String,Object> |
getState()
Prepare and return internal state of this trigger in a format suitable for persisting in ZK.
|
int |
getWaitForSecond()
Number of seconds to wait between fired events ("waitFor" property).
|
int |
hashCode() |
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 |
saveState()
Save internal state of this trigger in ZooKeeper.
|
void |
setProcessor(AutoScaling.TriggerEventProcessor processor)
Set event processor to call when event is fired.
|
protected abstract void |
setState(Map<String,Object> state)
Restore internal state of this trigger from properties retrieved from ZK.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitrestoreStateprotected final String name
protected SolrCloudManager cloudManager
protected SolrResourceLoader loader
protected DistribStateManager stateManager
protected final Set<String> validProperties
TriggerUtils.validProperties(Set, String...)protected final Set<String> requiredProperties
TriggerUtils.requiredProperties(Set, Set, String...)
(required properties are also valid properties).protected final TriggerEventType eventType
protected int waitForSecond
protected final AtomicReference<AutoScaling.TriggerEventProcessor> processorRef
protected List<TriggerAction> actions
protected boolean enabled
protected boolean isClosed
protected TriggerBase(TriggerEventType eventType, String name)
public void configure(SolrResourceLoader loader, SolrCloudManager cloudManager, Map<String,Object> properties) throws TriggerValidationException
AutoScaling.Triggerconfigure in interface AutoScaling.Triggerproperties - configuration propertiesTriggerValidationException - contains details of invalid configuration parameters.public void init()
throws Exception
AutoScaling.Triggerinit in interface AutoScaling.TriggerExceptionpublic void setProcessor(AutoScaling.TriggerEventProcessor processor)
AutoScaling.TriggersetProcessor in interface AutoScaling.Triggerpublic AutoScaling.TriggerEventProcessor getProcessor()
AutoScaling.TriggergetProcessor in interface AutoScaling.Triggerpublic String getName()
AutoScaling.TriggergetName in interface AutoScaling.Triggerpublic TriggerEventType getEventType()
AutoScaling.TriggergetEventType in interface AutoScaling.Triggerpublic boolean isEnabled()
AutoScaling.TriggerisEnabled in interface AutoScaling.Triggerpublic int getWaitForSecond()
AutoScaling.TriggergetWaitForSecond in interface AutoScaling.Triggerpublic Map<String,Object> getProperties()
AutoScaling.TriggergetProperties in interface AutoScaling.Triggerpublic List<TriggerAction> getActions()
AutoScaling.TriggergetActions in interface AutoScaling.Triggerpublic boolean isClosed()
AutoScaling.TriggerisClosed in interface AutoScaling.Triggerpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionprotected abstract Map<String,Object> getState()
Utils.toJSON(Object).protected abstract void setState(Map<String,Object> state)
state - never null but may be empty.public Map<String,Object> deepCopyState()
getState()public void saveState()
AutoScaling.TriggersaveState in interface AutoScaling.Triggerpublic void restoreState()
AutoScaling.TriggerrestoreState in interface AutoScaling.TriggerCopyright © 2000-2020 Apache Software Foundation. All Rights Reserved.