|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.planx.xmlstore.routing.Kademlia
public class 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,
int contactPort,
InetSocketAddress bootstrap,
Configuration config)
Creates a Kademlia DistributedMap using the specified name as filename base. |
|
Kademlia(String name,
int udpPort,
int contactPort,
InetSocketAddress bootstrap)
Creates a Kademlia DistributedMap using the specified name as filename base. |
|
Kademlia(String name,
int udpPort,
int contactPort,
InetSocketAddress bootstrap,
Configuration config)
Creates a Kademlia DistributedMap using the specified name as filename base. |
|
| Method Summary | |
|---|---|
void |
addNeighbourhoodListener(NeighbourhoodListener listener)
Adds a NeighbourhoodListener. |
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. |
int |
getContactPort()
Returns the contact port set using the DistributedMap.setContactPort(int) method. |
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. |
void |
removeNeighbourhoodListener(NeighbourhoodListener listener)
Removes a NeighbourhoodListener. |
List |
responsiblePeers(Identifier key)
Returns a List of InetSocketAddresses identifying the peers
responsible for the specified key according to the underlying
routing algorithm. |
void |
setContactPort(int port)
Sets the contact port of this peer. |
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,
int contactPort,
InetSocketAddress bootstrap)
throws IOException,
RoutingException
name - Filename base or null if persistence should not be usedudpPort - The UDP port to use for routing messagescontactPort - The application specific port (TCP or UDP) used to contact
this peerbootstrap - IP and UDP port of bootstrap node or null if the instance
should not attempt to connect
IOException
RoutingException
public Kademlia(String name,
int udpPort,
int contactPort,
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 messagescontactPort - The application specific port (TCP or UDP) used to contact
this peerbootstrap - 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,
int contactPort,
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 messagescontactPort - The application specific port (TCP or UDP) used to contact
this peerbootstrap - 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 and UDP port of a known node in the peer-to-peer network.
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 int getContactPort()
DistributedMapDistributedMap.setContactPort(int) method.
getContactPort in interface DistributedMappublic void setContactPort(int port)
DistributedMapDistributedMap.responsiblePeers(org.planx.xmlstore.routing.Identifier) method.
The behavoir of setting the contact port after bootstrapping is unspecified.
setContactPort in interface DistributedMap
public List responsiblePeers(Identifier key)
throws IOException,
RoutingException
DistributedMapInetSocketAddresses identifying the peers
responsible for the specified key according to the underlying
routing algorithm. The InetSocketAddresses consist of the IP number of
the peer and the contact port specified using the DistributedMap.setContactPort(int)
method at the peer.
Note that the number of returned peers is not specified - the specific
number will be implementation dependent.
responsiblePeers in interface DistributedMapIOException
RoutingExceptionpublic void addNeighbourhoodListener(NeighbourhoodListener listener)
DistributedMapNeighbourhoodListener.
addNeighbourhoodListener in interface DistributedMappublic void removeNeighbourhoodListener(NeighbourhoodListener listener)
DistributedMapNeighbourhoodListener.
removeNeighbourhoodListener in interface DistributedMappublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||