|
||||||||||
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.
Constructor Summary | |
---|---|
ChordImpl()
Creates a new instance of ChordImpl which initially is disconnected. |
Method Summary | |
---|---|
void |
addNewFloor(Floor floor,
URL nodeURL,
int ns)
|
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. |
Floor |
createFloor(URL url)
|
Floor |
createNewFloor(URL url)
|
int |
generateNewTag(URL url)
|
java.util.ArrayList<MyFloor> |
getAllFloors()
|
Entries |
getEntriesForFloor(Floor floor)
|
ID |
getIdForFloor(Floor floor)
|
References |
getReferencesForFloor(Floor floor)
|
int |
getTag_counter()
|
int[] |
getTag()
|
URL |
getURL()
Returns the URL of the local node; is null if no network has been
created or joined. |
boolean |
goodDeal(URL url,
Floor floor)
|
void |
initialJoin(Floor floor,
URL bootstrapURL)
|
void |
initialJoin(Floor floor,
URL localURL1,
URL bootstrapURL)
|
boolean |
inMyFloorList(Floor floor)
|
void |
insert(java.lang.String res,
java.io.Serializable s)
Inserts a new data object into the network stored under the given key. |
void |
insert(java.lang.String res,
java.io.Serializable entry,
ChordCallback callback)
Asynchronous method to insert entry under the provided
key . |
ChordFuture |
insertAsync(java.lang.String res,
java.io.Serializable entry)
Asynchronous method to insert entry with key . |
void |
insertNewTag(int t)
|
boolean |
isTagInList(int t)
|
void |
join(Floor floor,
URL bootstrapURL)
Joins an existing chord network and announces its presence to the other nodes. |
void |
join(Floor floor,
URL localURL1,
URL bootstrapURL)
Joins an existing chord network and announces its presence to the other nodes. |
Floor |
join(URL bootstrapURL)
|
void |
leave()
Disconnects from the network. |
java.lang.String |
printEntries(Floor floor)
Returns a formatted String containing all entries stored on this node. |
java.lang.String |
printFingerTable(Floor floor)
Returns a formatted String containing all references stored in the finger table of this node. |
java.lang.String |
printPredecessor(Floor floor)
Returns a formatted String containing the predecessor reference of this node. |
java.lang.String |
printReferences(Floor floor)
Returns a formatted String containing all references stored on this node. |
java.lang.String |
printSuccessorList(Floor floor)
Returns a formatted String containing all references stored in the successor list of this node. |
void |
remove(java.lang.String res,
java.io.Serializable s)
Removes the given object stored under given key from the network. |
void |
remove(java.lang.String res,
java.io.Serializable entry,
ChordCallback callback)
Asynchronous method to remove entry under the provided
key . |
ChordFuture |
removeAsync(java.lang.String res,
java.io.Serializable entry)
Asynchronous method to remove entry with key . |
java.util.Set<java.io.Serializable> |
retrieve(java.lang.String res)
Attempts to find all objects with given key. |
void |
retrieve(java.lang.String res,
ChordCallback callback)
Asynchronous method to retrieve the entries associated with key . |
ChordRetrievalFuture |
retrieveAsync(java.lang.String res)
Asynchronous method to retrieve the entries associated with key . |
void |
setURL(URL nodeURL)
Sets the URL of the local node to the given value; only available
before creating or joining a network. |
java.lang.String |
toString()
Returns a human-readable string representation containing this node's node ID and URL. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ChordImpl()
Method Detail |
---|
public final void addNewFloor(Floor floor, URL nodeURL, int ns)
public final void create() throws ServiceException
Chord
Chord.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 AsynChord
create
in interface Chord
ServiceException
- 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
Chord
URL
.
create
in interface AsynChord
create
in interface Chord
localURL1
- 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 Floor createNewFloor(URL url)
public final Floor createFloor(URL url)
public final int generateNewTag(URL url)
public final java.util.ArrayList<MyFloor> getAllFloors()
public final Entries getEntriesForFloor(Floor floor)
public final ID getIdForFloor(Floor floor)
public final References getReferencesForFloor(Floor floor)
public int[] getTag()
public final int getTag_counter()
public final URL getURL()
Chord
URL
of the local node; is null
if no network has been
created or joined.
getURL
in interface AsynChord
getURL
in interface Chord
URL
of local node.public final boolean goodDeal(URL url, Floor floor)
public final void initialJoin(Floor floor, URL bootstrapURL) throws ServiceException
initialJoin
in interface AsynChord
initialJoin
in interface Chord
ServiceException
public final void initialJoin(Floor floor, URL localURL1, URL bootstrapURL) throws ServiceException
initialJoin
in interface AsynChord
initialJoin
in interface Chord
ServiceException
public final boolean inMyFloorList(Floor floor)
public final void insert(java.lang.String res, java.io.Serializable s)
Chord
insert
in interface Chord
res
- Res, under which the new item is stored.s
- Object for storage in the network.public final void insert(java.lang.String res, java.io.Serializable entry, ChordCallback callback)
AsynChord
entry
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 AsynChord
entry
- The entry to insert.callback
- The ChordCallback
to which to pass the retrieval
result.public final ChordFuture insertAsync(java.lang.String res, java.io.Serializable entry)
AsynChord
entry
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 AsynChord
entry
- The entry to insert.
ChordFuture
, which can be used later on to determine
completion of the insertion.public final void insertNewTag(int t)
public final boolean isTagInList(int t)
public final void join(Floor floor, URL bootstrapURL) throws ServiceException
Chord
URL
has been set before by
Chord.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 AsynChord
join
in interface Chord
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. Is also thrown if no URL
has been set before.public final void join(Floor floor, URL localURL1, URL bootstrapURL) throws ServiceException
Chord
ID
is generated by applying a hash function on
the node URL
.
join
in interface AsynChord
join
in interface Chord
localURL1
- 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 Floor join(URL bootstrapURL) throws ServiceException
ServiceException
public final void leave()
Chord
leave
in interface AsynChord
leave
in interface Chord
public final java.lang.String printEntries(Floor floor)
Report
printEntries
in interface Report
public final java.lang.String printFingerTable(Floor floor)
Report
printFingerTable
in interface Report
public final java.lang.String printPredecessor(Floor floor)
Report
printPredecessor
in interface Report
public final java.lang.String printReferences(Floor floor)
Report
printReferences
in interface Report
public final java.lang.String printSuccessorList(Floor floor)
Report
printSuccessorList
in interface Report
public final void remove(java.lang.String res, java.io.Serializable s)
Chord
remove
in interface Chord
s
- Object to remove from the network.public final void remove(java.lang.String res, java.io.Serializable entry, ChordCallback callback)
AsynChord
entry
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 AsynChord
entry
- The entry to insert.callback
- The ChordCallback
to which to pass the retrieval
result.public final ChordFuture removeAsync(java.lang.String res, java.io.Serializable entry)
AsynChord
entry
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 AsynChord
entry
- The entry to remove.
ChordFuture
, which can be used later on to determine
completion of the removal.public final java.util.Set<java.io.Serializable> retrieve(java.lang.String res)
Chord
retrieve
in interface Chord
Serializable
public final void retrieve(java.lang.String res, ChordCallback callback)
AsynChord
key
. Implementations of this method must return
immediately and the result of the retrieval must be passed to the
provided callback
instance.
retrieve
in interface AsynChord
callback
- The ChordCallback
to which to pass the retrieval
result.public final ChordRetrievalFuture retrieveAsync(java.lang.String res)
AsynChord
key
. 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 AsynChord
ChordRetrievalFuture
that represents the result of the
retrieve method.public final void setURL(URL nodeURL)
Chord
URL
of the local node to the given value; only available
before creating or joining a network.
setURL
in interface AsynChord
setURL
in interface Chord
nodeURL
- New URL
of local node.public final java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |