
public final class ConfigurationService extends Object implements ServiceLifecycle, ClearAlertHandler, AgentPresenceListener, AgentService
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.
INITIAL_SAFE and only
a full configuration load can be performed.
If the first configuration load is successful, 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
Gets a handle on the configuration lock when an object of this class is
instantiated.
|
ClearAlertHandler.ClearAlertCode| Constructor and Description |
|---|
ConfigurationService() |
| Modifier and Type | Method and Description |
|---|---|
ConfigurationService.ConfigurationLock |
acquireConfigurationLock()
Acquires the configuration lock.
|
ClearAlertHandler.ClearAlertCode |
canClearAlert(Alert alert)
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 |
connecting(AgentInfo ai)
Indicates that the agent represented by
agent is present on the
buses. |
void |
disconnecting(AgentInfo agent)
Indicates that the agent represented by
agent has left the buses. |
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.
|
Set<String> |
findAvailableConfigurationsForCategory(String category)
Returns the available configuration names for the given category.
|
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.
|
Set<String> |
getCategories()
Returns the set of categories the subsystem's configurable parameters are
split into.
|
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) |
Map<String,String> |
getCurrentValuesForComponent(String componentName,
Set<String> categorySet)
Returns the current values of the configuration parameters that belong to
componentName and that belong to the specified categories. |
Map<String,String> |
getSubmittedChangesForComponent(String name)
Gets the submitted changes for the specified component
|
String |
getTag() |
boolean |
isParameterConfigurable(String componentName,
String parameterName)
Indicates whether their is a configuration parameter named
parameterName that belong to the component componentName. |
void |
loadCategories(String... taggedCategories)
Loads a configuration for the specified categories.
|
void |
loadConfiguration(String... taggedCategories)
Full configuration load.
|
void |
loadGlobalConfiguration(String globalName,
int version)
Full configuration load, based on a named combination of named
configurations for each existing category.
|
String |
locateConfigurations() |
void |
preBuild() |
void |
preInit() |
void |
preStart()
Called from the enclosing
Subsystem when
org.lsst.ccs.Subsystem#start() has been called. |
String |
printConfigurationParameters() |
void |
publishConfigurationInfo()
Publishes the current configurationInfo object on the status bus.
If configuration parameters are modified outside of one of the provided configuration API command, they will no be reflected by the published ConfigurationInfo object. |
void |
saveAllChanges()
Saves the current value of each parameter in the current running
configuration.
|
void |
saveAllChanges(String configName) |
void |
saveChangesForCategories(String... categories)
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... taggedCategories)
Saves the current value of each parameter that belongs to one of the
specified categories in a new configuration for this category.
|
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 the configuration lock if it is free within the given waiting
time and the current thread has not been
Thread.interrupt. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpreShutdownconnectingstartForAgentpublic String getAgentServiceName()
AgentServicegetAgentServiceName in interface AgentServicepublic void preBuild()
preBuild in interface ServiceLifecyclepublic ClearAlertHandler.ClearAlertCode canClearAlert(Alert alert)
ClearAlertHandlerAlert instance.
Return true/false if the Alert can be cleared.
When true is returned the Alert is cleared and no more handlers will
be checked. When false is returned other handlers will be handed the Alert
instance to be cleared. If no handler returns true, the Alert will not be
cleared.canClearAlert in interface ClearAlertHandleralert - The Alert instance to clear.public 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 ServiceLifecycle@Command public String getConfigurationParameterValue(@Argument(allowedValueProvider="getAllConfigurableComponents") String componentName, String parameterName)
@Command(description="Saves all changes in the current configurations", type=CONFIGURATION) public void saveAllChanges()
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
or if the subsystem is is INITIAL_SAFE configuration state.@Command(description="Saves all changes in the current configurations", type=CONFIGURATION) public void saveAllChanges(String configName)
@Command(description="Saves the specified categories with a name", type=CONFIGURATION) public void saveChangesForCategories(@Argument(name="taggedCategories",description="A list of categories") String... categories)
categories - 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
or if the subsystem is is INITIAL_SAFE configuration state.@Command(description="Saves the specified categories with a name", type=CONFIGURATION) public void saveChangesForCategoriesAs(@Argument(name="taggedCategories",description="A list of pairs categoryName:configurationName") String... taggedCategories)
taggedCategories - a list of pairs
categoryName:configurationName. {ConfigurationServiceException - if the configuration service is not
available.IllegalStateException - if the subsystem is not in engineering mode
or if the subsystem is is INITIAL_SAFE configuration state.@Command(description="drop all unsaved changes", type=CONFIGURATION) public void dropAllChanges()
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
or if the subsystem is is INITIAL_SAFE configuration state.@Command(description="drop unsaved changes for the specified categories", type=CONFIGURATION) public void dropChangesForCategories(@Argument(name="categories",description="A list of categories") String... categories)
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
or if the subsystem is is INITIAL_SAFE configuration state.@Command(description="loads a new configuration", type=CONFIGURATION) public void loadConfiguration(@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 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 all categories for a given configuration", type=CONFIGURATION) public void loadGlobalConfiguration(@Argument(description="a name that defines a combination of tagegd categories") String globalName, int version)
globalName - a name that defines a combination of tagged categories.version - a version number. if negative, the latest version for the given tag is retrieved.IllegalArgumentException - if the named configuration does not
define a configuration to load for all categories.@Command(description="loads the configuration for the specified categories", type=CONFIGURATION) 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
or if the subsystem is is INITIAL_SAFE configuration state.@Command(description="return a ConfigurationInfo object", type=QUERY) public ConfigurationInfo getConfigurationInfo()
@Command(description="publish a ConfigurationInfo object", type=QUERY) public void publishConfigurationInfo()
@Command(description="Submits a single change to be processed immediately", type=CONFIGURATION) public void change(@Argument(allowedValueProvider="getAllConfigurableComponents") 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 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
or if the subsystem is is INITIAL_SAFE configuration state.@Command(description="Submits a change of parameter to be validated later", type=CONFIGURATION) public void submitChange(@Argument(allowedValueProvider="getAllConfigurableComponents") String componentName, String parameterName, Object value)
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
or if the subsystem is is INITIAL_SAFE configuration state.@Command(description="Submits changes of parameters to be validated later", type=CONFIGURATION) public void submitChanges(@Argument(allowedValueProvider="getAllConfigurableComponents") String componentName, Map<String,Object> changes)
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(description="processes the bulk change", type=CONFIGURATION) public void commitBulkChange()
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
or if the subsystem is is INITIAL_SAFE configuration state.@Command(description="Drops the submitted changes for all components", type=CONFIGURATION) public void dropAllSubmittedChanges()
@Command(description="Drops the submitted changes for the given component", type=CONFIGURATION) 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) 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) 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) public Set<String> getCategories()
@Command(description="returns the available configurations for the given category", type=CONFIGURATION) public Set<String> findAvailableConfigurationsForCategory(@Argument(allowedValueProvider="getCategoriesList") String category)
category - ConfigurationServiceException - if the configuration service is unavailable@Command(description="returns the current values for a given component that belong to the specified categories", type=CONFIGURATION) public Map<String,String> getCurrentValuesForComponent(@Argument(allowedValueProvider="getAllConfigurableComponents") String componentName, Set<String> categorySet)
componentName and that belong to the specified categories.componentName - the component namecategorySet - regardless of the category if null.IllegalArgumentException - if there is no component named
name@Command(type=CONFIGURATION) public boolean isParameterConfigurable(@Argument(allowedValueProvider="getAllConfigurableComponents") String componentName, String parameterName)
parameterName that belong to the component componentName.componentName - the component nameparameterName - the parameter namename
which belong to the component {@Command(description="locates configurations when they are loaded from the filesystem.", type=CONFIGURATION) public String locateConfigurations()
public String getTag()
public void connecting(AgentInfo ai)
AgentPresenceListeneragent is present on the
buses.
The implementation should return immediately : any blocking operations
should be scheduled on a separate thread.connecting in interface AgentPresenceListenerpublic void disconnecting(AgentInfo agent)
AgentPresenceListeneragent has left the buses.
The implementation should return immediately : any blocking operations
should be scheduled on a separate thread.disconnecting in interface AgentPresenceListenerpublic ConfigurationService.ConfigurationLock acquireConfigurationLock()
ConfigurationService.ConfigurationLock object holding the lock.public ConfigurationService.ConfigurationLock tryAcquireConfigurationLock(long time, TimeUnit unit) throws InterruptedException, TimeoutException
Thread.interrupt.time - unit - 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 ComponentConfigurationEnvironment getComponentConfigurationEnvironment(String name)
name - the name of the componentComponentConfigurationEnvironment object, providing a
component level configuration APICopyright © 2018 LSST. All rights reserved.