All Implemented Interfaces:
TunnelGateway.QueuePreprocessor

class BatchedRouterPreprocessorextends BatchedPreprocessor
Honor the 'batchFrequency' tunnel pool setting or the 'router.batchFrequency' router config setting, and track fragmentation.
  • Field Details

    • _config

      private final TunnelCreatorConfig _config
      The tunnel the batch is built for.
    • _hopConfig

      protected final HopConfig _hopConfig
      The hop config for inbound gateways.
    • _sendDelay

      private final long _sendDelay
      Delay before the first batch is sent, in ms.
    • PROP_BATCH_FREQUENCY

      public static final String PROP_BATCH_FREQUENCY
      How frequently should we flush non-full messages, in milliseconds This goes in I2CP custom options for the pool. Only applies to OBGWs.
      See Also:
    • PROP_ROUTER_BATCH_FREQUENCY

      public static final String PROP_ROUTER_BATCH_FREQUENCY
      This goes in router advanced config.
      See Also:
    • OB_CLIENT_BATCH_FREQ

      public static final int OB_CLIENT_BATCH_FREQ
      For client OBGWs only (our data).
    • OB_EXPL_BATCH_FREQ

      public static final int OB_EXPL_BATCH_FREQ
      For exploratory OBGWs only (our tunnel tests and build messages).
    • DEFAULT_BATCH_FREQUENCY

      public static final int DEFAULT_BATCH_FREQUENCY
      For IBGWs for efficiency (not our data).
  • Constructor Details

    • BatchedRouterPreprocessor

      public BatchedRouterPreprocessor(RouterContext ctx, TunnelCreatorConfig cfg)
      Create a preprocessor for outbound gateway tunnels.
      Parameters:
      ctx - the router context
      cfg - the tunnel creator config
    • BatchedRouterPreprocessor

      public BatchedRouterPreprocessor(RouterContext ctx, HopConfig cfg)
      Create a preprocessor for inbound gateway tunnels.
      Parameters:
      ctx - the router context
      cfg - the hop config
  • Method Details

    • getName

      private static String getName(HopConfig cfg)
      Names a hop for the log.
      Parameters:
      cfg - the hop's configuration
      Returns:
      the name to show
    • getName

      private static String getName(TunnelCreatorConfig cfg)
      Names a tunnel for the log.
      Parameters:
      cfg - the tunnel's configuration
      Returns:
      the name to show
    • getSendDelay

      protected long getSendDelay()
      How long we should wait before flushing a batch.
      Overrides:
      getSendDelay in class BatchedPreprocessor
      Returns:
      the send delay, in ms
    • initialSendDelay

      private long initialSendDelay()
      Chooses the delay before the first batch is sent, extending the batching time for exploratory OBGWs: they carry many small tunnel test messages and build messages that don't fit perfectly, and those are not as delay-sensitive. Config changes are not picked up after the preprocessor is created, but a preprocessor's lifetime is only 10 minutes, so just wait.
      Returns:
      the delay, in ms
    • notePreprocessing

      protected void notePreprocessing(long messageId, int numFragments, int totalLength, List<Long> messageIds, String msg)
      Description copied from class: TrivialPreprocessor
      Note preprocessing statistics. No-op - intentionally empty.
      Overrides:
      notePreprocessing in class TrivialPreprocessor
      Parameters:
      messageId - the message this fragment carries data for
      numFragments - the fragment number within that message
      totalLength - the total length of the message the fragment belongs to
      messageIds - the message ids of everything coalesced into this fragment
      msg - a description of the flush event, for debugging output