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 java.lang.Object

Provides methods which remote nodes can invoke.

Version:
1.0.5 modified, 0.99b
Author:
Sven Kaffille, Karsten Loesing, bojanm, francesco

Constructor Summary
Node()
           
 
Method Summary
abstract  void disconnect()
          Closes the connection to the node.
 boolean equals(java.lang.Object arg0)
           
abstract  java.util.List<ResponsibleNode> findSuccessor(int tag, java.lang.String res, URL url)
          Returns the node which is responsible for the given resource.
abstract  Node findSuccessorAtFloor(Floor f, ID key)
          Returns the node which is responsible for the given key at given floor.
abstract  Floor getFirstFloor()
           
abstract  ID getIdForFloor(Floor floor)
           
 URL getNodeURL()
           
 int hashCode()
           
abstract  void insertEntry(Floor floor, Entry entryToInsert)
          Stores the given object under the given ID at given floor.
abstract  void insertReplicas(Floor floor, java.util.Set<Entry> entries)
          Inserts replicates of the given entries for given floor.
abstract  void leavesNetwork(Floor floor, Node predecessor)
          Inform all predecessor of given node that it leaves the network.
abstract  java.util.List<Node> notify(Floor floor, Node potentialPredecessor)
          Requests this node's predecessor at given floor in result[0] and successor list in result[1..length-1].
abstract  RefsAndEntries notifyAndCopyEntries(Floor floor, Node potentialPredecessor)
          Requests this node's predecessor, successor list and entries at given floor.
abstract  void ping()
          Requests a sign of live.
abstract  void removeEntry(Floor floor, Entry entryToRemove)
          Removes the given object from the list stored under the given ID at given floor.
abstract  void removeReplicas(Floor floor, ID sendingNode, java.util.Set<Entry> replicasToRemove)
          Removes replicates of the given entries for given floor.
abstract  java.util.Set<Entry> retrieveEntries(Floor floor, ID id)
          Returns all entries stored under the given ID.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node()
Method Detail

equals

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

hashCode

public final int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getNodeURL

public final URL getNodeURL()
Returns:

findSuccessorAtFloor

public abstract Node findSuccessorAtFloor(Floor f,
                                          ID key)
                                   throws CommunicationException
Returns the node which is responsible for the given key at given floor.

Parameters:
f - Floor at which is searched being held.
key - Key for which the successor is searched for.
Returns:
Throws:
CommunicationException

findSuccessor

public abstract java.util.List<ResponsibleNode> findSuccessor(int tag,
                                                              java.lang.String res,
                                                              URL url)
                                                       throws CommunicationException
Returns the node which is responsible for the given resource.

Parameters:
tag - Tag for checking is the request is already processed.
res - Resource for which the successor is searched for.
url - URL of the node which successor is searched for.
Returns:
Throws:
CommunicationException

notify

public abstract java.util.List<Node> notify(Floor floor,
                                            Node potentialPredecessor)
                                     throws CommunicationException
Requests this node's predecessor at given floor 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 -
floor -
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(Floor floor,
                                                    Node potentialPredecessor)
                                             throws CommunicationException
Requests this node's predecessor, successor list and entries at given floor.

Parameters:
floor -
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(Floor floor,
                                 Entry entryToInsert)
                          throws CommunicationException
Stores the given object under the given ID at given floor.

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

insertReplicas

public abstract void insertReplicas(Floor floor,
                                    java.util.Set<Entry> entries)
                             throws CommunicationException
Inserts replicates of the given entries for given floor.

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

removeEntry

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

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

removeReplicas

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

Parameters:
floor -
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 java.util.Set<Entry> retrieveEntries(Floor floor,
                                                     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(Floor floor,
                                   Node predecessor)
                            throws CommunicationException
Inform all predecessor of given node that it 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.


getIdForFloor

public abstract ID getIdForFloor(Floor floor)

getFirstFloor

public abstract Floor getFirstFloor()
                             throws CommunicationException
Throws:
CommunicationException