java.lang.Object
net.i2p.i2ptunnel.ConnThrottler.Record
Enclosing class:
ConnThrottler

private static class ConnThrottler.Recordextends Object
Keep a list of seen times, and a ban-until time. Caller must sync all methods.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final List<Long>
    When this peer's connections arrived.
    private long
    When this peer's throttle expires.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Builds an empty record for one peer.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    void
    ban(long untilTime)
    Throttles this peer until the given time.
    int
    countSince(long time)
    Counts this peer's connections since the given time, dropping the older ones.
    long
    When this peer's throttle expires.
    void
    Caller must synch.

    Methods inherited from class Object

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

    • times

      private final List<Long> times
      When this peer's connections arrived.
    • until

      private long until
      When this peer's throttle expires.
  • Constructor Details

    • Record

      public Record()
      Builds an empty record for one peer.
  • Method Details

    • countSince

      public int countSince(long time)
      Counts this peer's connections since the given time, dropping the older ones. Caller must synch.
      Parameters:
      time - drop the connections before this time
      Returns:
      the connections counted since then
    • increment

      public void increment()
      Caller must synch.
    • ban

      public void ban(long untilTime)
      Throttles this peer until the given time. Caller must synch.
      Parameters:
      untilTime - when the throttle expires
    • getUntil

      public long getUntil()
      When this peer's throttle expires. Caller must synch.
      Returns:
      the expiry time, 0 if not throttled