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.


Field Summary
protected  List<InvocationListener> invocationListeners
          Listof listenersthat want to be notified if a method is invoked on this endpoint.
protected  Registry registry
          The registryof local endpoints.
 
Fields inherited from class de.uniba.wiai.lspi.chord.com.Endpoint
ACCEPT_ENTRIES, DISCONNECTED, endpoints, LISTENING, METHODS_ALLOWED_IN_ACCEPT_ENTRIES, node, STARTED, url
 
Constructor Summary
ThreadEndpoint(Node node1, URL url1)
          Creates a new Endpoint for communication via Java Threads.
 
Method Summary
protected  void closeConnections()
          This method has to be overwritten by sub classes and is invoked by Endpoint.disconnect()to close all connections from the chord network.
 void crash()
          Method to emulate a crash of the node that this is the endpoint for.
protected  void entriesAcceptable()
          This method has to be overwritten by subclasses.
 boolean equals(Object obj)
          Overwritten from Object.
 Node findSuccessor(ID key)
           
 ID getNodeID()
           
 int hashCode()
          Overwritten from Object.
 void insertEntry(Entry entry)
           
 void insertReplicas(Set<Entry> entries)
           
 void leavesNetwork(Node predecessor)
           
 List<Node> notify(Node potentialPredecessor)
           
 RefsAndEntries notifyAndCopyEntries(Node potentialPredecessor)
           
protected  void openConnections()
          To implemented by sub classes.
 void ping()
           
 void register(InvocationListener listener)
           
 void removeEntry(Entry entry)
           
 void removeReplicas(ID sendingNodeID, Set<Entry> entriesToRemove)
           
 Set<Entry> retrieveEntries(ID id)
           
 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, notify, register, setState
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

registry

protected final Registry registry
The registryof local endpoints.


invocationListeners

protected List<InvocationListener> invocationListeners
Listof listenersthat want to be notified if a method is invoked on this endpoint.

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

getNodeID

public ID getNodeID()
Returns:
Implementation of Node.notify(Node). See documentation of Node.

register

public void register(InvocationListener listener)
Parameters:
listener -

findSuccessor

public Node findSuccessor(ID key)
                   throws CommunicationException
Parameters:
key -
Returns:
The successor of key.
Throws:
CommunicationException

insertEntry

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

removeEntry

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

notify

public List<Node> notify(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 Set<Entry> retrieveEntries(ID id)
                           throws CommunicationException
Parameters:
id -
Returns:
The retrieved entries.
Throws:
CommunicationException

leavesNetwork

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

removeReplicas

public void removeReplicas(ID sendingNodeID,
                           Set<Entry> entriesToRemove)
                    throws CommunicationException
Parameters:
sendingNodeID -
entriesToRemove -
Throws:
CommunicationException

insertReplicas

public void insertReplicas(Set<Entry> entries)
                    throws CommunicationException
Parameters:
entries -
Throws:
CommunicationException

notifyAndCopyEntries

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

openConnections

protected void openConnections()
Description copied from class: Endpoint
To implemented by sub classes. This method is called by Endpoint.listen()to make it possible for other chord nodes to connect to the node on that this endpoint invocates methods. TODO: This method may throw an exception when starting to listen for incoming connections.

Specified by:
openConnections in class Endpoint

closeConnections

protected void closeConnections()
Description copied from class: Endpoint
This method has to be overwritten by sub classes and is invoked by Endpoint.disconnect()to close all connections from the chord network.

Specified by:
closeConnections in class Endpoint

entriesAcceptable

protected void entriesAcceptable()
Description copied from class: Endpoint
This method has to be overwritten by subclasses. It is called from Endpoint.acceptEntries()to indicate that entries can now be accepted. So maybe if an endpoint queues incoming requests for storage or removal of entries this requests can be answered when endpoint changes it state to ACCEPT_ENTRIES.

Specified by:
entriesAcceptable in class Endpoint

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(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 Object
Parameters:
obj -
Returns:
true if this equals the provided obj.

hashCode

public int hashCode()
Overwritten from Object.

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

toString

public String toString()
Overwritten from Object.

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


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