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:
@ -18,16 +18,24 @@ import net.i2p.data.i2np.SourceRouteBlock;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class InNetMessage {
|
public class InNetMessage {
|
||||||
|
private RouterContext _context;
|
||||||
private I2NPMessage _message;
|
private I2NPMessage _message;
|
||||||
private RouterIdentity _fromRouter;
|
private RouterIdentity _fromRouter;
|
||||||
private Hash _fromRouterHash;
|
private Hash _fromRouterHash;
|
||||||
private SourceRouteBlock _replyBlock;
|
private SourceRouteBlock _replyBlock;
|
||||||
|
private long _created;
|
||||||
|
|
||||||
public InNetMessage() {
|
public InNetMessage(RouterContext context) {
|
||||||
|
_context = context;
|
||||||
setMessage(null);
|
setMessage(null);
|
||||||
setFromRouter(null);
|
setFromRouter(null);
|
||||||
setFromRouterHash(null);
|
setFromRouterHash(null);
|
||||||
setReplyBlock(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 SourceRouteBlock getReplyBlock() { return _replyBlock; }
|
||||||
public void setReplyBlock(SourceRouteBlock block) { _replyBlock = block; }
|
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() {
|
public String toString() {
|
||||||
StringBuffer buf = new StringBuffer(512);
|
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();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user