org.lsst.ccs.config
Class ConfigurationFacade

java.lang.Object
  extended by org.lsst.ccs.config.ConfigurationFacade

public class ConfigurationFacade
extends Object

implements complex strategies on top of the DBInterface. Dues to cache problems there should be only one instance of this class operating on the network. services are to be addressed remotely if needed.

Author:
bamade

Constructor Summary
ConfigurationFacade(DBInterface dao)
          creates a facade object on top of a Data Access Object that implements the base services.
 
Method Summary
 ConfigProfile deprecateConfigProfile(String name, String tag)
          Deprecates a ConfigProfile.
 SubsystemDescription deprecateSubsystemDescription(String subsystemName, String tag)
          Deprecates a Subsystem description already in the database.
 void endRun(String subsystemName, String configName, String tag, long endTime)
          marks the end of a run.
 ParameterConfiguration engineerParmConfig(ParameterConfiguration parameterConfiguration)
          registers modified parameter during an engineering session
 org.lsst.gruth.jutils.ComponentNode getActiveComponentNode(MachineConfiguration machineConfiguration)
          gets a ComponentNode from a MachineConfiguration object
 org.lsst.gruth.jutils.ComponentNode getActiveComponentNode(String subsystemName, String configName, String tag)
          Gets a ComponentNode that can ge used to start a subsystem.
 ConfigProfile getActiveConfigProfile(String name, String tag)
          returns an active ConfigProfile with name and tag
 SubsystemDescription getActiveSubsystemDescription(String name, String tag)
          returns the active subsystem description with name and tag.
 String getActiveValueAt(String subsystemName, String parameterPath, long date)
          returns the value of a parameter for a subsystem at a given date.
 ConfigProfile getConfigRunningAt(String subsystemName, long date)
          returns the ConfigProfile active when a subsystem was running at that date.
 ConfigProfile getConfigValidAt(String configName, String configTag, long date)
          tries to get a ConfigProfile which was valid at a given date.
 MachineConfiguration getMachineConfiguration(String macAddress)
          get a MachineConfiguration object from the database.
 ConfigProfile getNext(ConfigProfile current)
          gets the next modified ConfigProfile with same name and tag
 ConfigProfile getPrevious(ConfigProfile current)
          gets a previous ConfigProfile with the same name and tag.
 SubsystemDescription getPrevious(SubsystemDescription current)
          returns the previous description with same name and tag.
 String getValueValidAt(String profileName, String profileTag, String parameterPath, long date)
          returns the value of a parameter at a given time for a given Profile.
 ConfigProfile registerConfigProfile(ConfigProfile newProfile)
          registers a ConfigProfile in the database.
 void registerMachineConfiguration(MachineConfiguration machineConfiguration)
          regsiters a MachineConfiguration object to the database
 PreparedConfiguration registerPreparedConfiguration(String subsystemName, String configName, String tag, String user)
          creates and registers a PreparedConfiguration.
 void registerRun(String subsystemName, String configName, String tag, long startTime)
          the run and end registrations are based on messages received from a subsystem.
 SubsystemDescription registerSubsystemDescription(SubsystemDescription newDescription)
          registers a new (and complete) SubsystemDescription to the persistence Layer.
 void setDeprecationListener(DeprecationListener deprecationListener)
           
 List<?> simpleHQLRequest(String hqlString)
          forwards an HQLrequest to the DAO.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationFacade

public ConfigurationFacade(DBInterface dao)
creates a facade object on top of a Data Access Object that implements the base services.

Parameters:
dao -
Method Detail

setDeprecationListener

public void setDeprecationListener(DeprecationListener deprecationListener)

registerSubsystemDescription

public SubsystemDescription registerSubsystemDescription(SubsystemDescription newDescription)
                                                  throws PersistenceLayerException
registers a new (and complete) SubsystemDescription to the persistence Layer. if a previous SubsystemDescription with same subsystemName AND tag is present then it is pushed in history and replaced by the new one as a subsystem which is "alive".

To avoid side effects always write code like this:

 description = facade.registerSubsystemDescription(description);
 

if trying to save a Subsystem description already under DB management this method does nothing.

Parameters:
newDescription - a new SubsystemDescription with all ParameterDescriptions (this object is managed and modified by the persistence layer)
Returns:
an unmodifiable version of the modified parameter
Throws:
PersistenceLayerException
IllegalArgumentException - if argument not a "new" description (generated by the factories)

deprecateSubsystemDescription

public SubsystemDescription deprecateSubsystemDescription(String subsystemName,
                                                          String tag)
                                                   throws PersistenceLayerException
Deprecates a Subsystem description already in the database. If it's not there nothing happens!

Parameters:
subsystemName -
tag - use "" if there is no tag
Returns:
the deprecated description (or null if none was deprecated)
Throws:
PersistenceLayerException

getActiveSubsystemDescription

public SubsystemDescription getActiveSubsystemDescription(String name,
                                                          String tag)
                                                   throws PersistenceLayerException
returns the active subsystem description with name and tag.

Parameters:
name -
tag -
Returns:
null if none is found
Throws:
PersistenceLayerException

registerConfigProfile

public ConfigProfile registerConfigProfile(ConfigProfile newProfile)
                                    throws PersistenceLayerException
registers a ConfigProfile in the database. if one with the same name and tag exists it is pushed in history and a DeprecationListener is warned.

Beware of side effect: better assign the returned object to the reference holding the argument.

if trying to save a Config Profile already under DB management this method does nothing.

Parameters:
newProfile -
Returns:
unmodifiable copy of argument
Throws:
PersistenceLayerException

deprecateConfigProfile

public ConfigProfile deprecateConfigProfile(String name,
                                            String tag)
                                     throws PersistenceLayerException
Deprecates a ConfigProfile. If not in database does nothing.

Important note: deprecating a configProfile to provide later a replacement will break the link between ConfigProfile (previousConfigID) so it is preferable to create directly a new replacement that will deprecate the previous one and update the link.

Parameters:
name -
tag -
Returns:
the deprecated ConfigProfile (or null if there was none)
Throws:
PersistenceLayerException

getActiveConfigProfile

public ConfigProfile getActiveConfigProfile(String name,
                                            String tag)
                                     throws PersistenceLayerException
returns an active ConfigProfile with name and tag

Parameters:
name -
tag -
Returns:
null if none found
Throws:
PersistenceLayerException

engineerParmConfig

public ParameterConfiguration engineerParmConfig(ParameterConfiguration parameterConfiguration)
                                          throws PersistenceLayerException
registers modified parameter during an engineering session

Parameters:
parameterConfiguration -
Returns:
Throws:
PersistenceLayerException
IllegalArgumentException - if the parameterConfiguration is not a regsitered active parameter of if the configuration is not in engineering mode

registerRun

public void registerRun(String subsystemName,
                        String configName,
                        String tag,
                        long startTime)
                 throws PersistenceLayerException
the run and end registrations are based on messages received from a subsystem. As much as possible the code tries to deal with lost messages (there is only one subsystem with a given name running at any time):

Parameters:
subsystemName -
configName -
tag -
startTime -
Throws:
PersistenceLayerException

endRun

public void endRun(String subsystemName,
                   String configName,
                   String tag,
                   long endTime)
            throws PersistenceLayerException
marks the end of a run. See the documentation of registerRun

Parameters:
subsystemName -
configName -
tag -
endTime -
Throws:
PersistenceLayerException

registerPreparedConfiguration

public PreparedConfiguration registerPreparedConfiguration(String subsystemName,
                                                           String configName,
                                                           String tag,
                                                           String user)
                                                    throws PersistenceLayerException
creates and registers a PreparedConfiguration.

Parameters:
subsystemName - can be null or empty if configName is valid
configName - can be null or empty if subsystemName is valid
tag -
Returns:
null if preparation is impossible
Throws:
PersistenceLayerException - id db problem
IllegalArgumentException - if subsystemName and ConfigName are incompatible

getActiveComponentNode

public org.lsst.gruth.jutils.ComponentNode getActiveComponentNode(String subsystemName,
                                                                  String configName,
                                                                  String tag)
                                                           throws PersistenceLayerException
Gets a ComponentNode that can ge used to start a subsystem. Depending on the value of parameters this can be build from a "default" description or from an active config Profile.

Parameters:
subsystemName -
configName -
tag -
Returns:
Throws:
PersistenceLayerException

getActiveComponentNode

public org.lsst.gruth.jutils.ComponentNode getActiveComponentNode(MachineConfiguration machineConfiguration)
                                                           throws PersistenceLayerException
gets a ComponentNode from a MachineConfiguration object

Parameters:
machineConfiguration -
Returns:
Throws:
PersistenceLayerException

registerMachineConfiguration

public void registerMachineConfiguration(MachineConfiguration machineConfiguration)
                                  throws PersistenceLayerException
regsiters a MachineConfiguration object to the database

Parameters:
machineConfiguration -
Throws:
PersistenceLayerException

getMachineConfiguration

public MachineConfiguration getMachineConfiguration(String macAddress)
                                             throws PersistenceLayerException
get a MachineConfiguration object from the database.

Parameters:
macAddress -
Returns:
null if none found
Throws:
PersistenceLayerException

getConfigRunningAt

public ConfigProfile getConfigRunningAt(String subsystemName,
                                        long date)
                                 throws PersistenceLayerException
returns the ConfigProfile active when a subsystem was running at that date.
PROBLEM: a subsystem may be running without a configProfile. so beware

Parameters:
subsystemName -
date -
Returns:
Throws:
PersistenceLayerException

getConfigValidAt

public ConfigProfile getConfigValidAt(String configName,
                                      String configTag,
                                      long date)
                               throws PersistenceLayerException
tries to get a ConfigProfile which was valid at a given date. Since there is only one Config profile active with a given name at a given date there is only one parameter needed (there is no need for a subsystem name)

Parameters:
configName -
configTag -
Returns:
Throws:
PersistenceLayerException

getActiveValueAt

public String getActiveValueAt(String subsystemName,
                               String parameterPath,
                               long date)
                        throws PersistenceLayerException
returns the value of a parameter for a subsystem at a given date.

BUG: this method is not correct when a "default" subsystem is run without a configuration. Will be changed!

Parameters:
subsystemName -
parameterPath -
date -
Returns:
Throws:
PersistenceLayerException

getValueValidAt

public String getValueValidAt(String profileName,
                              String profileTag,
                              String parameterPath,
                              long date)
                       throws PersistenceLayerException
returns the value of a parameter at a given time for a given Profile.

Parameters:
profileName -
profileTag -
parameterPath - a String in Path syntax ("componentName//parameterName")
date -
Returns:
null if profile or parameter not found
Throws:
PersistenceLayerException

getPrevious

public ConfigProfile getPrevious(ConfigProfile current)
                          throws PersistenceLayerException
gets a previous ConfigProfile with the same name and tag.

Parameters:
current -
Returns:
null if there is none (or if the deprecation was not carried out through a replacement or repair)
Throws:
PersistenceLayerException

getNext

public ConfigProfile getNext(ConfigProfile current)
                      throws PersistenceLayerException
gets the next modified ConfigProfile with same name and tag

Parameters:
current -
Returns:
null if none or deprecation was not carried out through a replacement or repair
Throws:
PersistenceLayerException

getPrevious

public SubsystemDescription getPrevious(SubsystemDescription current)
                                 throws PersistenceLayerException
returns the previous description with same name and tag.

Parameters:
current -
Returns:
previous description or null if there was none (or if the previous one was not deprecated through a replacement)
Throws:
PersistenceLayerException

simpleHQLRequest

public List<?> simpleHQLRequest(String hqlString)
                         throws PersistenceLayerException
forwards an HQLrequest to the DAO. Though this is not yet tested only "from" (SELECT) request should be accepted

Parameters:
hqlString -
Returns:
Throws:
PersistenceLayerException


Copyright © 2013 LSST. All Rights Reserved.