com.isti.trinetwatch.controlAgentSim
Class ControlAgentSim

java.lang.Object
  extended by com.isti.trinetwatch.controlAgentSim.ControlAgentSim

public class ControlAgentSim
extends java.lang.Object

Class ControlAgentSim defines a simulated control agent used to change usage levels on simulated stations.


Command Line Options

-c, --ctaSimConfig [path] : The file to use as the configuration file for the Control Agent Simulator. The default file is [baseDir]/conf/CTASim.conf
-b, --baseDir [path] : The base directory into which the different program files, configuration files and log files are placed. The directories are [baseDir}/bin, [baseDir]/conf, [baseDir]/class, and [baseDir]/log. Any program executables are place in 'bin', configuration files are placed in 'conf', the Java class files are placed in 'class', and any log files are placed in 'log'. The default base directory is '/usr/local/TSOI'.
-d, --daemon : puts the CTASim in daemon mode (run forever). Default is to accept a terminate command on the keyboard to shutdown.
-l, --globalLogFileName [file] : The Control Agent Sim logs much information. It is all put into a single global log file. The default name of the file is "CTASim.log" and it is placed in the directory '[baseDir]/log/'. The option accepts absolute paths, relative paths or just the file name.
-o, --logfileLogLevel [level] :There are six (6) different levels at which logging can be done. They are: 'NO_MSGS', 'INFO', 'WARNING', 'ERROR', 'DEBUG', and 'ALL_MSGS'. One of these must be used as the argument. The default level is ERROR.
-O, --consoleLogLevel [level] : Log messages are also printed to the terminal. This switch tells the Control Agent Sim what level of messages to print to the console. The levels are the same as for logfileLogLevel. The default level is ERROR.
-C, --controlFileName [file] : The control file is a file which holds information about how the Control Agent Sim will treat requests for usage level changes for different stations. The switch accepts absolute paths, relative paths, or just the file name. The default location of this file is '[baseDir]/conf/controlSim.ini'.
-ORBconfig [file] : The orb.conf file is needed to correctly set up CORBA communications. The switch accepts absolute paths, relative paths, or just the file name. The default location of this file is '[baseDir]/conf/orb.config'.
-n, --ctaSimName {name_of_server] : This is where the name of the Control Agent Sim is entered. The default value is an empty string.


The CTASim.conf file

All the options the user can change on the command line can also be changed in the file 'CTASim.conf', except for the option to specify where the file is. The format of the file goes like this: Each item has the format 'name = value'; string values must be enclosed in double quotes (""); 'special' characters must be 'quoted' using a backslash (\), including \n \r \t\ \" \#; and comments begin with '#', '//' or are C-style comments. Following is a list of the configurable parameters which can be specified in this file. They mirror the command line switches and use the same values.

     baseDir = "[path]"
     globalLogFileName = "[filename]"
     logfileLogLevel = "[level]"
     consoleLogLevel = "[level]"
     controlFileName = "[filename]"
     orbConfig = "[filename]"
     ctaSimName = "{serverName}"
     daemon = 'true or false'
 



Constructor Summary
ControlAgentSim(LogFile log, CfgProperties cfgPropObj)
          Creates an instance of ControlAgentSim.
 
Method Summary
 java.lang.String agentName()
          Returns the name of the control agent.
static java.lang.String doesFileExist(java.lang.String fileName)
          This method checks to see if the file 'fileName' exists.
static java.lang.String doesFileExist(java.lang.String fileName, java.lang.String baseDir, java.lang.String specialDir)
          This method checks to see if the given file exists.
 java.util.Vector getCurrentControlVec()
          Returns a vector of the stations that are currently being controled.
 LevChange_provider getLevChangeChan()
          Returns a handle to the event channel used to inform the collection agent about a successful change in usage level for a given station.
 LevChangeUpdate getLevChUpdate()
          Returns a handle to the event channel used to send a message to the NSI server with an update for the new usage level for a given station.
 java.lang.String getOrbCfgFilePath()
          Returns the path to the orb configuration file.
 CtaSimToS_provider getResultChan()
          Returns a handle to the CTRL_RESULT event channel.
 java.lang.Runtime getRuntime()
          Returns the runtime object for this program.
 java.lang.String getScriptPath(java.lang.String stationName, int level)
          Returns the path to the script file used to change a given station to a new usage level.
 java.lang.Integer getTimeout(java.lang.String stationName, int level)
          Returns the maximum length of time (timeout) a station should take to complete to change to a given usage level.
static java.lang.String getVersion()
          Returns the version of this agent.
 boolean initCORBAservices(java.lang.String[] args, boolean daemonFlag)
          Initializes CORBA services and connects to the CORBA event channels.
static void main(java.lang.String[] args)
          The method executed to begin the simulated control agent.
static int propLogLevel(CfgPropItem tmpProp)
          This method looks at the string value of the given property item and returns the integer for the loging level that string represents.
 boolean readConfigFiles(java.lang.String controlFileName)
          Reads in the necessary configuration file(s).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControlAgentSim

public ControlAgentSim(LogFile log,
                       CfgProperties cfgPropObj)
Creates an instance of ControlAgentSim.

Parameters:
log - a log file object.
cfgPropObj - the configuration properties object.
Method Detail

readConfigFiles

public boolean readConfigFiles(java.lang.String controlFileName)
Reads in the necessary configuration file(s). There is one configuration file needed, 'controlSim.ini'.

Parameters:
controlFileName - a string containing the filename of the 'controlSim.ini' file.
Returns:
true if the file is successfully read in; false if error.

initCORBAservices

public boolean initCORBAservices(java.lang.String[] args,
                                 boolean daemonFlag)
Initializes CORBA services and connects to the CORBA event channels.

Parameters:
args - array of command line argument strings.
daemonFlag - true if "daemon" mode is enabled, false if not.
Returns:
true if successful, false if error.

getRuntime

public java.lang.Runtime getRuntime()
Returns the runtime object for this program.


getScriptPath

public java.lang.String getScriptPath(java.lang.String stationName,
                                      int level)
Returns the path to the script file used to change a given station to a new usage level.

Parameters:
stationName - a string with the name of the station whose level will be changed.
level - an integer representing the level to which the station will be changed.
Returns:
The path to the script file to use for the level change or an empty string if an error occurs.

getTimeout

public java.lang.Integer getTimeout(java.lang.String stationName,
                                    int level)
Returns the maximum length of time (timeout) a station should take to complete to change to a given usage level.

Parameters:
stationName - the name of the station whose usage level is to be changed.
level - the integer value of the usage level the station is being changed to.
Returns:
An Integer indicating the length of time before timeout.

getCurrentControlVec

public java.util.Vector getCurrentControlVec()
Returns a vector of the stations that are currently being controled.


getLevChUpdate

public LevChangeUpdate getLevChUpdate()
Returns a handle to the event channel used to send a message to the NSI server with an update for the new usage level for a given station.

Returns:
A handle to an object of type LevChangeUpdate.

getLevChangeChan

public LevChange_provider getLevChangeChan()
Returns a handle to the event channel used to inform the collection agent about a successful change in usage level for a given station.

Returns:
A handle to an object of type LevChange_provider.

getResultChan

public CtaSimToS_provider getResultChan()
Returns a handle to the CTRL_RESULT event channel.

Returns:
A handle to an object of type CtaToS_provider.

getOrbCfgFilePath

public java.lang.String getOrbCfgFilePath()
Returns the path to the orb configuration file.

Returns:
The path to the orb configuration file.

agentName

public java.lang.String agentName()
Returns the name of the control agent.

Returns:
String containing the name of the agent.

getVersion

public static java.lang.String getVersion()
Returns the version of this agent.

Returns:
A string holding the version number.

propLogLevel

public static int propLogLevel(CfgPropItem tmpProp)
This method looks at the string value of the given property item and returns the integer for the loging level that string represents.

Parameters:
tmpProp - A CfgPropItem who's string value data represents a logging level.
Returns:
The integer of the log level asscoiated with the string value in the configuration property.

doesFileExist

public static java.lang.String doesFileExist(java.lang.String fileName)
This method checks to see if the file 'fileName' exists. 'fileName' can be either a relative path or a full bath to the file.

Parameters:
fileName - The relative path or full path to a file.
Returns:
If the file was found the path (relative or full) to the file is returned, otherwise an empty string is returned.

doesFileExist

public static java.lang.String doesFileExist(java.lang.String fileName,
                                             java.lang.String baseDir,
                                             java.lang.String specialDir)
This method checks to see if the given file exists. The order of searching goes like this:
1) use just 'fileName' to search for file existence in the current directory (can be a sub-directory path) or from the root directory as a full pathname (must begin with a '/').
2) if searching for 'fileName' fails to find an existing file then the path '[baseDir][specialDir][fileName]' is used to attempt to find an existing file.
If there is no file found by this procedure then an empty string is returned.

Parameters:
fileName - The relative path or full path to a file.
baseDir - A base directory to fall back upon if 'fileName' is a relative path and does not point directly to a file somewhere in the current directory.
specialDir - The special (sub) directory of [baseDir] in which the file should reside. It can be either 'bin', 'class', 'conf', or 'log'.
Returns:
If the file was found the path (relative or full) to the file is returned, otherwise an empty string is returned.

main

public static void main(java.lang.String[] args)
The method executed to begin the simulated control agent.

Parameters:
args - a string containing the command line arguments.