ptolemy.distributed.actor
Class DistributedReceiver

java.lang.Object
  extended by ptolemy.actor.AbstractReceiver
      extended by ptolemy.distributed.actor.DistributedReceiver
All Implemented Interfaces:
Receiver

public class DistributedReceiver
extends AbstractReceiver

An implementation of the Receiver interface for distributed environments. Basically, its task is to forward tokens to distributed services whenever the put method is called.

Since:
Ptolemy II 5.1
Version:
$Id: DistributedReceiver.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Daniel Lazaro Cuadrado (kapokasa@kom.aau.dk)
See Also:
AbstractReceiver
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (kapokasa)

Field Summary
private  java.util.HashMap servicesReceiversListMap
          Map containing a set of of services and the receiver's IDs in those services where the tokens put in the receiver have to be forwarded to.
private  boolean VERBOSE
          When true shows debugging messages.
 
Constructor Summary
DistributedReceiver()
           
 
Method Summary
 Token get()
          Empty implementation of the inherited abstract method.
 boolean hasRoom()
          Empty implementation of the inherited abstract method.
 boolean hasRoom(int numberOfTokens)
          Empty implementation of the inherited abstract method.
 boolean hasToken()
          Empty implementation of the inherited abstract method.
 boolean hasToken(int numberOfTokens)
          Empty implementation of the inherited abstract method.
 void put(Token token)
          Forward copies of the token to the distributed services specified in the servicesReceiversListMap.
 void setServicesReceiversListMap(java.util.HashMap servRecListMap)
          Specify the servicesReceiversListMap that contains a sequence of services and IDs of receivers in the service.
 
Methods inherited from class ptolemy.actor.AbstractReceiver
clear, elementList, getArray, getContainer, getCurrentTime, getModelTime, isKnown, putArray, putArrayToAll, putToAll, reset, setContainer, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

servicesReceiversListMap

private java.util.HashMap servicesReceiversListMap
Map containing a set of of services and the receiver's IDs in those services where the tokens put in the receiver have to be forwarded to.


VERBOSE

private boolean VERBOSE
When true shows debugging messages.

Constructor Detail

DistributedReceiver

public DistributedReceiver()
Method Detail

get

public Token get()
          throws NoTokenException
Empty implementation of the inherited abstract method.

Specified by:
get in interface Receiver
Specified by:
get in class AbstractReceiver
Returns:
A token read from the receiver.
Throws:
NoTokenException - If there is no token.

hasRoom

public boolean hasRoom()
Empty implementation of the inherited abstract method.

Specified by:
hasRoom in interface Receiver
Specified by:
hasRoom in class AbstractReceiver
Returns:
True if the next call to put() will not result in a NoRoomException.

hasRoom

public boolean hasRoom(int numberOfTokens)
Empty implementation of the inherited abstract method.

Specified by:
hasRoom in interface Receiver
Specified by:
hasRoom in class AbstractReceiver
Parameters:
numberOfTokens - The number of tokens to put into this receiver.
Returns:
True if the next numberOfTokens calls to put() will not result in a NoRoomException.

hasToken

public boolean hasToken()
Empty implementation of the inherited abstract method.

Specified by:
hasToken in interface Receiver
Specified by:
hasToken in class AbstractReceiver
Returns:
True if the next call to get() will not result in a NoTokenException.

hasToken

public boolean hasToken(int numberOfTokens)
Empty implementation of the inherited abstract method.

Specified by:
hasToken in interface Receiver
Specified by:
hasToken in class AbstractReceiver
Parameters:
numberOfTokens - The number of tokens desired.
Returns:
True if the next numberOfTokens calls to get() will not result in a NoTokenException.

put

public void put(Token token)
         throws IllegalActionException
Forward copies of the token to the distributed services specified in the servicesReceiversListMap. //TODO:This could be done in parallel. Is it worth the effort?

Specified by:
put in interface Receiver
Specified by:
put in class AbstractReceiver
Parameters:
token - The token to be forwarded, or null to forward no token.
Throws:
IllegalActionException - If the put fails (e.g. because of incompatible types).

setServicesReceiversListMap

public void setServicesReceiversListMap(java.util.HashMap servRecListMap)
Specify the servicesReceiversListMap that contains a sequence of services and IDs of receivers in the service.

Parameters:
servRecListMap - The map that contains a sequence of services and IDs of receivers.