|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.uniba.wiai.lspi.chord.service.impl.ChordImpl
public final class ChordImpl
Implements all operations which can be invoked on the local node.
| Field Summary | |
|---|---|
protected Logger |
logger
Object logger. |
protected de.uniba.wiai.lspi.chord.service.impl.References |
references
References to remote nodes. |
| Constructor Summary | |
|---|---|
ChordImpl()
Creates a new instance of ChordImpl which initially is disconnected. |
|
| Method Summary | |
|---|---|
void |
create()
Creates a new chord network which is not connected to any other node. |
void |
create(URL localURL1)
Creates a new chord network which is not connected to any other node. |
void |
create(URL localURL1,
ID localID1)
Creates a new chord network which is not connected to any other node. |
ID |
getID()
Returns the ID of the local node; is null if no network has been
created or joined. |
URL |
getURL()
Returns the URL of the local node; is null if no network has been
created or joined. |
void |
insert(Key key,
Serializable s)
Inserts a new data object into the network stored under the given key. |
void |
insert(Key key,
Serializable entry,
ChordCallback callback)
Asynchronous method to insert entry under the provided
key. |
ChordFuture |
insertAsync(Key key,
Serializable entry)
Asynchronous method to insert entry with key. |
void |
join(URL bootstrapURL)
Joins an existing chord network and announces its presence to the other nodes. |
void |
join(URL localURL1,
ID localID1,
URL bootstrapURL)
Joins an existing chord network and announces its presence to the other nodes. |
void |
join(URL localURL1,
URL bootstrapURL)
Joins an existing chord network and announces its presence to the other nodes. |
void |
leave()
Disconnects from the network. |
String |
printEntries()
Returns a formatted String containing all entries stored on this node. |
String |
printFingerTable()
Returns a formatted String containing all references stored in the finger table of this node. |
String |
printPredecessor()
Returns a formatted String containing the predecessor reference of this node. |
String |
printReferences()
Returns a formatted String containing all references stored on this node. |
String |
printSuccessorList()
Returns a formatted String containing all references stored in the successor list of this node. |
void |
remove(Key key,
Serializable s)
Removes the given object stored under given key from the network. |
void |
remove(Key key,
Serializable entry,
ChordCallback callback)
Asynchronous method to remove entry under the provided
key. |
ChordFuture |
removeAsync(Key key,
Serializable entry)
Asynchronous method to remove entry with key. |
Set<Serializable> |
retrieve(Key key)
Attempts to find all objects with given key. |
void |
retrieve(Key key,
ChordCallback callback)
Asynchronous method to retrieve the entries associated with key. |
ChordRetrievalFuture |
retrieveAsync(Key key)
Asynchronous method to retrieve the entries associated with key. |
void |
setID(ID nodeID)
Sets the ID of the local node to the given value; only available
before creating or joining a network. |
void |
setURL(URL nodeURL)
Sets the URL of the local node to the given value; only available
before creating or joining a network. |
String |
toString()
Returns a human-readable string representation containing this node's node ID and URL. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected Logger logger
protected de.uniba.wiai.lspi.chord.service.impl.References references
| Constructor Detail |
|---|
public ChordImpl()
| Method Detail |
|---|
public final URL getURL()
AsynChordURL of the local node; is null if no network has been
created or joined.
getURL in interface AsynChordgetURL in interface ChordURL of local node.public final void setURL(URL nodeURL)
AsynChordURL of the local node to the given value; only available
before creating or joining a network.
setURL in interface AsynChordsetURL in interface ChordnodeURL - New URL of local node.public final ID getID()
AsynChordID of the local node; is null if no network has been
created or joined.
getID in interface AsynChordgetID in interface ChordID of local node.public final void setID(ID nodeID)
AsynChordID of the local node to the given value; only available
before creating or joining a network.
setID in interface AsynChordsetID in interface ChordnodeID - New ID of local node.
public final void create()
throws ServiceException
AsynChordAsynChord.setURL(de.uniba.wiai.lspi.chord.data.URL).
If no ID has been set before, it is generated by applying a hash function
on the node URL.
create in interface AsynChordcreate in interface ChordServiceException - Is thrown if creating the local chord node fails, e.g. due to
unability of creating the endpoint for incoming messages. Is
also thrown if no URL has been set before.
public final void create(URL localURL1)
throws ServiceException
AsynChordURL.
create in interface AsynChordcreate in interface ChordlocalURL1 - URL on which this node accepts incoming requests from
other chord nodes. The ID of this node is generated by
applying a hash function on the node URL.
ServiceException - Is thrown if creating the local chord node fails, e.g. due to
unability of creating the endpoint for incoming messages.
public final void create(URL localURL1,
ID localID1)
throws ServiceException
AsynChord
create in interface AsynChordcreate in interface ChordlocalURL1 - URL on which this node accepts incoming requests from
other chord nodes.localID1 - ID of this node.
ServiceException - Is thrown if creating the local chord node fails, e.g. due to
unability of creating the endpoint for incoming messages.
public final void join(URL bootstrapURL)
throws ServiceException
AsynChordURL has been set before by
AsynChord.setURL(de.uniba.wiai.lspi.chord.data.URL). If no ID has been set before, it is generated
by applying a hash function on the node URL.
join in interface AsynChordjoin in interface ChordbootstrapURL - URL of one existing node which is used as bootstrap
node.
ServiceException - If joining fails this exception is thrown. This may be due to
failure of establishing an endpoint or communication problems
when contacting the bootstrap node. Is also thrown if no URL
has been set before.
public final void join(URL localURL1,
URL bootstrapURL)
throws ServiceException
AsynChordID is generated by applying a hash function on
the node URL.
join in interface AsynChordjoin in interface ChordlocalURL1 - The local node is made available under this URL.bootstrapURL - URL of one existing node which is used as bootstrap
node.
ServiceException - If joining fails this exception is thrown. This may be due to
failure of establishing an endpoint or communication problems
when contacting the bootstrap node.
public final void join(URL localURL1,
ID localID1,
URL bootstrapURL)
throws ServiceException
AsynChord
join in interface AsynChordjoin in interface ChordlocalURL1 - The local node is made available under this URL.localID1 - ID of this node.bootstrapURL - URL of one existing node which is used as bootstrap
node.
ServiceException - If joining fails this exception is thrown. This may be due to
failure of establishing an endpoint or communication problems
when contacting the bootstrap node.public final void leave()
AsynChord
leave in interface AsynChordleave in interface Chord
public final void insert(Key key,
Serializable s)
Chord
insert in interface Chordkey - Key, under which the new item is stored.s - Object for storage in the network.public final Set<Serializable> retrieve(Key key)
Chord
retrieve in interface Chordkey - Key for which objects shall be retrieved.
Serializable
public final void remove(Key key,
Serializable s)
Chord
remove in interface Chordkey - Key under which the object currently is stored.s - Object to remove from the network.public final String toString()
toString in class ObjectObject.toString()public final String printEntries()
Report
printEntries in interface Reportpublic final String printFingerTable()
Report
printFingerTable in interface Reportpublic final String printSuccessorList()
Report
printSuccessorList in interface Reportpublic final String printReferences()
Report
printReferences in interface Reportpublic final String printPredecessor()
Report
printPredecessor in interface Report
public void retrieve(Key key,
ChordCallback callback)
AsynChordkey. Implementations of this method must return
immediately and the result of the retrieval must be passed to the
provided callback instance.
retrieve in interface AsynChordkey - The key for which the associated entries should be retrieved.callback - The ChordCallback to which to pass the retrieval
result.
public void insert(Key key,
Serializable entry,
ChordCallback callback)
AsynChordentry under the provided
key. Implementations of this method must return
immediately and the completion of the insertion must be reported to the
provided callback instance.
insert in interface AsynChordkey - The Key to associate with entryentry - The entry to insert.callback - The ChordCallback to which to pass the retrieval
result.
public void remove(Key key,
Serializable entry,
ChordCallback callback)
AsynChordentry under the provided
key. Implementations of this method must return
immediately and the completion of the removal must be reported to the
provided callback instance.
remove in interface AsynChordkey - The Key associated with entryentry - The entry to insert.callback - The ChordCallback to which to pass the retrieval
result.public ChordRetrievalFuture retrieveAsync(Key key)
AsynChordkey. Implementations of this method must return
immediately and return an implementation of ChordRetrievalFuture,
which can be used later on to retrieve the retrieved results.
retrieveAsync in interface AsynChordkey - The Key for that the associated entries should be
retrieved.
ChordRetrievalFuture that represents the result of the
retrieve method.
public ChordFuture insertAsync(Key key,
Serializable entry)
AsynChordentry with key.
Implementations of this method must return immediately and return an
implementation of ChordFuture, which can be used later on to
determine completion of the insertion.
insertAsync in interface AsynChordkey - The Key with which entry will be
associated.entry - The entry to insert.
ChordFuture, which can be used later on to determine
completion of the insertion.
public ChordFuture removeAsync(Key key,
Serializable entry)
AsynChordentry with key.
Implementations of this method must return immediately and return an
implementation of ChordFuture, which can be used later on to
determine completion of the removal.
removeAsync in interface AsynChordkey - The Key with which entry is associated.entry - The entry to remove.
ChordFuture, which can be used later on to determine
completion of the removal.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||