|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectplanet.generic.commonapi.NodeImpl
planet.chord.ChordNode
A Chord node is single entity in the chord network. It extends of the class Node and specializes following the lookup Chord protocol. Moreover, the stabilization implementation, producing the periodic stabilition events.
Nested Class Summary | |
class |
ChordNode.FindPredListener
|
class |
ChordNode.FindSuccListener
|
class |
ChordNode.FixFingerTask
Simple TimerTask that invoke fix_fingers() Node method. |
class |
ChordNode.GetPreListener
|
class |
ChordNode.LookupListener
|
class |
ChordNode.StabilizeTask
Simple TimerTask that invoke stabilize() Node method. |
Field Summary | |
protected java.util.Vector |
auxCAPI
Temporal use in Common API methods. |
static int |
BROADCAST
Type value: The message with this type identifies a broadcast message. |
static int |
DATA
Type value: It identifies that this message contains an application level Message. |
Id |
deux
|
static int |
FIND_PRE
Type value: Start a set of messages that permits to find the inmediate successor of any new incoming node to the network. |
static int |
FIND_SUCC
Type value: First message that is send by any node to get its inmediate successor. |
NodeHandle[] |
finger
|
protected int |
finger_changes
Detect the number of finger changes only on one simulation step. |
static int |
GET_PRE
Type value: Start a set of messages that permits to find the inmediate node in charge of any key. |
protected boolean |
hasFailed
|
protected boolean |
hasLeaved
|
protected Id |
MAX
|
static java.lang.String[] |
MODES
This String contains a string representation of each mode value of the RouteMessage. |
static int |
NOTIFY
Type value: Informs to the node that receive this message its inmediate predecessor. |
protected int |
null_pointers
|
protected NodeHandle |
predecessor
|
protected int |
realStabilizationRate
Number of simulation steps without changes on finger table, that represents a real stabilization of this node. |
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). |
static int |
SET_PRE
Type value: Informs to the node that receive this message its new inmediate predecessor. |
static int |
SET_SUCC
Type value: Informs to the node that receives this message its new inmediate successor. |
protected int |
stabRate
Number of simulation steps without changes on finger table. |
Id[] |
start
|
java.util.Vector |
succ_list
|
static int |
SUCC_LIST
Type value: Start a set of messages that permits the harvesting of successors of the node that send originally this message. |
protected NodeHandle[] |
temp
|
static java.lang.String[] |
TYPES
This String contains a string representation of each of types and modes values of the RouteMessage. |
Fields inherited from class planet.generic.commonapi.NodeImpl |
endpoints, id, listeners, nodeHandle, role |
Constructor Summary | |
ChordNode(Id id)
Constructor, create a new BadChordNode instance with this node Id |
Method Summary | |
void |
broadcast(java.lang.String appId,
NodeHandle to,
NodeHandle nextHop,
Message msg)
Initiating a Broadcast Message |
protected void |
clearFingerChanges()
Clears the counter of the finger table changes |
protected NodeHandle |
closest_preceding_finger(Id id)
Finds the closest preceding finger of a node |
void |
dispatcher(RouteMessage msg)
Treats the messages and according to the case, executes the generic listeners or listeners specialized, forward the messages or send responses messages |
void |
fail()
Sets alive flag to false. |
protected NodeHandle |
find_predecessor(int pos)
Finds the predecessor of a node. |
protected NodeHandle |
find_predecessor(NodeHandle handle)
Finds the predecessor of a node. |
protected NodeHandle |
find_successor(int pos)
Finds the successor of a node. |
protected NodeHandle |
find_successor(NodeHandle handle)
Finds the successor of a node. |
int |
firstLocalLookup(Id key)
Detects de first position that key is in range of some position of finger table. |
protected void |
fix_fingers()
This method allows to update a finger table position. |
java.util.Set |
getAllLinks()
Gets all node connections to other nodes as its NodeHandles. |
static RouteMessage |
getBroadcastMessage(java.lang.String appId,
NodeHandle from,
NodeHandle to,
NodeHandle nextHop,
Message msg)
Return a RouteMessage with the specified values. |
NodeHandle |
getClosestNodeHandle(Id id)
Returns the NodeHandle closest to id. |
static RouteMessage |
getDataMessage(java.lang.String appId,
NodeHandle from,
NodeHandle to,
NodeHandle nextHop,
Message msg)
Return a RouteMessage with the specified values. |
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. |
protected int |
getFingerChanges()
Returns the count of the finger table changes |
java.util.Hashtable |
getInfo()
Returns information of the node |
NodeHandle |
getLocalHandle()
Return the local NodeHandle. |
NodeHandle |
getPred()
Returns the NodeHandle of the present identification of the precursor of the node |
NodeHandle |
getSucc()
Returns the NodeHandle of the present identification of the successor of the node |
java.util.Vector |
getSuccList(int max)
Returns the successor list of the present node |
boolean |
isAlive()
Informs if this node is alive. |
void |
join(Id bootstrap)
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 id)
Given a key, it generates the message and listener to obtain the owner of this one. |
java.util.Vector |
neighborSet(int max)
Obtains an unordered list of up to max nodes that are neighbors of the local node. |
void |
networkStabilized(boolean networkStable)
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. |
protected void |
notify(NodeHandle nh)
Verify if the indicated node is the true predecessor |
Queue |
outMessages()
Overwrites the outMessages to evaluates the internal flag hasFailed for not to deliver the outgoing queue of messages. |
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, treats the messages and executes the periodicas actions, as for example, the stabilization methods |
boolean |
range(NodeHandle node,
Id rank,
Id leftKey,
Id rightKey)
This operation provides information about ranges of keys for which the node is currently a root. |
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. |
void |
routeData(java.lang.String appId,
NodeHandle to,
NodeHandle nextHop,
Message msg)
Sends a RouteMessage to the ring. |
protected void |
routingData(RouteMessage message,
NodeHandle nextHop)
Send a message to unknown destination node via routing. |
protected void |
sendData(RouteMessage message,
NodeHandle hint)
Send a message to destination node directly. |
protected void |
setFinger(int pos,
NodeHandle handle)
Sets a especific finger of the finger table |
void |
setPred(NodeHandle handle)
Sets the predecessor node |
void |
setSucc(NodeHandle handle)
Sets the successor node |
protected void |
stabilize()
Verify node immediate successor and tell the successor about this, moreover generate and update the successor list. |
java.lang.String |
toString()
|
Methods inherited from class planet.generic.commonapi.NodeImpl |
addMessageListener, dispatchDataMessage, getId, getIdFactory, getNewE, getRegisteredApplications, hasMoreMessages, invokeByStepToAllApplications, isLocalMessage, nextMessage, 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 |
public static final int REQUEST
public static final int REPLY
public static final int REFRESH
public static final int FIND_SUCC
public static final int FIND_PRE
public static final int SET_SUCC
public static final int SET_PRE
public static final int GET_PRE
public static final int NOTIFY
public static final int SUCC_LIST
public static final int BROADCAST
public static final int DATA
public static final java.lang.String[] TYPES
public static final java.lang.String[] MODES
protected Id MAX
protected int null_pointers
protected int finger_changes
protected int stabRate
protected int realStabilizationRate
protected NodeHandle predecessor
protected boolean hasFailed
protected boolean hasLeaved
public NodeHandle[] finger
public Id[] start
public java.util.Vector succ_list
protected java.util.Vector auxCAPI
public Id deux
protected NodeHandle[] temp
Constructor Detail |
public ChordNode(Id id) throws InitializationException
id
- Id to set to the new nodeMethod Detail |
public static RouteMessage getDataMessage(java.lang.String appId, NodeHandle from, NodeHandle to, NodeHandle nextHop, Message msg) throws InitializationException
appId
- Application Id name.from
- Source node.to
- Destination node.nextHop
- NextHop node.
InitializationException
public static RouteMessage getBroadcastMessage(java.lang.String appId, NodeHandle from, NodeHandle to, NodeHandle nextHop, Message msg) throws InitializationException
appId
- Application Id name.from
- Source node.to
- Destination node.nextHop
- NextHop node.
InitializationException
public void setPred(NodeHandle handle)
handle
- NodeHandle of the predecessorpublic void setSucc(NodeHandle handle)
handle
- NodeHandle of the successorpublic NodeHandle getPred()
public NodeHandle getSucc()
public java.util.Vector getSuccList(int max)
max
- number of the elements to return
protected void clearFingerChanges()
protected int getFingerChanges()
protected void setFinger(int pos, NodeHandle handle)
pos
- position of the fingerhandle
- new NodeHandle to changepublic java.util.Hashtable getInfo()
NodeImpl
getInfo
in class NodeImpl
public void printNode()
public void prettyPrintNode()
protected NodeHandle find_successor(NodeHandle handle)
handle
- NodeHandle of the one node
protected NodeHandle find_predecessor(NodeHandle handle)
handle
- NodeHandle of the one node
protected NodeHandle closest_preceding_finger(Id id)
id
- Id of the one node
protected NodeHandle find_successor(int pos)
pos
- position of NodeHandle in the start table
protected NodeHandle find_predecessor(int pos)
pos
- position of NodeHandle in the start table
public void join(Id bootstrap)
join
in interface Node
join
in class NodeImpl
bootstrap
- Id of arbitrary node in the networkpublic void leave()
leave
in interface Node
leave
in class NodeImpl
protected void stabilize()
protected void notify(NodeHandle nh)
nh
- node to checkprotected void fix_fingers()
public void lookup(Id id)
lookup
in class NodeImpl
id
- Id of the keyprotected void sendData(RouteMessage message, NodeHandle hint)
message
- Message to deliver from application.hint
- Proposed node handle for the next hop.protected void routingData(RouteMessage message, NodeHandle nextHop)
message
- Message to deliver from application.nextHop
- Proposed next hop.public void routeData(java.lang.String appId, NodeHandle to, NodeHandle nextHop, Message msg)
appId
- The applicationId The application identifier of the incoming
application message.to
- The destination NodeHandle.nextHop
- The next hop NodeHandle if it is known.msg
- The incoming message from above layers.public void broadcast(java.lang.String appId, NodeHandle to, NodeHandle nextHop, Message msg)
appId
- Application which sends this broadcast.to
- Destination of the broadcast.nextHop
- Next hop.msg
- Message to be sent into the broadcast.public void dispatcher(RouteMessage msg)
msg
- IMessage to treatpublic boolean process(int actualStep)
process
in interface Node
process
in class NodeImpl
actualStep
- Actual simulation step.
public boolean isAlive()
Node
Test if Node is alive
public java.lang.String toString()
public NodeHandle getLocalHandle()
getLocalHandle
in interface Node
getLocalHandle
in class NodeImpl
Node.getLocalHandle()
public void fail()
Node.fail()
public Queue outMessages()
outMessages
in interface Node
outMessages
in class NodeImpl
Node.outMessages()
,
NodeImpl.outMessages()
public void networkStabilized(boolean networkStable)
networkStable
- True wether the network is stable.public void getEInGML(java.util.Collection E, GMLConstraint constraint)
E
- Edge Setconstraint
- Constraints for edge selectionpublic java.util.Vector localLookup(Id key, int max, boolean safe)
key
- Target keymax
- Number of next hops.safe
- This flag is not consulted.
Node.localLookup(planet.commonapi.Id, int, boolean)
public int firstLocalLookup(Id key)
key
- Id to find the first position of finger table is responsible.
public java.util.Vector neighborSet(int max)
Node
max
- Maximum of nodes to return.
Obtains an unordered list of up to max nodes that are neighbors
of the local node.
public boolean range(NodeHandle node, Id rank, Id leftKey, Id rightKey)
Node
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. It must be initialized to 0 (zero) before this method could be invoked.
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.
public java.util.Vector replicaSet(Id key, int maxRank)
Node
key
- Key from which obtain the replica set.maxRank
- Number of nodes in replica set.
Returns the replica node set.
The number of successor list is defined in the context.
public java.util.Set getAllLinks()
public NodeHandle getClosestNodeHandle(Id id)
getClosestNodeHandle
in class NodeImpl
id
- Id to find.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |