org.planx.xmlstore.routing
Interface DistributedMap

All Known Implementing Classes:
Kademlia

public interface DistributedMap

Maps keys to values in a distributed setting using Identifiers as keys. Methods throw IOException if a network error occurs and RoutingException if a routing specific error occurs in the overlay network. Note that RoutingException is a subclass of IOException so if the distinction is not needed, IOException is the only checked exception that needs to be handled.

Author:
Thomas Ambus

Method Summary
 void addNeighbourhoodListener(NeighbourhoodListener listener)
          Adds a NeighbourhoodListener.
 void close()
          Closes the map and releases all ressources.
 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 or null if does not exist.
 int getContactPort()
          Returns the contact port set using the 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 from this map (optional operation).
 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.
 

Method Detail

close

void close()
           throws IOException
Closes the map and releases all ressources. Any subsequent calls to methods are invalid.

Throws:
IOException

contains

boolean contains(Identifier key)
                 throws IOException,
                        RoutingException
Returns true if the map contains the specified key and false otherwise.

Throws:
IOException
RoutingException

get

Serializable get(Identifier key)
                 throws IOException,
                        RoutingException
Returns the value associated with the specified key or null if does not exist.

Throws:
IOException
RoutingException

put

void put(Identifier key,
         Serializable value)
         throws IOException,
                RoutingException
Associates the specified value with the specified key.

Throws:
IOException
RoutingException

remove

void remove(Identifier key)
            throws IOException,
                   RoutingException
Removes the mapping with the specified key from this map (optional operation). If the underlying routing algorithm does not support removing mappings this method should do nothing.

Throws:
IOException
RoutingException

getContactPort

int getContactPort()
Returns the contact port set using the setContactPort(int) method.


setContactPort

void setContactPort(int port)
Sets the contact port of this peer. This can be either a TCP or an UDP port. The interpretation is entirely up to the application programmer. The contact port is retrieved by other peers invoking the responsiblePeers(org.planx.xmlstore.routing.Identifier) method. The behavoir of setting the contact port after bootstrapping is unspecified.


responsiblePeers

List responsiblePeers(Identifier key)
                      throws IOException,
                             RoutingException
Returns a List of InetSocketAddresses 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 setContactPort(int) method at the peer. Note that the number of returned peers is not specified - the specific number will be implementation dependent.

Throws:
IOException
RoutingException

addNeighbourhoodListener

void addNeighbourhoodListener(NeighbourhoodListener listener)
Adds a NeighbourhoodListener.


removeNeighbourhoodListener

void removeNeighbourhoodListener(NeighbourhoodListener listener)
Removes a NeighbourhoodListener.



Copyright © 2010. All Rights Reserved.