
public final class ConfigurationService extends Object implements ServiceLifecycle, ClearAlertHandler, AgentPresenceListener, AgentService, HasDataProviderInfos, HasLifecycle
ConfigurationParameter are found
within the subsystem or its components. It is responsible for modifying
configuration parameters of the subsystems and for interacting with the
configuration service.
The configuration API covers the following actions :
ConfigurationBulkChangeHandler.
ConfigurationParameter annotation.
If the component implements
ConfigurationBulkChangeHandler, its validation
method is invoked. If the validation step fails,
BulkValidationException is thrown, submitted changes are not dropped
and the bulk change process is interrupted If out of the validation step,
some parameters have been detected to have changed, a
BulkSettingException is thrown, submitted changes are dropped and an
alarm is raised, indicating an operator error.
ConfigurationBulkChangeHandler, its setting
method is invoked. Remaining parameters to be set are set through their
corresponding
ConfigurationParameterChanger
annotated method if present, or directly set by reflection. If the validation
step fails, the submitted changes are dropped, an alarm indicating an
operator error is raised and a BulkSettingException is thrown. If at
the end of the process, the values of the parameters don't match the one
expected by the submitted changes, the submitted changes are dropped, an
alarm indicating an operator error (id CCSCFGOP) is raised and
a BulkSettingException is thrown.
Each of the methods of this object that involve changing parameters are internally following the bulk change process, and are therefore likely to throw one of the exceptions mentioned above, or to raise one of the alarms mentioned above.
CONFIGURED.
When configuration tags (or full configurations) are loaded successfully, the state is
CONFIGURED
Changing one or more parameters makes the subsystem go into
DIRTY state
Saving the changes makes the subsystem go into CONFIGURED
The commands that cause changes of parameters are only available when in
engineering mode. The subsystem can switch from engineering mode to normal
mode only if the state is CONFIGURED.
ConfigurationServiceException if the configuration service is
unavailable. In that case an alarm with id CCSCFGSRV will also
be raised.
ConfigurationInfo publication representing the
resulting configuration state| Modifier and Type | Class and Description |
|---|---|
class |
ConfigurationService.ConfigurationLock
Encapsulates a reader lock on the subsystem configuration.
|
class |
ConfigurationService.ConfigurationWriteLock
Encapsulates a writer lock on the subsystem configuration.
|
ClearAlertHandler.ClearAlertCode| Constructor and Description |
|---|
ConfigurationService() |
| Modifier and Type | Method and Description |
|---|---|
ConfigurationService.ConfigurationLock |
acquireConfigurationLock()
Acquires a read lock on the subsystem configuration.
|
ConfigurationService.ConfigurationWriteLock |
acquireConfigurationWriteLock()
Acquires a writer lock on the subsystem configuration.
|
void |
addConfigurationListener(ConfigurationListener listener)
Add a configuration listener.
|
ConfigurationInfo.Builder |
buildConfigurationInfo(ConfigurationView newView)
See the description for
buildConfigurationInfo(org.lsst.ccs.config.ConfigurationView, boolean)
which this method calls with a second argument of true (new configuration must be complete). |
ConfigurationInfo.Builder |
buildConfigurationInfo(ConfigurationView newView,
boolean mustBeComplete)
Takes a configuration view and extracts from it the information needed to construct an instance
of
ConfigurationInfo, which is what later gets sent on the CCS status bus. |
ClearAlertHandler.ClearAlertCode |
canClearAlert(Alert alert,
AlertState state)
Callback to clear an
Alert instance. |
void |
change(String componentName,
String parameterName,
Object value)
Single change of parameter.
|
void |
commitBulkChange()
Initiates the bulk change process of the submitted changes.
|
void |
commitBulkChangeForComponent(String component) |
void |
connected(AgentInfo... ai)
All the provided
agents are fully connected to the buses, they
are OPERATIONAL and ready to receive commands. |
void |
dropAllChanges()
Sets back all parameters to the value defined by the current configuration
they are running.
|
void |
dropAllSubmittedChanges()
Drops the submitted changes for all components of the subsystem.
|
void |
dropChangesForCategories(String... categories)
Sets all parameters that belong to one of the specified categories to the
value defined by the current running configuration for this category.
|
void |
dropSubmittedChangesForComponent(String name)
Drops the submitted changes for a given component of the subsystem.
|
String |
getAgentServiceName()
Get the name of this service.
|
List<String> |
getAllConfigurableComponents() |
Map<String,Map<String,String>> |
getAllSubmittedChanges()
Returns the current submitted changes for each component.
|
Properties |
getBuildProperties() |
static Properties |
getBuildProperties(String descriptionName,
String initialConfig)
Utility method to fetch build level properties.
|
Set<String> |
getCategories()
Returns the set of categories the subsystem's configurable parameters are
split into.
|
List<ConfigurationParameterHandler> |
getCategoryParameters(String category)
CORE ONLY.
|
ComponentConfigurationEnvironment |
getComponentConfigurationEnvironment(String name)
Gets a configuration service dedicated to a specific component
|
ConfigurationInfo |
getConfigurationInfo()
Gets the current configurationInfo object depicting the state of the
configuration parameters of this subsystem.
|
String |
getConfigurationParameterValue(String componentName,
String parameterName)
Get the current value of a configuration parameter by providing its component
name and the parameter name.
|
Map<String,String> |
getConfigurationParameterValuesForComponent(String componentName,
String... categories)
Returns the current values of the configuration parameters that belong to
componentName and that belong to the specified categories. |
ConfigurationDescription |
getCurrentConfigurationDescription(String... categories)
Get the current configuration description.
|
List<DataProviderInfo> |
getDataProviderInfos()
Get the list of available
DataProviderInfos. |
ConfigurationDescription |
getInitialConfigurationDescription(String... categories)
Get the initial configuration description.
|
ConfigurationView |
getInitialView()
CORE ONLY.
|
ConfigurationParameterHandler |
getParameterByPath(ParameterPath path)
CORE ONLY.
|
ConfigurationDescription |
getRequestedConfigurationDescription(String... categories)
Get the requested configuration description.
|
Map<String,String> |
getSubmittedChangesForComponent(String name)
Gets the submitted changes for the specified component
|
String |
getTag() |
boolean |
isParameterReadOnly(String componentName,
String parameterName) |
void |
loadCategories(String... taggedCategories)
Loads a configuration for the specified categories.
|
void |
loadConfiguration(String... taggedCategories)
Full configuration load.
|
void |
preBuild() |
void |
preInit() |
void |
preStart()
Called from the enclosing
Subsystem when
org.lsst.ccs.Subsystem#start() has been called. |
String |
printConfigurationParameters(String... categories)
Returns the current values of the configuration parameters that belong to
the specified categories.
|
String |
printDirtyConfigurationParameters(String... categories)
Returns the current values of the dirty configuration parameters that belong to
the specified categories.
|
void |
publishConfigurationInfo()
Publishes the current configurationInfo object on the status bus.
|
void |
publishDataProviderCurrentData(AgentInfo agentInfo)
Publish the current data of all the
DataProviderInfos managed
by this object. |
void |
removeConfigurationListener(ConfigurationListener listener)
Remove a configuration listener.
|
void |
saveChanges()
Saves the current value of each parameter that has changed from the last configuration load.
|
void |
saveChangesForCategories(String... categoryTags)
Saves the current value of each parameter that belongs to one of the
specified categories in the current running configuration for this category.
|
void |
saveChangesForCategoriesAs(String... categoryTags)
Deprecated.
Use saveChangesForCategories instead
|
void |
saveFullConfiguration()
Saves the current values for all the parameters.
|
void |
saveFullConfigurationForCategories(String... categoryTags) |
boolean |
saveInitialConfiguration()
CORE ONLY.
|
void |
setReadOnlyParameter(String componentName,
String parameterName,
Object value)
Set ReadOnly Configuration Parameter.
|
void |
shutdown()
Called from the enclosing
Subsystem when
org.lsst.ccs.Subsystem#shutdown() has been called. |
void |
submitChange(String componentName,
String parameterName,
Object value)
Submits a configuration parameter change.
|
void |
submitChanges(String componentName,
Map<String,Object> changes)
Submits several parameter changes.
|
ConfigurationService.ConfigurationLock |
tryAcquireConfigurationLock(long time,
TimeUnit unit)
Acquires a configuration read lock if it is free within the given waiting
time and the current thread has not been interrupted.
|
ConfigurationService.ConfigurationWriteLock |
tryAcquireConfigurationWriteLock(long time,
TimeUnit unit)
Acquires a configuration writer lock if it is available within the given waiting
time and the current thread has not been interrupted.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitafterInit, afterStart, preShutdownconnecting, disconnected, disconnectingstartForAgentfinalizeDictionarybuild, init, postBuild, postInit, postShutdown, postStart, startpublic String getAgentServiceName()
AgentServicegetAgentServiceName in interface AgentServicepublic static Properties getBuildProperties(String descriptionName, String initialConfig)
descriptionName - The description name (groovy file)initialConfig - The initial configuration stringpublic Properties getBuildProperties()
public void shutdown()
HasLifecycleSubsystem when
org.lsst.ccs.Subsystem#shutdown() has been called. At the time it
is called :
PhaseState is CLOSING.
HardwareController.checkStopped() has
been called
shutdown in interface HasLifecyclepublic ClearAlertHandler.ClearAlertCode canClearAlert(Alert alert, AlertState state)
ClearAlertHandlerAlert instance.
Return a ClearAlertCode for the provided Alert.canClearAlert in interface ClearAlertHandleralert - The Alert instance to clear.state - The AlertState for the provided Alert.public void preBuild()
preBuild in interface ServiceLifecyclepublic void preInit()
preInit in interface ServiceLifecyclepublic 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 List<DataProviderInfo> getDataProviderInfos()
HasDataProviderInfosDataProviderInfos.getDataProviderInfos in interface HasDataProviderInfosDataProviderInfospublic void publishDataProviderCurrentData(AgentInfo agentInfo)
HasDataProviderInfosDataProviderInfos managed
by this object.publishDataProviderCurrentData in interface HasDataProviderInfosagentInfo - The AgentInfo for which we are requesting to publish the data.@Command(category=CORE, type=QUERY, level=0) public String getConfigurationParameterValue(@Argument(allowedValueProvider="getAllConfigurableComponents") String componentName, String parameterName)
componentName - The component the parameter belongs to.parameterName - The name of the configuration parameter.@Command(category=CORE, type=QUERY, level=0) public String printConfigurationParameters(String... categories)
categories - The categories to print. If empty or null, all categories are displayed.@Command(category=CORE, type=QUERY, level=0) public String printDirtyConfigurationParameters(String... categories)
categories - The categories to print. If empty or null, all categories are displayed.@Command(description="Saves all changes in the current configurations", type=CONFIGURATION, category=CORE, level=1) public void saveChanges()
If it succeeds, the state will be CONFIGURED.
ConfigurationServiceException - if the configuration service is unavailable. The configuration
state does not change and the run-time changes are still
considered unsaved. In addition, an alert is raised to indicate
the configuration service unavailability.IllegalStateException - if the subsystem is not in engineering mode.@Command(description="Saves all changes in the current configurations", type=CONFIGURATION, category=CORE, level=1) public void saveFullConfiguration()
If it succeeds, the state will be CONFIGURED.
ConfigurationServiceException - if the configuration service is unavailable. The configuration
state does not change and the run-time changes are still
considered unsaved. In addition, an alert is raised to indicate
the configuration service unavailability.IllegalStateException - if the subsystem is not in engineering mode.@Command(description="Saves the specified categories with a name", type=CONFIGURATION, category=CORE, level=1) public void saveChangesForCategories(@Argument(name="categoryTags",description="A list of categories or category tags") String... categoryTags)
If there were run-time changes in other categories, the state is DIRTY, otherwise CONFIGURED.
categoryTags - a list of categories to saveConfigurationServiceException - if the configuration service is unavailable. The configuration
state does not change and existing run-time changes are still
considered unsaved. In addition, an alert is raised to indicate
the configuration service unavailability.IllegalStateException - if the subsystem is not in engineering mode.@Deprecated public void saveChangesForCategoriesAs(@Argument(name="categoryTags",description="A list of categories or category tags") String... categoryTags)
categoryTags - @Command(description="Saves the specified categories with a name", type=CONFIGURATION, category=CORE, level=1) public void saveFullConfigurationForCategories(@Argument(name="taggedCategories",description="A list of categories") String... categoryTags)
@Command(description="drop all unsaved changes", type=CONFIGURATION, category=CORE, level=1) public void dropAllChanges()
First, all existing submitted changes are dropped.
ConfigurationServiceException - if the configuration service is unavailable.BulkValidationException - if setting the parameters back to their configured value fails at
the validation step.BulkSettingException - if setting the parameters back to their configured value fails at
the setting step. An alert is raised.IllegalStateException - if the subsystem is not in engineering mode.@Command(description="drop unsaved changes for the specified categories", type=CONFIGURATION, category=CORE, level=1) public void dropChangesForCategories(@Argument(name="categories",description="A list of categories") String... categories)
First, all existing submitted changes are dropped.
categories - A list of categoriesConfigurationServiceException - if the configuration service is unavailable.BulkValidationException - if setting the parameters back to their configured value fails at
the validation step.BulkSettingException - if setting the parameters back to their configured value fails at
the setting step. An alert is raised.IllegalStateException - if the subsystem is not in engineering mode.@Command(name="loadAllCategories", description="loads a new configuration", type=CONFIGURATION, category=CORE, level=0) public void loadConfiguration(@Argument(name="taggedCategories",description="a list of pairs categoryName:configurationName(version)") String... taggedCategories)
Not allowed if there are uncommitted submitted changes. For each specified pair "cat:tag(v)" the parameters that belong to "cat" will be set to the value defined by the configuration named "tag". The parameters that belong to unspecified categories will be set to the value defined by their default configuration. If the fetched configurations are incomplete, missing parameters are set to their initial value.
taggedCategories - a list of pairs categoryName:configurationName(version)ConfigurationServiceException - if the configuration service is unavailable.BulkValidationException - if loading the configuration fails at the validation step. The
configuration state remains unchanged.BulkSettingException - if loading the configuration fails at the setting step. An alert
is raised.IllegalStateException - if the subsystem is not connected on the buses.@Command(description="loads the configuration for the specified categories", type=CONFIGURATION, category=CORE, level=1) public void loadCategories(@Argument(name="taggedCategories",description="a list of pairs categoryName:configurationName(version)") String... taggedCategories)
taggedCategories - a list of pairs categoryName:configurationName(version)ConfigurationServiceException - if the configuration service is unavailable.BulkValidationException - if loading the configurations fails at the validation step. The
configuration state remains unchanged.BulkSettingException - if loading the configuration fails at the setting step. An alert
is raised.IllegalStateException - if the subsystem is not in engineering mode.@Command(description="return a ConfigurationInfo object", type=QUERY, category=SYSTEM, level=0) public ConfigurationInfo getConfigurationInfo()
If configuration parameters are modified outside of one of the provided configuration API commands, the changes will not be reflected in the returned ConfigurationInfo object.
@Command(description="return the initial configuration for the provided categories", type=QUERY, category=CORE, level=0) public ConfigurationDescription getInitialConfigurationDescription(String... categories)
The - categories that should be contained in the ConfigurationDescription.
If no categories are provided, the ConfigurationDescription will include all
categories.@Command(description="return the requested configuration for the provided categories", type=QUERY, category=CORE, level=0) public ConfigurationDescription getRequestedConfigurationDescription(String... categories)
The - categories that should be contained in the ConfigurationDescription.
If no categories are provided, the ConfigurationDescription will include all
categories.@Command(description="return the current configuration for the provided categories", type=QUERY, category=CORE, level=0) public ConfigurationDescription getCurrentConfigurationDescription(String... categories)
The - categories that should be contained in the ConfigurationDescription.
If no categories are provided, the ConfigurationDescription will include all
categories.public void setReadOnlyParameter(String componentName, String parameterName, Object value)
This method is to be used when changing values of ReadOnly configuration parameters. The configuration state is unchanged.
componentName - the name of the component the parameter belongs to.parameterName - the name of the parameter.value - the new value to affect to this parameterConfigurationServiceException - if the change has not been registered to the configuration
service.@Command(description="publish a ConfigurationInfo object", type=QUERY, category=SYSTEM, level=0) public void publishConfigurationInfo()
If configuration parameters are modified outside of one of the provided configuration API command, they will not be reflected by the published ConfigurationInfo object.
@Command(description="Submits a single change to be processed immediately", type=CONFIGURATION, category=CORE, level=1) public void change(@Argument(allowedValueProvider="getAllConfigurableComponents") String componentName, String parameterName, Object value)
The value is validated and the parameter is immediately set to this value, without interfering with the current set of submitted changes. If the change is effective, the configuration state goes to DIRTY.
componentName - the name of the component the parameter belongs to.parameterName - the name of the parameter.value - the new value to affect to this parameterConfigurationServiceException - if the change has not been registered to the configuration
service.BulkValidationException - if setting the parameters fails at the validation step. The
configuration state remains unchanged.BulkSettingException - if setting the parameter fails at the setting step, or if a
suspicious change is detected at the validation step, or if the
final values of the parameters is not consistent with the
performed change. Existing submitted changes are dropped and an
alert is raised.IllegalStateException - if the subsystem is not in engineering mode.@Command(description="Submits a change of parameter to be validated later", type=CONFIGURATION, category=CORE, level=1) public void submitChange(@Argument(allowedValueProvider="getAllConfigurableComponents") String componentName, String parameterName, Object value)
The change will be effective once commitBulkChange is invoked and successful. This does not affect the subsystem configuration state.
componentName - the component the parameter belongs toparameterName - the parameter namevalue - the submitted parameter valueIllegalArgumentException - if componentName does not have a configurable
parameter named parameterNameIllegalStateException - if the subsystem is not in engineering mode.@Command(description="Submits changes of parameters to be validated later", type=CONFIGURATION, category=CORE, level=1) public void submitChanges(@Argument(allowedValueProvider="getAllConfigurableComponents") String componentName, Map<String,Object> changes)
The changes will be effective once commitBulkChange is invoked and successful. Until then the subsystem configuration state is not changed.
componentName - the component namechanges - a map of parameter names to their submitted value. All parameters
are assumed to belong to componentNameIllegalArgumentException - if componentName does not have a configurable
parameter named parameterName@Command(name="applySubmittedChanges", description="processes the bulk change", type=CONFIGURATION, category=CORE, level=1) public void commitBulkChange()
The bulk change process is described in the class documentation. If the validation step fails, the configuration state is unchanged, as no parameters have been modified yet. If the setting step fails (an exception is thrown), the current value for each parameter is retrieved, the subsystem goes into DIRTY state if one or more have been modified and an alarm is raised, indicating an operator error. If the setting step succeeds, the subsystem goes into DIRTY state if one or more parameters have been effectively modified.
BulkValidationException - if setting the parameters fails at the validation step. The
configuration state remains unchanged. Submitted changes are not
dropped.BulkSettingException - if setting the parameter fails at the setting step, or if a
suspicious change is detected at the validation step, or if the
final values of the parameters is not consistent with the
submitted changes. In all of those cases, an alarm is raised and
the submitted changes are dropped.IllegalStateException - if the subsystem is not in engineering mode.public void commitBulkChangeForComponent(String component)
@Command(description="Drops the submitted changes for all components", type=CONFIGURATION, category=CORE, level=1) public void dropAllSubmittedChanges()
@Command(description="Drops the submitted changes for the given component", type=CONFIGURATION, category=CORE, level=1) public void dropSubmittedChangesForComponent(@Argument(allowedValueProvider="getAllConfigurableComponents",description="the component name") String name)
name - the component name.IllegalArgumentException - if there is no component named name@Command(description="Returns the current submitted changes for the given component", type=CONFIGURATION, category=CORE, level=1) public Map<String,String> getSubmittedChangesForComponent(@Argument(allowedValueProvider="getAllConfigurableComponents",description="the component name") String name)
name - the component nameIllegalArgumentException - if there is no component named name@Command(description="Returns the current submitted changes for each component", type=CONFIGURATION, category=CORE, level=1) public Map<String,Map<String,String>> getAllSubmittedChanges()
IllegalArgumentException - if there is no component named name@Command(description="returns the categories of this subsystem", type=QUERY, category=CORE, level=0) public Set<String> getCategories()
@Command(description="returns the current values for a given component that belong to the specified categories", type=QUERY, category=CORE, level=0) public Map<String,String> getConfigurationParameterValuesForComponent(@Argument(allowedValueProvider="getAllConfigurableComponents") String componentName, String... categories)
componentName and that belong to the specified categories.componentName - the component namecategories - regardless of the category if null.IllegalArgumentException - if there is no component named namepublic String getTag()
public void connected(AgentInfo... ai)
AgentPresenceListeneragents are fully connected to the buses, they
are OPERATIONAL and ready to receive commands.
This method is invoked when the listener is added with all the agents that
are already connected.
When this method is invoked the agent is in PhaseState::OPERATIONAL state
and all its services are guaranteed to have been properly initialized.
The implementation should return immediately : any blocking operations
should be scheduled on a separate thread.connected in interface AgentPresenceListenerpublic ConfigurationService.ConfigurationLock acquireConfigurationLock()
ConfigurationService.ConfigurationLock object holding the lock.public ConfigurationService.ConfigurationLock tryAcquireConfigurationLock(long time, TimeUnit unit) throws InterruptedException, TimeoutException
time - how long to wait.unit - the units in which the wait time is expressed.ConfigurationService.ConfigurationLock object holding the lockInterruptedException - if the current thread is interrupted while this lock is being
acquired.TimeoutException - if the waiting time elapsed before the lock was acquired.public ConfigurationService.ConfigurationWriteLock acquireConfigurationWriteLock()
ConfigurationService.ConfigurationWriteLock object holding the lock.public ConfigurationService.ConfigurationWriteLock tryAcquireConfigurationWriteLock(long time, TimeUnit unit) throws InterruptedException, TimeoutException
time - how long to wait.unit - the units in which the wait time is expressed.ConfigurationService.ConfigurationWriteLock object holding the lockInterruptedException - if the current thread is interrupted while
this lock is being acquired.TimeoutException - if the wait time elapses before the lock is
acquired.public ComponentConfigurationEnvironment getComponentConfigurationEnvironment(String name)
name - the name of the componentComponentConfigurationEnvironment object, providing a
component level configuration APIpublic void addConfigurationListener(ConfigurationListener listener)
listener - The ConfigurationListener to be addedpublic void removeConfigurationListener(ConfigurationListener listener)
listener - The ConfigurationListener to be addedpublic ConfigurationInfo.Builder buildConfigurationInfo(ConfigurationView newView)
buildConfigurationInfo(org.lsst.ccs.config.ConfigurationView, boolean)
which this method calls with a second argument of true (new configuration must be complete).newView - the view of the new configuration which needs a ConfigurationInfo made for it.ConfigurationInfo.ConfigurationInfopublic ConfigurationInfo.Builder buildConfigurationInfo(ConfigurationView newView, boolean mustBeComplete)
ConfigurationInfo, which is what later gets sent on the CCS status bus.newView - the view of the new configuration which needs a ConfigurationInfo made for it.mustBeComplete - true if and only if no missing parameters can be tolerated.ConfigurationInfo.ConfigurationInfopublic List<ConfigurationParameterHandler> getCategoryParameters(String category)
category - the name of the category.RuntimeException - if no such category exists.public ConfigurationParameterHandler getParameterByPath(ParameterPath path)
path - the parameter path object.IllegalArgumentException - if the parameter doesn't exist.public boolean saveInitialConfiguration()
true if it was, else false.public ConfigurationView getInitialView()
Copyright © 2021 LSST. All rights reserved.