planet.symphony
Class SymphonyNode

java.lang.Object
  extended byplanet.generic.commonapi.NodeImpl
      extended byplanet.symphony.SymphonyNode
All Implemented Interfaces:
Node, java.io.Serializable

public class SymphonyNode
extends NodeImpl

This node is an implementation of the Symphony overlay.

Author:
Helio Tejedor, Marc Sanchez, Ruben Mondejar, Carles Pairot, Jordi Pujol
See Also:
Serialized Form

Nested Class Summary
 class SymphonyNode.StabilizeTask
          Simple TimerTask that invoke stabilize() Node method.
 
Field Summary
static int ACCEPT_CONNECT
           
 boolean alive
           
static int CANCEL_CONNECT
           
static int CLOSE_LONG_CONNECT
           
static int CLOSE_NEIGHBOUR_CONNECT
           
static int DATA
          Type value: It identifies that this message contains an application level Message.
static java.lang.String[] MODES
          This String contains a string representation of each mode value of the RouteMessage.
static int NumberOfModes
           
static int NumberOfTypes
           
static int QUERY_CONNECT
           
static int QUERY_JOIN
          Type value: First message that is send by any node to get its inmediate successor.
static int REFRESH
          Mode value: Defines a message's mode that requires only communication on one way.
static int REPLY
          Mode value: Defines the response of a communication.
static int REQUEST
          Mode value: Defines the start of communication that requires response (REPLY).
 int retriesNewLongDistance
           
static int SET_INFO
           
 boolean stabilized
           
static java.lang.String[] TYPES
          This String contains a string representation of each type value of the RouteMessage.
 
Fields inherited from class planet.generic.commonapi.NodeImpl
endpoints, id, listeners, nodeHandle, role
 
Constructor Summary
SymphonyNode(Id id)
           
 
Method Summary
 void addToNeighbourSet(java.util.Collection c)
           
 void addToNeighbourSet(NodeHandle neighbour)
           
 void broadcast(java.lang.String appId, NodeHandle to, NodeHandle nextHop, Message msg)
          This method throws a NoSuchMethodError, because the broadcast algorithm is not implemented yet.
 RouteMessage buildMessage(NodeHandle from, NodeHandle to, int type, int mode, Message m)
           
 RouteMessage buildMessage(NodeHandle from, NodeHandle to, int type, int mode, Message m, java.lang.String key)
           
 RouteMessage buildMessage(NodeHandle from, NodeHandle to, NodeHandle nextHop, int type, int mode, Message m)
           
 RouteMessage buildMessage(NodeHandle from, NodeHandle to, NodeHandle nextHop, int type, int mode, Message m, java.lang.String key)
           
 void dispatcher(RouteMessage msg)
           
 void fail()
          The leave protocol is the same as in leave case.
 java.util.Set getAllLinks()
          Gets all node connections to other nodes as its NodeHandles.
 NodeHandle getClosestNodeHandle(Id id)
          Returns the NodeHandle closest to id.
 void getEInGML(java.util.Collection E, GMLConstraint constraint)
          This method is a callback method used to collect all of the edges of a graph according to GML file format for latter visual graph performance.
 java.util.Hashtable getEndPoints()
           
 java.util.Set getIncommingSet()
           
 java.util.Hashtable getInfo()
          Returns information of the node
 java.util.Collection getNeighbourSet()
           
 RouteMessage getNewLongDistance()
           
 java.util.Set getNewSet()
           
 java.util.Set getOutcommingSet()
           
 NodeHandle getPred()
          Returns the NodeHandle of the present predecessor of the node
 NodeHandle getSucc()
          Returns the NodeHandle of the present successor of the node
 java.util.Vector getSuccList(int max)
          Returns up to max successors of the actual node.
 boolean isAlive()
          Informs if this node is alive.
 boolean isLocalMessage(RouteMessage msg)
          The isLocalMessage's method is an extension method for commonapi specs.
 boolean IsStabilized()
           
 void join(Id bsId)
          The node joins in the network
 void leave()
          The node leaves the network
 java.util.Vector localLookup(Id key, int max, boolean safe)
          Returns a list of nodes that can be used as next hops on a route towards key.
 void lookup(Id key)
          Lookup of a key
 java.util.Vector neighborSet(int max)
          Obtains an unordered list of up to max nodes that are neighbors of the local node.
 boolean neighbourSetContains(NodeHandle o)
           
 void networkStabilized(boolean stabilized)
          The networkStabilized's method is a callback method used for the network simulator to notify to all nodes the stabilization process has finished and the topology is built up.
 void prettyPrintNode()
          Shows for System.out only the owner Id, its predecessor and successor.
 void printNode()
          Shows for System.out all information of the node, including finger table.
 boolean process(int actualStep)
          Given a time fraction, the node it can do everything what needs during this
 boolean range(NodeHandle node, Id rank, Id leftKey, Id rightKey)
          This methods ALWAYS return false.
 boolean remove(NodeHandle o)
           
 java.util.Vector replicaSet(Id key, int maxRank)
          Returns an ordered set of nodes on which replicas of the object with this key can be stored.
 NodeHandle route(NodeHandle to)
           
 void routeData(java.lang.String appId, NodeHandle to, NodeHandle nextHop, Message msg)
          Receive's data of the application level and sends it through de network.
 java.lang.String toString()
           
 
Methods inherited from class planet.generic.commonapi.NodeImpl
addMessageListener, dispatchDataMessage, getId, getIdFactory, getLocalHandle, getNewE, getRegisteredApplications, hasMoreMessages, invokeByStepToAllApplications, nextMessage, outMessages, playsGoodRole, receive, registerApplication, removeMessageListener, send, setGoodRole, setTimer, setTimer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REQUEST

public static final int REQUEST
Mode value: Defines the start of communication that requires response (REPLY).

See Also:
Constant Field Values

REPLY

public static final int REPLY
Mode value: Defines the response of a communication.

See Also:
Constant Field Values

REFRESH

public static final int REFRESH
Mode value: Defines a message's mode that requires only communication on one way.

See Also:
Constant Field Values

QUERY_JOIN

public static final int QUERY_JOIN
Type value: First message that is send by any node to get its inmediate successor.

See Also:
Constant Field Values

SET_INFO

public static final int SET_INFO
See Also:
Constant Field Values

QUERY_CONNECT

public static final int QUERY_CONNECT
See Also:
Constant Field Values

ACCEPT_CONNECT

public static final int ACCEPT_CONNECT
See Also:
Constant Field Values

CANCEL_CONNECT

public static final int CANCEL_CONNECT
See Also:
Constant Field Values

CLOSE_LONG_CONNECT

public static final int CLOSE_LONG_CONNECT
See Also:
Constant Field Values

CLOSE_NEIGHBOUR_CONNECT

public static final int CLOSE_NEIGHBOUR_CONNECT
See Also:
Constant Field Values

NumberOfTypes

public static final int NumberOfTypes
See Also:
Constant Field Values

NumberOfModes

public static final int NumberOfModes
See Also:
Constant Field Values

DATA

public static final int DATA
Type value: It identifies that this message contains an application level Message.

See Also:
Constant Field Values

TYPES

public static final java.lang.String[] TYPES
This String contains a string representation of each type value of the RouteMessage.


MODES

public static final java.lang.String[] MODES
This String contains a string representation of each mode value of the RouteMessage.


retriesNewLongDistance

public int retriesNewLongDistance

alive

public boolean alive

stabilized

public boolean stabilized
Constructor Detail

SymphonyNode

public SymphonyNode(Id id)
             throws InitializationException
Method Detail

getEndPoints

public java.util.Hashtable getEndPoints()

buildMessage

public RouteMessage buildMessage(NodeHandle from,
                                 NodeHandle to,
                                 int type,
                                 int mode,
                                 Message m)

buildMessage

public RouteMessage buildMessage(NodeHandle from,
                                 NodeHandle to,
                                 int type,
                                 int mode,
                                 Message m,
                                 java.lang.String key)

buildMessage

public RouteMessage buildMessage(NodeHandle from,
                                 NodeHandle to,
                                 NodeHandle nextHop,
                                 int type,
                                 int mode,
                                 Message m)

buildMessage

public RouteMessage buildMessage(NodeHandle from,
                                 NodeHandle to,
                                 NodeHandle nextHop,
                                 int type,
                                 int mode,
                                 Message m,
                                 java.lang.String key)

addToNeighbourSet

public void addToNeighbourSet(java.util.Collection c)

addToNeighbourSet

public void addToNeighbourSet(NodeHandle neighbour)

getNeighbourSet

public java.util.Collection getNeighbourSet()

neighbourSetContains

public boolean neighbourSetContains(NodeHandle o)

remove

public boolean remove(NodeHandle o)

getSucc

public NodeHandle getSucc()
Description copied from interface: Node
Returns the NodeHandle of the present successor of the node

Returns:
successor NodeHandle of this Node

getPred

public NodeHandle getPred()
Description copied from interface: Node
Returns the NodeHandle of the present predecessor of the node

Returns:
predeccesor NodeHandle of this Node

getOutcommingSet

public java.util.Set getOutcommingSet()

getIncommingSet

public java.util.Set getIncommingSet()

getNewSet

public java.util.Set getNewSet()

lookup

public void lookup(Id key)
Description copied from class: NodeImpl
Lookup of a key

Specified by:
lookup in class NodeImpl
Parameters:
key - Id

join

public void join(Id bsId)
Description copied from class: NodeImpl
The node joins in the network

Specified by:
join in interface Node
Specified by:
join in class NodeImpl
Parameters:
bsId - Id of a node in the network

leave

public void leave()
Description copied from class: NodeImpl
The node leaves the network

Specified by:
leave in interface Node
Specified by:
leave in class NodeImpl

getNewLongDistance

public RouteMessage getNewLongDistance()

dispatcher

public void dispatcher(RouteMessage msg)

process

public boolean process(int actualStep)
Description copied from class: NodeImpl
Given a time fraction, the node it can do everything what needs during this

Specified by:
process in interface Node
Overrides:
process in class NodeImpl
Parameters:
actualStep - Actual step in simulation time.
Returns:
Always true.

isLocalMessage

public boolean isLocalMessage(RouteMessage msg)
The isLocalMessage's method is an extension method for commonapi specs. This method is used to allow BehavioursPool decide wether the incoming RouteMessage is for the local node or for a remote node. Remenber, this decision may only be addressed by the underlying overlay protocol. For example, for Symphony's Lookup protocol a node is responsible for all RouteMessages whose keys have as an immediate succesor the node's id or have as destination the own node.

Specified by:
isLocalMessage in interface Node
Overrides:
isLocalMessage in class NodeImpl
Returns:
True if the incoming RouteMessage taken as input its for the local node.
See Also:
BehavioursPool

getInfo

public java.util.Hashtable getInfo()
Description copied from class: NodeImpl
Returns information of the node

Specified by:
getInfo in class NodeImpl
Returns:
info Hashtable with the information

routeData

public void routeData(java.lang.String appId,
                      NodeHandle to,
                      NodeHandle nextHop,
                      Message msg)
Description copied from interface: Node
Receive's data of the application level and sends it through de network.

Parameters:
appId - String that includes the application identification.
to - Node that must receive this message. If cannot represents a real node.
nextHop - Node that must receive this message as first hop.
msg - Message to be sent. If it is null, the message must be routed.

printNode

public void printNode()
Description copied from interface: Node
Shows for System.out all information of the node, including finger table.


prettyPrintNode

public void prettyPrintNode()
Description copied from interface: Node
Shows for System.out only the owner Id, its predecessor and successor.


isAlive

public boolean isAlive()
Description copied from interface: Node
Informs if this node is alive.

Returns:
true if the node is alive. false if the node has fail or leave.

route

public NodeHandle route(NodeHandle to)

toString

public java.lang.String toString()

IsStabilized

public boolean IsStabilized()

networkStabilized

public void networkStabilized(boolean stabilized)
The networkStabilized's method is a callback method used for the network simulator to notify to all nodes the stabilization process has finished and the topology is built up.

Parameters:
stabilized - True wether the network is stable.

broadcast

public void broadcast(java.lang.String appId,
                      NodeHandle to,
                      NodeHandle nextHop,
                      Message msg)
This method throws a NoSuchMethodError, because the broadcast algorithm is not implemented yet.

Parameters:
appId - Application identification.
to - Source of the message.
nextHop - NextHop of the message.
msg - Message to be send as broadcast.
See Also:
Node.broadcast(java.lang.String, planet.commonapi.NodeHandle, planet.commonapi.NodeHandle, planet.commonapi.Message)

fail

public void fail()
The leave protocol is the same as in leave case.

See Also:
Node.fail()

getSuccList

public java.util.Vector getSuccList(int max)
Returns up to max successors of the actual node.

Parameters:
max - Maximum number of successors to return.
Returns:
Up to max successors.
See Also:
Node.getSuccList(int)

localLookup

public java.util.Vector localLookup(Id key,
                                    int max,
                                    boolean safe)
Returns a list of nodes that can be used as next hops on a route towards key. If is safe, the expected fraction of faulty nodes in the list is guaranteed to be no higher than the fraction of faulty nodes in the overlay.

Parameters:
key - Target key
max - Number of next hops.
safe - If true, the expected fraction of faulty nodes are the same of the nodes in the overlay.
Returns:
Until a maximum of max nodes to use as next hop.
See Also:
Node.localLookup(planet.commonapi.Id, int, boolean)

neighborSet

public java.util.Vector neighborSet(int max)
Obtains an unordered list of up to max nodes that are neighbors of the local node.

Parameters:
max - Maximum of nodes to return.
Returns:
Neighbor nodes.
See Also:
Node.neighborSet(int)

range

public boolean range(NodeHandle node,
                     Id rank,
                     Id leftKey,
                     Id rightKey)
This methods ALWAYS return false. It is not implemented yet. This operation provides information about ranges of keys for which the node is currently a root. Returns false if the range could not be determined, true otherwise.

It is an error to query the range of a node not present in the neighbor set.

The [leftKey,rightKey] denotes the inclusive range of key values.

Parameters:
node - Node that is currently a root of some range of keys.
rank - Number of keys that is root the node (rank=rightKey-leftKey).
leftKey - The value that appears in the invokation is the candidate left key of the range. It may be modified to reflect the correct left margin once invokation has finished.
rightKey - Shows once the invokation has finished the left margin of the range.
Returns:
true if the range chold be determined; false otherwise, including the case of node is not present in the neighbor set returned by neighborSet().
See Also:
Node.range(planet.commonapi.NodeHandle, planet.commonapi.Id, planet.commonapi.Id, planet.commonapi.Id)

replicaSet

public java.util.Vector replicaSet(Id key,
                                   int maxRank)
Returns an ordered set of nodes on which replicas of the object with this key can be stored. The maximum number of nodes is maxRank. If the implementation's maximum replica set size is lower, then its maximum replica set is returned.

Parameters:
key - Id for which we find the replica set.
maxRank - Maximum number of members in replica set.
Returns:
An array of nodes with the replica set.
See Also:
Node.replicaSet(planet.commonapi.Id, int)

getClosestNodeHandle

public NodeHandle getClosestNodeHandle(Id id)
Returns the NodeHandle closest to id.

Specified by:
getClosestNodeHandle in class NodeImpl
Parameters:
id - Id to find.
Returns:
The NodeHandle closest to id.

getAllLinks

public java.util.Set getAllLinks()
Gets all node connections to other nodes as its NodeHandles. The order of NodeHandles is unexpected.

Returns:
A set with all connections as NodeHandles.

getEInGML

public void getEInGML(java.util.Collection E,
                      GMLConstraint constraint)
This method is a callback method used to collect all of the edges of a graph according to GML file format for latter visual graph performance.

Parameters:
E - Edge Set
constraint - Constraints for edge selection