Package me.ahoo.cosid.test.segment
Class AtomicIdSegmentDistributor
java.lang.Object
me.ahoo.cosid.test.segment.AtomicIdSegmentDistributor
- All Implemented Interfaces:
Grouped,IdSegmentDistributor
In-memory
IdSegmentDistributor for tests and benchmarks (moved from IdSegmentDistributor.Atomic in 4.0).
This implementation uses atomic operations to allocate ID segments, making it suitable for single-instance scenarios or testing.
-
Field Summary
Fields inherited from interface me.ahoo.cosid.segment.IdSegmentDistributor
DEFAULT_OFFSET, DEFAULT_SEGMENTS, DEFAULT_STEP -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new Atomic distributor with default step size.AtomicIdSegmentDistributor(long step) Create a new Atomic distributor with custom step size. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.ahoo.cosid.segment.IdSegmentDistributor
allowReset, getNamespacedName, getStep, nextIdSegment, nextIdSegment, nextIdSegment, nextIdSegmentChain, nextIdSegmentChain, nextMaxId
-
Constructor Details
-
AtomicIdSegmentDistributor
public AtomicIdSegmentDistributor()Create a new Atomic distributor with default step size. -
AtomicIdSegmentDistributor
public AtomicIdSegmentDistributor(long step) Create a new Atomic distributor with custom step size.- Parameters:
step- The step size for ID segments
-
-
Method Details
-
getNamespace
Get the namespace for this distributor.- Specified by:
getNamespacein interfaceIdSegmentDistributor- Returns:
- The namespace
-
getName
Get the name for this distributor.- Specified by:
getNamein interfaceIdSegmentDistributor- Returns:
- The name
-
getStep
public long getStep()Get the step size for ID segments.- Specified by:
getStepin interfaceIdSegmentDistributor- Returns:
- The step size
-
nextMaxId
public long nextMaxId(long step) Allocate the next maximum ID for the specified step size.- Specified by:
nextMaxIdin interfaceIdSegmentDistributor- Parameters:
step- The step size for allocation- Returns:
- The maximum ID in the allocated range
-