|
||||||||||
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. |
static int |
LISTENING
Integer representation of state. |
static java.util.List<java.lang.String> |
METHODS_ALLOWED_IN_ACCEPT_ENTRIES
Array containing names of methods only allowed to be invoked in state ACCEPT_ENTRIES . |
static int |
STARTED
Integer representation of state. |
Method Summary | |
---|---|
void |
acceptEntries()
Tell this endpoint that the node is now able to receive messages that request the storage and removal of entries. |
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. |
static Endpoint |
getEndpoint(URL url)
Get the Endpoint for the given url . |
Node |
getNode()
|
int |
getState()
|
URL |
getURL()
Get the URL of this endpoint. |
void |
listen()
Tell this endpoint that it can listen to incoming messages from other chord nodes. |
void |
register(EndpointStateListener listener)
Register a listener that is notified when the state of this endpoint changes. |
java.lang.String |
toString()
Overwritten from Object . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int STARTED
public static final int LISTENING
public static final int ACCEPT_ENTRIES
public static final int DISCONNECTED
public static final java.util.List<java.lang.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!
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.public URL getURL()
URL
of this endpoint.
URL
that can be used to connect to this endpoint.public final int getState()
public final void listen()
public final void acceptEntries()
public final void disconnect()
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
.
java.lang.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 java.lang.String toString()
Object
.
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |