use of net.i2p.data.i2np.DeliveryStatusMessage in project i2p.i2p by i2p.
the class TestJob method runJob.
public void runJob() {
if (_pool == null || !_pool.isAlive())
return;
long lag = getContext().jobQueue().getMaxLag();
if (lag > 3000) {
if (_log.shouldLog(Log.WARN))
_log.warn("Deferring test of " + _cfg + " due to job lag = " + lag);
getContext().statManager().addRateData("tunnel.testAborted", _cfg.getLength(), 0);
scheduleRetest();
return;
}
if (getContext().router().gracefulShutdownInProgress())
// don't reschedule
return;
_found = false;
// note: testing with exploratory tunnels always, even if the tested tunnel
// is a client tunnel (per _cfg.getDestination())
// should we test with the tunnel that we exposed the creation with?
// (accessible as _cfg.getPairedTunnel())
_replyTunnel = null;
_outTunnel = null;
if (_cfg.isInbound()) {
_replyTunnel = _cfg;
// TODO if testing is re-enabled, pick closest to far end
_outTunnel = getContext().tunnelManager().selectOutboundTunnel();
_otherTunnel = (PooledTunnelCreatorConfig) _outTunnel;
} else {
// TODO if testing is re-enabled, pick closest to far end
_replyTunnel = getContext().tunnelManager().selectInboundTunnel();
_outTunnel = _cfg;
_otherTunnel = (PooledTunnelCreatorConfig) _replyTunnel;
}
if ((_replyTunnel == null) || (_outTunnel == null)) {
if (_log.shouldLog(Log.WARN))
_log.warn("Insufficient tunnels to test " + _cfg + " with: " + _replyTunnel + " / " + _outTunnel);
getContext().statManager().addRateData("tunnel.testAborted", _cfg.getLength(), 0);
scheduleRetest();
} else {
int testPeriod = getTestPeriod();
long testExpiration = getContext().clock().now() + testPeriod;
DeliveryStatusMessage m = new DeliveryStatusMessage(getContext());
m.setArrival(getContext().clock().now());
m.setMessageExpiration(testExpiration);
m.setMessageId(getContext().random().nextLong(I2NPMessage.MAX_ID_VALUE));
ReplySelector sel = new ReplySelector(getContext(), m.getMessageId(), testExpiration);
OnTestReply onReply = new OnTestReply(getContext());
OnTestTimeout onTimeout = new OnTestTimeout(getContext());
OutNetMessage msg = getContext().messageRegistry().registerPending(sel, onReply, onTimeout);
onReply.setSentMessage(msg);
sendTest(m);
}
}
use of net.i2p.data.i2np.DeliveryStatusMessage in project i2p.i2p by i2p.
the class OutboundClientMessageJobHelper method buildDSM.
/**
* Make a basic DSM
* @since 0.9.12
*/
private static DeliveryStatusMessage buildDSM(RouterContext ctx, long replyToken) {
DeliveryStatusMessage msg = new DeliveryStatusMessage(ctx);
msg.setArrival(ctx.clock().now());
msg.setMessageId(replyToken);
return msg;
}
Aggregations