More information: http://www.cs.berkeley.edu/~mdw/proj/seda/

seda.sandStorm.main
Class SandstormConfig

java.lang.Object
  |
  +--seda.sandStorm.main.SandstormConfig
All Implemented Interfaces:
java.lang.Cloneable

public class SandstormConfig
extends java.lang.Object
implements java.lang.Cloneable

This class is used to pass configuration parameters into Sandstorm at startup time. It reads initial configuration parameters from a file, using an XML-like format. Various operations can be performed upon this class to modify the configuration of the Sandstorm runtime.

Author:
Matt Welsh
See Also:
Sandstorm, Main

Inner Class Summary
(package private)  class SandstormConfig.configSection
           
(package private)  class SandstormConfig.directiveReader
          Internal class to preprocess special directives in the config file.
 
Field Summary
static java.lang.String CONFIG_FALSE
          String value for setting boolean configuration entries to false.
static java.lang.String CONFIG_TRUE
          String value for setting boolean configuration entries to true.
 java.util.Hashtable defaultInitArgs
          Default initialization arguments passed to every stage.
static java.lang.String[] defaults
          The set of default values for the Sandstorm configuration.
static java.lang.String LIST_ELEMENT_DELIMITER
           
static java.lang.String THREADMGR_AggTPSTM
          Value for defaultThreadMgr to use the aggregating TPSTM.
static java.lang.String THREADMGR_TPPTM
          Value for defaultThreadMgr to use the thread-per-CPU thread manager.
static java.lang.String THREADMGR_TPSTM
          Value for defaultThreadMgr to use the thread-per-stage thread manager.
 
Constructor Summary
SandstormConfig()
          Create a new SandstormConfig with the default settings.
SandstormConfig(java.lang.String fname)
          Create a new SandstormConfig, reading the configration from the given file.
SandstormConfig(java.lang.String[] defaultArgs)
          Create a new SandstormConfig with the default settings, with the given default init args, which will be passed to every stage.
SandstormConfig(java.lang.String fname, java.lang.String[] defaultArgs)
          Create a new SandstormConfig, reading the configration from the given file.
 
Method Summary
 void addStage(java.lang.String stageName, java.lang.String className, java.lang.String[] initargs)
          Add a stage to this SandstormConfig.
 boolean getBoolean(java.lang.String key)
          Return the configuration option associated with the given key as a boolean.
 boolean getBoolean(java.lang.String key, boolean defaultval)
          Return the configuration option associated with the given key as a boolean.
 SandstormConfig getCopy()
          Return a copy of this object.
 double getDouble(java.lang.String key)
          Return the configuration option associated with the given key as a double.
 double getDouble(java.lang.String key, double defaultval)
          Return the configuration option associated with the given key as a double.
 int getInt(java.lang.String key)
          Return the configuration option associated with the given key as an int.
 int getInt(java.lang.String key, int defaultval)
          Return the configuration option associated with the given key as an int.
 java.util.Enumeration getKeys()
          Return an enumeration of the top-level keys in this configuration.
 java.util.Enumeration getKeys(java.lang.String prefix)
          Return an enumeration of the keys matching the given prefix.
 java.util.Enumeration getStages()
          Return an Enumeration of the stages specified by this SandstormConfig.
 java.lang.String getString(java.lang.String key)
          Return the configuration option associated with the given key as a String.
 java.lang.String getString(java.lang.String key, java.lang.String defaultval)
          Return the configuration option associated with the given key as a String.
 java.lang.String[] getStringList(java.lang.String key)
          Get the string list value corresponding to the given key.
 void putBoolean(java.lang.String key, boolean val)
          Set the given configuration option specified as a boolean.
 void putDouble(java.lang.String key, double val)
          Set the given configuration option specified as an int.
 void putInt(java.lang.String key, int val)
          Set the given configuration option specified as an int.
 void putString(java.lang.String key, java.lang.String val)
          Set the given configuration option specified as a String.
 void puttStringList(java.lang.String key, java.lang.String[] valarr)
          Set the given key to the given string list value.
 void readFile(java.lang.String fname)
          Read the configuration from the given file.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIST_ELEMENT_DELIMITER

public static final java.lang.String LIST_ELEMENT_DELIMITER

THREADMGR_TPPTM

public static final java.lang.String THREADMGR_TPPTM
Value for defaultThreadMgr to use the thread-per-CPU thread manager.

THREADMGR_TPSTM

public static final java.lang.String THREADMGR_TPSTM
Value for defaultThreadMgr to use the thread-per-stage thread manager.

THREADMGR_AggTPSTM

public static final java.lang.String THREADMGR_AggTPSTM
Value for defaultThreadMgr to use the aggregating TPSTM.

CONFIG_TRUE

public static final java.lang.String CONFIG_TRUE
String value for setting boolean configuration entries to true.

CONFIG_FALSE

public static final java.lang.String CONFIG_FALSE
String value for setting boolean configuration entries to false.

defaults

public static final java.lang.String[] defaults
The set of default values for the Sandstorm configuration. In order to modify the default configuration used by Sandstorm, edit SandstormConfig.java and recompile.

defaultInitArgs

public java.util.Hashtable defaultInitArgs
Default initialization arguments passed to every stage.
Constructor Detail

SandstormConfig

public SandstormConfig()
Create a new SandstormConfig with the default settings.

SandstormConfig

public SandstormConfig(java.lang.String[] defaultArgs)
                throws java.io.IOException
Create a new SandstormConfig with the default settings, with the given default init args, which will be passed to every stage. Each element of defaultArgs[] is a String in the format "key=value". If "key" contains a dot ("."), then it will be treated as a key to be added to the Sandstorm configuration's global parameters. Otherwise, the key-value pair will be added to the "initargs" section for each stage.

SandstormConfig

public SandstormConfig(java.lang.String fname)
                throws java.io.IOException
Create a new SandstormConfig, reading the configration from the given file. The configuration file uses an XML-like structure; see the Sandstorm documentation for more information on its format.

SandstormConfig

public SandstormConfig(java.lang.String fname,
                       java.lang.String[] defaultArgs)
                throws java.io.IOException
Create a new SandstormConfig, reading the configration from the given file. The configuration file uses an XML-like structure; see the Sandstorm documentation for more information on its format.
Parameters:
defaultInitArgs - Default initialization arguments passed to every stage. These override any arguments found in the config file. Each element of this array must be a string with the format "key=value".
Method Detail

getString

public java.lang.String getString(java.lang.String key)
Return the configuration option associated with the given key as a String. Returns null if not set.

getString

public java.lang.String getString(java.lang.String key,
                                  java.lang.String defaultval)
Return the configuration option associated with the given key as a String. Returns default if not set.

putString

public void putString(java.lang.String key,
                      java.lang.String val)
Set the given configuration option specified as a String.

getBoolean

public boolean getBoolean(java.lang.String key)
Return the configuration option associated with the given key as a boolean. Returns false if not set.

getBoolean

public boolean getBoolean(java.lang.String key,
                          boolean defaultval)
Return the configuration option associated with the given key as a boolean. Returns default if not set.

putBoolean

public void putBoolean(java.lang.String key,
                       boolean val)
Set the given configuration option specified as a boolean.

getInt

public int getInt(java.lang.String key)
Return the configuration option associated with the given key as an int. Returns -1 if not set or if the value of the key cannot be expressed as an int.

getInt

public int getInt(java.lang.String key,
                  int defaultval)
Return the configuration option associated with the given key as an int. Returns default if not set or if the value of the key cannot be expressed as an int.

putInt

public void putInt(java.lang.String key,
                   int val)
Set the given configuration option specified as an int.

getDouble

public double getDouble(java.lang.String key)
Return the configuration option associated with the given key as a double. Returns -1 if not set or if the value of the key cannot be expressed as a double.

getDouble

public double getDouble(java.lang.String key,
                        double defaultval)
Return the configuration option associated with the given key as a double. Returns default if not set or if the value of the key cannot be expressed as a double.

getStringList

public java.lang.String[] getStringList(java.lang.String key)
Get the string list value corresponding to the given key. Returns null if not set.

putDouble

public void putDouble(java.lang.String key,
                      double val)
Set the given configuration option specified as an int.

puttStringList

public void puttStringList(java.lang.String key,
                           java.lang.String[] valarr)
Set the given key to the given string list value.

getKeys

public java.util.Enumeration getKeys(java.lang.String prefix)
Return an enumeration of the keys matching the given prefix. A given key maps onto a set of child keys if it ends in a "." character (that is, it is an internal node within the tree). A key not ending in "." is a terminal node and maps onto a value that may be obtained using getString, getInt, or getDouble.

getKeys

public java.util.Enumeration getKeys()
Return an enumeration of the top-level keys in this configuration.

getCopy

public SandstormConfig getCopy()
Return a copy of this object.

addStage

public void addStage(java.lang.String stageName,
                     java.lang.String className,
                     java.lang.String[] initargs)
              throws StageNameAlreadyBoundException,
                     java.io.IOException
Add a stage to this SandstormConfig.
Parameters:
stageName - The name of the stage as it should be registered.
className - The fully-qualified class name of the stage event handler.
initargs - The initial arguments to pass into the stage.

getStages

public java.util.Enumeration getStages()
Return an Enumeration of the stages specified by this SandstormConfig.

readFile

public void readFile(java.lang.String fname)
              throws java.io.IOException
Read the configuration from the given file.

More information: http://www.cs.berkeley.edu/~mdw/proj/seda/