stella.net
Class TestReceiver

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.net.ReceiverServer
                              extended by stella.net.ErrorServer
                                  extended by stella.net.CommandReceiver
                                      extended by stella.net.TestReceiver
All Implemented Interfaces:
Cloneable, Runnable, Remote, ErrorProcessing, RmiErrorCaster, CancelRunnable, ExitCleaning, Initializable, LocalizedSupplying, PropertySupplying, ResourceSupplying, RmiCaster, RmiPropertyBearing

public final class TestReceiver
extends CommandReceiver

The receiver end to the test caster method. This class waits for command from the test caster and generates (sometimes multiple) acknowledge events and a done event as a return. To test the time-out capabilities of the caster, the processCommand(stella.CommandEvent, int) method has a probablility to generate a time-out on the caster end.
Additionally, this class also transfers errors as an ascii-string to a port specified by KEY_ERRORPORT on KEY_ERRORHOST. The processError(stella.ErrorEvent) method is distorted to (additionally) open a socket connetion, writes into the ascii-error and closes the socket again.


Nested Class Summary
 
Nested classes/interfaces inherited from class stella.net.CommandReceiver
CommandReceiver.CommandHandler
 
Nested classes/interfaces inherited from class util.PropertyResources
PropertyResources.URLResource
 
Field Summary
private static long DEFACKMAX
          The default maximum acknowledge time.
private static long DEFACKMIN
          The default minimum acknowledge time.
private static double DEFCOMMANDFAIL
          The default probability of command execution failure.
private static double DEFCOMMANDLONG
          The default probability of command execution time-out.
private static int DEFERRORPORT
          The default port to connect to the host of the ascii-error server.
private static double DEFINFOPROB
          The default probability of generating an info.
private static double DEFSTATUSPROB
          The default probability of generating a status.
private  List errors
          The error classes available for this test receiver.
static String KEY_ACKMAX
          The maximum acknowledge time sent back.
static String KEY_ACKMIN
          The minimum acknowledge time sent back.
static String KEY_COMMANDFAIL
          The probability of command execution failure.
static String KEY_COMMANDLONG
          The probability of command execution time-out.
static String KEY_ERRORHOST
          The host of the ascii-error server.
static String KEY_ERRORPORT
          The port to connect to the host of the ascii-error server.
static String KEY_ERRORS
          A list of error classes that might be generated.
static String KEY_INFOPROB
          The probability of generating an info.
static String KEY_STATUS
          A list of status messages to generate.
static String KEY_STATUSPROB
          The probability of generating a status.
private  List stati
          The status classes available for this test receiver.
 
Fields inherited from class stella.net.CommandReceiver
KEY_AVAILABLE, KEY_COMMANDGROUP, KEY_TIMEOUT
 
Fields inherited from class stella.net.ErrorServer
KEY_BIND, KEY_BINDNAME
 
Fields inherited from class stella.net.ReceiverServer
DEFSERVERPORT, handlerGroup, KEY_BUFFERSIZE, KEY_HANDLERPRIORITY, KEY_HOSTADDRESS, KEY_LOGOUT, KEY_RECEIVERNAME, KEY_SERVERPORT, KEY_SERVERPRIORITY
 
Fields inherited from class util.rmi.AbstractRmiCaster
ALTERNATEHOST, ALTERNATEPORT, 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.ResourceSupplying
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Fields inherited from interface util.PropertySupplying
CONFIG, KEY_CLASS
 
Constructor Summary
TestReceiver(Map ensure)
          Constructs a new test receiver.
 
Method Summary
private  ErrorEvent createErrorEventFromList(List classes)
          Takes a list of error event classes and creates a living object out of it.
protected  int getAcknowledgeNumber(CommandEvent cmd)
          Returns the type of the first acknowledge event.
protected  long getCompletionTime(CommandEvent ignore, int dummytype)
          Returns a time between KEY_ACKMIN and KEY_ACKMAX.
protected  ErrorEvent getLastError()
          Returns a randomly selected error out of the errorlist.
static void main(String[] arg)
          For testing.
protected  boolean processCommand(CommandEvent ignore, int dummytype)
          Processes the given command.
 void processError(ErrorEvent ee)
          Processes the error in a way that it send it as an ascii string to the specified post, KEY_ERRORPORT, on the specified host, KEY_ERRORHOST.
 
Methods inherited from class stella.net.CommandReceiver
cancel, protocol, sendInfo, sendStatus
 
Methods inherited from class stella.net.ErrorServer
exit, init
 
Methods inherited from class stella.net.ReceiverServer
getAsociatedThread, getBufferSize, getHandlerPriority, getReceiverName, getServerPort, getServerPriority, initReceiverServer, maxTimeToCancel, run
 
Methods inherited from class stella.CastingContainer
addErrorListener, addRmiErrorListener, isValid, notifyErrorListener, removeErrorListener, removeRmiErrorListener, sendError, sendError, sendError, 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, 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.rmi.RmiErrorCaster
addRmiErrorListener, removeRmiErrorListener
 
Methods inherited from interface util.rmi.RmiCaster
bindToRegistry, isValid, unbindFromRegistry
 
Methods inherited from interface util.ResourceSupplying
getResource, getResourceAsStream, getResources
 
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
 

Field Detail

KEY_ERRORHOST

public static final String KEY_ERRORHOST
The host of the ascii-error server.

See Also:
Constant Field Values

KEY_ERRORPORT

public static final String KEY_ERRORPORT
The port to connect to the host of the ascii-error server.

See Also:
Constant Field Values

KEY_ERRORS

public static final String KEY_ERRORS
A list of error classes that might be generated.

See Also:
Constant Field Values

KEY_ACKMIN

public static final String KEY_ACKMIN
The minimum acknowledge time sent back.

See Also:
Constant Field Values

KEY_ACKMAX

public static final String KEY_ACKMAX
The maximum acknowledge time sent back.

See Also:
Constant Field Values

KEY_COMMANDFAIL

public static final String KEY_COMMANDFAIL
The probability of command execution failure.

See Also:
Constant Field Values

KEY_COMMANDLONG

public static final String KEY_COMMANDLONG
The probability of command execution time-out.

See Also:
Constant Field Values

KEY_STATUSPROB

public static final String KEY_STATUSPROB
The probability of generating a status.

See Also:
Constant Field Values

KEY_STATUS

public static final String KEY_STATUS
A list of status messages to generate. If null, only test stati.

See Also:
Constant Field Values

KEY_INFOPROB

public static final String KEY_INFOPROB
The probability of generating an info.

See Also:
Constant Field Values

DEFERRORPORT

private static final int DEFERRORPORT
The default port to connect to the host of the ascii-error server.

See Also:
Constant Field Values

DEFACKMIN

private static final long DEFACKMIN
The default minimum acknowledge time.

See Also:
Constant Field Values

DEFACKMAX

private static final long DEFACKMAX
The default maximum acknowledge time.

See Also:
Constant Field Values

DEFCOMMANDFAIL

private static final double DEFCOMMANDFAIL
The default probability of command execution failure.

See Also:
Constant Field Values

DEFCOMMANDLONG

private static final double DEFCOMMANDLONG
The default probability of command execution time-out.

See Also:
Constant Field Values

DEFSTATUSPROB

private static final double DEFSTATUSPROB
The default probability of generating a status.

See Also:
Constant Field Values

DEFINFOPROB

private static final double DEFINFOPROB
The default probability of generating an info.

See Also:
Constant Field Values

errors

private List errors
The error classes available for this test receiver.


stati

private List stati
The status classes available for this test receiver.

Constructor Detail

TestReceiver

public TestReceiver(Map ensure)
             throws RemoteException
Constructs a new test receiver. Registers System.err as an error listener.

Throws:
RemoteException
Method Detail

processError

public void processError(ErrorEvent ee)
Processes the error in a way that it send it as an ascii string to the specified post, KEY_ERRORPORT, on the specified host, KEY_ERRORHOST. The socket connection is terminated after the error has been sent. Additionally, the super class's method is called for additional notification of RMI error listeners.

Specified by:
processError in interface ErrorProcessing
Overrides:
processError in class ErrorServer
Parameters:
ee - The ErrorEvent to pass to the Listeners.

getAcknowledgeNumber

protected int getAcknowledgeNumber(CommandEvent cmd)
Returns the type of the first acknowledge event. A probability of 0.3 to return a multi-acknowledge type.

Overrides:
getAcknowledgeNumber in class CommandReceiver

getCompletionTime

protected long getCompletionTime(CommandEvent ignore,
                                 int dummytype)
Returns a time between KEY_ACKMIN and KEY_ACKMAX.

Specified by:
getCompletionTime in class CommandReceiver
Parameters:
ignore - The command to process.
dummytype - The type of the acknowledge that will be sent back.

processCommand

protected boolean processCommand(CommandEvent ignore,
                                 int dummytype)
Processes the given command. Depending on the KEY_COMMANDLONG probability, the execution of this command may take longer than the acknowledge time sent back. Note that KEY_COMMANDLONG probability is a maximum failure probability because the acknowledge time sent back may vary between KEY_ACKMIN and KEY_ACKMAX, while the KEY_COMMANDLONG probability is the probability that the execution of the command will take longert than KEY_ACKMIN. With a probability of KEY_COMMANDFAIL the command execution will fail, resulting in an error to be generated and sent back, see KEY_ERRORS. A simple status message is sent with a probability of KEY_STATUSPROB.

Specified by:
processCommand in class CommandReceiver

getLastError

protected ErrorEvent getLastError()
Returns a randomly selected error out of the errorlist. If the errorlist is not present or the error cannot be instantiated, null is returned.

Overrides:
getLastError in class CommandReceiver

createErrorEventFromList

private ErrorEvent createErrorEventFromList(List classes)
Takes a list of error event classes and creates a living object out of it. The constructor of the class must support a single-Object argument. In case of failure, null is returned.


main

public static void main(String[] arg)
                 throws RemoteException
For testing. Registers to the command caster given in the first command line argument.

Throws:
RemoteException