de.uniba.wiai.lspi.chord.com.socket
Class SocketEndpoint

java.lang.Object
  extended by de.uniba.wiai.lspi.chord.com.Endpoint
      extended by de.uniba.wiai.lspi.chord.com.socket.SocketEndpoint
All Implemented Interfaces:
Runnable

public final class SocketEndpoint
extends Endpoint
implements Runnable

This class represents an Endpoint for communication over socket protocol. It provides a ServerSocket to that clients can connect and starts for each incoming connection a RequestHandler that handles Requests for method invocations from remote nodes. These Requests are sent by one SocketProxy representing the node, that this is the endpoint for, at another node.


Field Summary
 
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
SocketEndpoint(Node node1, URL url1)
          Creates a new SocketEndpoint for the given Node with url.
 
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.
protected  void entriesAcceptable()
          This method has to be overwritten by subclasses.
protected  void openConnections()
          To implemented by sub classes.
 void run()
          Run method from Runnable to accept connections from clients.
 
Methods inherited from class de.uniba.wiai.lspi.chord.com.Endpoint
acceptEntries, createEndpoint, deregister, disconnect, getEndpoint, getNode, getState, getURL, listen, notify, register, setState, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SocketEndpoint

public SocketEndpoint(Node node1,
                      URL url1)
Creates a new SocketEndpoint for the given Node with url. url must have the protocol indexed by URL.SOCKET_PROTOCOL in the URL.KNOWN_PROTOCOLS array.

Parameters:
node1 - The Node node this endpoint provides connections to.
url1 - The URL of this endpoint.
Method Detail

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

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

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

run

public void run()
Run method from Runnable to accept connections from clients. This method runs until closeConnections() is called. It creates threads responsible for the handling of requests from other nodes.

Specified by:
run in interface Runnable


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