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 String |
name |
protected AtomicReference<AutoScaling.TriggerEventProcessor> |
processorRef |
protected Map<String,Object> |
properties |
protected DistribStateManager |
stateManager |
protected int |
waitForSecond |
Modifier | Constructor and Description |
---|---|
protected |
TriggerBase(TriggerEventType eventType,
String name,
Map<String,Object> properties,
SolrResourceLoader loader,
SolrCloudManager cloudManager) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
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 final SolrCloudManager cloudManager
protected final DistribStateManager stateManager
protected final TriggerEventType eventType
protected final int waitForSecond
protected final AtomicReference<AutoScaling.TriggerEventProcessor> processorRef
protected final List<TriggerAction> actions
protected final boolean enabled
protected boolean isClosed
protected TriggerBase(TriggerEventType eventType, String name, Map<String,Object> properties, SolrResourceLoader loader, SolrCloudManager cloudManager)
public void init()
AutoScaling.Trigger
init
in interface AutoScaling.Trigger
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 void saveState()
AutoScaling.Trigger
saveState
in interface AutoScaling.Trigger
public void restoreState()
AutoScaling.Trigger
restoreState
in interface AutoScaling.Trigger
Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.