examples.communication
Class Launcher

java.lang.Object
  extended byexamples.communication.Launcher
All Implemented Interfaces:
LauncherService

public class Launcher
extends Object
implements LauncherService

This application launches a number of different types of agents which jump subseqeuently to remote hosts, and communicate with each other.

The launched agents can be three types: SENDER, RECEIVER or TRANSCEIVER. The SENDER agent only sends messages, the RECEIVER agent only receives messages and the TRANSCEIVER agent sends and receives messages.

Version:
$Revision: 1.5 $
Author:
Zaharina Velikova, Jan Peters

Field Summary
private  HashMap agentImplicitName_
          The HashMap object which contains the nicknames of the launched agents as keys and respectively their implicit names as values.
private  HashMap agentService_
          The HashMap object which contains the nicknames of the launched agents as keys and respectively the AgentService interfaces which the agents have published as values.
private  HashMap agentType_
          The HashMap object which contains the nicknames of the launched agents as keys and their type (1-SENDER, 2-RECEIVER, 3-TRANSCEIVER) as values.
private  Signals signals_
          The Signals object used to block/unblock or send terminating signal to the agents threads.
 
Fields inherited from interface examples.communication.LauncherService
PUBLISH_KEY
 
Constructor Summary
Launcher()
          Default constructor.
 
Method Summary
protected static String helpMessage()
          This function creates the help message for the application which is going to be written out if the following command line is written: java examples.communication.Launcher -help
protected  void informAgents()
          Collects the implicit names of receiver and transceiver agents and gives them to the sender and transceiver agents.
static void main(String[] argv)
          Creates communication agents and sets some agent properties.
 void reportError(String nickName, Throwable throwable)
          When an agent throws an exception(error) it should report it to the others using its nickname and the exception object(error).
 boolean reportName(String nickName, String implicitName, String servicePath, int type)
          When an agent is created it informs the launcher for his implicit name, nickname, the path under which it has published its AgentService interface and its type(Sender, Receiver or Transceiver).
protected  void terminateAgents()
          Terminates all agents which were launched.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agentImplicitName_

private HashMap agentImplicitName_
The HashMap object which contains the nicknames of the launched agents as keys and respectively their implicit names as values.


agentService_

private HashMap agentService_
The HashMap object which contains the nicknames of the launched agents as keys and respectively the AgentService interfaces which the agents have published as values.


agentType_

private HashMap agentType_
The HashMap object which contains the nicknames of the launched agents as keys and their type (1-SENDER, 2-RECEIVER, 3-TRANSCEIVER) as values.


signals_

private Signals signals_
The Signals object used to block/unblock or send terminating signal to the agents threads.

Constructor Detail

Launcher

public Launcher()
Default constructor.

Method Detail

helpMessage

protected static String helpMessage()
This function creates the help message for the application which is going to be written out if the following command line is written: java examples.communication.Launcher -help

Returns:
the help message

main

public static void main(String[] argv)
Creates communication agents and sets some agent properties. If no other arguments are given by the user the default values will be used.

Parameters:
argv - The command line parameters:

-hosts : The remote hosts where the agents will migrate. Default: automatically determines all the destinations within the LAN.

-jumps : The number of the jumps which an agent should make. Default value: 10.

-sa : The number of the sender agents which will be launched. Default value: 1.

-st : The time (in milliseconds) which each sending agent waits on a remote host before migration. Default value: 1000.

-ra : The number of receiver agents which will be launched. Default value: 1.

-rt : The time (in milliseconds) which each receiving agent waits on a remote host before migration. Default value: 1000.

-ta : The number of transceiver agents which will be launched. Default value: 1.

-tt : The time (in milliseconds) which each transceiver agent waits on a remote host before migration. Default value: 1000.

If some(or all) of these parameters are not defined, the default values will be used.


informAgents

protected void informAgents()
Collects the implicit names of receiver and transceiver agents and gives them to the sender and transceiver agents.


terminateAgents

protected void terminateAgents()
Terminates all agents which were launched.


reportError

public void reportError(String nickName,
                        Throwable throwable)
Description copied from interface: LauncherService
When an agent throws an exception(error) it should report it to the others using its nickname and the exception object(error).

Specified by:
reportError in interface LauncherService
Parameters:
nickName - the nickname of the agent which throws an exception throwable the Throwable object.
throwable - DOCUMENT ME!
See Also:
LauncherService.reportError(String, Throwable)

reportName

public boolean reportName(String nickName,
                          String implicitName,
                          String servicePath,
                          int type)
Description copied from interface: LauncherService
When an agent is created it informs the launcher for his implicit name, nickname, the path under which it has published its AgentService interface and its type(Sender, Receiver or Transceiver).

Specified by:
reportName in interface LauncherService
Parameters:
nickName - the String representation of the nickname of the agent. implicitName the String representation of the implicit name of the agent. servicePath the String representation of the path under which the agent has published its AgentService. type 1 = SENDER 2 = RECEIVER 3 = TRANSCEIVER
implicitName - DOCUMENT ME!
servicePath - DOCUMENT ME!
type - DOCUMENT ME!
Returns:
true - if there were no error while transferring the parameters false - otherwise
See Also:
LauncherService.reportName(String, String, String, int)


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.