de.uniba.wiai.lspi.chord.com.local
Class ThreadProxy

java.lang.Object
  extended by de.uniba.wiai.lspi.chord.com.Node
      extended by de.uniba.wiai.lspi.chord.com.Proxy
          extended by de.uniba.wiai.lspi.chord.com.local.ThreadProxy

public final class ThreadProxy
extends Proxy

This class represents a Proxy for the protocol that allows to be build a (local) chord network within one JVM.


Field Summary
protected  URL creatorURL
          The URLof the node that created this proxy.
protected  boolean hasBeenUsed
          Indicates if this proxy has been used to make a invocation.
protected  boolean isValid
          Indicates if this proxy can be used for communication;
protected  Registry registry
          Reference to the registrysingleton.
 
Fields inherited from class de.uniba.wiai.lspi.chord.com.Node
nodeID, nodeURL
 
Constructor Summary
ThreadProxy(URL creatorURL1, URL url)
          Creates a Proxy for the jchordlocal protocol.
 
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.
 ThreadEndpoint getEndpoint()
          Get a reference to the endpoint this proxy delegates methods to.
 void insertEntry(Entry entry)
          Stores the given object under the given ID.
 void insertReplicas(Set<Entry> entries)
          Inserts replicates of the given entries.
 void invalidate()
          Invalidates this proxy.
 boolean isValid()
          Test if this Proxy is valid.
 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 entry)
          Removes the given object from the list stored under the given ID.
 void removeReplicas(ID sendingNodeID, Set<Entry> entriesToRemove)
          Removes replicates of the given entries.
 Set<Entry> retrieveEntries(ID id)
          Returns all entries stored under the given ID.
 String toString()
           
 
Methods inherited from class de.uniba.wiai.lspi.chord.com.Proxy
createConnection
 
Methods inherited from class de.uniba.wiai.lspi.chord.com.Node
equals, getNodeID, getNodeURL, hashCode, setNodeID, setNodeURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

registry

protected Registry registry
Reference to the registrysingleton.


creatorURL

protected URL creatorURL
The URLof the node that created this proxy.


isValid

protected boolean isValid
Indicates if this proxy can be used for communication;


hasBeenUsed

protected boolean hasBeenUsed
Indicates if this proxy has been used to make a invocation.

Constructor Detail

ThreadProxy

public ThreadProxy(URL creatorURL1,
                   URL url)
            throws CommunicationException
Creates a Proxy for the jchordlocal protocol. The host name part of urlis the name of the node in the jchordlocal protocol.

Parameters:
creatorURL1 -
url - The URLof the node this proxy represents.
Throws:
CommunicationException
Method Detail

isValid

public boolean isValid()
Test if this Proxy is valid.

Returns:
true if this Proxy is valid.

invalidate

public void invalidate()
Invalidates this proxy.


getEndpoint

public ThreadEndpoint getEndpoint()
                           throws CommunicationException
Get a reference to the endpoint this proxy delegates methods to. If there is no endpoint a exception is thrown.

Returns:
Reference to the endpoint this proxy delegates methods to.
Throws:
CommunicationException - If there is no endpoint this exception is thrown.

findSuccessor

public Node findSuccessor(ID key)
                   throws CommunicationException
Description copied from class: Node
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.
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

insertEntry

public void insertEntry(Entry entry)
                 throws CommunicationException
Description copied from class: Node
Stores the given object under the given ID.

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

removeEntry

public void removeEntry(Entry entry)
                 throws CommunicationException
Description copied from class: Node
Removes the given object from the list stored under the given ID.

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

toString

public String toString()
Overrides:
toString in class Node

notify

public List<Node> notify(Node potentialPredecessor)
                  throws CommunicationException
Description copied from class: Node
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.
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

ping

public void ping()
          throws CommunicationException
Description copied from class: Node
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
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

retrieveEntries

public Set<Entry> retrieveEntries(ID id)
                           throws CommunicationException
Description copied from class: Node
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 void leavesNetwork(Node predecessor)
                   throws CommunicationException
Description copied from class: Node
Inform a node that its predecessor leaves the network.

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

removeReplicas

public void removeReplicas(ID sendingNodeID,
                           Set<Entry> entriesToRemove)
                    throws CommunicationException
Description copied from class: Node
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
entriesToRemove - 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.

insertReplicas

public void insertReplicas(Set<Entry> entries)
                    throws CommunicationException
Description copied from class: Node
Inserts replicates of the given entries.

Specified by:
insertReplicas in class Node
Parameters:
entries - The entries that are replicated.
Throws:
CommunicationException - Thrown if an unresolvable communication failure occurs.

notifyAndCopyEntries

public RefsAndEntries notifyAndCopyEntries(Node potentialPredecessor)
                                    throws CommunicationException
Description copied from class: Node
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

disconnect

public void disconnect()
Description copied from class: Node
Closes the connection to the node.

Specified by:
disconnect 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.