Package ptolemy.distributed.rmi
Class DistributedActorWrapper
- java.lang.Object
 - 
- ptolemy.distributed.rmi.DistributedActorWrapper
 
 
- 
- All Implemented Interfaces:
 java.rmi.Remote,DistributedActor,RemoteDistributedActor
public class DistributedActorWrapper extends java.lang.Object implements RemoteDistributedActor
The DistributedActorWrapper implements the RemoteDistributedActor interface. It is a remote distributed actor and wraps actors inside, making them believe they are executed locally while they are distributed. It receives rmi calls. The calls to methods that exist in the actor interface are forwarded to the wrapped actor.- Since:
 - Ptolemy II 5.1
 - Version:
 - $Id$
 - Author:
 - Daniel Lazaro Cuadrado (kapokasa@kom.aau.dk)
 - Pt.AcceptedRating:
 - Red (cxh)
 - Pt.ProposedRating:
 - Red (kapokasa)
 
 
- 
- 
Constructor Summary
Constructors Constructor Description DistributedActorWrapper()Construct an DistributedActorWrapper. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfire()Fire the wrapped actor.java.net.InetAddressgetAddress()Return the Internet Address where the wrapper is executing.voidinitialize()Begin execution of the wrapped actor.intiterate(int count)Invoke a specified number of iterations of the wrapped actor.booleanloadMoML(java.lang.String moml)Load a moml representation of an actor.booleanpostfire()This method should be invoked once per iteration, after the last invocation of fire() in that iteration.booleanprefire()This method should be invoked once per iteration, before the first invocation of fire() in that iteration.voidpreinitialize()This method should be invoked exactly once per execution of a model, before any of these other methods are invoked.voidput(java.util.HashMap data)Puts copies of the token received into the Receivers included in the IDlist.voidsetConnections(java.util.HashMap connections)Set the "virtual connections" concerning the wrapped actor.voidsetPortTypes(java.util.HashMap portTypes)Set the port types of the wrapped actor.voidstop()Request that execution of the wrapped actor to stop as soon as possible.voidstopFire()Request that execution of the current iteration of the wrapped actor complete.voidterminate()Terminate any currently executing model with extreme prejudice.voidwrapup()This method is invoked exactly once per execution of an application. 
 - 
 
- 
- 
Method Detail
- 
fire
public void fire() throws java.rmi.RemoteExceptionFire the wrapped actor.- Specified by:
 firein interfaceDistributedActor- Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
getAddress
public java.net.InetAddress getAddress() throws java.rmi.RemoteExceptionReturn the Internet Address where the wrapper is executing.- Specified by:
 getAddressin interfaceDistributedActor- Returns:
 - InetAddress the Internet Address where the distributed actor is being executed.
 - Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
initialize
public void initialize() throws java.rmi.RemoteExceptionBegin execution of the wrapped actor.- Specified by:
 initializein interfaceDistributedActor- Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
iterate
public int iterate(int count) throws java.rmi.RemoteExceptionInvoke a specified number of iterations of the wrapped actor.- Specified by:
 iteratein interfaceDistributedActor- Parameters:
 count- The number of iterations to perform.- Returns:
 - NOT_READY, STOP_ITERATING, or COMPLETED.
 - Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
loadMoML
public boolean loadMoML(java.lang.String moml) throws java.rmi.RemoteExceptionLoad a moml representation of an actor. The moml code is processed before loading.- Specified by:
 loadMoMLin interfaceDistributedActor- Parameters:
 moml- The moml code representing the actor to be loaded.- Returns:
 - True if the loading was successful.
 - Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
postfire
public boolean postfire() throws java.rmi.RemoteExceptionThis method should be invoked once per iteration, after the last invocation of fire() in that iteration.- Specified by:
 postfirein interfaceDistributedActor- Returns:
 - True if the execution can continue.
 - Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
prefire
public boolean prefire() throws java.rmi.RemoteExceptionThis method should be invoked once per iteration, before the first invocation of fire() in that iteration. The call is forwarded to the wrapped actor.- Specified by:
 prefirein interfaceDistributedActor- Returns:
 - True if the iteration can proceed.
 - Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
preinitialize
public void preinitialize() throws java.rmi.RemoteExceptionThis method should be invoked exactly once per execution of a model, before any of these other methods are invoked. The call is forwarded to the wrapped actor.- Specified by:
 preinitializein interfaceDistributedActor- Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
put
public void put(java.util.HashMap data) throws java.rmi.RemoteException, IllegalActionExceptionPuts copies of the token received into the Receivers included in the IDlist. The data map contains a token and a list of IDs.- Specified by:
 putin interfaceDistributedActor- Parameters:
 data- contains a token and a list of IDs.- Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.IllegalActionException- If the transaction fails (e.g. the data type is incompatible).
 
- 
setConnections
public void setConnections(java.util.HashMap connections) throws java.rmi.RemoteExceptionSet the "virtual connections" concerning the wrapped actor. The connections HashMap contains a list of ports, and for each of them a mapping depending on the type of port. - If the port is an input: a list of receiver IDs that are contained by the port. i.e.: inputport, (IDa, ..., IDn) - If it is an output port: a mapping of services to lists of receivers. i.e.: outputport, (servicea, (IDi, ..., IDk), ... servicen, (IDn, ..., IDs)) For the input ports, a new relation of the type is created of the type DistributedTypepIORelation for every ID that is received. This is to force a Receiver to be created whenever createReceivers in the corresponding port is called. For the output ports, one only relation of the type DistributedTypepIORelation is created and the mapping of services to IDs is set into the relation. The relation sets that same structure in its internal DistributedReceiver that is in charge of token forwarding whenever send is called on the port.- Specified by:
 setConnectionsin interfaceDistributedActor- Parameters:
 connections- a mapping of ports, services and receiver IDs (see before).- Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
setPortTypes
public void setPortTypes(java.util.HashMap portTypes) throws java.rmi.RemoteExceptionSet the port types of the wrapped actor.- Specified by:
 setPortTypesin interfaceDistributedActor- Parameters:
 portTypes- is a Map of ports to port types.- Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
stop
public void stop() throws java.rmi.RemoteExceptionRequest that execution of the wrapped actor to stop as soon as possible.- Specified by:
 stopin interfaceDistributedActor- Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
stopFire
public void stopFire() throws java.rmi.RemoteExceptionRequest that execution of the current iteration of the wrapped actor complete.- Specified by:
 stopFirein interfaceDistributedActor- Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
terminate
public void terminate() throws java.rmi.RemoteExceptionTerminate any currently executing model with extreme prejudice.- Specified by:
 terminatein interfaceDistributedActor- Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
- 
wrapup
public void wrapup() throws java.rmi.RemoteExceptionThis method is invoked exactly once per execution of an application.- Specified by:
 wrapupin interfaceDistributedActor- Throws:
 java.rmi.RemoteException- If a communication-related exception may occur during the execution of a remote method call.
 
 - 
 
 -