planet.generic.commonapi
Class RouteMessageImpl

java.lang.Object
  extended byplanet.generic.commonapi.RouteMessageImpl
All Implemented Interfaces:
RouteMessage, java.io.Serializable

public class RouteMessageImpl
extends java.lang.Object
implements RouteMessage

Message that wold be routed throwghout network.

Author:
Jordi Pujol
See Also:
Serialized Form

Field Summary
protected  java.lang.String appId
          The application Id who generates the related data and will receive on to remote Node.
protected  NodeHandle destination
          Destination Node Id who will receive this message.
protected  java.lang.String key
          Identification key of this message, necessary to known relationships between sent messages and new incoming messages.
protected  Message message
          Message (data) to be routed
protected  int mode
          Mode of this message.
protected  NodeHandle nextHop
          Next node to arrive
protected  java.lang.Object options
          RouteMessage additional options.
protected  NodeHandle previousHop
          Previous node on path to current node.
protected  java.util.List route
          Route from the source to the destination.
protected  NodeHandle source
          Source Node Id who sends this message.
protected  int ttl
          Time to live for the packet.
protected  int type
          Type of this message.
 
Constructor Summary
RouteMessageImpl(java.lang.String appId, NodeHandle source, NodeHandle destination, Message data, NodeHandle nextHop)
          Constructor who initialize all data.
RouteMessageImpl(java.lang.String appId, NodeHandle to, NodeHandle from, NodeHandle nh, Message msg, java.lang.String key, int type, int mode)
          Sets all values of the actual RouteMessage, before to be sent.
 
Method Summary
 void decTimeToLive()
          Decreases the Time to Live for the packet.
 java.lang.String getApplicationId()
          Gets the related application's identification.
 NodeHandle getDestination()
          Get the destination node's NodeHandle.
 java.lang.String getKey()
          Gets the identification key of this message.
 Message getMessage()
          Get the Message to route.
 int getMode()
          Gets the mode of this message.
 NodeHandle getNextHopHandle()
          Get next node's NodeHandle to send this message.
 java.lang.Object getOptions()
           
 NodeHandle getPreviousHopHandle()
          Gets the previous hop handle for this message.
 java.util.Collection getRoute()
          Returns the route from the source to the destination.
 NodeHandle getSource()
          Gets de source Node NodeHandle of the message
 int getTimeToLive()
          Gets the time to live for the packet.
 int getType()
          Gets the type of this message.
 void inverse()
          Reverse path.
 boolean routeMessagesHasExpired()
          Returns true if RouteMessage has expired.
 void setApplicationId(java.lang.String app)
          Sets the application's identification who sends and will receive this message.
 void setDestination(NodeHandle handle)
          Sets the destination's NodeHandle.
 void setKey(java.lang.String key)
          Sets the identification key of this communication.
 void setMessage(Message message)
          Sets the Message to route.
 void setMode(int mode)
          Sets the mode of this messge.
 void setNewNodeAlongRoute(NodeHandle node)
          Adds a new node along the current path.
 void setNextHopHandle(NodeHandle nextHop)
          Sets the next node's Id to send immediately this message.
 void setOptions(java.lang.Object o)
          Set RouteMessage additional options.
 void setPreviousHopHandle(NodeHandle previousHop)
          Sets the previous hop handle for this message.
 void setRoute(java.util.Collection route)
          Sets the route for the new path from the source to the destination
 void setSource(NodeHandle handle)
          Sets the source Node NodeHandle who sends this message.
 void setTimeToLive(int ttl)
          Sets Time to Live For The Message.
 void setType(int type)
          Sets the type of this message.
 void setValues(java.lang.String appId, NodeHandle to, NodeHandle from, NodeHandle nh, Message msg, java.lang.String key, int type, int mode)
          Sets all values of the actual RouteMessage, before to be sent.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

appId

protected java.lang.String appId
The application Id who generates the related data and will receive on to remote Node.


message

protected Message message
Message (data) to be routed


nextHop

protected NodeHandle nextHop
Next node to arrive


destination

protected NodeHandle destination
Destination Node Id who will receive this message.


source

protected NodeHandle source
Source Node Id who sends this message.


previousHop

protected NodeHandle previousHop
Previous node on path to current node.


type

protected int type
Type of this message.


mode

protected int mode
Mode of this message.


key

protected java.lang.String key
Identification key of this message, necessary to known relationships between sent messages and new incoming messages.


options

protected java.lang.Object options
RouteMessage additional options.


route

protected java.util.List route
Route from the source to the destination.


ttl

protected int ttl
Time to live for the packet.

Constructor Detail

RouteMessageImpl

public RouteMessageImpl(java.lang.String appId,
                        NodeHandle source,
                        NodeHandle destination,
                        Message data,
                        NodeHandle nextHop)
Constructor who initialize all data.

Parameters:
appId - Application's identification who generates this data.
source - Source Node Id who sends this message.
destination - Destination Node Id who receive this message.
data - The generated data to application level.
nextHop - Next Node to hop in the ring.

RouteMessageImpl

public RouteMessageImpl(java.lang.String appId,
                        NodeHandle to,
                        NodeHandle from,
                        NodeHandle nh,
                        Message msg,
                        java.lang.String key,
                        int type,
                        int mode)
Sets all values of the actual RouteMessage, before to be sent.

Parameters:
appId - Identification of the Application which generate this message.
to - Destination Id of this RouteMessage.
from - Source Id of this RouteMessage.
nh - NodeHandle for next hop.
msg - Message wrapped to this RouteMessage.
key - Identification key for this communication with the remote node.
type - Type of this message.
mode - Mode of this message.
See Also:
RouteMessage.setValues(java.lang.String, planet.commonapi.NodeHandle,planet.commonapi.NodeHandle, planet.commonapi.NodeHandle, planet.commonapi.Message, java.lang.String, int, int)
Method Detail

getDestination

public NodeHandle getDestination()
Get the destination node's NodeHandle.

Specified by:
getDestination in interface RouteMessage
Returns:
The destination NodeHandle
See Also:
RouteMessage.getDestination()

getMessage

public Message getMessage()
Get the Message to route.

Specified by:
getMessage in interface RouteMessage
Returns:
The enclosed message
See Also:
RouteMessage.getMessage()

getNextHopHandle

public NodeHandle getNextHopHandle()
Get next node's NodeHandle to send this message.

Specified by:
getNextHopHandle in interface RouteMessage
Returns:
The next hop
See Also:
RouteMessage.getNextHopHandle()

setDestination

public void setDestination(NodeHandle handle)
Sets the destination's NodeHandle.

Specified by:
setDestination in interface RouteMessage
Parameters:
handle - The destination NodeHandle
See Also:
RouteMessage.setDestination(planet.commonapi.NodeHandle)

setMessage

public void setMessage(Message message)
Sets the Message to route.

Specified by:
setMessage in interface RouteMessage
Parameters:
message - The internal message
See Also:
RouteMessage.setMessage(planet.commonapi.Message)

setNextHopHandle

public void setNextHopHandle(NodeHandle nextHop)
Sets the next node's Id to send immediately this message.

Specified by:
setNextHopHandle in interface RouteMessage
Parameters:
nextHop - The next hop for this handle
See Also:
RouteMessage.setNextHopHandle(planet.commonapi.NodeHandle)

getPreviousHopHandle

public NodeHandle getPreviousHopHandle()
Gets the previous hop handle for this message.

Specified by:
getPreviousHopHandle in interface RouteMessage
Returns:
The previous hop.

setPreviousHopHandle

public void setPreviousHopHandle(NodeHandle previousHop)
Sets the previous hop handle for this message.

Specified by:
setPreviousHopHandle in interface RouteMessage
Parameters:
previousHop - The previous hop to Set.

getApplicationId

public java.lang.String getApplicationId()
Gets the related application's identification.

Specified by:
getApplicationId in interface RouteMessage
Returns:
Identification of the application
See Also:
RouteMessage.getApplicationId()

getSource

public NodeHandle getSource()
Gets de source Node NodeHandle of the message

Specified by:
getSource in interface RouteMessage
Returns:
Source Node NodeHandle of the message
See Also:
RouteMessage.getSource()

setApplicationId

public void setApplicationId(java.lang.String app)
Sets the application's identification who sends and will receive this message.

Specified by:
setApplicationId in interface RouteMessage
Parameters:
app - Application's identification who generates this message.
See Also:
RouteMessage.setApplicationId(java.lang.String)

setSource

public void setSource(NodeHandle handle)
Sets the source Node NodeHandle who sends this message.

Specified by:
setSource in interface RouteMessage
Parameters:
handle - The Node NodeHandle who sends this message through de ring.
See Also:
RouteMessage.setSource(planet.commonapi.NodeHandle)

getType

public int getType()
Gets the type of this message.

Specified by:
getType in interface RouteMessage
Returns:
Type of this message
See Also:
RouteMessage.getType()

getMode

public int getMode()
Gets the mode of this message.

Specified by:
getMode in interface RouteMessage
Returns:
Mode of this message.
See Also:
RouteMessage.getMode()

getKey

public java.lang.String getKey()
Gets the identification key of this message. This key is different between any pair of sent meesages to the same destination node.

Specified by:
getKey in interface RouteMessage
Returns:
Identification key of this message.
See Also:
RouteMessage.getKey()

setType

public void setType(int type)
Sets the type of this message.

Specified by:
setType in interface RouteMessage
Parameters:
type - Type of message.
See Also:
RouteMessage.setType(int)

setMode

public void setMode(int mode)
Sets the mode of this messge.

Specified by:
setMode in interface RouteMessage
Parameters:
mode - Mode of message.
See Also:
RouteMessage.setMode(int)

setKey

public void setKey(java.lang.String key)
Sets the identification key of this communication.

Specified by:
setKey in interface RouteMessage
Parameters:
key - Identification key of this communication.
See Also:
RouteMessage.setKey(java.lang.String)

setOptions

public void setOptions(java.lang.Object o)
Set RouteMessage additional options.

Specified by:
setOptions in interface RouteMessage
Parameters:
o - additional options.

getOptions

public java.lang.Object getOptions()
Specified by:
getOptions in interface RouteMessage
Returns:
RouteMessage additional options for future use.

setNewNodeAlongRoute

public void setNewNodeAlongRoute(NodeHandle node)
Adds a new node along the current path.

Specified by:
setNewNodeAlongRoute in interface RouteMessage
Parameters:
node - the new node to be added.

getRoute

public java.util.Collection getRoute()
Returns the route from the source to the destination.

Specified by:
getRoute in interface RouteMessage
Returns:
returns the route from the source to the destination.

setRoute

public void setRoute(java.util.Collection route)
              throws InitializationException
Sets the route for the new path from the source to the destination

Specified by:
setRoute in interface RouteMessage
Parameters:
route - route from the source to the destination.
Throws:
planet.commonapi.exception.InitializationException.
InitializationException

setTimeToLive

public void setTimeToLive(int ttl)
Sets Time to Live For The Message.

Specified by:
setTimeToLive in interface RouteMessage
Parameters:
ttl - time to live number.

getTimeToLive

public int getTimeToLive()
Gets the time to live for the packet.

Specified by:
getTimeToLive in interface RouteMessage
Returns:
returns the time to live for the packet.

routeMessagesHasExpired

public boolean routeMessagesHasExpired()
Returns true if RouteMessage has expired.

Specified by:
routeMessagesHasExpired in interface RouteMessage
Returns:
true if RouteMessage has finished its time to live.

decTimeToLive

public void decTimeToLive()
Decreases the Time to Live for the packet.

Specified by:
decTimeToLive in interface RouteMessage

setValues

public void setValues(java.lang.String appId,
                      NodeHandle to,
                      NodeHandle from,
                      NodeHandle nh,
                      Message msg,
                      java.lang.String key,
                      int type,
                      int mode)
Sets all values of the actual RouteMessage, before to be sent.

Specified by:
setValues in interface RouteMessage
Parameters:
appId - Identification of the Application which generate this message.
to - Destination Id of this RouteMessage.
from - Source Id of this RouteMessage.
nh - NodeHandle for next hop.
msg - Message wrapped to this RouteMessage.
key - Identification key for this communication with the remote node.
type - Type of this message.
mode - Mode of this message.
See Also:
RouteMessage.setValues(java.lang.String, planet.commonapi.NodeHandle, planet.commonapi.NodeHandle, planet.commonapi.NodeHandle, planet.commonapi.Message, java.lang.String, int, int)

inverse

public void inverse()
Reverse path. The destination become source and source become destination.


toString

public java.lang.String toString()
See Also:
Object.toString()