visidia.simulation.process
Class MessageProcess

java.lang.Object
  extended by visidia.simulation.process.ProcessType
      extended by visidia.simulation.process.MessageProcess

public class MessageProcess
extends ProcessType

This class represents a communication process based on message passing.


Field Summary
protected  VQueue msgVQueue
          The message queue.
 
Fields inherited from class visidia.simulation.process.ProcessType
id, server
 
Constructor Summary
MessageProcess(Server server, Vertex vertex)
          Instantiates a new message process.
 
Method Summary
 boolean emptyVQueue(Criterion c)
          Tests if the message VQueue is empty.
 Algorithm getAlgorithm()
          Gets the algorithm.
 Message getNextMessage(Door door, Criterion c)
          Gets the next message received on the specified door (if any) corresponding to the criterion (if any).
 MessagePacket getNextMessagePacketNoWait(Criterion c)
          Gets the next message packet matching the criterion.
 java.lang.Object getNodeProperty(java.lang.String key)
          Gets the node property.
 Vertex getVertex()
          Gets the vertex.
 void initNodeProperty(VisidiaProperty property)
          Initializes the node property.
 void putMessage(MessagePacket msgPacket)
          Puts message on the queue.
 boolean sendMessageTo(int door, Message msg)
          Sends a message.
 void setAlgorithm(Algorithm algorithm)
          Sets the algorithm.
 void setNodeProperty(int nodeId, VisidiaProperty property)
          Sets the node property.
 void start()
          Starts the process.
 void terminatedAlgorithm()
          Terminated algorithm.
 
Methods inherited from class visidia.simulation.process.ProcessType
changeEdgeState, getEdgeProperty, getId, getServer, runningControl, setEdgeProperty, setEdgeProperty, setThread, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msgVQueue

protected VQueue msgVQueue
The message queue.

Constructor Detail

MessageProcess

public MessageProcess(Server server,
                      Vertex vertex)
Instantiates a new message process.

Parameters:
server - the server
vertex - the vertex
Method Detail

getAlgorithm

public Algorithm getAlgorithm()
Gets the algorithm.

Returns:
the algorithm

setAlgorithm

public void setAlgorithm(Algorithm algorithm)
Sets the algorithm.

Parameters:
algorithm - the new algorithm

getVertex

public Vertex getVertex()
Gets the vertex.

Returns:
the vertex

start

public void start()
Description copied from class: ProcessType
Starts the process.

Overrides:
start in class ProcessType

sendMessageTo

public boolean sendMessageTo(int door,
                             Message msg)
                      throws java.lang.InterruptedException
Sends a message.

Parameters:
door - the door
msg - the message
Returns:
true, if successful
Throws:
java.lang.InterruptedException - the interrupted exception

getNextMessage

public Message getNextMessage(Door door,
                              Criterion c)
                       throws java.lang.InterruptedException
Gets the next message received on the specified door (if any) corresponding to the criterion (if any).

Parameters:
c - the criterion
door - the door
Returns:
the next message
Throws:
java.lang.InterruptedException - the interrupted exception

getNextMessagePacketNoWait

public MessagePacket getNextMessagePacketNoWait(Criterion c)
                                         throws java.lang.InterruptedException
Gets the next message packet matching the criterion. Does not block until a message has arrived.

Parameters:
c - the criterion
Returns:
the next message packet, or null if no message has arrived
Throws:
java.lang.InterruptedException - the interrupted exception

putMessage

public void putMessage(MessagePacket msgPacket)
                throws java.lang.InterruptedException
Puts message on the queue.

Parameters:
msgPacket - the message packet
Throws:
java.lang.InterruptedException - the interrupted exception

terminatedAlgorithm

public void terminatedAlgorithm()
                         throws java.lang.InterruptedException
Terminated algorithm.

Throws:
java.lang.InterruptedException - the interrupted exception

emptyVQueue

public boolean emptyVQueue(Criterion c)
                    throws java.lang.InterruptedException
Tests if the message VQueue is empty.

Parameters:
c - the criterion
Returns:
true, if the queue is empty
Throws:
java.lang.InterruptedException - the interrupted exception

initNodeProperty

public void initNodeProperty(VisidiaProperty property)
Initializes the node property. Do not use this method in algorithm implementation!

Parameters:
property - the property

setNodeProperty

public void setNodeProperty(int nodeId,
                            VisidiaProperty property)
                     throws java.lang.InterruptedException
Sets the node property.

Parameters:
nodeId - the node id
property - the property
Throws:
java.lang.InterruptedException - the interrupted exception

getNodeProperty

public java.lang.Object getNodeProperty(java.lang.String key)
Gets the node property.

Parameters:
key - the key
Returns:
the node property value