|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.ConnectionManager
The list of all ManagedConnection'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. Use the setKeepAlive(int) method control the number of connections; modifying the KEEP_ALIVE property of SettingsManager does not automatically affect this.
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.
ConnectionManager has methods to get up and downstream bandwidth, but it doesn't quite fit the BandwidthTracker interface.
Field Summary | |
static int |
ALLOWED_BAD_LEAF_CONNECTIONS
Similar to RESERVED_GOOD_CONNECTIONS, but measures the number of slots allowed for bad leaf connections. |
static int |
PREFERRED_CONNECTIONS_FOR_LEAF
The number of connections leaves should maintain to Ultrapeers. |
static int |
RESERVED_GOOD_LEAF_CONNECTIONS
The number of leaf connections reserved for "good" clients. |
static int |
ULTRAPEER_CONNECTIONS
The number of Ultrapeer connections to ideally maintain as an Ultrapeer. |
Constructor Summary | |
ConnectionManager(Authenticator authenticator)
Constructs a ConnectionManager. |
Method Summary | |
boolean |
allowAnyConnection()
Checks if there is any available slot of any kind. |
boolean |
allowConnection(HandshakeResponse hr)
Checks if the connection received can be accepted, based upon the type of connection (e.g. |
boolean |
allowConnection(HandshakeResponse hr,
boolean leaf)
Returns true if this has slots for an incoming connection, without accounting for this' ultrapeer capabilities. |
boolean |
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. |
void |
connect()
Connects to the network. |
void |
createConnectionAsynchronously(java.lang.String hostname,
int portnum)
Create a new connection, allowing it to initialize and loop for messages on a new thread. |
ManagedConnection |
createConnectionBlocking(java.lang.String hostname,
int portnum)
Create a new connection, blocking until it's initialized, but launching a new thread to do the message loop. |
void |
disconnect()
Disconnects from the network. |
Authenticator |
getAuthenticator()
Provides handle to the authenticator instance |
Endpoint |
getConnectedGUESSUltrapeer()
Returns the Endpoint for an Ultrapeer connected via TCP, if available. |
java.util.List |
getConnectedGUESSUltrapeers()
Returns a List of Ultrapeers connected via TCP that are GUESS enabled. |
java.util.List |
getConnections()
|
java.util.List |
getInitializedClientConnections()
|
java.util.List |
getInitializedClientConnections2()
|
java.util.List |
getInitializedConnections()
|
java.util.List |
getInitializedConnections2()
|
int |
getKeepAlive()
Get the number of connections we are attempting to maintain. |
float |
getMeasuredDownstreamBandwidth()
Returns the downstream bandwidth between the last two calls to measureBandwidth. |
float |
getMeasuredUpstreamBandwidth()
Returns the upstream bandwidth between the last two calls to measureBandwidth. |
int |
getNumClientSupernodeConnections()
|
int |
getNumConnections()
|
int |
getNumInitializedClientConnections()
|
int |
getNumInitializedConnections()
|
int |
getNumOldConnections()
|
int |
getNumUltrapeerConnections()
|
java.util.Set |
getPushProxies()
Accessor for the Set of push proxies for this node. |
java.util.Set |
getSupernodeEndpoints()
Returns the endpoints of the best known ultrapeers. |
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. |
void |
initialize()
Links the ConnectionManager up with the other back end pieces and launches the ConnectionWatchdog and the initial ConnectionFetchers. |
boolean |
isConnected()
Returns whether or not the client has an established connection with another Gnutella client. |
boolean |
isShieldedLeaf()
Returns true if this is a leaf node with a connection to a ultrapeer. |
boolean |
isSupernode()
Tells whether the node is gonna be an Ultrapeer or not |
void |
measureBandwidth()
Takes a snapshot of the upstream and downstream bandwidth since the last call to measureBandwidth. |
void |
remove(ManagedConnection mc)
Removes the specified connection from currently active connections, also removing this connection from routing tables and modifying active connection fetchers accordingly. |
void |
setKeepAlive(int newKeep)
Reset how many connections you want and start kicking more off if required. |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int ULTRAPEER_CONNECTIONS
public static final int PREFERRED_CONNECTIONS_FOR_LEAF
public static final int RESERVED_GOOD_LEAF_CONNECTIONS
public static final int ALLOWED_BAD_LEAF_CONNECTIONS
Constructor Detail |
public ConnectionManager(Authenticator authenticator)
authenticator
- Authenticator instance for authenticating usersMethod Detail |
public void initialize()
public ManagedConnection createConnectionBlocking(java.lang.String hostname, int portnum) throws java.io.IOException
java.io.IOException
public void createConnectionAsynchronously(java.lang.String hostname, int portnum)
public void remove(ManagedConnection mc)
mc
- the ManagedConnection instance to removepublic int getKeepAlive()
public void setKeepAlive(int newKeep)
public boolean isSupernode()
public boolean isShieldedLeaf()
public boolean hasSupernodeClientConnection()
public boolean hasFreeSlots()
public int getNumConnections()
public int getNumInitializedConnections()
public int getNumInitializedClientConnections()
public int getNumClientSupernodeConnections()
public int getNumUltrapeerConnections()
public int getNumOldConnections()
public boolean isConnected()
public void measureBandwidth()
BandwidthTracker.measureBandwidth()
public float getMeasuredUpstreamBandwidth()
BandwidthTracker.measureBandwidth()
public float getMeasuredDownstreamBandwidth()
BandwidthTracker.measureBandwidth()
public boolean allowConnectionAsLeaf(HandshakeResponse hr)
public boolean allowConnection(HandshakeResponse hr)
public boolean allowAnyConnection()
public boolean allowConnection(HandshakeResponse hr, boolean leaf)
public boolean supernodeNeeded()
public Authenticator getAuthenticator()
public java.util.List getInitializedConnections()
public java.util.List getInitializedClientConnections()
public java.util.List getInitializedConnections2()
public java.util.List getInitializedClientConnections2()
public java.util.List getConnections()
public java.util.Set getPushProxies()
public java.util.Set getSupernodeEndpoints()
public Endpoint getConnectedGUESSUltrapeer()
public java.util.List getConnectedGUESSUltrapeers()
public void disconnect()
public void connect()
public boolean allowLeafDemotion()
public 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 Ultrapeer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |