stella.util
Class DummySequencer

java.lang.Object
  extended by util.PropertyContainer
      extended by util.PropertyResources
          extended by util.PropertyBundles
              extended by util.rmi.RmiPropertyContainer
                  extended by util.rmi.AbstractRmiCaster
                      extended by stella.CastingContainer
                          extended by stella.AbstractSequencer
                              extended by stella.util.DummySequencer
All Implemented Interfaces:
Cloneable, Runnable, Remote, Caster, ClusterDepending, ErrorCaster, ReplySubscriber, Sequencing, CancelRunnable, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiCaster, RmiPropertyBearing

public class DummySequencer
extends AbstractSequencer
implements ErrorCaster

A class that implements a sequencer for testing the master mind. This sequencer simply waits for the approximated observation time if its start() method is called. For timing, it uses the KEY_TIME parameter provided by the ParameterClustering instance handed over, thus accelerated times are handled correctly.

To check the scheduler's response on different sequencing results, one can provide a list of error names, KEY_ERRORS that might be generated randomly as a result of the sequencing. The probabilities may be stated with the KEY_ERRORPROSPECTS list. Note that this list is different from KEY_INTERRUPTS.

To check the error handler's response on different errors during the scheduling, one might provide a KEY_INTERRUPTS list. These errors may be produced during a normal sequence and are sent back to the error listeners. Again, the probability of such errors to happen is governed in the KEY_INTERRUPTPROSPECTS list. Note that this list is different from KEY_ERRORS.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private  boolean cancel
          The prematurely stop the sequencer.
private static long DEFDURATION
          The default duration.
private static int DEFSTEP
          The default duration.
private static String DEFTIME
          The default time parameter.
private  long duration
          The estimated observation time of the target.
private static String ERRORPACKAGE
          The package-path to the error events.
private  Map errors
          The map of the error-event results.
private  Map interrupts
          The map of the error interrupts.
static String KEY_DURATION
          The duration to use for a target if not explicetly given.
static String KEY_ERRORPROSPECTS
          The time to use from the parameters for sleeps.
static String KEY_ERRORS
          The time to use from the parameters for sleeps.
static String KEY_INTERRUPTPROSPECTS
          The time to use from the parameters for sleeps.
static String KEY_INTERRUPTS
          The time to use from the parameters for sleeps.
static String KEY_STEP
          The choping intervall for the duration to derive a sleep time.
static String KEY_TIME
          The time to use from the parameters for sleeps.
private  Thread mythread
          The thread this sequencer runs in.
private static String NOERROR
          The place holder for a null-error event.
private  ParameterClustering set
          Reference to the parameters.
private  Value time
          The time value.
 
Fields inherited from class util.rmi.AbstractRmiCaster
ALTERNATEHOST, ALTERNATEPORT, KEY_BINDNAME, KEY_EXPORTPORT, KEY_REGISTRYHOST, KEY_REGISTRYPORT
 
Fields inherited from class util.PropertyBundles
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES
 
Fields inherited from class util.PropertyResources
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Fields inherited from interface util.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
DummySequencer(Map prop)
          Constructs a new dummy sequencer.
 
Method Summary
 void abort(List dummy)
          Abort sequence, not necessary.
 void append(List dummy)
          Append to sequence, not necessary.
 void cancel()
          Cancels the execution of the sequencer.
 void forward(ReplyEvent re)
          This method is called from reply deliverers.
private  ErrorEvent generateErrorEvent(Map errs)
          Generates an error event out of a map of available error event names.
 Thread getAsociatedThread()
          Always return a reference to mythread.
private static Map getErrorMap(String errorlist, String problist)
          Returns an error map linking error names to probabilities.
 List getStepsForTarget(TargetDefinition aux)
          Returns an empty list.
 Thread getThread()
          Returns the sequencer thread.
private  long getTime()
          Returns the time.
 boolean isCancel()
          Returns the cancel flag.
 void load(List dummy)
          Not necessary, returns immediately.
 long maxTimeToCancel()
          Returns 1000.
 void prepend(List dummy)
          Prepend to sequence, not necessary.
 void registerCluster(ParameterClustering cluster)
          Registers the parameter set.
 void registerLauncher(CommandLaunching[] launch)
          Register the command launchers.
 void registerRender(CommandRendering dummy)
          Register command renderer.
 void run()
          The run method of the dummy sequencer.
 Thread start()
          Starts the sequence.
 ErrorEvent success()
          Queries the result of a sequencing procedure.
 
Methods inherited from class stella.AbstractSequencer
createSequencer
 
Methods inherited from class stella.CastingContainer
addErrorListener, addRmiErrorListener, exit, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, sendStatus, sendStatus, sendStatus
 
Methods inherited from class util.rmi.AbstractRmiCaster
bindAlternate, bindToRegistry, bindToRegistry, bindToRegistry, casterExit, casterExit, getBindName, getBindName, unbindFromRegistry, unbindFromRegistry
 
Methods inherited from class util.rmi.RmiPropertyContainer
containsRemoteProperty, getRemoteProperties, getRemoteProperty, setRemoteProperty
 
Methods inherited from class util.PropertyBundles
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource
 
Methods inherited from class util.PropertyResources
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, init, keyCreate, keyCreate, reload, setApplet
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface stella.ErrorCaster
addErrorListener, removeErrorListener
 
Methods inherited from interface util.PropertySupplying
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
Methods inherited from interface util.Initializable
init
 

Field Detail

KEY_TIME

public static final String KEY_TIME
The time to use from the parameters for sleeps.

See Also:
Constant Field Values

KEY_DURATION

public static final String KEY_DURATION
The duration to use for a target if not explicetly given.

See Also:
Constant Field Values

KEY_STEP

public static final String KEY_STEP
The choping intervall for the duration to derive a sleep time.

See Also:
Constant Field Values

KEY_ERRORS

public static final String KEY_ERRORS
The time to use from the parameters for sleeps.

See Also:
Constant Field Values

KEY_ERRORPROSPECTS

public static final String KEY_ERRORPROSPECTS
The time to use from the parameters for sleeps.

See Also:
Constant Field Values

KEY_INTERRUPTS

public static final String KEY_INTERRUPTS
The time to use from the parameters for sleeps.

See Also:
Constant Field Values

KEY_INTERRUPTPROSPECTS

public static final String KEY_INTERRUPTPROSPECTS
The time to use from the parameters for sleeps.

See Also:
Constant Field Values

DEFTIME

private static final String DEFTIME
The default time parameter.

See Also:
Constant Field Values

DEFDURATION

private static final long DEFDURATION
The default duration.

See Also:
Constant Field Values

DEFSTEP

private static final int DEFSTEP
The default duration.

See Also:
Constant Field Values

NOERROR

private static final String NOERROR
The place holder for a null-error event.

See Also:
Constant Field Values

ERRORPACKAGE

private static final String ERRORPACKAGE
The package-path to the error events.

See Also:
Constant Field Values

set

private ParameterClustering set
Reference to the parameters. Needed for observation time retrieval.


time

private Value time
The time value.


errors

private Map errors
The map of the error-event results. Erros are keys, probabilites vals.


interrupts

private Map interrupts
The map of the error interrupts. Erros are keys, probabilites vals.


duration

private long duration
The estimated observation time of the target. Equals sleep time.


cancel

private boolean cancel
The prematurely stop the sequencer.


mythread

private Thread mythread
The thread this sequencer runs in.

Constructor Detail

DummySequencer

public DummySequencer(Map prop)
Constructs a new dummy sequencer. If at least one of the KEY_ERRORS or the KEY_INTERRUPTS is given, the probabilities for the occurence of such an error is calcualted in the following way:

Method Detail

getStepsForTarget

public List getStepsForTarget(TargetDefinition aux)
Returns an empty list. No sequencing steps are needed for a dummy sequencer. Stores the observation time of the target, if this target is Appointable.

Specified by:
getStepsForTarget in interface Sequencing

load

public void load(List dummy)
Not necessary, returns immediately.

Specified by:
load in interface Sequencing

abort

public void abort(List dummy)
Abort sequence, not necessary. For testing, this list may be dumped to some output.

Specified by:
abort in interface Sequencing

append

public void append(List dummy)
Append to sequence, not necessary.

Specified by:
append in interface Sequencing

prepend

public void prepend(List dummy)
Prepend to sequence, not necessary.

Specified by:
prepend in interface Sequencing

registerRender

public void registerRender(CommandRendering dummy)
Register command renderer. Not needed.

Specified by:
registerRender in interface Sequencing

registerLauncher

public void registerLauncher(CommandLaunching[] launch)
Register the command launchers. Not needed.

Specified by:
registerLauncher in interface Sequencing

registerCluster

public void registerCluster(ParameterClustering cluster)
Registers the parameter set. Only needed for the time. If the time is not found in the parameters, the system clock is used.

Specified by:
registerCluster in interface ClusterDepending

start

public Thread start()
Starts the sequence. Simply wraps a thread over this runnable instance, starts it and returns the thread reference. Stores the thread reference internally for getThread() method.

Specified by:
start in interface Sequencing
Returns:
The thread that has just been started

getThread

public Thread getThread()
Returns the sequencer thread. If the sequncer is not running, i.e. the sequncer's thread is not alive, this method returns null.


getAsociatedThread

public Thread getAsociatedThread()
Always return a reference to mythread.

Specified by:
getAsociatedThread in interface CancelRunnable

maxTimeToCancel

public long maxTimeToCancel()
Returns 1000.

Specified by:
maxTimeToCancel in interface CancelRunnable

success

public ErrorEvent success()
Queries the result of a sequencing procedure. Depending on the values of the KEY_ERRORS and KEY_ERRORPROSPECTS keys, this method returns an error event or null.


cancel

public void cancel()
Cancels the execution of the sequencer.

Specified by:
cancel in interface CancelRunnable

isCancel

public boolean isCancel()
Returns the cancel flag.

Specified by:
isCancel in interface Sequencing

forward

public void forward(ReplyEvent re)
This method is called from reply deliverers. We do not have any, therefore this method will never be called.

Specified by:
forward in interface ReplySubscriber

run

public void run()
The run method of the dummy sequencer. This method only waits until the estimated observation time has passed. But it does that in a certain way.

Specified by:
run in interface Runnable

getErrorMap

private static final Map getErrorMap(String errorlist,
                                     String problist)
Returns an error map linking error names to probabilities. If no error names are handed over in the comma-separated string of the first argument, only the null-error-event is valid.
Note that all error names must be class names in the stella.error package.

Parameters:
errorlist - A coma-separated list of error class names.
problist - A coma-separated list of probabilites to errors above.

generateErrorEvent

private ErrorEvent generateErrorEvent(Map errs)
Generates an error event out of a map of available error event names. The procedure is as follows:


getTime

private long getTime()
Returns the time. If the parameter set contained a time parameter matching KEY_TIME, its value is used, otherwise the system time is returned.