LimeWire Consolidated API

com.limegroup.gnutella.dht
Interface DHTManager

All Superinterfaces:
ConnectionLifecycleListener, EventDispatcher<DHTEvent,DHTEventListener>, EventListener
All Known Implementing Classes:
DHTManagerImpl

public interface DHTManager
extends ConnectionLifecycleListener, EventDispatcher<DHTEvent,DHTEventListener>

The DHT Manager interface defines methods to start, stop and perform operations related to the maintenance of the DHT (bootstrapping, etc.). It also takes care of switching between different DHT modes for a DHT node.


Nested Class Summary
static class DHTManager.DHTMode
          Defines the modes of a DHT Node (inactive, active, passive and passive leaf).
 
Method Summary
 void addActiveDHTNode(SocketAddress hostAddress)
          Passes the given active DHT node to the DHT controller in order to bootstrap or perform other maintenance operations.
 void addPassiveDHTNode(SocketAddress hostAddress)
          Passes the given passive DHT node to the DHT controller in order to bootstrap or perform other maintenance operations.
 void addressChanged()
          Notifies the DHT controller that our external Address has changed
 DHTFuture<FindValueResult> get(EntityKey eKey)
          Calls the MojitoDHT.get(EntityKey) if a bootstrappable DHT is available.
 List<IpPort> getActiveDHTNodes(int maxNodes)
          Returns maxNodes number of active Node's IP:Ports
 DHTManager.DHTMode getDHTMode()
          Returns the mode of the DHT
 MojitoDHT getMojitoDHT()
          Returns the MojitoDHT instance (null if Node is running in inactive mode!)
 Vendor getVendor()
          Returns the Vendor code of this Node
 Version getVersion()
          Returns the Vendor code of this Node
 void handleDHTContactsMessage(DHTContactsMessage msg)
          Callback to notify the manager about new DHT Contacts that were exchanged over regular Gnutella messages.
 boolean isBootstrapped()
          Returns whether this Node is bootstrapped
 boolean isEnabled()
          Returns whether or not the DHT is enabled
 boolean isMemberOfDHT()
          Returns whether this Node is part of the DHT.
 boolean isRunning()
          Returns whether this Node is running
 boolean isWaitingForNodes()
          Returns whether this Node is waiting for Nodes or not
 DHTFuture<StoreResult> put(KUID key, DHTValue value)
          Calls the MojitoDHT.put(KUID, DHTValue) if a bootstrappable DHT is available.
 void setEnabled(boolean enabled)
          Sets whether or not the DHT is enabled
 void start(DHTManager.DHTMode mode)
          Starts the DHT Node either in active or passive mode.
 void stop()
          Stops the DHT Node
 
Methods inherited from interface com.limegroup.gnutella.connection.ConnectionLifecycleListener
handleConnectionLifecycleEvent
 
Methods inherited from interface com.limegroup.gnutella.util.EventDispatcher
addEventListener, dispatchEvent, removeEventListener
 

Method Detail

setEnabled

void setEnabled(boolean enabled)
Sets whether or not the DHT is enabled


isEnabled

boolean isEnabled()
Returns whether or not the DHT is enabled


start

void start(DHTManager.DHTMode mode)
Starts the DHT Node either in active or passive mode.

Note: You can use this method to stop the DHT by passing in DHTMode.INACTIVE. The difference between using this method and the stop() method is that stop() is synchronous (i.e. blocking) and start() with DHTMode.INACTIVE isn't.


stop

void stop()
Stops the DHT Node


addActiveDHTNode

void addActiveDHTNode(SocketAddress hostAddress)
Passes the given active DHT node to the DHT controller in order to bootstrap or perform other maintenance operations.


addPassiveDHTNode

void addPassiveDHTNode(SocketAddress hostAddress)
Passes the given passive DHT node to the DHT controller in order to bootstrap or perform other maintenance operations.


addressChanged

void addressChanged()
Notifies the DHT controller that our external Address has changed


getActiveDHTNodes

List<IpPort> getActiveDHTNodes(int maxNodes)
Returns maxNodes number of active Node's IP:Ports


getDHTMode

DHTManager.DHTMode getDHTMode()
Returns the mode of the DHT


isRunning

boolean isRunning()
Returns whether this Node is running


isBootstrapped

boolean isBootstrapped()
Returns whether this Node is bootstrapped


isMemberOfDHT

boolean isMemberOfDHT()
Returns whether this Node is part of the DHT.


isWaitingForNodes

boolean isWaitingForNodes()
Returns whether this Node is waiting for Nodes or not


getMojitoDHT

MojitoDHT getMojitoDHT()
Returns the MojitoDHT instance (null if Node is running in inactive mode!)


getVendor

Vendor getVendor()
Returns the Vendor code of this Node


getVersion

Version getVersion()
Returns the Vendor code of this Node


handleDHTContactsMessage

void handleDHTContactsMessage(DHTContactsMessage msg)
Callback to notify the manager about new DHT Contacts that were exchanged over regular Gnutella messages.

See Also:
DHTContactsMessage

get

DHTFuture<FindValueResult> get(EntityKey eKey)
Calls the MojitoDHT.get(EntityKey) if a bootstrappable DHT is available. Also handles the locking properly to ensure thread safety.

Parameters:
eKey - the entity key used to perform lookup in the DHT.
Returns:
an instance of DHTFuture containing the result of the lookup.
Returns null if DHT is unavailable or the DHT is not bootstrapped.

put

DHTFuture<StoreResult> put(KUID key,
                           DHTValue value)
Calls the MojitoDHT.put(KUID, DHTValue) if a bootstrappable DHT is available. Also handles the locking properly to ensure thread safety.

Parameters:
eKey - the entity key used to perform lookup in the DHT.
Returns:
an instance of DHTFuture containing the result of the lookup.
Returns null if DHT is unavailable or the DHT is not bootstrapped.

LimeWire Consolidated API

Copyright © 2009. All Rights Reserved.