public class Agent extends Object implements CommandExecutor, ServiceLifecycle
AgentMessagingLayer.| Modifier and Type | Class and Description |
|---|---|
class |
Agent.RunningCommand
Represents a command accepted for execution by this
Agent. |
class |
Agent.ShutdownResult |
| Modifier and Type | Field and Description |
|---|---|
static String |
AGENT_DESCRIPTION |
static String |
AGENT_RUNTIMEINFO_TASK |
protected Object |
commandExecutorLock
Lock that guards command executor state.
|
protected Agent.RunningCommand |
currentAction
Currently running CONFIGURATION or ACTION command.
|
protected Set<Agent.RunningCommand> |
currentQueries
Currently running QUERY commands.
|
protected Set<Agent.RunningCommand> |
currentSignals
Currently running SIGNAL commands.
|
protected AtomicBoolean |
jvmShutdown
Flag indicating that shutdownAgent() is being executed in a JVM shutdown
hook.
|
protected LogBusHandler |
logBusHandler
Logging bus handler
|
protected AgentStateService |
stateService |
protected boolean |
treeComponentInitialized |
| Constructor and Description |
|---|
Agent(String name,
AgentInfo.AgentType agentType)
Constructs an
Agent. |
| Modifier and Type | Method and Description |
|---|---|
protected CommandHelper |
createHelper()
This method can be overridden by subclasses of Agent to create a subclass
of CommandHelper to be returned by
helper() |
void |
executeCommandRequest(CommandRequest request)
Executes the received command
|
AgentInfo |
getAgentInfo()
Returns
AgentIfno instance associated with this Agent. |
PersistencyService |
getAgentPersistenceService()
Get this agent's local persistence service.
|
<T extends AgentService> |
getAgentService(Class<T> agentClass)
Generic method to access agent services.
|
List<AgentService> |
getAgentServices()
Get the list of available services for this Agent.
|
int |
getCommandCount(Command.CommandType... types)
Returns the number of currently running commands of given types.
|
ComponentConfigurationEnvironment |
getComponentConfigurationEnvironment(Object obj)
Deprecated.
Use ConfigurationService instead.
|
ComponentConfigurationEnvironment |
getComponentConfigurationEnvironmentByName(String name)
Deprecated.
Use ConfigurationService instead.
|
ComponentLookup |
getComponentLookup()
Provides access to the inner modular structure of this Subsystem.
|
Agent.RunningCommand |
getCurrentAction()
Get the current RunningCommand action.
|
String |
getDescription()
Gets the name of the description this subsystem was built from.
|
static AgentLockService |
getEnvironmentLockService() |
static AgentMessagingLayer |
getEnvironmentMessagingAccess()
Returns
AgentMessagingLayer associated with this JVM. |
Logger |
getLogger()
Returns the current logger (use sparingly and prefer your own logger).
|
AgentMessagingLayer |
getMessagingAccess()
Get the underlying AgentMessagingLayer instance.
|
String |
getName()
Returns the name of this
Agent. |
Scheduler |
getScheduler()
Returns
Scheduler used by this Agent. |
CommandHelper |
helper()
A convenience method for creating a new CommandHelper
|
void |
initAgent() |
void |
initLogBusHandler()
connects a LogBusHandler to the Log bus.
|
boolean |
isInEngineeringMode()
Command to tell if the subsystem is in Engineering mode.
|
protected void |
populateComponentLookup(ComponentLookup lookup)
Sets the component lookup for this Agent.
|
void |
preInit() |
void |
preStart()
Called from the enclosing
Subsystem when
org.lsst.ccs.Subsystem#start() has been called. |
String |
printComponentNodeTree()
Get a representation of the component tree.
|
void |
publishMonitoringDataOnStatusBus(KeyValueData keyValueData)
This method should only be used by Monitor.java to publish monitoring data
|
void |
publishSubsystemDataOnStatusBus(KeyValueData keyValueData)
Publishes the provided
KeyValueData on the Status bus. |
boolean |
sendAck(Duration timeout)
Sends an ACK to the command originator.
|
boolean |
sendNack(Serializable reason)
Sends a NACK to the command originator.
|
void |
sendStatusMessage(StatusMessage msg)
Method for sending messages on the status bus.
|
void |
setAgentName(String alias) |
Object |
shutdownAgent()
Clean shutdown of subsystem: call stop for hardware stopping before
invoking this method.
|
protected Object |
shutdownAgent(boolean goOffline) |
void |
startAgent()
Starts this Agent
|
String |
vetoTransitionToNormalMode()
Method to be overwritten by Agents that wish to veto the transition to
NORMAL mode.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitafterBuild, afterInit, afterStart, preBuild, preShutdownprotected final AtomicBoolean jvmShutdown
protected LogBusHandler logBusHandler
protected final Object commandExecutorLock
protected final Set<Agent.RunningCommand> currentQueries
protected volatile Agent.RunningCommand currentAction
protected final Set<Agent.RunningCommand> currentSignals
protected volatile boolean treeComponentInitialized
@LookupField(strategy=CHILDREN) protected AgentStateService stateService
public static final String AGENT_RUNTIMEINFO_TASK
public static final String AGENT_DESCRIPTION
public Agent(String name, AgentInfo.AgentType agentType)
Agent.name - name of this Agent; for CONSOLE and
LISTENER agents, the name will be modified to ensure uniqueness.agentType - type of this Agent.public void preInit()
preInit in interface ServiceLifecycleprotected final void populateComponentLookup(ComponentLookup lookup)
lookup - the lookuppublic 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 final List<AgentService> getAgentServices()
public final <T extends AgentService> T getAgentService(Class<T> agentClass)
T - The class of the service to fetch.agentClass - public final ComponentLookup getComponentLookup()
ComponentLookup object.protected CommandHelper createHelper()
helper()public CommandHelper helper()
createHelper()public final void setAgentName(String alias)
public final void initAgent()
public void startAgent()
@Command(name="shutdown", description="shutdown", type=ACTION, category=CORE) public Object shutdownAgent() throws Exception
Exception - If anything goes wrong during shutdownpublic Logger getLogger()
public final String getName()
Agent.Agentpublic AgentInfo getAgentInfo()
AgentIfno instance associated with this Agent.AgentIfno instance associated with this Agentpublic Scheduler getScheduler()
Scheduler used by this Agent. Subsystem
developers are encouraged to use this scheduler for running all periodic
and delayed short tasks.Scheduler provided by this Agent.public int getCommandCount(Command.CommandType... types)
types - Types of commands to include in the count. In no types are
given, all commands are included.@Command(description="is the system in engineering mode ?", type=QUERY, category=CORE) public boolean isInEngineeringMode()
true if this Agent is in ENGINEERING_OK or
ENGINEERING_FAULT mode.@Command(description="Print component lookup", type=QUERY, category=SYSTEM) public String printComponentNodeTree()
public AgentMessagingLayer getMessagingAccess()
public static AgentMessagingLayer getEnvironmentMessagingAccess()
AgentMessagingLayer associated with this JVM. Normally,
there is only one instance of AgentMessagingLayer per JVM,
providing busses access to the Agent and all its clients. In the
test environment, however, multiple agents can run on the same JVM.AgentMessagingLayer associated with this JVMpublic static AgentLockService getEnvironmentLockService()
public void sendStatusMessage(StatusMessage msg)
msg - The StatusMessage to send on the buses.public void initLogBusHandler()
public final void publishSubsystemDataOnStatusBus(KeyValueData keyValueData)
KeyValueData on the Status bus. Internally
the KeyValueData is wrapped into a StatusSubsystemData
before publication.keyValueData - The KeyValueData to be published.public final void publishMonitoringDataOnStatusBus(KeyValueData keyValueData)
keyValueData - public void executeCommandRequest(CommandRequest request)
CommandExecutorexecuteCommandRequest in interface CommandExecutorrequest - the command to be executed by the CommandExecutorpublic boolean sendNack(Serializable reason)
autoAck=false. It
should be called on the same thread the command method was invoked on. If
this method is called under any other circumstances, it has no effect and
returns false. The value returned by the command method after
sending NACK is ignored.reason - Reason for rejecting the command.true if the NACK has been sent as a result of this call.public boolean sendAck(Duration timeout)
autoAck=false. It
should be called on the same thread the command method was invoked on. If
this method is called under any other circumstances, it has no effect and
returns false.timeout - Timeout for the command. Specifying non-positive or
null timeout indicates the default should be used.true if the ACK has been sent as a result of this call.public Agent.RunningCommand getCurrentAction()
@Deprecated public ComponentConfigurationEnvironment getComponentConfigurationEnvironment(Object obj)
obj - the object for which to get the component configuration
service@Deprecated public ComponentConfigurationEnvironment getComponentConfigurationEnvironmentByName(String name)
name - the name of the object for which to get the component
configuration service.public PersistencyService getAgentPersistenceService()
public String getDescription()
public String vetoTransitionToNormalMode()
Copyright © 2023 LSST. All rights reserved.