de.uniba.wiai.lspi.chord.service.impl
Class NodeImpl

java.lang.Object
  extended by de.uniba.wiai.lspi.chord.com.Node
      extended by de.uniba.wiai.lspi.chord.service.impl.NodeImpl

public final class NodeImpl
extends Node

Implements all operations which can be invoked remotely by other nodes.

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

Method Summary
 void disconnect()
          Closes the connection to the node.
 java.util.List<ResponsibleNode> findSuccessor(int tag, java.lang.String res, URL url)
          Returns the node which is responsible for the given resource.
 Node findSuccessorAtFloor(Floor floor, ID key)
          Returns the node which is responsible for the given key at given floor.
 java.util.ArrayList<MyFloor> getAllFloors()
           
 Entries getEntriesForFloor(Floor floor)
          
 Floor getFirstFloor()
           
 ID getIdForFloor(Floor floor)
           
 References getReferencesForFloor(Floor floor)
          
 void insertEntry(Floor floor, Entry toInsert)
          Stores the given object under the given ID at given floor.
 void insertReplicas(Floor floor, java.util.Set<Entry> replicatesToInsert)
          Inserts replicates of the given entries for given floor.
 void leavesNetwork(Floor floor, Node predecessor)
          Inform all predecessor of given node that it leaves the network.
 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].
 RefsAndEntries notifyAndCopyEntries(Floor floor, Node potentialPredecessor)
          Requests this node's predecessor, successor list and entries at given floor.
 void ping()
          Requests a sign of live.
 void removeEntry(Floor floor, Entry entryToRemove)
          Removes the given object from the list stored under the given ID at given floor.
 void removeReplicas(Floor floor, ID sendingNodeID, java.util.Set<Entry> replicasToRemove)
          Removes replicates of the given entries for given floor.
 java.util.Set<Entry> retrieveEntries(Floor floor, ID id)
          Returns all entries stored under the given ID.
 
Methods inherited from class de.uniba.wiai.lspi.chord.com.Node
equals, getNodeURL, hashCode, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

disconnect

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

Specified by:
disconnect in class Node

getReferencesForFloor

public final References getReferencesForFloor(Floor floor)


getEntriesForFloor

public final Entries getEntriesForFloor(Floor floor)


getIdForFloor

public final ID getIdForFloor(Floor floor)
Specified by:
getIdForFloor in class Node

getAllFloors

public final java.util.ArrayList<MyFloor> getAllFloors()

findSuccessorAtFloor

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

Specified by:
findSuccessorAtFloor in class Node
Parameters:
floor - Floor at which is searched being held.
key - Key for which the successor is searched for.
Returns:

findSuccessor

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

Specified by:
findSuccessor in class Node
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:

notify

public final 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]. This method is invoked by another node which thinks it is this node's predecessor.

Specified by:
notify in class Node
Returns:
A list containing the predecessor at first position of the list and the successors in the rest of the list.

notifyAndCopyEntries

public final RefsAndEntries notifyAndCopyEntries(Floor floor,
                                                 Node potentialPredecessor)
                                          throws CommunicationException
Requests this node's predecessor, successor list and entries at given floor.

Specified by:
notifyAndCopyEntries in class Node
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 final void ping()
Requests a sign of live. This method is invoked by another node which thinks it is this node's successor.

Specified by:
ping in class Node

insertEntry

public final void insertEntry(Floor floor,
                              Entry toInsert)
                       throws CommunicationException
Stores the given object under the given ID at given floor.

Specified by:
insertEntry in class Node
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

insertReplicas

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

Specified by:
insertReplicas in class Node
replicatesToInsert - The entries that are replicated.

removeEntry

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

Specified by:
removeEntry in class Node
entryToRemove - The entry to remove from the dht.
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

removeReplicas

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

Specified by:
removeReplicas in class Node
sendingNodeID - 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

retrieveEntries

public final java.util.Set<Entry> retrieveEntries(Floor floor,
                                                  ID id)
                                           throws CommunicationException
Returns all entries stored under the given ID.

Specified by:
retrieveEntries in class Node
Returns:
A Set of entries associated with id.
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

leavesNetwork

public final void leavesNetwork(Floor floor,
                                Node predecessor)
Inform all predecessor of given node that it leaves the network.

Specified by:
leavesNetwork in class Node

getFirstFloor

public Floor getFirstFloor()
Specified by:
getFirstFloor in class Node