
public final class AgentStateService extends Object implements AgentService, ServiceLifecycle
| Modifier and Type | Class and Description |
|---|---|
class |
AgentStateService.AgentStateServiceCommands |
| Constructor and Description |
|---|
AgentStateService() |
| Modifier and Type | Method and Description |
|---|---|
void |
addStateChangeListener(StateChangeListener stateChangeListener,
Class... states) |
String |
getAgentServiceName()
Get the name of this service.
|
Enum |
getComponentState(String component,
Class stateClass)
Returns the state of this Agent's component for the provided class.
|
StateBundle |
getState() |
Enum |
getState(Class stateClass)
Returns the state of this Agent for the provided class.
|
Object |
getStateLock()
Get the state lock to perform synchronized state operations.
|
boolean |
isComponentInState(String component,
Enum state)
Check if a component of this
Agent is in the given state. |
boolean |
isInState(Enum state)
Check if this
Agent is in the given state. |
boolean |
isInState(StateBundle state)
Checks if this
Agent is in all of the states contained in the given StateBundle. |
void |
preInit() |
void |
preStart()
Called from the enclosing
Subsystem when
org.lsst.ccs.Subsystem#start() has been called. |
protected void |
publishStateChange(StateBundle before,
StateBundle after)
Publishes state transition.
|
<T extends Enum<T>> |
registerState(Class<T> state,
String description,
Object obj)
Register a State with the AgentStateService.
|
void |
removeStateChangeListener(StateChangeListener stateChangeListener) |
boolean |
startForAgent(AgentInfo agentInfo)
This method is invoked after an agent service is created to see if
this service is to be started for the tiven Agent.
|
void |
updateAgentComponentState(Object component,
Enum... stateChanges)
Updates the state of this Agent and publishes StateChangeNotification message
only if the Agent is connected to the buses.
|
void |
updateAgentState(Enum... stateChanges)
Updates the state of this Agent and publishes StateChangeNotification message
only if the Agent is connected to the buses.
|
void |
updateAgentState(StateBundle stateChanges)
Updates the state of this Agent and publishes StateChangeNotification message
only if the Agent is connected to the buses.
|
void |
updateInternalState(AgentState... stateChanges)
Updates the internal state of this Agent and publishes StateChangeNotification message.
|
boolean |
waitFor(Predicate<StateBundle> target,
long timeout,
TimeUnit unit)
Block until this
Agent is in state that satisfies the specified predicate. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitafterInit, preBuild, preShutdownpublic String getAgentServiceName()
AgentServicegetAgentServiceName in interface AgentServicepublic boolean startForAgent(AgentInfo agentInfo)
AgentServicestartForAgent in interface AgentServicepublic void preStart()
ServiceLifecycleSubsystem when
org.lsst.ccs.Subsystem#start() has been called.
The preceding lifecycle step is HasLifecycle.postInit()
The following lifecycle step is HasLifecycle.start()
At the time it is called :
PhaseState is
INITIALIZING
connection with the messaging layer is effective, the enclosing
subsystem has started StatusHeartBeat
publication
preStart in interface ServiceLifecyclepublic void preInit()
preInit in interface ServiceLifecyclepublic final <T extends Enum<T>> void registerState(Class<T> state, String description, Object obj)
T - state - The State Enumeration Class to be registereddescription - The state descriptionobj - The object on which the state will be set.public Object getStateLock()
public boolean isInState(Enum state)
Agent is in the given state.state - The state to check.true if this Agent is in the specified state.public boolean isComponentInState(String component, Enum state)
Agent is in the given state.component - The name of the componentstate - The state to check.true if this Agent's component is in the specified state.public boolean isInState(StateBundle state)
Agent is in all of the states contained in the given StateBundle.state - A StateBundle.true if the Agent is in the provided StateBundle.public Enum getState(Class stateClass)
stateClass - The class of the Enum for which we would like the Agent's state.public Enum getComponentState(String component, Class stateClass)
component - The Agent's component namestateClass - The class of the Enum for which we would like the Agent's state.public void updateAgentState(Enum... stateChanges)
HasLifecyclestateChanges - The list of the states that have changed.IllegalArgumentException - if the list of arguments contains internal Agent states.public void updateAgentState(StateBundle stateChanges)
HasLifecyclestateChanges - The StateBundle with all the changes.IllegalArgumentException - if the list of arguments contains internal Agent states.public void updateAgentComponentState(Object component, Enum... stateChanges)
HasLifecyclecomponent - The name of the component to be updatedstateChanges - The list of the states that have changed.IllegalArgumentException - if the list of arguments contains internal Agent states.public final void updateInternalState(AgentState... stateChanges)
stateChanges - The list of the states that have changed.IllegalArgumentException - if the update would bring this Agent into a prohibited stateprotected void publishStateChange(StateBundle before, StateBundle after)
before - states before the transitionafter - states after the transitionpublic final boolean waitFor(Predicate<StateBundle> target, long timeout, TimeUnit unit) throws InterruptedException
Agent is in state that satisfies the specified predicate.
The condition is not guaranteed to remain true when the thread resumes.
The predicate provided to this method should not depend on anything other than
its argument, and should not have side effects.target - Condition to be satisfied for this method to return.timeout - Timeout value.unit - Timeout unit.True if the condition was satisfied; false if the method timed out.InterruptedException - if the thread is interrupted while waiting.public void addStateChangeListener(StateChangeListener stateChangeListener, Class... states)
public void removeStateChangeListener(StateChangeListener stateChangeListener)
public StateBundle getState()
Copyright © 2018 LSST. All rights reserved.