Class PartitionUpdateCounterVolatileImpl
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.PartitionUpdateCounterVolatileImpl
-
- All Implemented Interfaces:
Iterable<long[]>,PartitionUpdateCounter
public class PartitionUpdateCounterVolatileImpl extends Object implements PartitionUpdateCounter
Partition update counter for volatile caches.Doesn't track gaps in update sequence because it's not needed for volatile caches (because their state is lost on node failure).
In this mode LWM and HWM are non distinguishable.
-
-
Constructor Summary
Constructors Constructor Description PartitionUpdateCounterVolatileImpl(CacheGroupContext grp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectcomparableState()CacheGroupContextcontext()PartitionUpdateCountercopy()booleanempty()booleanequals(Object o)GridLongListfinalizeUpdateCounters()Flushes pending update counters closing all possible gaps.longget()Get LWM.@org.jetbrains.annotations.Nullable byte[]getBytes()longhighestAppliedCounter()Returns highest applied update counter.voidinit(long initUpdCntr, @org.jetbrains.annotations.Nullable byte[] cntrUpdData)Restores update counter state.longinitial()Iterator<long[]>iterator()longnext()Increment LWM by 1.longnext(long delta)Increment LWM by delta.longreserve(long delta)Increment HWM by delta.longreserved()Returns HWM.voidreset()Reset counter internal state to zero.voidresetInitialCounter()Reset the initial counter value to zero.booleansequential()StringtoString()voidupdate(long val)Sets update counter to absolute value.booleanupdate(long start, long delta)Applies counter update out of range.voidupdateInitial(long start, long delta)-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
PartitionUpdateCounterVolatileImpl
public PartitionUpdateCounterVolatileImpl(CacheGroupContext grp)
- Parameters:
grp- Group.
-
-
Method Detail
-
init
public void init(long initUpdCntr, @Nullable @org.jetbrains.annotations.Nullable byte[] cntrUpdData)Restores update counter state.- Specified by:
initin interfacePartitionUpdateCounter- Parameters:
initUpdCntr- LWM.cntrUpdData- Counter updates raw data.
-
initial
public long initial()
- Specified by:
initialin interfacePartitionUpdateCounter
-
get
public long get()
Get LWM.- Specified by:
getin interfacePartitionUpdateCounter- Returns:
- Current LWM.
-
next
public long next()
Increment LWM by 1.- Specified by:
nextin interfacePartitionUpdateCounter- Returns:
- New LWM.
-
update
public void update(long val)
Sets update counter to absolute value. All missed updates will be discarded.- Specified by:
updatein interfacePartitionUpdateCounter- Parameters:
val- Absolute value.
-
update
public boolean update(long start, long delta)Applies counter update out of range. Update ranges must not intersect.- Specified by:
updatein interfacePartitionUpdateCounter- Parameters:
start- Start (<= lwm).delta- Delta.- Returns:
Trueif update was actually applied.
-
updateInitial
public void updateInitial(long start, long delta)- Specified by:
updateInitialin interfacePartitionUpdateCounter- Parameters:
start- Counter.delta- Delta.
-
finalizeUpdateCounters
public GridLongList finalizeUpdateCounters()
Flushes pending update counters closing all possible gaps.- Specified by:
finalizeUpdateCountersin interfacePartitionUpdateCounter- Returns:
- Even-length array of pairs [start, end] for each gap.
-
reserve
public long reserve(long delta)
Increment HWM by delta.- Specified by:
reservein interfacePartitionUpdateCounter- Parameters:
delta- Delta.- Returns:
- New HWM.
-
next
public long next(long delta)
Increment LWM by delta.- Specified by:
nextin interfacePartitionUpdateCounter- Parameters:
delta- Delta.- Returns:
- New LWM.
-
sequential
public boolean sequential()
- Specified by:
sequentialin interfacePartitionUpdateCounter- Returns:
Trueif counter has no missed updates.
-
getBytes
@Nullable public @org.jetbrains.annotations.Nullable byte[] getBytes()
- Specified by:
getBytesin interfacePartitionUpdateCounter
-
reset
public void reset()
Reset counter internal state to zero.- Specified by:
resetin interfacePartitionUpdateCounter
-
resetInitialCounter
public void resetInitialCounter()
Reset the initial counter value to zero.- Specified by:
resetInitialCounterin interfacePartitionUpdateCounter
-
reserved
public long reserved()
Returns HWM.- Specified by:
reservedin interfacePartitionUpdateCounter- Returns:
- Current HWM.
-
highestAppliedCounter
public long highestAppliedCounter()
Returns highest applied update counter.- Specified by:
highestAppliedCounterin interfacePartitionUpdateCounter- Returns:
- Highest applied counter.
-
empty
public boolean empty()
- Specified by:
emptyin interfacePartitionUpdateCounter- Returns:
Trueif counter has not seen any update.
-
iterator
public Iterator<long[]> iterator()
- Specified by:
iteratorin interfaceIterable<long[]>- Specified by:
iteratorin interfacePartitionUpdateCounter- Returns:
- Iterator for pairs [start, range] for each out-of-order update in the update counter sequence.
-
context
public CacheGroupContext context()
- Specified by:
contextin interfacePartitionUpdateCounter- Returns:
- Cache group context.
-
copy
public PartitionUpdateCounter copy()
- Specified by:
copyin interfacePartitionUpdateCounter- Returns:
- A deep copy of current instance.
-
comparableState
public Object comparableState()
- Specified by:
comparableStatein interfacePartitionUpdateCounter- Returns:
- Comparable counter state.
-
-