LimeWire Consolidated API

com.limegroup.gnutella.connection
Class GnutellaConnection

java.lang.Object
  extended by com.limegroup.gnutella.connection.AbstractConnection
      extended by com.limegroup.gnutella.connection.GnutellaConnection
All Implemented Interfaces:
Connection, ConnectionMessageStatistics, ConnectionRoutingStatistics, MessageReceiver, RoutedConnection, SentMessageHandler, ReplyHandler, Inspectable, Address, Connectable, IpPort, ListenerSupport<GnutellaConnectionEvent>, Shutdownable

public class GnutellaConnection
extends AbstractConnection
implements ReplyHandler, MessageReceiver, SentMessageHandler, Shutdownable, Inspectable, RoutedConnection, ConnectionRoutingStatistics, ConnectionMessageStatistics, ListenerSupport<GnutellaConnectionEvent>

A Connection managed by a ConnectionManager. GnutellaConnection provides a sophisticated message buffering mechanism. When you call send(Message), the message is not actually delivered to the socket; instead it buffered in an application-level buffer. Periodically, messages are read from the buffer and written to the network. Furthermore, GnutellaConnection provides a simple form of flow control. If messages are queued faster than they can be written to the network, they are dropped in the following order: PingRequest, PingReply, QueryRequest, QueryReply, and PushRequest. See the implementation notes below for more details.

All GnutellaConnection have two underlying spam filters: a personal filter (controls what I see) and a route filter (also controls what I pass along to others). See SpamFilter for a description. You can change them with setPersonalFilter and setRouteFilter.

GnutellaConnection maintain a large number of statistics, such as the current bandwidth for upstream & downstream.

GnutellaConnection also takes care of various VendorMessage handling, in particular Hops Flow, UDP ConnectBack, and TCP ConnectBack. See handleVendorMessage().

This class implements ReplyHandler to route pongs and query replies that originated from it.


Nested Class Summary
static class GnutellaConnection.EventType
           
 
Nested classes/interfaces inherited from interface org.limewire.io.IpPort
IpPort.IpComparator, IpPort.IpPortComparator
 
Field Summary
 
Fields inherited from class com.limegroup.gnutella.connection.AbstractConnection
CONNECTION_CLOSED, myIp, socket
 
Fields inherited from interface org.limewire.io.Connectable
COMPARATOR, EMPTY_LIST, EMPTY_SET
 
Fields inherited from interface org.limewire.io.IpPort
IP_COMPARATOR
 
Constructor Summary
GnutellaConnection(Socket socket, ConnectionManager connectionManager, NetworkManager networkManager, QueryRequestFactory queryRequestFactory, HeadersFactory headersFactory, HandshakeResponderFactory handshakeResponderFactory, QueryReplyFactory queryReplyFactory, MessageDispatcher messageDispatcher, NetworkUpdateSanityChecker networkUpdateSanityChecker, SearchResultHandler searchResultHandler, CapabilitiesVMFactory capabilitiesVMFactory, Acceptor acceptor, MessagesSupportedVendorMessage supportedVendorMessage, com.google.inject.Provider<SimppManager> simppManager, com.google.inject.Provider<UpdateHandler> updateHandler, com.google.inject.Provider<ConnectionServices> connectionServices, GuidMapManager guidMapManager, SpamFilterFactory spamFilterFactory, MessageReaderFactory messageReaderFactory, MessageFactory messageFactory, ApplicationServices applicationServices, SecureMessageVerifier secureMessageVerifier, OutOfBandStatistics outOfBandStatistics, NetworkInstanceUtils networkInstanceUtils)
          Creates an incoming connection.
GnutellaConnection(String host, int port, SocketsManager.ConnectType type, ConnectionManager connectionManager, NetworkManager networkManager, QueryRequestFactory queryRequestFactory, HeadersFactory headersFactory, HandshakeResponderFactory handshakeResponderFactory, QueryReplyFactory queryReplyFactory, MessageDispatcher messageDispatcher, NetworkUpdateSanityChecker networkUpdateSanityChecker, SearchResultHandler searchResultHandler, CapabilitiesVMFactory capabilitiesVMFactory, SocketsManager socketsManager, Acceptor acceptor, MessagesSupportedVendorMessage supportedVendorMessage, com.google.inject.Provider<SimppManager> simppManager, com.google.inject.Provider<UpdateHandler> updateHandler, com.google.inject.Provider<ConnectionServices> connectionServices, GuidMapManager guidMapManager, SpamFilterFactory spamFilterFactory, MessageReaderFactory messageReaderFactory, MessageFactory messageFactory, ApplicationServices applicationServices, SecureMessageVerifier secureMessageVerifier, OutOfBandStatistics outOfBandStatistics, NetworkInstanceUtils networkInstanceUtils)
          Creates a new outgoing connection to the specified host on the specified port, using the specified kind of ConnectType.
 
Method Summary
 void addListener(EventListener<GnutellaConnectionEvent> listener)
          Adds the listener.
protected  void closeImpl()
          This should be implemented by subclasses to close any resources they acquired during the lifetime of the connection.
 void countDroppedMessage()
          A callback for the ConnectionManager to inform this connection that a message was dropped.
 byte[] getClientGUID()
          Gets the clientGUID of this ReplyHandler.
 ConnectionMessageStatistics getConnectionMessageStatistics()
           
 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.
 Message.Network getNetwork()
          The network this message-receiver uses for creating messages.
 long getNextQRPForwardTime()
          Returns the system time that we should next forward a query route table along this connection.
 int getNumMessagesReceived()
          Returns the number of messages received on this connection
 int getNumMessagesSent()
          Returns the number of messages sent on this connection
 long getNumQueriesReceived()
          Returns the number of queries received over this connection.
 long getNumQueryReplies()
          Returns the number of query replies received over this connection.
 long getNumReceivedMessagesDropped()
          The number of messages received on this connection either filtered out or dropped because we didn't know how to route them.
 int getNumSentMessagesDropped()
          Returns the number of messages I dropped while trying to send on this connection.
 Object getQRPLock()
           
 int getQueryRouteTableEmptyUnits()
          Accessor for the last QueryRouteTable's Empty Units.
 double getQueryRouteTablePercentFull()
          Accessor for the last QueryRouteTable's percent full.
 QueryRouteTable getQueryRouteTableReceived()
          Accessor for the QueryRouteTable received along this connection.
 QueryRouteTable getQueryRouteTableSent()
          Accessor for the query route table associated with this.
 int getQueryRouteTableSize()
          Accessor for the last QueryRouteTable's size.
 int getQueryRouteTableUnitsInUse()
          Accessor for the last QueryRouteTable's Units In Use.
 ConnectionRoutingStatistics getRoutedConnectionStatistics()
           
 byte getSoftMax()
          The soft-max this message-receiver uses for creating messages.
 void handlePingReply(PingReply pingReply, ReplyHandler receivingConnection)
          Handle the PingReply, failing silently
 void handlePushRequest(PushRequest pushRequest, ReplyHandler receivingConnection)
          Handle the PushRequest, failing silently
 void handleQueryReply(QueryReply queryReply, ReplyHandler receivingConnection)
          Handle the QueryReply, failing silently
 void handleVendorMessage(VendorMessage vm)
          Call this method when you want to handle us to handle a VM.
protected  boolean hitsQueryRouteTable(QueryRequest query)
          Determines whether or not this query hits the QRT.
 void incrementNextQRPForwardTime(long curTime)
          Increments the next time we should forward query route tables for this connection.
 void initialize(GnetConnectObserver observer)
          Attempts to initialize the connection.
protected  void initialize(Properties requestHeaders, HandshakeResponder responder, int timeout, GnetConnectObserver observer)
          Initialize the connection by doing the handshake.
 Map<String,Object> inspect()
           
 boolean isBusyLeaf()
          Returns true iff this connection is a shielded leaf connection, and has signalled that it does not want to receive routed queries (no upload slots or some other reason).
 boolean isGoodLeaf()
          Returns whether or not this handler is considered a "good" leaf connection.
 boolean isGoodUltrapeer()
          Returns whether or not this handler is considered a "good" Ultrapeer connection.
 boolean isHighDegreeConnection()
          Returns whether or not this connection is a high-degree connection, meaning that it maintains a high number of intra-Ultrapeer connections.
 boolean isKillable()
          Returns whether or not this handler is killable by the handler watchdog.
 boolean isLeafConnection()
          Returns whether or not this reply handler is a leaf -- whether or not the host on the other end of this connection is a leaf of this (necessarily) Ultrapeer.
 boolean isMyPushProxy()
          Returns whether or not this connection is a push proxy for me
 boolean isPersonalSpam(Message m)
           
 boolean isPushProxyFor()
          Returns whether or not I'm a push proxy for this connection
 boolean isSupernodeClientConnection()
          Returns whether or not this ReplyHandler sends replies from an Ultrapeer to a leaf.
 boolean isUltrapeerQueryRoutingConnection()
          Returns whether or not this handler uses Ultrapeer query routing.
 void measureBandwidth()
          Takes a snapshot of the upstream and downstream bandwidth since the last call to measureBandwidth.
 void messagingClosed()
          Notification that the stream is closed.
 void originateQuery(QueryRequest query)
          This is a specialized send method for queries that we originate, either from ourselves directly, or on behalf of one of our leaves when we're an Ultrapeer.
 void patchQueryRouteTable(PatchTableMessage ptm)
          Patches the QueryRouteTable for this connection.
 void processReadMessage(Message m)
          Notification that a message is available for processing.
 void processSentMessage(Message m)
           
 boolean removeListener(EventListener<GnutellaConnectionEvent> listener)
          Returns true if the listener was removed.
 void reply(Message m)
          Just sends whatever message we ask it to.
 void resetQueryRouteTable(ResetTableMessage rtm)
          Resets the query route table for this connection.
 void send(Message m)
          Sends the message through this connection.
 void setBusy(boolean bSet)
          Set's a leaf's busy timer to now, if bSet is true, else clears the flag
 void setLocalePreferencing(boolean b)
          set preferencing for the responder (The preference of the Responder is used when creating the response (in Connection.java: conclude..))
 void setPersonalFilter(SpamFilter filter)
           
 void setPushProxyFor(boolean pushProxyFor)
          Sets whether or not I'm a push proxy for this connection
 void setQueryRouteTableSent(QueryRouteTable qrt)
          Mutator for the last query route table that was sent along this connection.
 void setRouteFilter(SpamFilter filter)
           
 boolean shouldForwardQuery(QueryRequest query)
          Determines whether or not the specified QueryRequest instance should be sent to the connection.
 void shutdown()
          Releases any resources used by this component.
 void startMessaging()
          Handles core Gnutella request/reply protocol.
 boolean supportsPongCaching()
          Returns whether or not this node supports pong caching.
 
Methods inherited from class com.limegroup.gnutella.connection.AbstractConnection
allowNewPings, allowNewPongs, close, getAddress, getAddressBytes, getAddressDescription, getConnectionBandwidthStatistics, getConnectionCapabilities, getConnectionTime, getConnectType, getInetAddress, getInetSocketAddress, getListeningPort, getLocalePref, getPort, getPropertyWritten, getSocket, handleSimppVM, handshakeInitialized, initializeHandshake, isOpen, isOutgoing, isReadDeflated, isStable, isStable, isTLSCapable, isTLSEncoded, isWriteDeflated, processWrittenMessage, sendPostInitializeMessages, sendUpdatedCapabilities, setHeaders, setListeningPort, setSocket, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.limegroup.gnutella.connection.Connection
allowNewPings, allowNewPongs, close, getAddress, getConnectionBandwidthStatistics, getConnectionCapabilities, getConnectionTime, getInetAddress, getInetSocketAddress, getListeningPort, getLocalePref, getPort, getPropertyWritten, getSocket, handleSimppVM, isOpen, isOutgoing, isReadDeflated, isStable, isStable, isTLSCapable, isTLSEncoded, isWriteDeflated, sendPostInitializeMessages, sendUpdatedCapabilities, setListeningPort
 
Methods inherited from interface org.limewire.io.Address
equals, getAddressDescription, hashCode
 
Methods inherited from interface com.limegroup.gnutella.ReplyHandler
allowNewPings, getLocalePref, handleSimppVM, isOpen, isOutgoing, isStable
 

Constructor Detail

GnutellaConnection

public GnutellaConnection(String host,
                          int port,
                          SocketsManager.ConnectType type,
                          ConnectionManager connectionManager,
                          NetworkManager networkManager,
                          QueryRequestFactory queryRequestFactory,
                          HeadersFactory headersFactory,
                          HandshakeResponderFactory handshakeResponderFactory,
                          QueryReplyFactory queryReplyFactory,
                          MessageDispatcher messageDispatcher,
                          NetworkUpdateSanityChecker networkUpdateSanityChecker,
                          SearchResultHandler searchResultHandler,
                          CapabilitiesVMFactory capabilitiesVMFactory,
                          SocketsManager socketsManager,
                          Acceptor acceptor,
                          MessagesSupportedVendorMessage supportedVendorMessage,
                          com.google.inject.Provider<SimppManager> simppManager,
                          com.google.inject.Provider<UpdateHandler> updateHandler,
                          com.google.inject.Provider<ConnectionServices> connectionServices,
                          GuidMapManager guidMapManager,
                          SpamFilterFactory spamFilterFactory,
                          MessageReaderFactory messageReaderFactory,
                          MessageFactory messageFactory,
                          ApplicationServices applicationServices,
                          SecureMessageVerifier secureMessageVerifier,
                          OutOfBandStatistics outOfBandStatistics,
                          NetworkInstanceUtils networkInstanceUtils)
Creates a new outgoing connection to the specified host on the specified port, using the specified kind of ConnectType.

Parameters:
host - the address of the host we're connecting to
port - the port the host is listening on
type - the type of outgoing connection we want to make (TLS, PLAIN, etc)

GnutellaConnection

public GnutellaConnection(Socket socket,
                          ConnectionManager connectionManager,
                          NetworkManager networkManager,
                          QueryRequestFactory queryRequestFactory,
                          HeadersFactory headersFactory,
                          HandshakeResponderFactory handshakeResponderFactory,
                          QueryReplyFactory queryReplyFactory,
                          MessageDispatcher messageDispatcher,
                          NetworkUpdateSanityChecker networkUpdateSanityChecker,
                          SearchResultHandler searchResultHandler,
                          CapabilitiesVMFactory capabilitiesVMFactory,
                          Acceptor acceptor,
                          MessagesSupportedVendorMessage supportedVendorMessage,
                          com.google.inject.Provider<SimppManager> simppManager,
                          com.google.inject.Provider<UpdateHandler> updateHandler,
                          com.google.inject.Provider<ConnectionServices> connectionServices,
                          GuidMapManager guidMapManager,
                          SpamFilterFactory spamFilterFactory,
                          MessageReaderFactory messageReaderFactory,
                          MessageFactory messageFactory,
                          ApplicationServices applicationServices,
                          SecureMessageVerifier secureMessageVerifier,
                          OutOfBandStatistics outOfBandStatistics,
                          NetworkInstanceUtils networkInstanceUtils)
Creates an incoming connection. ManagedConnections should only be constructed within ConnectionManager.

Method Detail

initialize

public void initialize(GnetConnectObserver observer)
                throws IOException
Description copied from interface: RoutedConnection
Attempts to initialize the connection. This will return immediately.

Specified by:
initialize in interface RoutedConnection
Throws:
IOException

initialize

protected void initialize(Properties requestHeaders,
                          HandshakeResponder responder,
                          int timeout,
                          GnetConnectObserver observer)
                   throws IOException
Initialize the connection by doing the handshake. Throws IOException if we were unable to establish a normal messaging connection for any reason. Do not call send or receive if this happens.

Parameters:
timeout - for outgoing connections, the timeout in milliseconds to use in establishing the socket, or 0 for no timeout. If the platform does not support native timeouts, it will be emulated with threads.
Throws:
IOException - we were unable to connect to the host
NoGnutellaOkException - one of the participants responded with an error code other than 200 OK (possibly after several rounds of 401's)
BadHandshakeException - some other problem establishing the connection, e.g., the server responded with HTTP, closed the the connection during handshaking, etc.

resetQueryRouteTable

public void resetQueryRouteTable(ResetTableMessage rtm)
Description copied from interface: RoutedConnection
Resets the query route table for this connection. The new table will be of the size specified in rtm and will contain no data. If there is no QueryRouteTable yet created for this connection, this method will create one.

Specified by:
resetQueryRouteTable in interface RoutedConnection
Parameters:
rtm - the ResetTableMessage

patchQueryRouteTable

public void patchQueryRouteTable(PatchTableMessage ptm)
Description copied from interface: RoutedConnection
Patches the QueryRouteTable for this connection.

Specified by:
patchQueryRouteTable in interface RoutedConnection
Parameters:
ptm - the patch with the data to update

setBusy

public void setBusy(boolean bSet)
Set's a leaf's busy timer to now, if bSet is true, else clears the flag

Parameters:
bSet - Whether to SET or CLEAR the busy timer for this host

isBusyLeaf

public boolean isBusyLeaf()
Description copied from interface: RoutedConnection
Returns true iff this connection is a shielded leaf connection, and has signalled that it does not want to receive routed queries (no upload slots or some other reason). If so, we will not include its QRT table in last hop QRT tables we send out (if we are an Ultrapeer)

Specified by:
isBusyLeaf in interface RoutedConnection
Returns:
true iff this connection is a busy leaf (don't include his QRT table)

shouldForwardQuery

public boolean shouldForwardQuery(QueryRequest query)
Description copied from interface: RoutedConnection
Determines whether or not the specified QueryRequest instance should be sent to the connection. The method takes a couple factors into account, such as QRP tables, type of query, etc.

Specified by:
shouldForwardQuery in interface RoutedConnection
Parameters:
query - the QueryRequest to check against the data
Returns:
true if the QueryRequest should be sent to this connection, otherwise false

hitsQueryRouteTable

protected boolean hitsQueryRouteTable(QueryRequest query)
Determines whether or not this query hits the QRT.


getQueryRouteTableReceived

public QueryRouteTable getQueryRouteTableReceived()
Description copied from interface: ConnectionRoutingStatistics
Accessor for the QueryRouteTable received along this connection. Can be null if no query routing table has been received yet.

Specified by:
getQueryRouteTableReceived in interface ConnectionRoutingStatistics
Returns:
the last QueryRouteTable received along this connection

getQueryRouteTablePercentFull

public double getQueryRouteTablePercentFull()
Description copied from interface: ConnectionRoutingStatistics
Accessor for the last QueryRouteTable's percent full.

Specified by:
getQueryRouteTablePercentFull in interface ConnectionRoutingStatistics

getQueryRouteTableSize

public int getQueryRouteTableSize()
Description copied from interface: ConnectionRoutingStatistics
Accessor for the last QueryRouteTable's size.

Specified by:
getQueryRouteTableSize in interface ConnectionRoutingStatistics

getQueryRouteTableEmptyUnits

public int getQueryRouteTableEmptyUnits()
Description copied from interface: ConnectionRoutingStatistics
Accessor for the last QueryRouteTable's Empty Units.

Specified by:
getQueryRouteTableEmptyUnits in interface ConnectionRoutingStatistics

getQueryRouteTableUnitsInUse

public int getQueryRouteTableUnitsInUse()
Description copied from interface: ConnectionRoutingStatistics
Accessor for the last QueryRouteTable's Units In Use.

Specified by:
getQueryRouteTableUnitsInUse in interface ConnectionRoutingStatistics

send

public void send(Message m)
Description copied from interface: RoutedConnection
Sends the message through this connection. This will return immediately and the message will be sent asynchronously.

Specified by:
send in interface Connection
Specified by:
send in interface RoutedConnection

originateQuery

public void originateQuery(QueryRequest query)
Description copied from interface: RoutedConnection
This is a specialized send method for queries that we originate, either from ourselves directly, or on behalf of one of our leaves when we're an Ultrapeer. These queries have a special sending queue of their own and are treated with a higher priority.

Specified by:
originateQuery in interface RoutedConnection
Parameters:
query - the QueryRequest to send

shutdown

public void shutdown()
Description copied from interface: Shutdownable
Releases any resources used by this component.

shutdown must never throw any exceptions.

Specified by:
shutdown in interface Shutdownable

closeImpl

protected void closeImpl()
Description copied from class: AbstractConnection
This should be implemented by subclasses to close any resources they acquired during the lifetime of the connection.

Specified by:
closeImpl in class AbstractConnection

startMessaging

public void startMessaging()
Handles core Gnutella request/reply protocol. If asynchronous messaging is supported, this immediately returns and messages are processed asynchronously via processMessage calls. Otherwise, if reading blocks, this will run until the connection is closed.

Specified by:
startMessaging in interface RoutedConnection
Throws:
IOException - passed on from the receive call; failures to forward or route messages are silently swallowed, allowing the message loop to continue.

messagingClosed

public void messagingClosed()
Description copied from interface: MessageReceiver
Notification that the stream is closed.

Specified by:
messagingClosed in interface MessageReceiver

processReadMessage

public void processReadMessage(Message m)
Description copied from interface: MessageReceiver
Notification that a message is available for processing.

Specified by:
processReadMessage in interface MessageReceiver
Overrides:
processReadMessage in class AbstractConnection

processSentMessage

public void processSentMessage(Message m)
Specified by:
processSentMessage in interface SentMessageHandler

getNumQueryReplies

public long getNumQueryReplies()
Description copied from interface: ConnectionMessageStatistics
Returns the number of query replies received over this connection.

Specified by:
getNumQueryReplies in interface ConnectionMessageStatistics

getNumQueriesReceived

public long getNumQueriesReceived()
Description copied from interface: ConnectionMessageStatistics
Returns the number of queries received over this connection.

Specified by:
getNumQueriesReceived in interface ConnectionMessageStatistics

getNetwork

public Message.Network getNetwork()
Description copied from interface: MessageReceiver
The network this message-receiver uses for creating messages.

Specified by:
getNetwork in interface MessageReceiver

getSoftMax

public byte getSoftMax()
Description copied from interface: MessageReceiver
The soft-max this message-receiver uses for creating messages.

Specified by:
getSoftMax in interface MessageReceiver
Overrides:
getSoftMax in class AbstractConnection

countDroppedMessage

public void countDroppedMessage()
Description copied from interface: ConnectionMessageStatistics
A callback for the ConnectionManager to inform this connection that a message was dropped. This happens when a reply received from this connection has no routing path.

Specified by:
countDroppedMessage in interface ConnectionMessageStatistics
Specified by:
countDroppedMessage in interface ReplyHandler

isPersonalSpam

public boolean isPersonalSpam(Message m)
Specified by:
isPersonalSpam in interface ReplyHandler

setRouteFilter

public void setRouteFilter(SpamFilter filter)
Specified by:
setRouteFilter in interface RoutedConnection

setPersonalFilter

public void setPersonalFilter(SpamFilter filter)
Specified by:
setPersonalFilter in interface RoutedConnection

handlePingReply

public void handlePingReply(PingReply pingReply,
                            ReplyHandler receivingConnection)
Description copied from interface: ReplyHandler
Handle the PingReply, failing silently

Specified by:
handlePingReply in interface ReplyHandler

handleQueryReply

public void handleQueryReply(QueryReply queryReply,
                             ReplyHandler receivingConnection)
Description copied from interface: ReplyHandler
Handle the QueryReply, failing silently

Specified by:
handleQueryReply in interface ReplyHandler

getClientGUID

public byte[] getClientGUID()
Description copied from interface: ReplyHandler
Gets the clientGUID of this ReplyHandler.

Specified by:
getClientGUID in interface ReplyHandler

handlePushRequest

public void handlePushRequest(PushRequest pushRequest,
                              ReplyHandler receivingConnection)
Description copied from interface: ReplyHandler
Handle the PushRequest, failing silently

Specified by:
handlePushRequest in interface ReplyHandler

handleVendorMessage

public void handleVendorMessage(VendorMessage vm)
Description copied from class: AbstractConnection
Call this method when you want to handle us to handle a VM. We may....

Specified by:
handleVendorMessage in interface Connection
Overrides:
handleVendorMessage in class AbstractConnection

addListener

public void addListener(EventListener<GnutellaConnectionEvent> listener)
Description copied from interface: ListenerSupport
Adds the listener.

Specified by:
addListener in interface ListenerSupport<GnutellaConnectionEvent>

removeListener

public boolean removeListener(EventListener<GnutellaConnectionEvent> listener)
Description copied from interface: ListenerSupport
Returns true if the listener was removed.

Specified by:
removeListener in interface ListenerSupport<GnutellaConnectionEvent>

getNumMessagesSent

public int getNumMessagesSent()
Description copied from interface: ConnectionMessageStatistics
Returns the number of messages sent on this connection

Specified by:
getNumMessagesSent in interface ConnectionMessageStatistics

getNumMessagesReceived

public int getNumMessagesReceived()
Description copied from interface: ConnectionMessageStatistics
Returns the number of messages received on this connection

Specified by:
getNumMessagesReceived in interface ConnectionMessageStatistics
Specified by:
getNumMessagesReceived in interface ReplyHandler

getNumSentMessagesDropped

public int getNumSentMessagesDropped()
Description copied from interface: ConnectionMessageStatistics
Returns the number of messages I dropped while trying to send on this connection. This happens when the remote host cannot keep up with me.

Specified by:
getNumSentMessagesDropped in interface ConnectionMessageStatistics

getNumReceivedMessagesDropped

public long getNumReceivedMessagesDropped()
Description copied from interface: ConnectionMessageStatistics
The number of messages received on this connection either filtered out or dropped because we didn't know how to route them.

Specified by:
getNumReceivedMessagesDropped in interface ConnectionMessageStatistics

measureBandwidth

public void measureBandwidth()
Description copied from interface: RoutedConnection
Takes a snapshot of the upstream and downstream bandwidth since the last call to measureBandwidth.

Specified by:
measureBandwidth in interface RoutedConnection
See Also:
BandwidthTracker.measureBandwidth()

getMeasuredUpstreamBandwidth

public float getMeasuredUpstreamBandwidth()
Description copied from interface: RoutedConnection
Returns the upstream bandwidth between the last two calls to measureBandwidth.

Specified by:
getMeasuredUpstreamBandwidth in interface RoutedConnection
See Also:
BandwidthTracker.measureBandwidth()

getMeasuredDownstreamBandwidth

public float getMeasuredDownstreamBandwidth()
Description copied from interface: RoutedConnection
Returns the downstream bandwidth between the last two calls to measureBandwidth.

Specified by:
getMeasuredDownstreamBandwidth in interface RoutedConnection
See Also:
BandwidthTracker.measureBandwidth()

getNextQRPForwardTime

public long getNextQRPForwardTime()
Description copied from interface: ConnectionRoutingStatistics
Returns the system time that we should next forward a query route table along this connection. Only valid if isClientSupernodeConnection() is true.

Specified by:
getNextQRPForwardTime in interface ConnectionRoutingStatistics

incrementNextQRPForwardTime

public void incrementNextQRPForwardTime(long curTime)
Description copied from interface: ConnectionRoutingStatistics
Increments the next time we should forward query route tables for this connection. This depends on whether or not this is a connection to a leaf or to an Ultrapeer.

Specified by:
incrementNextQRPForwardTime in interface ConnectionRoutingStatistics
Parameters:
curTime - the current time in milliseconds, used to calculate the next update time

isKillable

public boolean isKillable()
Description copied from interface: ReplyHandler
Returns whether or not this handler is killable by the handler watchdog. In particular, this is used for old Clip2 indexing queries, which should not be killed.

Specified by:
isKillable in interface ReplyHandler
Returns:
true if the handler is 'killable', i.e. a clip2 indexing query, otherwise false

getQueryRouteTableSent

public QueryRouteTable getQueryRouteTableSent()
Description copied from interface: ConnectionRoutingStatistics
Accessor for the query route table associated with this. This is guaranteed to be non-null, but it may not yet contain any data.

Specified by:
getQueryRouteTableSent in interface ConnectionRoutingStatistics
Returns:
the QueryRouteTable instance containing query route table data sent along this connection, or null if no data has yet been sent

setQueryRouteTableSent

public void setQueryRouteTableSent(QueryRouteTable qrt)
Description copied from interface: ConnectionRoutingStatistics
Mutator for the last query route table that was sent along this connection.

Specified by:
setQueryRouteTableSent in interface ConnectionRoutingStatistics
Parameters:
qrt - the last query route table that was sent along this connection

isMyPushProxy

public boolean isMyPushProxy()
Description copied from interface: RoutedConnection
Returns whether or not this connection is a push proxy for me

Specified by:
isMyPushProxy in interface RoutedConnection

isPushProxyFor

public boolean isPushProxyFor()
Description copied from interface: RoutedConnection
Returns whether or not I'm a push proxy for this connection

Specified by:
isPushProxyFor in interface RoutedConnection

setPushProxyFor

public void setPushProxyFor(boolean pushProxyFor)
Description copied from interface: RoutedConnection
Sets whether or not I'm a push proxy for this connection

Specified by:
setPushProxyFor in interface RoutedConnection

getQRPLock

public Object getQRPLock()
Specified by:
getQRPLock in interface RoutedConnection

setLocalePreferencing

public void setLocalePreferencing(boolean b)
Description copied from interface: RoutedConnection
set preferencing for the responder (The preference of the Responder is used when creating the response (in Connection.java: conclude..))

Specified by:
setLocalePreferencing in interface RoutedConnection

reply

public void reply(Message m)
Description copied from interface: ReplyHandler
Just sends whatever message we ask it to.

Specified by:
reply in interface ReplyHandler

inspect

public Map<String,Object> inspect()
Specified by:
inspect in interface Inspectable
Returns:
a descriptive object for the target object.

getRoutedConnectionStatistics

public ConnectionRoutingStatistics getRoutedConnectionStatistics()
Specified by:
getRoutedConnectionStatistics in interface RoutedConnection

isGoodLeaf

public final boolean isGoodLeaf()
Description copied from interface: ReplyHandler
Returns whether or not this handler is considered a "good" leaf connection. The definition of a good connection changes over time as new features are released.

Specified by:
isGoodLeaf in interface ReplyHandler
Returns:
true if this is considered a good leaf connection, otherwise false

isGoodUltrapeer

public final boolean isGoodUltrapeer()
Description copied from interface: ReplyHandler
Returns whether or not this handler is considered a "good" Ultrapeer connection. The definition of a good connection changes over time as new features are released.

Specified by:
isGoodUltrapeer in interface ReplyHandler
Returns:
true if this is considered a good Ultrapeer connection, otherwise false

isHighDegreeConnection

public final boolean isHighDegreeConnection()
Description copied from interface: ReplyHandler
Returns whether or not this connection is a high-degree connection, meaning that it maintains a high number of intra-Ultrapeer connections.

Specified by:
isHighDegreeConnection in interface ReplyHandler
Returns:
true if this is a 'high-degree' connection, otherwise false

isLeafConnection

public final boolean isLeafConnection()
Description copied from interface: ReplyHandler
Returns whether or not this reply handler is a leaf -- whether or not the host on the other end of this connection is a leaf of this (necessarily) Ultrapeer.

Specified by:
isLeafConnection in interface ReplyHandler
Returns:
true if the host on the other end of this connection is a leaf, making this an Ultrapeer, false otherwise

isSupernodeClientConnection

public final boolean isSupernodeClientConnection()
Description copied from interface: ReplyHandler
Returns whether or not this ReplyHandler sends replies from an Ultrapeer to a leaf. This returns true only if this node is an Ultrapeer, and the node receiving these replies is a leaf of that Ultrapeer.

Specified by:
isSupernodeClientConnection in interface ReplyHandler
Returns:
true if this node is an Ultrapeer, and the node it is sending replies to is a leaf, otherwise returns false

isUltrapeerQueryRoutingConnection

public final boolean isUltrapeerQueryRoutingConnection()
Description copied from interface: ReplyHandler
Returns whether or not this handler uses Ultrapeer query routing.

Specified by:
isUltrapeerQueryRoutingConnection in interface ReplyHandler
Returns:
true if this connection uses query routing between Ultrapeers, otherwise false

supportsPongCaching

public final boolean supportsPongCaching()
Description copied from interface: ReplyHandler
Returns whether or not this node supports pong caching.

Specified by:
supportsPongCaching in interface ReplyHandler
Returns:
true if this node supports pong caching, otherwise false

getConnectionMessageStatistics

public final ConnectionMessageStatistics getConnectionMessageStatistics()
Specified by:
getConnectionMessageStatistics in interface RoutedConnection

LimeWire Consolidated API

Copyright © 2009. All Rights Reserved.