Search in sources :

Example 6 with DeliveryStatusMessage

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);
    }
}
Also used : OutNetMessage(net.i2p.router.OutNetMessage) DeliveryStatusMessage(net.i2p.data.i2np.DeliveryStatusMessage)

Example 7 with DeliveryStatusMessage

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;
}
Also used : DeliveryStatusMessage(net.i2p.data.i2np.DeliveryStatusMessage)

Aggregations

DeliveryStatusMessage (net.i2p.data.i2np.DeliveryStatusMessage)7 Hash (net.i2p.data.Hash)3 TunnelId (net.i2p.data.TunnelId)2 DatabaseStoreMessage (net.i2p.data.i2np.DatabaseStoreMessage)2 DeliveryInstructions (net.i2p.data.i2np.DeliveryInstructions)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Certificate (net.i2p.data.Certificate)1 GarlicMessage (net.i2p.data.i2np.GarlicMessage)1 I2NPMessage (net.i2p.data.i2np.I2NPMessage)1 TunnelGatewayMessage (net.i2p.data.i2np.TunnelGatewayMessage)1 RouterInfo (net.i2p.data.router.RouterInfo)1 Job (net.i2p.router.Job)1 OutNetMessage (net.i2p.router.OutNetMessage)1 TunnelInfo (net.i2p.router.TunnelInfo)1 SendMessageDirectJob (net.i2p.router.message.SendMessageDirectJob)1 Log (net.i2p.util.Log)1