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.


Field Summary
 
Fields inherited from class de.uniba.wiai.lspi.chord.com.Node
nodeID, nodeURL
 
Method Summary
 void disconnect()
          Closes the connection to the node.
 Node findSuccessor(ID key)
          Returns the Chord node which is responsible for the given key.
 void insertEntry(Entry toInsert)
          Stores the given object under the given ID.
 void insertReplicas(Set<Entry> replicatesToInsert)
          Inserts replicates of the given entries.
 void leavesNetwork(Node predecessor)
          Inform a node that its predecessor leaves the network.
 List<Node> notify(Node potentialPredecessor)
          Requests this node's predecessor in result[0] and successor list in result[1..length-1].
 RefsAndEntries notifyAndCopyEntries(Node potentialPredecessor)
          Requests this node's predecessor, successor list and entries.
 void ping()
          Requests a sign of live.
 void removeEntry(Entry entryToRemove)
          Removes the given object from the list stored under the given ID.
 void removeReplicas(ID sendingNodeID, Set<Entry> replicasToRemove)
          Removes replicates of the given entries.
 Set<Entry> retrieveEntries(ID id)
          Returns all entries stored under the given ID.
 
Methods inherited from class de.uniba.wiai.lspi.chord.com.Node
equals, getNodeID, getNodeURL, hashCode, setNodeID, setNodeURL, toString
 
Methods inherited from class java.lang.Object
clone, finalize, 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

findSuccessor

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

Specified by:
findSuccessor in class Node
Parameters:
key - Key for which the successor is searched for.
Returns:
Responsible node.

notify

public final List<Node> notify(Node potentialPredecessor)
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.

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(Node potentialPredecessor)
                                          throws CommunicationException
Requests this node's predecessor, successor list and entries.

Specified by:
notifyAndCopyEntries in class Node
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 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(Entry toInsert)
                       throws CommunicationException
Stores the given object under the given ID.

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

insertReplicas

public final void insertReplicas(Set<Entry> replicatesToInsert)
Inserts replicates of the given entries.

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

removeEntry

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

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

removeReplicas

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

Specified by:
removeReplicas in class Node
Parameters:
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 Set<Entry> retrieveEntries(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(Node predecessor)
Inform a node that its predecessor leaves the network.

Specified by:
leavesNetwork in class Node


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