Package me.ahoo.cosid.segment
Class IdSegmentDistributor.Mock
java.lang.Object
me.ahoo.cosid.segment.IdSegmentDistributor.Mock
- All Implemented Interfaces:
Grouped,IdSegmentDistributor
- Enclosing interface:
- IdSegmentDistributor
Mock implementation of IdSegmentDistributor for testing purposes.
This implementation simulates network I/O delays to test the behavior of ID segment distributors under realistic conditions.
-
Nested Class Summary
Nested classes/interfaces inherited from interface me.ahoo.cosid.segment.IdSegmentDistributor
IdSegmentDistributor.Atomic, IdSegmentDistributor.Mock -
Field Summary
Fields inherited from interface me.ahoo.cosid.segment.IdSegmentDistributor
DEFAULT_OFFSET, DEFAULT_SEGMENTS, DEFAULT_STEP -
Constructor Summary
Constructors -
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
-
Mock
public Mock()Create a new Mock distributor with default configuration. -
Mock
public Mock(long step, int tps) Create a new Mock distributor with custom configuration.- Parameters:
step- The step size for ID segmentstps- The transactions per second to simulate for I/O waiting
-
-
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.This method simulates network I/O delay before allocating the ID.
- Specified by:
nextMaxIdin interfaceIdSegmentDistributor- Parameters:
step- The step size for allocation- Returns:
- The maximum ID in the allocated range
-