net.i2p.router

## Class RouterThrottleImpl

- java.lang.Object
- - net.i2p.router.RouterThrottleImpl

- All Implemented Interfaces:
    RouterThrottle

      public class RouterThrottleImpl
      extends Object
      implements RouterThrottle

  Simple throttle that basically stops accepting messages or nontrivial requests if the jobQueue lag is too large.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected RouterContext` | `_context`
    `static int` | `DEFAULT_MAX_TUNNELS`
    `static int` | `DEFAULT_MESSAGES_PER_TUNNEL_ESTIMATE` This is the estimated number of 1 KB tunnel messages that we'll see in 10 minute lifetime of an exploratory tunnel.
    `static String` | `PROP_MAX_TUNNELS`
    `static int` | `TUNNEL_ACCEPT` tunnel acceptance

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RouterThrottleImpl(RouterContext context)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `acceptNetworkMessage()` Should we accept any more data from the network for any sort of message, taking into account our current load, or should we simply slow down? FIXME only called by SSU Receiver, not NTCP! FIXME should put warning on the console FIXME or should we do this at all? We have Codel queues all over now...
    `int` | `acceptTunnelRequest()` If we should send a reject, return a nonzero reject code.
    `void` | `cancelShutdownStatus()`
    `String` | `getLocalizedTunnelStatus()` getTunnelStatus(), translated if available.
    `long` | `getMessageDelay()` How backed up we are at the moment processing messages (in milliseconds)
    `long` | `getTunnelLag()` How backed up our tunnels are at the moment (in milliseconds)
    `String` | `getTunnelStatus()` Message on the state of participating tunnel acceptance
    `static boolean` | `isShuttingDown(RouterContext _context)`
    `void` | `setShutdownStatus()`
    `void` | `setTunnelStatus(String msg)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface net.i2p.router.RouterThrottle

      `acceptNetDbLookupRequest`

- - ### Field Detail

    - #### _context

          protected final RouterContext _context

    - #### DEFAULT_MAX_TUNNELS

          public static final int DEFAULT_MAX_TUNNELS

    - #### DEFAULT_MESSAGES_PER_TUNNEL_ESTIMATE

          public static final int DEFAULT_MESSAGES_PER_TUNNEL_ESTIMATE

      This is the estimated number of 1 KB tunnel messages that we'll see in 10 minute lifetime of an exploratory tunnel. We use it as a baseline minimum for estimating tunnel bandwidth, if accepted. 200 KB in 10 minutes equals 340 Bps - optimized for high bandwidth contexts.
      See Also:
        Constant Field Values

    - #### PROP_MAX_TUNNELS

          public static final String PROP_MAX_TUNNELS

      See Also:
        Constant Field Values

    - #### TUNNEL_ACCEPT

          public static final int TUNNEL_ACCEPT

      tunnel acceptance
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### RouterThrottleImpl

          public RouterThrottleImpl(RouterContext context)

  - ### Method Detail

    - #### acceptNetworkMessage

          public boolean acceptNetworkMessage()

      Should we accept any more data from the network for any sort of message, taking into account our current load, or should we simply slow down? FIXME only called by SSU Receiver, not NTCP! FIXME should put warning on the console FIXME or should we do this at all? We have Codel queues all over now...
      Specified by:
        `acceptNetworkMessage` in interface `RouterThrottle`

    - #### acceptTunnelRequest

          public int acceptTunnelRequest()

      If we should send a reject, return a nonzero reject code. Anything that causes us to drop a request instead of rejecting it must go in BuildHandler.handleInboundRequest(), not here.
      Specified by:
        `acceptTunnelRequest` in interface `RouterThrottle`
      Returns:
        0 for accept or nonzero reject code

    - #### cancelShutdownStatus

          public void cancelShutdownStatus()

      Specified by:
        `cancelShutdownStatus` in interface `RouterThrottle`

    - #### getLocalizedTunnelStatus

          public String getLocalizedTunnelStatus()

      getTunnelStatus(), translated if available.
      Specified by:
        `getLocalizedTunnelStatus` in interface `RouterThrottle`

    - #### getMessageDelay

          public long getMessageDelay()

      Description copied from interface: `RouterThrottle`
      How backed up we are at the moment processing messages (in milliseconds)
      Specified by:
        `getMessageDelay` in interface `RouterThrottle`

    - #### getTunnelLag

          public long getTunnelLag()

      Description copied from interface: `RouterThrottle`
      How backed up our tunnels are at the moment (in milliseconds)
      Specified by:
        `getTunnelLag` in interface `RouterThrottle`

    - #### getTunnelStatus

          public String getTunnelStatus()

      Description copied from interface: `RouterThrottle`
      Message on the state of participating tunnel acceptance
      Specified by:
        `getTunnelStatus` in interface `RouterThrottle`

    - #### isShuttingDown

          public static boolean isShuttingDown(RouterContext _context)

    - #### setShutdownStatus

          public void setShutdownStatus()

      Specified by:
        `setShutdownStatus` in interface `RouterThrottle`

    - #### setTunnelStatus

          public void setTunnelStatus(String msg)

      Specified by:
        `setTunnelStatus` in interface `RouterThrottle`