Class MongoIdSegmentDistributor

java.lang.Object
me.ahoo.cosid.mongo.MongoIdSegmentDistributor
All Implemented Interfaces:
Grouped, IdSegmentDistributor

public class MongoIdSegmentDistributor extends Object implements IdSegmentDistributor
Mongo IdSegment Distributor.
  • Constructor Details

  • Method Details

    • getNamespace

      @Nonnull public String getNamespace()
      Description copied from interface: IdSegmentDistributor
      Get the namespace for this distributor.

      The namespace provides a logical grouping for ID segments, allowing multiple independent segment spaces within the same system.

      Specified by:
      getNamespace in interface IdSegmentDistributor
      Returns:
      The namespace
    • getName

      @Nonnull public String getName()
      Description copied from interface: IdSegmentDistributor
      Get the name for this distributor.

      The name uniquely identifies this distributor within its namespace.

      Specified by:
      getName in interface IdSegmentDistributor
      Returns:
      The name
    • getStep

      public long getStep()
      Description copied from interface: IdSegmentDistributor
      Get the step size for ID segments.

      The step size determines how many IDs are allocated in each segment. Larger steps reduce coordination overhead but may lead to ID gaps.

      Specified by:
      getStep in interface IdSegmentDistributor
      Returns:
      The step size
    • nextMaxId

      public long nextMaxId(long step)
      Description copied from interface: IdSegmentDistributor
      Allocate the next maximum ID for the specified step size.

      This method allocates a new range of IDs by returning the maximum ID in the allocated range. The range starts at the previous maximum plus one and ends at the returned value.

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