java.lang.Object
net.i2p.router.transport.ntcp.EventPumper.InboundFloodDecision
Enclosing class:
EventPumper

static final class EventPumper.InboundFloodDecisionextends Object
Outcome of EventPumper.evaluateInboundFlood(long, int, int, long, boolean, int, int, RandomSource): whether to reject the incoming connection plus the numbers used in the warn log, so the caller stays side-effect free.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    Inbound connections per minute right now.
    private final boolean
    Whether the throttle drops connections outright.
    private final int
    Connection count used to compute the current rate.
    private final int
    Percent of connections the throttle allows through.
    (package private) static final EventPumper.InboundFloodDecision
    Constant for "accept, nothing to report", reused on every non-drop path.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    InboundFloodDecision(boolean drop, int percent, int lastConnections, int currentConnectionsPerMinute)
    Freeze one accept decision: whether to drop, the nominal rejection chance to render, and the counts it was projected from.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    (package private) int
    The accept rate the decision was projected from.
    (package private) int
    The accept count the rate was measured against.
    (package private) int
    The nominal share of inbound connections to refuse.
    (package private) boolean
    Whether to refuse the connection, per the flood decision.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ALLOW

      Constant for "accept, nothing to report", reused on every non-drop path.
    • _drop

      private final boolean _drop
      Whether the throttle drops connections outright.
    • _percent

      private final int _percent
      Percent of connections the throttle allows through.
    • _lastConnections

      private final int _lastConnections
      Connection count used to compute the current rate.
    • _currentConnectionsPerMinute

      private final int _currentConnectionsPerMinute
      Inbound connections per minute right now.
  • Constructor Details

    • InboundFloodDecision

      private InboundFloodDecision(boolean drop, int percent, int lastConnections, int currentConnectionsPerMinute)
      Freeze one accept decision: whether to drop, the nominal rejection chance to render, and the counts it was projected from.
      Parameters:
      drop - true to reject the connection
      percent - nominal rejection chance, 0-100 (0 renders as "1%")
      lastConnections - baseline connections in the previous period
      currentConnectionsPerMinute - projected current accept rate
  • Method Details

    • isDrop

      boolean isDrop()
      Whether to refuse the connection, per the flood decision.
      Returns:
      true if the connection should be rejected
    • getPercent

      int getPercent()
      The nominal share of inbound connections to refuse.
      Returns:
      nominal rejection chance percent (0 renders as "1%")
    • getLastConnections

      int getLastConnections()
      The accept count the rate was measured against.
      Returns:
      baseline connections in the previous full rate period
    • getCurrentConnectionsPerMinute

      int getCurrentConnectionsPerMinute()
      The accept rate the decision was projected from.
      Returns:
      projected current accept rate in connections per minute