
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.
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.
|
void |
addConfigurationListener(ConfigurationListener listener)
Add a configuration listener.
|
void |
afterStart() |
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 |
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.
|
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.
|
Properties |
getBuildProperties() |
static Properties |
getBuildProperties(String agentName,
String descriptionName)
Utility method to fetch build level properties.
|
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) |
String |
getConfigurationState()
Gets the current configuration state.
|
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. |
List<DataProviderInfo> |
getDataProviderInfos()
Get the list of available
DataProviderInfos. |
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. |
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 |
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 |
publishDataProviderCurrentData()
Publish the current data of all the
DataProviderInfos managed
by this object. |
void |
removeConfigurationListener(ConfigurationListener listener)
Remove a configuration listener.
|
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 |
setReadOnlyParameter(String componentName,
String parameterName,
Object value)
Set ReadOnly Configuration Parameter.
|
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, waitafterInit, preShutdownconnecting, disconnected, disconnectingstartForAgentbuild, init, postBuild, postInit, postShutdown, postStart, shutdown, startpublic String getAgentServiceName()
AgentServicegetAgentServiceName in interface AgentServicepublic static Properties getBuildProperties(String agentName, String descriptionName)
agentName - The name of the agentdescriptionName - The description name (groovy file)public Properties getBuildProperties()
public 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 void afterStart()
afterStart in interface ServiceLifecyclepublic List<DataProviderInfo> getDataProviderInfos()
HasDataProviderInfosDataProviderInfos.getDataProviderInfos in interface HasDataProviderInfosDataProviderInfospublic void publishDataProviderCurrentData()
HasDataProviderInfosDataProviderInfos managed
by this object.publishDataProviderCurrentData in interface HasDataProviderInfos@Command(category=CORE) public String getConfigurationParameterValue(@Argument(allowedValueProvider="getAllConfigurableComponents") String componentName, String parameterName)
@Command(category=CORE) public String printConfigurationParameters()
@Command(description="Saves all changes in the current configurations",
type=CONFIGURATION,
category=CORE)
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,
category=CORE)
public void saveAllChanges(String configName)
@Command(description="Saves the specified categories with a name",
type=CONFIGURATION,
category=CORE)
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,
category=CORE)
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,
category=CORE,
level=1)
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,
category=CORE,
level=1)
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,
category=CORE)
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,
category=CORE)
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,
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 or if the subsystem
is is INITIAL_SAFE configuration state.@Command(description="return a ConfigurationInfo object",
type=QUERY,
category=SYSTEM)
public ConfigurationInfo getConfigurationInfo()
@Command(description="return a ConfigurationInfo object",
type=QUERY,
category=CORE)
public String getConfigurationState()
public void setReadOnlyParameter(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.@Command(description="publish a ConfigurationInfo object",
type=QUERY,
category=SYSTEM)
public void publishConfigurationInfo()
@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)
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,
category=CORE,
level=1)
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,
category=CORE,
level=1)
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,
category=CORE,
level=1)
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,
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)
public Set<String> getCategories()
@Command(description="returns the available configurations for the given category",
type=CONFIGURATION,
category=CORE)
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,
category=CORE)
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,
category=CORE)
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,
category=SYSTEM)
public String locateConfigurations()
public 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
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 APIpublic void addConfigurationListener(ConfigurationListener listener)
listener - The ConfigurationListener to be addedpublic void removeConfigurationListener(ConfigurationListener listener)
listener - The ConfigurationListener to be addedCopyright © 2020 LSST. All rights reserved.