com.limegroup.gnutella
Class PongCacher

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

public final class PongCacher
extends java.lang.Object

This class caches pongs from the network. Caching pongs saves considerable bandwidth because only a controlled number of pings are sent to maintain adequate host data, with Ultrapeers caching and responding to pings with the best pongs available.


Field Summary
static int NUM_HOPS
          Constant for the number of hops to keep track of in our pong cache.
static int NUM_PONGS_PER_HOP
          Constant for the number of pongs to store per hop.
 
Method Summary
 void addPong(PingReply pr)
          Adds the specified PingReply instance to the cache of pongs.
 java.util.List getBestPongs()
          Accessor for the Set of cached pongs.
static PongCacher instance()
          Returns the single PongCacher instance.
 boolean needsPongs()
          Returns whether or not we need pongs for the cacher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_PONGS_PER_HOP

public static final int NUM_PONGS_PER_HOP
Constant for the number of pongs to store per hop. Public to make testing easier.

See Also:
Constant Field Values

NUM_HOPS

public static final int NUM_HOPS
Constant for the number of hops to keep track of in our pong cache.

See Also:
Constant Field Values
Method Detail

instance

public static PongCacher instance()
Returns the single PongCacher instance.


getBestPongs

public java.util.List getBestPongs()
Accessor for the Set of cached pongs. This List is unmodifiable and will throw IllegalOperationException if it is modified.

Returns:
the List of cached pongs -- continually updated

addPong

public void addPong(PingReply pr)
Adds the specified PingReply instance to the cache of pongs.

Parameters:
pr - the PingReply to add

needsPongs

public boolean needsPongs()
Returns whether or not we need pongs for the cacher.

Returns:
true if we need new pongs to cache, otherwise false