|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ConnectionManager
The list of all RoutedConnection's. Provides a factory method for creating user-requested outgoing connections, accepts incoming connections, and fetches "automatic" outgoing connections as needed. Creates threads for handling these connections when appropriate. Because this is the only list of all connections, it plays an important role in message broadcasting. For this reason, the code is highly tuned to avoid locking in the getInitializedConnections() methods. Adding and removing connections is a slower operation.
LimeWire follows the following connection strategy:
As a leaf, LimeWire will ONLY connect to 'good' Ultrapeers. The definition
of good is constantly changing. For a current view of 'good', review
HandshakeResponse.isGoodUltrapeer(). LimeWire leaves will NOT deny
a connection to an ultrapeer even if they've reached their maximum
desired number of connections (currently 3). This means that if 4
connections resolve simultaneously, the leaf will remain connected to all 4.
As an Ultrapeer, LimeWire will seek outgoing connections for 5 less than
the number of it's desired peer slots. This is done so that newcomers
on the network have a better chance of finding an ultrapeer with a slot
open. LimeWire ultrapeers will allow ANY other ultrapeer to connect to it,
and to ensure that the network does not become too LimeWire-centric, it
reserves 3 slots for non-LimeWire peers. LimeWire ultrapeers will allow
ANY leaf to connect, so long as there are atleast 15 slots open. Beyond
that number, LimeWire will only allow 'good' leaves. To see what consitutes
a good leaf, view HandshakeResponse.isGoodLeaf(). To ensure that the
network does not remain too LimeWire-centric, it reserves 2 slots for
non-LimeWire leaves.
ConnectionManager has methods to get up and downstream bandwidth, but it doesn't quite fit the BandwidthTracker interface.
| Field Summary | |
|---|---|
static int |
CONNECT_BACK_REDUNDANT_REQUESTS
How many connect back requests to send if we have a single connection |
static int |
PREFERRED_CONNECTIONS_FOR_LEAF
The number of connections leaves should maintain to Ultrapeers. |
static int |
RESERVED_NON_LIMEWIRE_LEAVES
The number of leaf connections reserved for non LimeWire clients. |
| Method Summary | |
|---|---|
void |
acceptConnection(Socket socket)
Create an incoming connection. |
boolean |
allowAnyConnection()
Checks if there is any available slot of any kind. |
HandshakeStatus |
allowConnection(HandshakeResponse hr)
Checks if the connection received can be accepted, based upon the type of connection (e.g. |
HandshakeStatus |
allowConnection(HandshakeResponse hr,
boolean leaf)
Returns true if this has slots for an incoming connection, without accounting for this' ultrapeer capabilities. |
HandshakeStatus |
allowConnectionAsLeaf(HandshakeResponse hr)
Checks if the connection received can be accepted, based upon the type of connection (e.g. |
boolean |
allowLeafDemotion()
Returns true if this can safely switch from Ultrapeer to leaf mode. |
boolean |
canSendConnectBack(Message.Network network)
|
void |
connect()
Connects to the network. |
void |
connectBackSent(Message.Network network)
notification that a connect back request has been sent on the given network |
boolean |
connectionInitialized(RoutedConnection c)
Marks a connection fully initialized, but only if that connection wasn't removed from the list of open connections during its initialization. |
void |
connectionInitializingIncoming(RoutedConnection c)
Adds an incoming connection to the list of connections. |
int |
countConnectionsWithNMessages(int messageThreshold)
Count how many connections have already received N messages |
void |
createConnectionAsynchronously(String hostname,
int portnum,
SocketsManager.ConnectType type)
Create a new connection, allowing it to initialize and loop for messages on a new thread. |
void |
disconnect(boolean willTryToReconnect)
Disconnects from the network. |
int |
getActiveConnectionMessages()
Count up all the messages on active connections |
Endpoint |
getConnectedGUESSUltrapeer()
Returns the Endpoint for an Ultrapeer connected via TCP, if available. |
List<RoutedConnection> |
getConnectedGUESSUltrapeers()
Returns a List of Ultrapeers connected via TCP that are GUESS enabled. |
List<RoutedConnection> |
getConnections()
|
long |
getCurrentAverageUptime()
Returns this node's average connection time - in ms - including the current session. |
List<RoutedConnection> |
getInitializedClientConnections()
Returns a list of this' initialized connections. |
List<RoutedConnection> |
getInitializedClientConnectionsMatchLocale(String loc)
return a list of initialized client connection that matches the parameter String loc. |
List<RoutedConnection> |
getInitializedConnections()
Returns a list of this' initialized connections. |
List<RoutedConnection> |
getInitializedConnectionsMatchLocale(String loc)
return a list of initialized connection that matches the parameter String loc. |
float |
getMeasuredDownstreamBandwidth()
Returns the downstream bandwidth in kbytes/sec between the last two calls to measureBandwidth. |
float |
getMeasuredUpstreamBandwidth()
Returns the upstream bandwidth in kbytes/sec between the last two calls to measureBandwidth. |
int |
getNumClientSupernodeConnections()
|
int |
getNumConnections()
|
int |
getNumFetchingConnections()
Returns the number of connections that are currently being fetched. |
int |
getNumFreeLeafSlots()
|
int |
getNumFreeLimeWireLeafSlots()
|
int |
getNumFreeLimeWireNonLeafSlots()
|
int |
getNumFreeNonLeafSlots()
|
int |
getNumInitializedClientConnections()
|
int |
getNumInitializedConnections()
|
int |
getNumLimeWireLocalePrefSlots()
|
int |
getNumOldConnections()
|
int |
getNumUltrapeerConnections()
|
int |
getPreferredConnectionCount()
Gets the number of preferred connections to maintain. |
Set<Connectable> |
getPushProxies()
Accessor for the Set of push proxies for this node. |
boolean |
hasFreeSlots()
Returns whether or not this node has any available connection slots. |
boolean |
hasSupernodeClientConnection()
Returns true if this is a super node with a connection to a leaf. |
boolean |
isActiveSupernode()
Tells whether or not we're actively being a supernode to anyone. |
boolean |
isBehindProxy()
|
boolean |
isConnected()
Returns whether or not the client has an established connection with another Gnutella client. |
boolean |
isConnectedTo(String hostName)
Returns whether this (probably) has a connection to the given host. |
boolean |
isConnecting()
Returns whether or not we are currently attempting to connect to the network. |
boolean |
isConnectingTo(IpPort host)
Returns true if we're currently attempting to connect to a particular host. |
boolean |
isConnectionIdle()
Determines if we're attempting to maintain the idle connection count. |
boolean |
isFullyConnected()
Determines if we've reached our maximum number of preferred connections. |
boolean |
isLocaleMatched()
Returns true if we've made a locale-matching connection (or don't want any at all). |
boolean |
isShieldedLeaf()
Returns true if this is a leaf node with a connection to a ultrapeer. |
boolean |
isSupernode()
True if this is currently or wants to be a supernode, otherwise false. |
boolean |
isSupernodeCapable()
Return true if we are not a private address, have been ultrapeer capable in the past, and are not being shielded by anybody, we don't have UP mode disabled AND we are not exclusively a DHT node. |
void |
measureBandwidth()
Takes a snapshot of the upstream and downstream bandwidth since the last call to measureBandwidth. |
void |
noInternetConnection()
This method notifies the connection manager that the user does not have a live connection to the Internet to the best of our determination. |
void |
remove(RoutedConnection mc)
Removes the specified connection from currently active connections, also removing this connection from routing tables and modifying active connection fetchers accordingly. |
boolean |
sendTCPConnectBackRequests()
Sends a TCPConnectBack request to (up to) 2 connected Ultrapeers. |
boolean |
sendUDPConnectBackRequests(GUID cbGuid)
Sends a UDPConnectBack request to (up to) 4 (and at least 2) connected Ultrapeers. |
void |
sendUpdatedCapabilities()
Iterates over all the connections and sends the updated CapabilitiesVM down every one of them. |
void |
start()
Links the ConnectionManager up with the other back end pieces and launches the ConnectionWatchdog and the initial ConnectionFetchers. |
boolean |
supernodeNeeded()
Tells if this node thinks that more ultrapeers are needed on the network. |
void |
tryToBecomeAnUltrapeer(int demotionLimit)
Notifies the connection manager that it should attempt to become an Ultrapeer. |
void |
updateQueryStatus(QueryStatusResponse stat)
Sends a QueryStatusResponse message to as many Ultrapeers as possible. |
| Methods inherited from interface org.limewire.net.ConnectionAcceptor |
|---|
acceptConnection, isBlocking |
| Methods inherited from interface com.limegroup.gnutella.util.EventDispatcher |
|---|
addEventListener, dispatchEvent, removeEventListener |
| Methods inherited from interface org.limewire.listener.EventListener |
|---|
handleEvent |
| Field Detail |
|---|
static final int PREFERRED_CONNECTIONS_FOR_LEAF
static final int CONNECT_BACK_REDUNDANT_REQUESTS
static final int RESERVED_NON_LIMEWIRE_LEAVES
| Method Detail |
|---|
void start()
void createConnectionAsynchronously(String hostname,
int portnum,
SocketsManager.ConnectType type)
void acceptConnection(Socket socket)
void remove(RoutedConnection mc)
mc - the RoutedConnection instance to removeboolean isSupernode()
boolean isSupernodeCapable()
boolean isBehindProxy()
boolean isActiveSupernode()
boolean isShieldedLeaf()
boolean hasSupernodeClientConnection()
boolean hasFreeSlots()
boolean isConnectedTo(String hostName)
boolean isConnectingTo(IpPort host)
int getNumConnections()
int getNumInitializedConnections()
int getNumInitializedClientConnections()
int getNumClientSupernodeConnections()
int getNumUltrapeerConnections()
int getNumOldConnections()
int getNumFreeLeafSlots()
int getNumFreeLimeWireLeafSlots()
int getNumFreeNonLeafSlots()
int getNumFreeLimeWireNonLeafSlots()
boolean isLocaleMatched()
int getNumLimeWireLocalePrefSlots()
boolean isFullyConnected()
boolean isConnected()
boolean isConnecting()
void measureBandwidth()
BandwidthTracker.measureBandwidth()float getMeasuredUpstreamBandwidth()
BandwidthTracker.measureBandwidth()float getMeasuredDownstreamBandwidth()
BandwidthTracker.measureBandwidth()HandshakeStatus allowConnectionAsLeaf(HandshakeResponse hr)
c - The connection we received, for which to
test if we have incoming slot.
HandshakeStatus allowConnection(HandshakeResponse hr)
c - The connection we received, for which to
test if we have incoming slot.
boolean allowAnyConnection()
HandshakeStatus allowConnection(HandshakeResponse hr,
boolean leaf)
outgoing - true if this is an outgoing connection; true if incomingultrapeerHeader - the value of the X-Ultrapeer header, or null
if it was not writtenuseragentHeader - the value of the User-Agent header, or null if
it was not written
boolean supernodeNeeded()
List<RoutedConnection> getInitializedConnections()
List<RoutedConnection> getInitializedConnectionsMatchLocale(String loc)
List<RoutedConnection> getInitializedClientConnections()
List<RoutedConnection> getInitializedClientConnectionsMatchLocale(String loc)
List<RoutedConnection> getConnections()
Set<Connectable> getPushProxies()
boolean sendTCPConnectBackRequests()
boolean sendUDPConnectBackRequests(GUID cbGuid)
void updateQueryStatus(QueryStatusResponse stat)
- Endpoint getConnectedGUESSUltrapeer()
List<RoutedConnection> getConnectedGUESSUltrapeers()
void connectionInitializingIncoming(RoutedConnection c)
boolean connectionInitialized(RoutedConnection c)
void sendUpdatedCapabilities()
void disconnect(boolean willTryToReconnect)
willTryToReconnect - Whether or not this is only a temporary disconnectionlong getCurrentAverageUptime()
void connect()
boolean allowLeafDemotion()
void tryToBecomeAnUltrapeer(int demotionLimit)
demotionLimit - the number of attempts by other Ultrapeers to
demote us to a leaf that we should allow before giving up in the
attempt to become an Ultrapeerint getPreferredConnectionCount()
boolean isConnectionIdle()
void noInternetConnection()
int countConnectionsWithNMessages(int messageThreshold)
int getActiveConnectionMessages()
boolean canSendConnectBack(Message.Network network)
void connectBackSent(Message.Network network)
int getNumFetchingConnections()
|
LimeWire Consolidated API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||