
public class Agent extends Object implements CommandExecutor
AgentMessagingLayer.| Modifier and Type | Class and Description |
|---|---|
class |
Agent.RunningCommand
Represents a command accepted for execution by this
Agent. |
| Modifier and Type | Field and Description |
|---|---|
static String |
AGENT_HEARTBEAT_TASK |
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 Object |
innerStateLock
Lock for innerState variable.
|
protected LogBusHandler |
logBusHandler
Logging bus handler
|
protected static Map<Object,Agent> |
OBJECT_SUBSYSTEM_MAP |
| Modifier | Constructor and Description |
|---|---|
|
Agent(String name,
AgentInfo.AgentType agentType)
Constructs an
Agent. |
protected |
Agent(String name,
AgentInfo.AgentType agentType,
ComponentLookup componentLookup) |
| Modifier and Type | Method and Description |
|---|---|
void |
addClearAlertHandler(ClearAlertHandler handler)
Deprecated.
This call is no longer needed as the ClearAlertHandler should be picked up by the framework
|
protected void |
addCommandSet(String fullPath,
CommandSet commandSet)
Adds a
CommandSet to extend the set of commands recognized by this Agent. |
void |
addCommandsFromObject(Object obj,
String path)
Add the commands defined in an Object to this Agent's CommandSet.
|
protected void |
broadcastStatus()
Broadcasts the current heartbeat status.
|
void |
change(String componentName,
String parameterName,
Object value)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
String[] |
clearAlerts(String... alertId)
Deprecated.
Address the alert service directly.
|
String[] |
clearAllAlerts()
Deprecated.
Use the alert service directly.
|
void |
commitBulkChange()
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
void |
dropAllChanges()
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
void |
dropAllSubmittedChanges()
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
void |
dropChangesForCategories(String... categories)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
void |
dropSubmittedChangesForComponent(String name)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
void |
executeCommandRequest(CommandRequest request)
Executes the received command
|
Set<String> |
findAvailableConfigurationsForCategory(String category)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
AgentInfo |
getAgentInfo()
Returns
AgentIfno instance associated with this Agent. |
AgentPeriodicTaskService |
getAgentPeriodicTaskService()
Get the AgentPeriodicTaskService.
|
AlertService |
getAlertService() |
Map<String,Map<String,String>> |
getAllSubmittedChanges()
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
Set<String> |
getCategories()
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
CCSVersions |
getCCSVersions()
Command to get the CCSVersions object for the current CCS Environment.
|
int |
getCommandCount(Command.CommandType... types)
Returns the number of currently running commands of given types.
|
protected CommandSet |
getCommandSet(String name) |
List<String> |
getCommandTargets()
Returns this
Agent list of command targets. |
ComponentConfigurationEnvironment |
getComponentConfigurationEnvironment(Object obj)
Get the ComponentConfigurationEnvironment object for a given Object.
|
ComponentConfigurationEnvironment |
getComponentConfigurationEnvironmentByName(String name)
Get the ComponentConfigurationEnvironment object for a given node name.
|
ComponentLookup |
getComponentLookup()
Provides access to the inner modular structure of this Subsystem.
|
ConfigurationInfo |
getConfigurationInfo()
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
Agent.RunningCommand |
getCurrentAction()
Get the current RunningCommand action.
|
Map<String,String> |
getCurrentValuesForComponent(String componentName,
Set<String> categorySet)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
String |
getDescription()
Gets the name of the description this subsystem was built from.
|
HashMap<String,Dictionary> |
getDictionaries()
Returns the command dictionary used by this
Agent. |
DistributionInfo |
getDistributionInfo()
Command to get the DistributionInfo object for this
Agent. |
static AgentMessagingLayer |
getEnvironmentMessagingAccess()
Returns
AgentMessagingLayer associated with this JVM. |
Logger |
getLogger()
Returns the current logger (use sparingly and prefer your own logger).
|
AgentMessagingLayer |
getMessagingAccess()
Returns
AgentMessagingLayer used by this Agent. |
Monitor |
getMonitor()
Provides access to this subsystem's monitor.
|
String |
getName()
Returns the name of this
Agent. |
RaisedAlertSummary |
getRaisedAlertSummary()
Deprecated.
Use the alert service directly.
|
Scheduler |
getScheduler()
Returns
Scheduler used by this Agent. |
StateBundle |
getState()
Returns a copy of a state bundle of this Agent.
|
Enum |
getState(Class stateClass)
Returns the state of this Agent for the provided class.
|
int |
getStatusBroadcastPeriod()
Returns heartbeat broadcasting period for this
Agent. |
Map<String,String> |
getSubmittedChangesForComponent(String name)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
SubsystemConfigurationEnvironment |
getSubsystemConfigurationEnvironment()
Provides programmatic access to the configuration API.
|
String |
getTag()
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
protected void |
internalShutdown()
This method is called by the framework at the beginning of Agent shutdown, once the phase has been switched to OPERATIONAL.
|
protected boolean |
internalStart()
This method is called by the framework at the end of Agent startup, before switching to OPERATIONAL phase.
|
boolean |
isInEngineeringMode()
Command to tell if the subsystem is in Engineering mode.
|
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. |
boolean |
isParameterConfigurable(String componentName,
String parameterName)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
void |
loadCategories(String... taggedCategories)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
void |
loadConfiguration(String... taggedCategories)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
void |
persistNow()
Deprecated.
Address the persistency service directly
|
protected void |
populateComponentLookup(ComponentLookup lookup)
Sets the component lookup for this Agent.
|
void |
postStart()
Called by the framework after subsystem has been started.
|
protected void |
publishStateChange(StateBundle before,
StateBundle after)
Publishes state transition.
|
void |
publishSubsystemDataOnStatusBus(KeyValueData keyValueData)
Publishes the provided
KeyValueData on the Status bus. |
void |
raiseAlert(Alert alert,
AlertState severity,
String cause)
Deprecated.
address the alert service directly
|
void |
saveAllChanges()
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
void |
saveChangesForCategories(String... categories)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
void |
saveChangesForCategoriesAs(String... taggedCategories)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
boolean |
sendAck(Duration timeout)
Sends an ACK to the command originator.
|
boolean |
sendNack(Serializable reason)
Sends a NACK to the command originator.
|
void |
setAgentProperty(String property,
String value)
Set an Agent property.startAge
This method can be invoked only up to the point the Agent is about to connect
to the buses.
|
Object |
shutdown()
Clean shutdown of subsystem: call stop for hardware stopping before invoking this method.
|
void |
start()
Deprecated.
use
startAgent() instead |
void |
startAgent()
Starts this Agent
|
void |
submitChange(String componentName,
String parameterName,
Object value)
Deprecated.
use the configuration API through the ConfigurationCommandSet
object accessible via getSubsystemConfigurationEnvironment()
|
void |
updateAgentState(Enum... stateChanges)
Updates the state of this Agent and publishes StateChangeNotification message.
|
protected void |
updateHeartBeat(StatusHeartBeat heartBeat)
Subclasses can override this method to add customized information to the heartbeat.
|
protected 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. |
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 final Object innerStateLock
public static final String AGENT_HEARTBEAT_TASK
public static final String AGENT_RUNTIMEINFO_TASK
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.protected Agent(String name, AgentInfo.AgentType agentType, ComponentLookup componentLookup)
protected final void populateComponentLookup(ComponentLookup lookup)
lookup - the lookuppublic final ComponentLookup getComponentLookup()
ComponentLookup object.public final AgentPeriodicTaskService getAgentPeriodicTaskService()
public void startAgent()
@Deprecated public void start()
startAgent() insteadpublic void postStart()
throws HardwareException
HardwareException - because some "homing" operations may be tried
by the hardware@Command(description="shutdown", type=ACTION) public final Object shutdown() throws Exception
Exception - If anything goes wrong during shutdownprotected boolean internalStart()
protected void internalShutdown()
throws Exception
Exception - Any Exception that caused to shutdown process to fail.public 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.public int getStatusBroadcastPeriod()
Agent.@Command(description="is the system in engineering mode ?", type=QUERY, category=SYSTEM) public boolean isInEngineeringMode()
true if this Agent is in ENGINEERING_OK or ENGINEERING_FAULT mode.@Command(description="Get the CCS Versions for the current CCS Environment", type=QUERY, category=SYSTEM) public CCSVersions getCCSVersions()
@Command(description="Get the Agent\'s DistributionInfo object.", type=QUERY, category=SYSTEM) public DistributionInfo getDistributionInfo()
Agent.
The DistributionInfo object contains version information about the distribution
from which this Agent was launched.Agent.@Command(description="get the command dictionary for the subsystem", type=QUERY, category=SYSTEM) public HashMap<String,Dictionary> getDictionaries()
Agent.@Command(description="Get the list of command targets", type=QUERY, category=SYSTEM) public List<String> getCommandTargets()
Agent list of command targets.protected CommandSet getCommandSet(String name)
protected void addCommandSet(String fullPath, CommandSet commandSet)
CommandSet to extend the set of commands recognized by this Agent.commandSet - command setfullPath - the full path of the component to addpublic void addCommandsFromObject(Object obj, String path)
obj - The Object from which to extract the commands.path - The path at which the resulting CommandSet will be added.public void setAgentProperty(String property, String value)
property - The name of the property to set.value - The value of the property.public AgentMessagingLayer getMessagingAccess()
AgentMessagingLayer used by this Agent.
The returned instance is used by the Agent internally, and can also
be used by the client code to publish messages on the buses.AgentMessagingLayer used by this Agentpublic 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 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 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 StateBundle getState()
public void updateAgentState(Enum... stateChanges)
postStart method of
HasLifecyclestateChanges - The list of the states that have changed.IllegalArgumentException - if the list of arguments contains internal Agent states.protected 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 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 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.protected final void broadcastStatus()
protected void updateHeartBeat(StatusHeartBeat heartBeat)
heartBeat - Heartbeat instance to be modified before publication.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()
public Monitor getMonitor()
public final SubsystemConfigurationEnvironment getSubsystemConfigurationEnvironment()
public final AlertService getAlertService()
public ComponentConfigurationEnvironment getComponentConfigurationEnvironment(Object obj)
obj - the object for which to get the component configuration servicepublic ComponentConfigurationEnvironment getComponentConfigurationEnvironmentByName(String name)
name - the name of the object for which to get the component configuration service.@Deprecated public final void persistNow()
Persist annotated fields.@Deprecated public final void addClearAlertHandler(ClearAlertHandler handler)
handler - The ClearAlertHandler class that will handle the clearing
of alerts.@Deprecated public final void raiseAlert(Alert alert, AlertState severity, String cause)
alert - The Alert instance to be raisedseverity - The AlertState of this Alert.cause - The reason the Alert was raised.@Deprecated public final String[] clearAlerts(String... alertId)
alertId - the Id of the Alerts to be cleared.@Deprecated public final String[] clearAllAlerts()
@Deprecated public final RaisedAlertSummary getRaisedAlertSummary()
@Deprecated public final void saveAllChanges() throws ConfigurationServiceException
ConfigurationServiceException - if configuration service
unavailable@Deprecated public final void saveChangesForCategories(@Argument(name="taggedCategories",description="A list of categories") String... categories)
categories - a list of categoriesConfigurationServiceException - if configuration service
unavailable.@Deprecated public final void saveChangesForCategoriesAs(@Argument(name="taggedCategories",description="A list of pairs categoryName:configurationName") String... taggedCategories)
taggedCategories - a list of pairs categoryName:configurationNameConfigurationServiceException - if the configuration service is not
available.@Deprecated public void dropAllChanges()
@Deprecated public void dropChangesForCategories(@Argument(name="categories",description="A list of categories") String... categories)
categories - A list of categories@Deprecated public void loadConfiguration(@Argument(name="taggedCategories",description="a list of pairs categoryName:configurationName") String... taggedCategories)
taggedCategories - a list of pairs categoryName:configurationNameConfigurationServiceExceptionTypeConversionException@Deprecated public void loadCategories(@Argument(name="taggedCategories",description="a list of pairs categoryName:configurationName") String... taggedCategories)
taggedCategories - a list of pairs categoryName:configurationNameConfigurationServiceException@Deprecated public void change(String componentName, String parameterName, Object value)
componentName - the name of the component the parameter belongs to.parameterName - the name of the parameter.value - the new value to affect to this parameter@Deprecated public void submitChange(String componentName, String parameterName, Object value)
componentName - parameterName - value - IllegalArgumentException - if componentName does not
have a configurable parameter named parameterName@Deprecated public void commitBulkChange()
@Deprecated public void dropAllSubmittedChanges()
@Deprecated public void dropSubmittedChangesForComponent(@Argument(description="the component name") String name)
@Deprecated public Map<String,String> getSubmittedChangesForComponent(@Argument(description="the component name") String name)
@Deprecated public Map<String,Map<String,String>> getAllSubmittedChanges()
@Deprecated public Set<String> getCategories()
@Deprecated public Set<String> findAvailableConfigurationsForCategory(String category)
category - @Deprecated public Map<String,String> getCurrentValuesForComponent(String componentName, Set<String> categorySet)
@Deprecated public boolean isParameterConfigurable(String componentName, String parameterName)
componentName - the component nameparameterName - the parameter name@Deprecated public ConfigurationInfo getConfigurationInfo()
@Deprecated public String getTag()
public String getDescription()
Copyright © 2017 LSST. All rights reserved.