
public final class AgentStateService extends Object implements AgentService, ServiceLifecycle, BusMessagePreProcessor
| 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.
|
Bus |
getBus()
The Bus this BusMessagePreProcessor applies to.
|
Enum |
getComponentState(String component,
Class stateClass)
Returns the state of this Agent's component for the provided class.
|
StateBundle |
getState()
Returns a clone of the current Agent state.
|
Enum |
getState(Class stateClass)
Returns the state of this Agent for the provided class.
|
Object |
getStateLock()
Returns the object whose monitor lock guards write-access to the agent state.
|
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 |
preBuild() |
void |
preInit() |
BusMessage |
preProcessMessage(BusMessage msg)
Pre-process the incoming BusMessage and return the message to be
forwarded to the bus message listeners.
|
void |
preShutdown() |
void |
preStart()
Called from the enclosing
Subsystem when
org.lsst.ccs.Subsystem#start() has been called. |
<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(org.lsst.ccs.utilities.taitime.CCSTimeStamp stateTransitionTimestamp,
Object component,
Enum... stateChanges)
Updates the state of this Agent and publishes StateChangeNotification message
only if the Agent is connected to the buses.
|
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(org.lsst.ccs.utilities.taitime.CCSTimeStamp stateTransitionTimestamp,
Enum... stateChanges)
Updates the state of this Agent and publishes StateChangeNotification message
only if the Agent is connected to the buses.
|
void |
updateAgentState(org.lsst.ccs.utilities.taitime.CCSTimeStamp stateTransitionTimestamp,
StateBundle 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, afterStartpublic 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 preShutdown()
preShutdown in interface ServiceLifecyclepublic void preBuild()
preBuild 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)
HasLifecycle
When this method is invoked the CCSTimeStamp.currentTime() is assigned to
the state transition.stateChanges - The list of the states that have changed.IllegalArgumentException - if the list of arguments contains internal Agent states.public void updateAgentState(org.lsst.ccs.utilities.taitime.CCSTimeStamp stateTransitionTimestamp,
Enum... stateChanges)
HasLifecyclestateTransitionTimestamp - The CCSTimeStamp corresponding to this state transitionstateChanges - The list of the states that have changed.IllegalArgumentException - if the list of arguments contains internal Agent states.public void updateAgentState(StateBundle stateChanges)
HasLifecycle
When this method is invoked the CCSTimeStamp.currentTime() is assigned to
the state transition.stateChanges - The StateBundle with all the changes.IllegalArgumentException - if the list of arguments contains internal Agent states.public void updateAgentState(org.lsst.ccs.utilities.taitime.CCSTimeStamp stateTransitionTimestamp,
StateBundle stateChanges)
HasLifecyclestateTransitionTimestamp - The CCSTimeStamp corresponding to this state transitionstateChanges - 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 void updateAgentComponentState(org.lsst.ccs.utilities.taitime.CCSTimeStamp stateTransitionTimestamp,
Object component,
Enum... stateChanges)
HasLifecyclestateTransitionTimestamp - The CCSTimeStamp corresponding to this state transitioncomponent - 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 statepublic 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()
public BusMessage preProcessMessage(BusMessage msg)
BusMessagePreProcessorpreProcessMessage in interface BusMessagePreProcessormsg - The incoming BusMessagepublic Bus getBus()
BusMessagePreProcessorgetBus in interface BusMessagePreProcessorCopyright © 2021 LSST. All rights reserved.