Class 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
      void fire()
      Fire the wrapped actor.
      java.net.InetAddress getAddress()
      Return the Internet Address where the wrapper is executing.
      void initialize()
      Begin execution of the wrapped actor.
      int iterate​(int count)
      Invoke a specified number of iterations of the wrapped actor.
      boolean loadMoML​(java.lang.String moml)
      Load a moml representation of an actor.
      boolean postfire()
      This method should be invoked once per iteration, after the last invocation of fire() in that iteration.
      boolean prefire()
      This method should be invoked once per iteration, before the first invocation of fire() in that iteration.
      void preinitialize()
      This method should be invoked exactly once per execution of a model, before any of these other methods are invoked.
      void put​(java.util.HashMap data)
      Puts copies of the token received into the Receivers included in the IDlist.
      void setConnections​(java.util.HashMap connections)
      Set the "virtual connections" concerning the wrapped actor.
      void setPortTypes​(java.util.HashMap portTypes)
      Set the port types of the wrapped actor.
      void stop()
      Request that execution of the wrapped actor to stop as soon as possible.
      void stopFire()
      Request that execution of the current iteration of the wrapped actor complete.
      void terminate()
      Terminate any currently executing model with extreme prejudice.
      void wrapup()
      This method is invoked exactly once per execution of an application.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DistributedActorWrapper

        public DistributedActorWrapper()
        Construct an DistributedActorWrapper. This empty constructor is required by RMI.
    • Method Detail

      • fire

        public void fire()
                  throws java.rmi.RemoteException
        Fire the wrapped actor.
        Specified by:
        fire in interface DistributedActor
        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.RemoteException
        Return the Internet Address where the wrapper is executing.
        Specified by:
        getAddress in interface DistributedActor
        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.RemoteException
        Begin execution of the wrapped actor.
        Specified by:
        initialize in interface DistributedActor
        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.RemoteException
        Invoke a specified number of iterations of the wrapped actor.
        Specified by:
        iterate in interface DistributedActor
        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.RemoteException
        Load a moml representation of an actor. The moml code is processed before loading.
        Specified by:
        loadMoML in interface DistributedActor
        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.RemoteException
        This method should be invoked once per iteration, after the last invocation of fire() in that iteration.
        Specified by:
        postfire in interface DistributedActor
        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.RemoteException
        This 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:
        prefire in interface DistributedActor
        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.RemoteException
        This 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:
        preinitialize in interface DistributedActor
        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,
                        IllegalActionException
        Puts 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:
        put in interface DistributedActor
        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.RemoteException
        Set 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:
        setConnections in interface DistributedActor
        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.RemoteException
        Set the port types of the wrapped actor.
        Specified by:
        setPortTypes in interface DistributedActor
        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.RemoteException
        Request that execution of the wrapped actor to stop as soon as possible.
        Specified by:
        stop in interface DistributedActor
        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.RemoteException
        Request that execution of the current iteration of the wrapped actor complete.
        Specified by:
        stopFire in interface DistributedActor
        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.RemoteException
        Terminate any currently executing model with extreme prejudice.
        Specified by:
        terminate in interface DistributedActor
        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.RemoteException
        This method is invoked exactly once per execution of an application.
        Specified by:
        wrapup in interface DistributedActor
        Throws:
        java.rmi.RemoteException - If a communication-related exception may occur during the execution of a remote method call.