de.uniba.wiai.lspi.chord.com
Class Node

java.lang.Object
  extended by de.uniba.wiai.lspi.chord.com.Node
Direct Known Subclasses:
NodeImpl, Proxy

public abstract class Node
extends Object

Provides methods which remote nodes can invoke.


Field Summary
protected  ID nodeID
          This is the id of this node.
protected  URL nodeURL
          This is the url of this node.
 
Constructor Summary
Node()
           
 
Method Summary
abstract  void disconnect()
          Closes the connection to the node.
 boolean equals(Object arg0)
           
abstract  Node findSuccessor(ID key)
          Returns the Chord node which is responsible for the given key.
 ID getNodeID()
          Returns the ID of a node.
 URL getNodeURL()
           
 int hashCode()
           
abstract  void insertEntry(Entry entryToInsert)
          Stores the given object under the given ID.
abstract  void insertReplicas(Set<Entry> entries)
          Inserts replicates of the given entries.
abstract  void leavesNetwork(Node predecessor)
          Inform a node that its predecessor leaves the network.
abstract  List<Node> notify(Node potentialPredecessor)
          Requests this node's predecessor in result[0] and successor list in result[1..length-1].
abstract  RefsAndEntries notifyAndCopyEntries(Node potentialPredecessor)
          Requests this node's predecessor, successor list and entries.
abstract  void ping()
          Requests a sign of live.
abstract  void removeEntry(Entry entryToRemove)
          Removes the given object from the list stored under the given ID.
abstract  void removeReplicas(ID sendingNode, Set<Entry> replicasToRemove)
          Removes replicates of the given entries.
abstract  Set<Entry> retrieveEntries(ID id)
          Returns all entries stored under the given ID.
protected  void setNodeID(ID nodeID)
           
protected  void setNodeURL(URL nodeURL)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

nodeID

protected ID nodeID
This is the id of this node. It has to be set by every implementation of this class!


nodeURL

protected URL nodeURL
This is the url of this node. It has to be set by every implementation of this class!

Constructor Detail

Node

public Node()
Method Detail

equals

public final boolean equals(Object arg0)
Overrides:
equals in class Object

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

getNodeID

public final ID getNodeID()
Returns the ID of a node. Is invoked by remote nodes which do not know the ID of this node, yet. After invocation, the nodeID is remembered by the remote node, s.t. future invocations of getNodeID are unnecessary.

Returns:
ID of a node.
Throws:
CommunicationException - If something goes wrong when contacting the node.

getNodeURL

public final URL getNodeURL()
Returns:

findSuccessor

public abstract Node findSuccessor(ID key)
                            throws CommunicationException
Returns the Chord node which is responsible for the given key.

Parameters:
key - Key for which the successor is searched for.
Returns:
Responsible node.
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

notify

public abstract List<Node> notify(Node potentialPredecessor)
                           throws CommunicationException
Requests this node's predecessor in result[0] and successor list in result[1..length-1]. This method is invoked by another node which thinks it is this node's predecessor.

Parameters:
potentialPredecessor -
Returns:
A list containing the predecessor at first position of the list and the successors in the rest of the list.
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

notifyAndCopyEntries

public abstract RefsAndEntries notifyAndCopyEntries(Node potentialPredecessor)
                                             throws CommunicationException
Requests this node's predecessor, successor list and entries.

Parameters:
potentialPredecessor - Remote node which invokes this method
Returns:
References to predecessor and successors and the entries this node will be responsible for.
Throws:
CommunicationException

ping

public abstract void ping()
                   throws CommunicationException
Requests a sign of live. This method is invoked by another node which thinks it is this node's successor.

Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

insertEntry

public abstract void insertEntry(Entry entryToInsert)
                          throws CommunicationException
Stores the given object under the given ID.

Parameters:
entryToInsert -
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

insertReplicas

public abstract void insertReplicas(Set<Entry> entries)
                             throws CommunicationException
Inserts replicates of the given entries.

Parameters:
entries - The entries that are replicated.
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

removeEntry

public abstract void removeEntry(Entry entryToRemove)
                          throws CommunicationException
Removes the given object from the list stored under the given ID.

Parameters:
entryToRemove - The entry to remove from the dht.
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

removeReplicas

public abstract void removeReplicas(ID sendingNode,
                                    Set<Entry> replicasToRemove)
                             throws CommunicationException
Removes replicates of the given entries.

Parameters:
sendingNode - ID of sending node; if entriesToRemove is empty, all replicas with ID smaller than the sending node's ID are removed
replicasToRemove - Replicas to remove; if empty, all replicas with ID smaller than the sending node's ID are removed
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

retrieveEntries

public abstract Set<Entry> retrieveEntries(ID id)
                                    throws CommunicationException
Returns all entries stored under the given ID.

Parameters:
id -
Returns:
A Set of entries associated with id.
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

leavesNetwork

public abstract void leavesNetwork(Node predecessor)
                            throws CommunicationException
Inform a node that its predecessor leaves the network.

Parameters:
predecessor -
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

disconnect

public abstract void disconnect()
Closes the connection to the node.


setNodeID

protected final void setNodeID(ID nodeID)
Parameters:
nodeID - the nodeID to set

setNodeURL

protected final void setNodeURL(URL nodeURL)
Parameters:
nodeURL - the nodeURL to set


Copyright © 2004-2008 Karsten Loesing, Sven Kaffille - Distributed and Mobile Systems Group, Lehrstuhl für Praktische Informatik, Universität Bamberg. All Rights Reserved.