edu.virginia.cs.mng.hypercast.testing_and_monitoring
Class RC2

java.lang.Object
  |
  +--edu.virginia.cs.mng.hypercast.testing_and_monitoring.RC2
Direct Known Subclasses:
DT_RC2, HC_RC2

public class RC2
extends java.lang.Object

This class provides an interface that allows users to view and manipulate statistics and variables which are made available by a class that implements the I_Stats interface through an instance of the StatsAccessor class. Ideally, the processes that make these values available will also use StatsAccessorAdvertisers with their StatsAccessors. This will allow an instance of the PortalListManager class to automatically discover the ports that are used by the StatsAccessor instances.

See Also:
I_Stats, StatsAccessor, StatsAccessorAdvertiser, ReliableXmlSocket, PortalListManager

Field Summary
 java.util.Hashtable commands
          A Hashtable mapping the commands, e.g.
static int DEFAULT_PORT_WITH_NO_SERVER
          Default port used for the ActiveStatsAccessor.
 Experiment experiment
          Values for the current experiment.
 java.lang.Object experimentLock
          A guard to control access to the object experiment.
 PortalListManager portalManager
          The PortalListManager object that is used to discover and keep track of the StatsAccessors.
 ReliableXmlSocket reliableSocket
          The ReliableXmlSocket object that is used to send messages to the StatsAccessors.
 
Constructor Summary
protected RC2()
          Inserts generic RC2Command objects into commands.
 
Method Summary
(package private) static void ()
           
protected  void addCommand(java.lang.String s, RC2Command c)
          Used to insert an RC2Command object into commands.
protected  void commandLine(java.io.BufferedReader in, java.io.PrintStream out, java.io.PrintStream err)
          Receives commands on the InputStream and processes them.
protected  Experiment createExperiment()
          Creates a new Experiment.
 void go(java.lang.String[] args)
          A psuedo-main() method.
static void main(java.lang.String[] args)
          Creates a new object of type RS2 and calls go(args).
protected  void processCommand(java.lang.String line, java.io.BufferedReader in, java.io.PrintStream out, java.io.PrintStream err)
          Performs actions for a single command.
protected  void processCommands(java.lang.String[] lines, java.io.BufferedReader in, java.io.PrintStream out, java.io.PrintStream err)
          Calls the processCommand method for each command.
protected  java.lang.String removeBackspaces(java.lang.String s)
          Compensates for terminals that do not allow backspaces with the readln command.
 void usage()
          Prints the arguments that may be used by go().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT_WITH_NO_SERVER

public static final int DEFAULT_PORT_WITH_NO_SERVER
Default port used for the ActiveStatsAccessor.

reliableSocket

public ReliableXmlSocket reliableSocket
The ReliableXmlSocket object that is used to send messages to the StatsAccessors.

portalManager

public PortalListManager portalManager
The PortalListManager object that is used to discover and keep track of the StatsAccessors.

experiment

public Experiment experiment
Values for the current experiment.

experimentLock

public java.lang.Object experimentLock
A guard to control access to the object experiment. This prevents race conditions when multiple terminals are open.

commands

public java.util.Hashtable commands
A Hashtable mapping the commands, e.g. "help" (represented as Strings) to their associated RC2Command objects.
Constructor Detail

RC2

protected RC2()
Inserts generic RC2Command objects into commands.
Method Detail

addCommand

protected void addCommand(java.lang.String s,
                          RC2Command c)
Used to insert an RC2Command object into commands. This may be modified in the future in order to achieve greater command functionality. For example, it could keep track of what order the commands were added in.

createExperiment

protected Experiment createExperiment()
Creates a new Experiment. This method is expected to be overridden by any class that needs to have more variables associated with an Experiment.

main

public static void main(java.lang.String[] args)
Creates a new object of type RS2 and calls go(args).

usage

public void usage()
Prints the arguments that may be used by go().

go

public void go(java.lang.String[] args)
A psuedo-main() method. Any derived class's main() is expected to call go(). This method creates the reliableSocket and portalManager and then calls commandLine() with System.in, System.out, and System.err.

commandLine

protected void commandLine(java.io.BufferedReader in,
                           java.io.PrintStream out,
                           java.io.PrintStream err)
Receives commands on the InputStream and processes them. This is connected to the console by go(). A command could connect it to a TCP socket for remote access. This function catches all exceptions. If the exception is Exception("quit"), then it will halt; all other exceptions will cause the stack to be printed and then operation will continue.

removeBackspaces

protected java.lang.String removeBackspaces(java.lang.String s)
Compensates for terminals that do not allow backspaces with the readln command. This method removes all backspaces from a string (and all of the characters preceding them).

processCommands

protected void processCommands(java.lang.String[] lines,
                               java.io.BufferedReader in,
                               java.io.PrintStream out,
                               java.io.PrintStream err)
                        throws java.lang.Exception
Calls the processCommand method for each command. If a command throws an Exception("break"), then the processing halts.

processCommand

protected void processCommand(java.lang.String line,
                              java.io.BufferedReader in,
                              java.io.PrintStream out,
                              java.io.PrintStream err)
                       throws java.lang.Exception
Performs actions for a single command.

static void ()