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

java.lang.Object
  extended by de.uniba.wiai.lspi.chord.com.Endpoint
      extended by de.uniba.wiai.lspi.chord.com.local.ThreadEndpoint

public final class ThreadEndpoint
extends Endpoint

This represents the Endpoint for the protocol that can be used to build a (local) chord network within one JVM.

Version:
1.0.5 modified, 0.99b
Author:
sven, bojanm

Field Summary
 
Fields inherited from class de.uniba.wiai.lspi.chord.com.Endpoint
ACCEPT_ENTRIES, DISCONNECTED, LISTENING, METHODS_ALLOWED_IN_ACCEPT_ENTRIES, STARTED
 
Constructor Summary
ThreadEndpoint(Node node1, URL url1)
          Creates a new Endpoint for communication via Java Threads.
 
Method Summary
 void crash()
          Method to emulate a crash of the node that this is the endpoint for.
 boolean equals(java.lang.Object obj)
          Overwritten from Object.
 java.util.List<ResponsibleNode> findSuccessor(int tag, java.lang.String res, URL url)
           
 Node findSuccessorAtFloor(Floor floor, ID key)
           
 int hashCode()
          Overwritten from Object.
 void insertEntry(Floor floor, Entry entry)
           
 void insertReplicas(Floor floor, java.util.Set<Entry> entries)
           
 void leavesNetwork(Floor floor, Node predecessor)
           
 java.util.List<Node> notify(Floor floor, Node potentialPredecessor)
           
 RefsAndEntries notifyAndCopyEntries(Floor floor, Node potentialPredecessor)
           
 void ping()
           
 void register(InvocationListener listener)
           
 void removeEntry(Floor floor, Entry entry)
           
 void removeReplicas(Floor floor, ID sendingNodeID, java.util.Set<Entry> entriesToRemove)
           
 java.util.Set<Entry> retrieveEntries(Floor floor, ID id)
           
 java.lang.String toString()
          Overwritten from Object.
 
Methods inherited from class de.uniba.wiai.lspi.chord.com.Endpoint
acceptEntries, createEndpoint, deregister, disconnect, getEndpoint, getNode, getState, getURL, listen, register
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadEndpoint

public ThreadEndpoint(Node node1,
                      URL url1)
Creates a new Endpoint for communication via Java Threads.

Parameters:
node1 - The Nodethis endpoint invocates methods on.
url1 - The URLof this endpoint. The hostname of url is the name of the node.
Method Detail

register

public void register(InvocationListener listener)
Parameters:
listener -

findSuccessorAtFloor

public Node findSuccessorAtFloor(Floor floor,
                                 ID key)
                          throws CommunicationException
Parameters:
key -
Returns:
The successor of key.
Throws:
CommunicationException

findSuccessor

public java.util.List<ResponsibleNode> findSuccessor(int tag,
                                                     java.lang.String res,
                                                     URL url)
                                              throws CommunicationException
Throws:
CommunicationException

insertEntry

public void insertEntry(Floor floor,
                        Entry entry)
                 throws CommunicationException
Parameters:
entry -
Throws:
CommunicationException

removeEntry

public void removeEntry(Floor floor,
                        Entry entry)
                 throws CommunicationException
Parameters:
entry -
Throws:
CommunicationException

notify

public java.util.List<Node> notify(Floor floor,
                                   Node potentialPredecessor)
                            throws CommunicationException
Parameters:
potentialPredecessor -
Returns:
Implementation of Node#notify(Node). See documentation of Node.
Throws:
CommunicationException

ping

public void ping()
          throws CommunicationException
Throws:
CommunicationException

retrieveEntries

public java.util.Set<Entry> retrieveEntries(Floor floor,
                                            ID id)
                                     throws CommunicationException
Parameters:
id -
Returns:
The retrieved entries.
Throws:
CommunicationException

leavesNetwork

public void leavesNetwork(Floor floor,
                          Node predecessor)
                   throws CommunicationException
Parameters:
predecessor -
Throws:
CommunicationException

removeReplicas

public void removeReplicas(Floor floor,
                           ID sendingNodeID,
                           java.util.Set<Entry> entriesToRemove)
                    throws CommunicationException
Parameters:
sendingNodeID -
entriesToRemove -
Throws:
CommunicationException

insertReplicas

public void insertReplicas(Floor floor,
                           java.util.Set<Entry> entries)
                    throws CommunicationException
Parameters:
entries -
Throws:
CommunicationException

notifyAndCopyEntries

public RefsAndEntries notifyAndCopyEntries(Floor floor,
                                           Node potentialPredecessor)
                                    throws CommunicationException
Parameters:
potentialPredecessor -
Returns:
Implementation of Node#notify(Node). See documentation of Node.
Throws:
CommunicationException

crash

public void crash()
Method to emulate a crash of the node that this is the endpoint for. This method heavily relise on the internal structure of service layer implementation to make it possible to emulate a chord overlay network within one JVM. This method may cause problems at runtime.


equals

public boolean equals(java.lang.Object obj)
Overwritten from Object. Two ThreadEndpoints A and B are equal if they are endpoints for the node with the same name. (A.name == B.name).

Overrides:
equals in class java.lang.Object
Parameters:
obj -
Returns:
true if this equals the provided obj.

hashCode

public int hashCode()
Overwritten from Object.

Overrides:
hashCode in class java.lang.Object
Returns:
Overwritten from Object.

toString

public java.lang.String toString()
Overwritten from Object.

Overrides:
toString in class Endpoint
Returns:
String representation of this endpoint.