Class MockIdSegmentDistributor

java.lang.Object
me.ahoo.cosid.test.segment.MockIdSegmentDistributor
All Implemented Interfaces:
Grouped, IdSegmentDistributor

public class MockIdSegmentDistributor extends Object implements IdSegmentDistributor
In-memory IdSegmentDistributor that simulates network latency, for tests and benchmarks (moved from IdSegmentDistributor.Mock in 4.0).

This implementation simulates network I/O delays to test the behavior of ID segment distributors under realistic conditions.

  • Constructor Details

    • MockIdSegmentDistributor

      public MockIdSegmentDistributor()
      Create a new Mock distributor with default configuration.
    • MockIdSegmentDistributor

      public MockIdSegmentDistributor(long step, int tps)
      Create a new Mock distributor with custom configuration.
      Parameters:
      step - The step size for ID segments
      tps - The transactions per second to simulate for I/O waiting
  • Method Details

    • getNamespace

      public @NonNull String getNamespace()
      Get the namespace for this distributor.
      Specified by:
      getNamespace in interface IdSegmentDistributor
      Returns:
      The namespace
    • getName

      public @NonNull String getName()
      Get the name for this distributor.
      Specified by:
      getName in interface IdSegmentDistributor
      Returns:
      The name
    • getStep

      public long getStep()
      Get the step size for ID segments.
      Specified by:
      getStep in interface IdSegmentDistributor
      Returns:
      The step size
    • nextMaxId

      public long nextMaxId(long step)
      Allocate the next maximum ID for the specified step size.

      This method simulates network I/O delay before allocating the ID.

      Specified by:
      nextMaxId in interface IdSegmentDistributor
      Parameters:
      step - The step size for allocation
      Returns:
      The maximum ID in the allocated range