Package me.ahoo.cosid.segment
Class IdSegmentChain
java.lang.Object
me.ahoo.cosid.segment.IdSegmentChain
- All Implemented Interfaces:
Comparable<IdSegment>
,Grouped
,IdSegment
Chained ID segment.
-
Field Summary
Fields inherited from interface me.ahoo.cosid.segment.IdSegment
SEQUENCE_OVERFLOW, TIME_TO_LIVE_FOREVER
-
Constructor Summary
ConstructorDescriptionIdSegmentChain
(long version, IdSegment idSegment, boolean allowReset) IdSegmentChain
(IdSegmentChain previousChain, IdSegment idSegment, boolean allowReset) -
Method Summary
Modifier and TypeMethodDescriptionensureSetNext
(Function<IdSegmentChain, IdSegmentChain> idSegmentChainSupplier) int
gap
(IdSegmentChain end, long step) long
ID segment fetch time.long
getMaxId()
getNext()
long
long
long
getStep()
long
getTtl()
the id segment time to live.long
group()
long
static IdSegmentChain
newRoot
(boolean allowReset) void
setNext
(IdSegmentChain nextIdSegmentChain) toString()
boolean
trySetNext
(Function<IdSegmentChain, IdSegmentChain> idSegmentChainSupplier) try set next Chained ID segment.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface me.ahoo.cosid.segment.IdSegment
compareTo, ensureNextIdSegment, isAvailable, isExpired, isOverflow, isOverflow
-
Field Details
-
ROOT_VERSION
public static final int ROOT_VERSION- See Also:
-
NOT_SET
-
-
Constructor Details
-
IdSegmentChain
-
IdSegmentChain
-
-
Method Details
-
trySetNext
public boolean trySetNext(Function<IdSegmentChain, IdSegmentChain> idSegmentChainSupplier) throws NextIdSegmentExpiredExceptiontry set next Chained ID segment.- Parameters:
idSegmentChainSupplier
-IdSegmentChain
supplier- Returns:
- true if set successfully
- Throws:
NextIdSegmentExpiredException
- This exception is thrown if the providedIdSegmentChain
has expired.
-
setNext
-
ensureSetNext
public IdSegmentChain ensureSetNext(Function<IdSegmentChain, IdSegmentChain> idSegmentChainSupplier) throws NextIdSegmentExpiredException- Throws:
NextIdSegmentExpiredException
-
getNext
-
getIdSegment
-
group
-
getVersion
public long getVersion() -
gap
-
newRoot
-
getFetchTime
public long getFetchTime()Description copied from interface:IdSegment
ID segment fetch time. unitTimeUnit.SECONDS
- Specified by:
getFetchTime
in interfaceIdSegment
- Returns:
- fetch time
-
getTtl
public long getTtl()Description copied from interface:IdSegment
the id segment time to live. unitTimeUnit.SECONDS
-
getMaxId
public long getMaxId() -
getOffset
public long getOffset() -
getSequence
public long getSequence()- Specified by:
getSequence
in interfaceIdSegment
-
getStep
public long getStep() -
incrementAndGet
public long incrementAndGet()- Specified by:
incrementAndGet
in interfaceIdSegment
-
toString
-