|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.RouteTable
The reply routing table. Given a GUID from a reply message header, this tells you where to route the reply. It is mutable mapping from globally unique 16-byte message IDs to connections. Old mappings may be purged without warning, preferably using a FIFO policy. This class makes a distinction between not having a mapping for a GUID and mapping that GUID to null (in the case of a removed ReplyHandler).
This class can also optionally keep track of the number of reply bytes routed per guid. This can be useful for implementing fair flow-control strategies.
Nested Class Summary | |
static class |
RouteTable.ReplyRoutePair
The return value from getReplyHandler. |
Constructor Summary | |
RouteTable(int seconds,
int maxSize)
Creates a new route table with enough space to hold the last seconds to 2*seconds worth of entries, or maxSize elements, whichever is smaller [sic]. |
Method Summary | |
boolean |
getAndSetTTL(byte[] guid,
byte getTTL,
byte setTTL)
Synchronizes a TTL get test with a set test. |
ReplyHandler |
getReplyHandler(byte[] guid)
Looks up the reply route for a given guid. |
RouteTable.ReplyRoutePair |
getReplyHandler(byte[] guid,
int replyBytes,
short numReplies)
Looks up the reply route and route volume for a given guid, incrementing the count of bytes routed for that GUID. |
void |
removeReplyHandler(ReplyHandler replyHandler)
Clears references to a given ReplyHandler. |
ResultCounter |
routeReply(byte[] guid,
ReplyHandler replyHandler)
Adds a new routing entry. |
void |
setTTL(ResultCounter entry,
byte ttl)
Optional operation - if you want to remember the TTL associated with a counter, in order to allow for extendable execution, you can set the TTL a message (guid). |
java.lang.String |
toString()
|
ResultCounter |
tryToRouteReply(byte[] guid,
ReplyHandler replyHandler)
Adds a new routing entry if one doesn't exist. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public RouteTable(int seconds, int maxSize)
Method Detail |
public ResultCounter routeReply(byte[] guid, ReplyHandler replyHandler)
public ResultCounter tryToRouteReply(byte[] guid, ReplyHandler replyHandler)
public void setTTL(ResultCounter entry, byte ttl)
ttl
- should be greater than 0.
java.lang.IllegalArgumentException
- thrown if !(ttl > 0), or if entry is
null or is not something I recognize. So only put in what I dole out.public boolean getAndSetTTL(byte[] guid, byte getTTL, byte setTTL)
getTTL
- the ttl you want getTTL() to be in order to setTTL().setTTL
- the ttl you want to setTTL() if getTTL() was correct.
java.lang.IllegalArgumentException
- if getTTL or setTTL is less than 1, or
if setTTL < getTTLpublic ReplyHandler getReplyHandler(byte[] guid)
public RouteTable.ReplyRoutePair getReplyHandler(byte[] guid, int replyBytes, short numReplies)
public void removeReplyHandler(ReplyHandler replyHandler)
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |