com.limegroup.gnutella
Class HorizonCounter

java.lang.Object
  extended bycom.limegroup.gnutella.HorizonCounter

public final class HorizonCounter
extends java.lang.Object

Horizon statistics. We measure the horizon by looking at all ping replies coming per connection--regardless whether they are in response to pings originating from us. To avoid double-counting ping replies, we keep a set of Endpoint's around, bounded in size to save memory. This scheme is robust in the face of pong throttling. Note however that we cannot discern pings from multiple hosts with the same private address. But you are probably not interested in such hosts anyway. The problem with this scheme is that the numbers tend to grow without bound, even if hosts leave the network. Ideally we'd like to clear all pongs that are more than HORIZON_UPDATE_TIME milliseconds old, but that's difficult to implement efficiently. As a simplication, we periodically clear the set of pongs every HORIZON_UPDATE_TIME milliseconds (by calling updateHorizonStats) and start recounting. While we are recounting, we return the last size of the set. So pongs in the set are HORIZON_UPDATE_TIME to 2*HORIZON_UPDATE_TIME milliseconds old. LOCKING: obtain this' monitor


Constructor Summary
HorizonCounter()
           
 
Method Summary
 void addPong(PingReply pong)
           
 long getNumFiles()
          Returns the number of files reachable from me.
 long getNumHosts()
          Returns the number of hosts reachable from me.
 long getTotalFileSize()
          Returns the size of all files reachable from me.
static HorizonCounter instance()
           
 void refresh()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HorizonCounter

public HorizonCounter()
Method Detail

instance

public static HorizonCounter instance()

addPong

public void addPong(PingReply pong)

refresh

public void refresh()

getNumHosts

public long getNumHosts()
Returns the number of hosts reachable from me.


getNumFiles

public long getNumFiles()
Returns the number of files reachable from me.


getTotalFileSize

public long getTotalFileSize()
Returns the size of all files reachable from me.