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, wait
restoreState
protected 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.Trigger
configure
in interface AutoScaling.Trigger
properties
- configuration propertiesTriggerValidationException
- contains details of invalid configuration parameters.public void init() throws Exception
AutoScaling.Trigger
init
in interface AutoScaling.Trigger
Exception
public void setProcessor(AutoScaling.TriggerEventProcessor processor)
AutoScaling.Trigger
setProcessor
in interface AutoScaling.Trigger
public AutoScaling.TriggerEventProcessor getProcessor()
AutoScaling.Trigger
getProcessor
in interface AutoScaling.Trigger
public String getName()
AutoScaling.Trigger
getName
in interface AutoScaling.Trigger
public TriggerEventType getEventType()
AutoScaling.Trigger
getEventType
in interface AutoScaling.Trigger
public boolean isEnabled()
AutoScaling.Trigger
isEnabled
in interface AutoScaling.Trigger
public int getWaitForSecond()
AutoScaling.Trigger
getWaitForSecond
in interface AutoScaling.Trigger
public Map<String,Object> getProperties()
AutoScaling.Trigger
getProperties
in interface AutoScaling.Trigger
public List<TriggerAction> getActions()
AutoScaling.Trigger
getActions
in interface AutoScaling.Trigger
public boolean isClosed()
AutoScaling.Trigger
isClosed
in interface AutoScaling.Trigger
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
protected 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.Trigger
saveState
in interface AutoScaling.Trigger
public void restoreState()
AutoScaling.Trigger
restoreState
in interface AutoScaling.Trigger
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.