new method - processingComplete(), which functions much just like OutNetMessage's discardData()

so drop the data when called, updating the MessageStateMonitor (and also telling the monitor on finalization, just cuz)
This commit is contained in:
jrandom
2004-06-20 01:40:12 +00:00
committed by zzz
parent d82796e3ad
commit 26138e213f

View File

@ -18,16 +18,24 @@ import net.i2p.data.i2np.SourceRouteBlock;
*
*/
public class InNetMessage {
private RouterContext _context;
private I2NPMessage _message;
private RouterIdentity _fromRouter;
private Hash _fromRouterHash;
private SourceRouteBlock _replyBlock;
private long _created;
public InNetMessage() {
public InNetMessage(RouterContext context) {
_context = context;
setMessage(null);
setFromRouter(null);
setFromRouterHash(null);
setReplyBlock(null);
context.messageStateMonitor().inboundMessageAdded();
_created = context.clock().now();
_context.statManager().createRateStat("inNetMessage.timeToDiscard",
"How long until we discard an inbound msg?",
"InNetMessage", new long[] { 5*60*1000, 30*60*1000, 60*60*1000 });
}
/**
@ -60,9 +68,28 @@ public class InNetMessage {
public SourceRouteBlock getReplyBlock() { return _replyBlock; }
public void setReplyBlock(SourceRouteBlock block) { _replyBlock = block; }
/**
* Call this after we're done dealing with this message (when we no
* longer need its data)
*
*/
public void processingComplete() {
_message = null;
_context.messageStateMonitor().inboundMessageRead();
long timeToDiscard = _context.clock().now() - _created;
_context.statManager().addRateData("inNetMessage.timeToDiscard",
timeToDiscard, timeToDiscard);
}
public void finalize() {
_context.messageStateMonitor().inboundMessageFinalized();
}
public String toString() {
StringBuffer buf = new StringBuffer(512);
buf.append("InNetMessage: from [").append(getFromRouter()).append("] aka [").append(getFromRouterHash()).append("] message: ").append(getMessage());
buf.append("InNetMessage: from [").append(getFromRouter());
buf.append("] aka [").append(getFromRouterHash());
buf.append("] message: ").append(getMessage());
return buf.toString();
}
}