|
|||||||||||
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 NodeImpl 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. |
protected int |
bitsPerKey
Number of bits per key to use as current configuration. |
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
Current finger table. |
protected int |
fingerChanges
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
Flag that shows when this node has failed. |
protected boolean |
hasLeaved
Flag that shows when this node has leaved. |
protected boolean |
hasReceivedSucc
Shows when has been received the GET_PRE response, requested on the stabilize() method to find the successor. |
protected Id |
MAX
Maximum Id value with the current configuration. |
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 |
nullPointers
Index to use within stabilization process onto the finger table. |
protected NodeHandle |
predecessor
The current predecessor in the Chord ring. |
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
The starting indices for the finger table (as Finger[k].start). |
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. |
java.util.Vector |
succList
Current successor list. |
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()
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 |
void |
buildEdges(java.lang.String resultName,
java.util.Collection edgeCollection,
ResultsConstraint constraint)
This method is a callback method used to collect all edges of a graph according to resultName format. |
protected void |
cleanSuccList()
Deletes all NodeHandles that exceeds the required size of successor list. |
protected void |
clearFingerChanges()
Clears the counter of the finger table changes |
protected NodeHandle |
closestPrecedingFinger(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 |
findPredecessor(int pos)
Finds the predecessor of a node. |
protected NodeHandle |
findPredecessor(NodeHandle handle)
Finds the predecessor of a node. |
protected NodeHandle |
findSuccessor(int pos)
Finds the successor of a node. |
protected NodeHandle |
findSuccessor(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 |
fixFingers()
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. |
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(NodeHandle 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. |
java.util.Vector |
neighborSet(int max)
Obtains an unordered list of up to max nodes that are neighbors of the local node. |
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,
int mode)
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 |
Node |
setValues(Id newId)
Sets the new Id for this 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 |
addEdges, addMessageListener, buildMessage, buildMessage, buildNewEdge, dispatchDataMessage, getId, getRegisteredApplication, getRegisteredApplications, hasMoreMessages, inMessages, invokeByStepToAllApplications, isLocalMessage, nextMessage, playsGoodRole, receive, registerApplication, removeMessageListener, send, sendMessage, sendMessage, sendMessage, sendMessage, 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 nullPointers
protected int fingerChanges
protected int stabRate
protected int bitsPerKey
protected int realStabilizationRate
protected NodeHandle predecessor
protected boolean hasFailed
protected boolean hasLeaved
protected boolean hasReceivedSucc
public NodeHandle[] finger
public Id[] start
public java.util.Vector succList
protected java.util.Vector auxCAPI
public Id deux
protected NodeHandle[] temp
Constructor Detail |
public ChordNode() throws InitializationException
Method 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 successorprotected void cleanSuccList()
public 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 findSuccessor(NodeHandle handle)
handle
- NodeHandle of the one node
protected NodeHandle findPredecessor(NodeHandle handle)
handle
- NodeHandle of the one node
protected NodeHandle closestPrecedingFinger(Id id)
id
- Id of the one node
protected NodeHandle findSuccessor(int pos)
pos
- position of NodeHandle in the start table
protected NodeHandle findPredecessor(int pos)
pos
- position of NodeHandle in the start table
public void join(NodeHandle 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 fixFingers()
protected void sendData(RouteMessage message, NodeHandle hint, int mode)
message
- Message to deliver from application.hint
- Proposed node handle for the next hop.mode
- Message mode (REQUEST or REFRESH)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 buildEdges(java.lang.String resultName, java.util.Collection edgeCollection, ResultsConstraint constraint)
resultName
- Result type name to use.edgeCollection
- Edge collection where to put in all produced ResultEdges.constraint
- ResultsConstraint 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 interface Node
getClosestNodeHandle
in class NodeImpl
id
- Id to find.
public Node setValues(Id newId) throws InitializationException
setValues
in interface Node
setValues
in class NodeImpl
newId
- The new Id.
InitializationException
Node.setValues(planet.commonapi.Id)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |