planet.trivialp2p
Class TrivialNode

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

public class TrivialNode
extends NodeImpl

It is a trivial implementation of a P2P overlay network. Each node only has two links: the predecessor and successor in a ring topology. This overlay not contains stabilization protocol and is assigned under network building.

Author:
Jordi Pujol 03-jun-2005
See Also:
Serialized Form

Field Summary
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 REFRESH
          Mode value: Defines a message's mode to be delivered directly in a oneway communication.
static int REQUEST
          Mode value: Defines a message's mode that requires a routing task in a oneway communication.
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
TrivialNode()
          Initialize the internal structure.
 
Method Summary
 void broadcast(java.lang.String appId, NodeHandle to, NodeHandle nextHop, Message msg)
          This routing method is not implemented and always throws a NoSuchMethodError.
 void buildEdges(java.lang.String resultName, java.util.Collection edgeCollection, ResultsConstraint constraint)
          Build the edges for its sucessor and predecessor links.
 void fail()
          Do nothing.
 java.util.Set getAllLinks()
          Gets all node connections to other nodes as its NodeHandles.
 NodeHandle getClosestNodeHandle(Id id)
          Returns the own nodehandle or its successor nodehandle, in a clockwise proximity.
 java.util.Hashtable getInfo()
          Gets the internal routing information in a hashtable.
 NodeHandle getPred()
          Gets the predecessor nodehandle.
 NodeHandle getSucc()
          Gets the successor nodehandle.
 java.util.Vector getSuccList(int max)
          Gets the successor list.
 boolean isAlive()
          Shows whenever this method is alive.
 void join(NodeHandle bootstrap)
          Nothing does.
 void leave()
          Nothing does.
 java.util.Vector localLookup(Id key, int max, boolean safe)
          Always return null.
 java.util.Vector neighborSet(int max)
          Always return null.
 void prettyPrintNode()
          Prints out the local node information.
 void printNode()
          Prints out the routing information of this node.
 boolean process(int actualStep)
          Process the local incoming messages.
 boolean range(NodeHandle node, Id rank, Id leftKey, Id rightKey)
          This methods ALWAYS return false.
 java.util.Vector replicaSet(Id key, int maxRank)
          Always return null.
 void routeData(java.lang.String appId, NodeHandle to, NodeHandle nextHop, Message msg)
          Routes an application level message to the destination node.
 void setPredecessor(NodeHandle pred)
          Updates the node predecessor.
 void setSuccessor(NodeHandle succ)
          Updates the node successor.
 java.lang.String toString()
           
 
Methods inherited from class planet.generic.commonapi.NodeImpl
addEdges, addMessageListener, buildMessage, buildMessage, buildNewEdge, dispatchDataMessage, getId, getLocalHandle, getRegisteredApplication, getRegisteredApplications, hasMoreMessages, inMessages, invokeByStepToAllApplications, isLocalMessage, nextMessage, outMessages, playsGoodRole, receive, registerApplication, removeMessageListener, send, sendMessage, sendMessage, sendMessage, sendMessage, setGoodRole, setTimer, setTimer, setValues
 
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 a message's mode that requires a routing task in a oneway communication.

See Also:
Constant Field Values

REFRESH

public static final int REFRESH
Mode value: Defines a message's mode to be delivered directly in a oneway communication.

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

NumberOfTypes

public static final int NumberOfTypes
See Also:
Constant Field Values

NumberOfModes

public static final int NumberOfModes
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.

Constructor Detail

TrivialNode

public TrivialNode()
            throws InitializationException
Initialize the internal structure.

Method Detail

join

public void join(NodeHandle bootstrap)
Nothing does. This implementation don't contain a stabilization protocol.

Specified by:
join in interface Node
Specified by:
join in class NodeImpl
Parameters:
bootstrap - Bootstrap node.
See Also:
Node.join(planet.commonapi.NodeHandle)

leave

public void leave()
Nothing does. Only sets the alive flag to false.

Specified by:
leave in interface Node
Specified by:
leave in class NodeImpl
See Also:
Node.leave()

getInfo

public java.util.Hashtable getInfo()
Gets the internal routing information in a hashtable. The key informs the concept of the related value.

Specified by:
getInfo in class NodeImpl
Returns:
A hashtable with the internal routing information.
See Also:
NodeImpl.getInfo()

getClosestNodeHandle

public NodeHandle getClosestNodeHandle(Id id)
Returns the own nodehandle or its successor nodehandle, in a clockwise proximity.

Specified by:
getClosestNodeHandle in interface Node
Specified by:
getClosestNodeHandle in class NodeImpl
Parameters:
id - The id to be find.
Returns:
The nearest nodehandle in a clockwise manner.
See Also:
Node.getClosestNodeHandle(planet.commonapi.Id)

routeData

public void routeData(java.lang.String appId,
                      NodeHandle to,
                      NodeHandle nextHop,
                      Message msg)
Routes an application level message to the destination node.

Parameters:
appId - Application name.
to - Destination node (or key).
nextHop - May be null. The next hop into the route.
msg - Application level message to be sent.
See Also:
Node.routeData(java.lang.String, planet.commonapi.NodeHandle, planet.commonapi.NodeHandle, planet.commonapi.Message)

fail

public void fail()
Do nothing. Only sets to false the alive flag.

See Also:
Node.fail()

printNode

public void printNode()
Prints out the routing information of this node.

See Also:
Node.printNode()

prettyPrintNode

public void prettyPrintNode()
Prints out the local node information.

See Also:
Node.prettyPrintNode()

broadcast

public void broadcast(java.lang.String appId,
                      NodeHandle to,
                      NodeHandle nextHop,
                      Message msg)
This routing method is not implemented and always throws a NoSuchMethodError.

Parameters:
appId - Application id that requires to send a broadcast message.
to - Source node.
nextHop - Next hop in the route.
msg - Application level message to be delivered in the broadcast.
Throws:
java.lang.NoSuchMethodError - always this method is invoked.
See Also:
Node.broadcast(java.lang.String, planet.commonapi.NodeHandle, planet.commonapi.NodeHandle, planet.commonapi.Message)

getPred

public NodeHandle getPred()
Gets the predecessor nodehandle.

Returns:
The predecessor nodeHandle.
See Also:
Node.getPred()

getSucc

public NodeHandle getSucc()
Gets the successor nodehandle.

Returns:
The successor nodehandle.
See Also:
Node.getSucc()

isAlive

public boolean isAlive()
Shows whenever this method is alive.

Returns:
true if the node is alive. false in other case.
See Also:
Node.isAlive()

getSuccList

public java.util.Vector getSuccList(int max)
Gets the successor list.

Parameters:
max - Maximum number of successor to be returned.
Returns:
A vector with a max as maximum.
See Also:
Node.getSuccList(int)

localLookup

public java.util.Vector localLookup(Id key,
                                    int max,
                                    boolean safe)
Always return null.

Parameters:
key - Key to be found
max - Maximum number of nodehandles to be returned.
safe - Shows if the connections have to be safe.
Returns:
Always null.
See Also:
Node.localLookup(planet.commonapi.Id, int, boolean)

neighborSet

public java.util.Vector neighborSet(int max)
Always return null.

Parameters:
max - Maximum number of neighbors to be returned.
Returns:
Always null.
See Also:
Node.neighborSet(int)

replicaSet

public java.util.Vector replicaSet(Id key,
                                   int maxRank)
Always return null.

Parameters:
key - Key to be replicated.
maxRank - Maximum number of nodes where to save the replicas.
Returns:
Always null.
See Also:
Node.replicaSet(planet.commonapi.Id, 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)

buildEdges

public void buildEdges(java.lang.String resultName,
                       java.util.Collection edgeCollection,
                       ResultsConstraint constraint)
Build the edges for its sucessor and predecessor links.

Parameters:
resultName - Result name to be used.
edgeCollection - Edge collection where to add all the new ones.
constraint - Constraint to verify the addition of the edges.
See Also:
Node.buildEdges(java.lang.String, java.util.Collection, planet.commonapi.results.ResultsConstraint)

getAllLinks

public java.util.Set getAllLinks()
Description copied from interface: Node
Gets all node connections to other nodes as its NodeHandles. The order of NodeHandles is unexpected.

Returns:
All the local links.
See Also:
Node.getAllLinks()

process

public boolean process(int actualStep)
Process the local incoming messages.

Specified by:
process in interface Node
Overrides:
process in class NodeImpl
Parameters:
actualStep - Actual step in the simulation process.
Returns:
Always false, whenever the node always is stabilized and don't require more steps for its stabilization.
See Also:
Node.process(int)

setPredecessor

public void setPredecessor(NodeHandle pred)
Updates the node predecessor.

Parameters:
pred - The new node predecessor.

setSuccessor

public void setSuccessor(NodeHandle succ)
Updates the node successor.

Parameters:
succ - The new node successor.

toString

public java.lang.String toString()
Returns:
The string representation of this node.
See Also:
Object.toString()