|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.planx.xmlstore.routing.Kademlia
Maps keys to values in a distributed setting using the Kademlia protocol. Three threads are started: One that listens for incoming routing messages, one that handles timeouts for routing messages, and one that handles hourly refresh/restore.
| Constructor Summary | |
|---|---|
Kademlia(Identifier id,
int udpPort)
Creates a Kademlia DistributedMap with the specified identifier and no persistence. |
|
Kademlia(Identifier id,
int udpPort,
Configuration config)
Creates a Kademlia DistributedMap with the specified identifier and no persistence. |
|
Kademlia(String name,
Identifier defaultId,
int udpPort,
InetSocketAddress bootstrap,
Configuration config)
Creates a Kademlia DistributedMap using the specified name as filename base. |
|
Kademlia(String name,
int udpPort,
InetSocketAddress bootstrap,
Configuration config)
Creates a Kademlia DistributedMap using the specified name as filename base. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the map. |
void |
connect(InetSocketAddress bootstrap)
Attempts to connect to an existing peer-to-peer network. |
boolean |
contains(Identifier key)
Returns true if the map contains the specified key and
false otherwise. |
Serializable |
get(Identifier key)
Returns the value associated with the specified key. |
void |
put(Identifier key,
Serializable value)
Associates the specified value with the specified key. |
void |
remove(Identifier key)
Removes the mapping with the specified key. |
String |
toString()
For debugging purposes, returns the contents of the internal space. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Kademlia(Identifier id,
int udpPort)
throws IOException,
RoutingException
id - The id to use or null to create a random idudpPort - The UDP port to use for routing messages
IOException
RoutingException
public Kademlia(Identifier id,
int udpPort,
Configuration config)
throws IOException,
RoutingException
id - The id to use or null to create a random idudpPort - The UDP port to use for routing messagesconfig - Configuration parameters
IOException
RoutingException
public Kademlia(String name,
int udpPort,
InetSocketAddress bootstrap,
Configuration config)
throws IOException,
RoutingException
name - Filename base or null if persistence should not be usedudpPort - The UDP port to use for routing messagesbootstrap - IP and UDP port of bootstrap node or null if the instance
should not attempt to connectconfig - Configuration parameters. If null default parameters are used.
IOException
RoutingException
public Kademlia(String name,
Identifier defaultId,
int udpPort,
InetSocketAddress bootstrap,
Configuration config)
throws IOException,
RoutingException
name - Filename base or null if persistence should not be useddefaultId - Default id if it could not be read from disk or null for
random default idudpPort - The UDP port to use for routing messagesbootstrap - IP and UDP port of bootstrap node or null if the instance
should not attempt to connectconfig - Configuration parameters. If null default parameters are used.
RoutingException - If the bootstrap node did not respond
IOException - If an error occurred while reading id or local map
from disk or a network error occurred while
attempting to connect to the network| Method Detail |
|---|
public void connect(InetSocketAddress bootstrap)
throws IOException,
RoutingException
bootstrap - The IP of a known node in the peer-to-peer networkbootPort - The UDP port of the bootstrap node
RoutingException - If the bootstrap node could not be contacted
IOException - If a network error occurred
IllegalStateException - If this object is closed
public void close()
throws IOException
close in interface DistributedMapIOException - If an error occurred while writing data to disk
IllegalStateException - If this object is closed
public boolean contains(Identifier key)
throws IOException,
RoutingException
true if the map contains the specified key and
false otherwise.
contains in interface DistributedMapkey - The key to lookup
true if a mappings with the key was found and
false otherwise.
RoutingException - If the lookup operation timed out
IOException - If a network error occurred
IllegalStateException - If this object is closed
public Serializable get(Identifier key)
throws IOException,
RoutingException
DataLookupOperation.
get in interface DistributedMapkey - The key to lookup
null if no value
is mapped to the key.
RoutingException - If the lookup operation timed out
IOException - If a network error occurred
IllegalStateException - If this object is closed
public void put(Identifier key,
Serializable value)
throws IOException,
RoutingException
StoreOperation.
put in interface DistributedMapkey - The keyvalue - The value associated with the key
RoutingException - If the operation timed out
IOException - If a network error occurred
IllegalStateException - If this object is closed
public void remove(Identifier key)
throws IOException
remove in interface DistributedMapkey - The key of the mapping to remove
RoutingException - If the operation timed out
IOException - If a network error occurred
IllegalStateException - If this object is closedpublic String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||