Class DefaultGroupedIdSegmentDistributor.GroupedBinding
- All Implemented Interfaces:
Grouped,GroupedIdSegmentDistributor,IdSegmentDistributor
- Enclosing class:
- DefaultGroupedIdSegmentDistributor
-
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
Modifier and TypeMethodDescriptiongetName()Get the name for this distributor.Get the namespace for this distributor.longgetStep()Get the step size for ID segments.group()nextIdSegment(int segments, long ttl) Allocate the next ID segment with multiple segments and specified time-to-live.nextIdSegment(long ttl) Allocate the next ID segment with the specified time-to-live.nextIdSegmentChain(IdSegmentChain previousChain, int segments, long ttl) Allocate the next ID segment chain with custom configuration.longnextMaxId(long step) Allocate the next maximum ID for the specified step size.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.grouped.GroupedIdSegmentDistributor
allowResetMethods inherited from interface me.ahoo.cosid.segment.IdSegmentDistributor
getNamespacedName, getStep, nextIdSegment, nextIdSegmentChain, nextMaxId
-
Constructor Details
-
GroupedBinding
-
-
Method Details
-
group
-
getNamespace
Description copied from interface:IdSegmentDistributorGet 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:
getNamespacein interfaceIdSegmentDistributor- Returns:
- The namespace
-
getName
Description copied from interface:IdSegmentDistributorGet the name for this distributor.The name uniquely identifies this distributor within its namespace.
- Specified by:
getNamein interfaceIdSegmentDistributor- Returns:
- The name
-
getStep
public long getStep()Description copied from interface:IdSegmentDistributorGet 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:
getStepin interfaceIdSegmentDistributor- Returns:
- The step size
-
nextMaxId
public long nextMaxId(long step) Description copied from interface:IdSegmentDistributorAllocate 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:
nextMaxIdin interfaceIdSegmentDistributor- Parameters:
step- The step size for allocation- Returns:
- The maximum ID in the allocated range
-
nextIdSegment
Description copied from interface:IdSegmentDistributorAllocate the next ID segment with the specified time-to-live.- Specified by:
nextIdSegmentin interfaceIdSegmentDistributor- Parameters:
ttl- The time-to-live for the segment- Returns:
- The allocated ID segment
-
nextIdSegment
Description copied from interface:IdSegmentDistributorAllocate the next ID segment with multiple segments and specified time-to-live.This method allocates a merged segment that represents multiple individual segments, useful for prefetching scenarios.
- Specified by:
nextIdSegmentin interfaceIdSegmentDistributor- Parameters:
segments- The number of segments to allocatettl- The time-to-live for the segment- Returns:
- The allocated merged ID segment
-
nextIdSegmentChain
@Nonnull public IdSegmentChain nextIdSegmentChain(IdSegmentChain previousChain, int segments, long ttl) Description copied from interface:IdSegmentDistributorAllocate the next ID segment chain with custom configuration.This method allocates a new segment chain that extends the previous chain, providing the foundation for the segment chain ID generation algorithm.
- Specified by:
nextIdSegmentChainin interfaceIdSegmentDistributor- Parameters:
previousChain- The previous segment chainsegments- The number of segments to allocatettl- The time-to-live for the segment- Returns:
- The allocated ID segment chain
-