|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.limegroup.gnutella.dht.AbstractDHTController
public abstract class AbstractDHTController
The controller for the LimeWire DHT. A node should connect to the DHT only if it has previously been designated as capable by the NodeAssigner or if it is forced to. Once the node is a DHT node (if EXCLUDE_ULTRAPEERS is set to true) it should not try to connect as an Ultrapeer.
The NodeAssigner should be the only class to have the authority
to initialize the DHT and connect to the network.
This controller can be in one of the four following states:
The current implementation is specific to the Mojito DHT.
| Field Summary | |
|---|---|
protected com.limegroup.gnutella.dht.DHTBootstrapper |
bootstrapper
The DHT bootstrapper instance. |
protected MojitoDHT |
dht
The instance of the DHT |
protected Log |
LOG
|
| Constructor Summary | |
|---|---|
AbstractDHTController(Vendor vendor,
Version version,
EventDispatcher<DHTEvent,DHTEventListener> dispatcher,
DHTManager.DHTMode mode,
DHTControllerFacade dhtControllerFacade)
|
|
| Method Summary | |
|---|---|
void |
addActiveDHTNode(SocketAddress hostAddress)
If this node is not bootstrapped, passes the given hostAddress
on to the DHT bootstrapper. |
protected void |
addActiveDHTNode(SocketAddress hostAddress,
boolean addToDHTNodeAdder)
If this node is not bootstrapped, passes the given hostAddress to the DHT bootstrapper. |
void |
addContact(Contact node)
Adds the given Contact to the local RouteTable |
void |
addPassiveDHTNode(SocketAddress hostAddress)
If this node is not bootstrapped, the controller requests active DHT nodes from the given SocketAddress. |
protected abstract MojitoDHT |
createMojitoDHT(Vendor vendor,
Version version)
A factory method to create MojitoDHTs |
List<IpPort> |
getActiveDHTNodes(int maxNodes)
Returns maxNodes number of active Node IP:Ports |
DHTManager.DHTMode |
getDHTMode()
Returns the mode of the DHTController |
MojitoDHT |
getMojitoDHT()
Returns this controller's Mojito DHT instance. |
protected List<IpPort> |
getMRSNodes(int numNodes,
boolean excludeLocal)
Returns a list of the Most Recently Seen nodes from the Mojito routing table. |
protected int |
getRouteTableVersion()
Returns the current RouteTable version |
void |
handleConnectionLifecycleEvent(ConnectionLifecycleEvent evt)
A callback method to notify the DHTController about ConnectionLifecycleEvents |
boolean |
isBootstrapped()
Returns whether or not this node is bootstrapped |
boolean |
isRunning()
Returns whether this Node is running or not |
boolean |
isWaitingForNodes()
Returns whether this Node is waiting for Nodes or not |
void |
sendUpdatedCapabilities()
Sends the updated CapabilitiesVM to our connections. |
void |
start()
Start the Mojito DHT and connects it to the network in either passive mode, or active mode (if we are a Gnutella leaf node). |
void |
stop()
Shuts down the DHT. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Log LOG
protected final MojitoDHT dht
protected final com.limegroup.gnutella.dht.DHTBootstrapper bootstrapper
| Constructor Detail |
|---|
public AbstractDHTController(Vendor vendor,
Version version,
EventDispatcher<DHTEvent,DHTEventListener> dispatcher,
DHTManager.DHTMode mode,
DHTControllerFacade dhtControllerFacade)
| Method Detail |
|---|
protected final int getRouteTableVersion()
protected abstract MojitoDHT createMojitoDHT(Vendor vendor,
Version version)
public DHTManager.DHTMode getDHTMode()
DHTController
getDHTMode in interface DHTControllerpublic List<IpPort> getActiveDHTNodes(int maxNodes)
DHTController
getActiveDHTNodes in interface DHTControllerpublic void handleConnectionLifecycleEvent(ConnectionLifecycleEvent evt)
DHTController
handleConnectionLifecycleEvent in interface DHTControllerpublic void start()
The start preconditions are the following:
We are not already connected, AND
start in interface DHTControllerpublic void stop()
Contacts in the route
table.
The persisted route table (stored contacts from the last session) is used as a secondary means to bootstrap, if the node didn't receive any hosts through the Gnutella network to bootstrap.
stop in interface DHTController
protected void addActiveDHTNode(SocketAddress hostAddress,
boolean addToDHTNodeAdder)
hostAddress - the SocketAddress of the DHT host.addToDHTNodeAdder - true to add to the random node adder if the DHT
is bootstrapped.public void addActiveDHTNode(SocketAddress hostAddress)
DHTControllerhostAddress
on to the DHT bootstrapper. If the node is already bootstrapped,
the controller randomly tries to add the node to the DHT routing table.
addActiveDHTNode in interface DHTControllerhostAddress - the SocketAddress of the DHT host.public void addPassiveDHTNode(SocketAddress hostAddress)
DHTController
addPassiveDHTNode in interface DHTControllerpublic void addContact(Contact node)
DHTControllerContact to the local RouteTable
addContact in interface DHTController
protected List<IpPort> getMRSNodes(int numNodes,
boolean excludeLocal)
numNodes - the number of nodes to returnexcludeLocal - true to exclude the local node
public boolean isRunning()
DHTController
isRunning in interface DHTControllerpublic boolean isBootstrapped()
DHTController
isBootstrapped in interface DHTControllerpublic boolean isWaitingForNodes()
DHTController
isWaitingForNodes in interface DHTControllerpublic MojitoDHT getMojitoDHT()
DHTController
getMojitoDHT in interface DHTControllerpublic void sendUpdatedCapabilities()
CapabilitiesVM to our connections. This
is used when a node has successfully bootstrapped to the network and wants
to notify its Gnutella peers that they can now bootstrap off of him.
sendUpdatedCapabilities in interface DHTController
|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||