|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.uniba.wiai.lspi.chord.com.Endpoint
public abstract class Endpoint
This class represents an endpoint, which wraps a Node, so that other
nodes can connect to the node using a protocol.
This class must be extended by endpoints that support a certain protocol as
e.g. RMI or a protocol over Sockets.
This is the abstract class that has to be implemented by all Endpoints. An
Endpoint enables other chord peers to connect to a node with
help of a given protocol. Each node in a chord network has to have exactly
one endpoint.
For each protocol that shall be supported a separate endpoint has to be
implemented. To initialise endpoints for a Node an URL has to
be provided to the createEndpoint(Node, URL) endpoint factory
method. This methods tries to determine the endpoint with help of the
protocol names defined by the url. Supported protocols can be found in the
URL class.
STARTED,LISTENING, andACCEPT_ENTRIES.
In state STARTED the endpoint has been initialised but does
not listen to (possibly) incoming messages from the chord network. An
endpoint gets into this state if it is created with help of its constructor.
In state LISTENING the endpoint accepts messages
that are received from the chord network to update the finger table or
request the predecessor or successor of the node of this endpoint. The
transition to this state is made by invocation of listen().
In state ACCEPT_ENTRIES. This endpoint accepts
messages from the chord network, that request storage or removal of entries
from the DHT. The transition to this state is made by invocation of
acceptEntries().
| Field Summary | |
|---|---|
static int |
ACCEPT_ENTRIES
Integer representation of state. |
static int |
DISCONNECTED
Integer representation of state. |
protected static Map<URL,Endpoint> |
endpoints
Map containing all endpoints. |
static int |
LISTENING
Integer representation of state. |
static List<String> |
METHODS_ALLOWED_IN_ACCEPT_ENTRIES
Array containing names of methods only allowed to be invoked in state ACCEPT_ENTRIES. |
protected Node |
node
The nodeon which this endpoint invokes methods. |
static int |
STARTED
Integer representation of state. |
protected URL |
url
The URLthat can be used to connect to this endpoint. |
| Constructor Summary | |
|---|---|
protected |
Endpoint(Node node1,
URL url1)
|
| Method Summary | |
|---|---|
void |
acceptEntries()
Tell this endpoint that the node is now able to receive messages that request the storage and removal of entries. |
protected abstract void |
closeConnections()
This method has to be overwritten by sub classes and is invoked by disconnect()to close all connections from the chord network. |
static Endpoint |
createEndpoint(Node node,
URL url)
Create the endpoints for the protocol given by url. |
void |
deregister(EndpointStateListener listener)
Remove a listener that listened for state changes of this endpoint. |
void |
disconnect()
Tell this endpoint to disconnect and close all connections. |
protected abstract void |
entriesAcceptable()
This method has to be overwritten by subclasses. |
static Endpoint |
getEndpoint(URL url)
Get the Endpoint for the given url. |
Node |
getNode()
|
int |
getState()
|
URL |
getURL()
Get the URLof this endpoint. |
void |
listen()
Tell this endpoint that it can listen to incoming messages from other chord nodes. |
protected void |
notify(int s)
Method to notify listeners about a change in state of this endpoint. |
protected abstract void |
openConnections()
To implemented by sub classes. |
void |
register(EndpointStateListener listener)
Register a listener that is notified when the state of this endpoint changes. |
protected void |
setState(int state1)
|
String |
toString()
Overwritten from Object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final Map<URL,Endpoint> endpoints
URL. Value:
Endpoint.
public static final int STARTED
public static final int LISTENING
public static final int ACCEPT_ENTRIES
public static final int DISCONNECTED
public static final List<String> METHODS_ALLOWED_IN_ACCEPT_ENTRIES
ACCEPT_ENTRIES. Remember to eventually edit this array if you
change the methods in interface Node. The method names contained
in this array must be sorted!
protected URL url
URLthat can be used to connect to this endpoint.
protected Node node
nodeon which this endpoint invokes methods.
| Constructor Detail |
|---|
protected Endpoint(Node node1,
URL url1)
node1 - The Node this is the Endpoint for.url1 - The URL that describes the location of this endpoint.| Method Detail |
|---|
public final Node getNode()
public final void register(EndpointStateListener listener)
listener - The listener to register.public final void deregister(EndpointStateListener listener)
listener - The listener instance to be removed.protected void notify(int s)
s - The integer identifying the state to that the endpoint
switched. See ACCEPT_ENTRIES,
DISCONNECTED, LISTENING,
and STARTED.public URL getURL()
URLof this endpoint.
URLthat can be used to connect to this endpoint.public final int getState()
protected final void setState(int state1)
state1 - The state to set.public final void listen()
protected abstract void openConnections()
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.
public final void acceptEntries()
protected abstract void entriesAcceptable()
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.
public final void disconnect()
protected abstract void closeConnections()
disconnect()to close all connections from the chord network.
public static Endpoint createEndpoint(Node node,
URL url)
url. An
URL must have a known protocol. An endpoint for an URL can only
be create once and then be obtained with help of
getEndpoint(URL). An endpoint for an url must again be
created if the disconnect() has been invoked.
node - The node to which this endpoint delegates incoming requests.url - The URL under which node will be reachable by
other nodes.
node for the protocol
specified in url.
RuntimeException - This can occur if any error that cannot be handled by this
method occurs during endpoint creation.public static Endpoint getEndpoint(URL url)
Endpoint for the given url.
url -
url.public String toString()
Object.
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||