public class PartitionUpdateCounterTrackingImpl extends Object implements PartitionUpdateCounter
Implements the partition update counter flow to avoid situations when:
The main idea is to track updates received out-of-order to ensure valid state of the update counter for rebalancing.
Below a short description of new flow:
RollbackRecord
for further recovery purposes.Modifier and Type | Field and Description |
---|---|
protected AtomicLong |
cntr
LWM.
|
protected boolean |
first |
protected CacheGroupContext |
grp |
protected long |
initCntr
Deprecated.
TODO FIXME https://issues.apache.org/jira/browse/IGNITE-11794
|
static int |
MAX_MISSED_UPDATES
Max allowed missed updates.
|
protected NavigableMap<Long,org.apache.ignite.internal.processors.cache.PartitionUpdateCounterTrackingImpl.Item> |
queue
Queue of applied out of order counter updates.
|
protected AtomicLong |
reserveCntr
HWM.
|
Constructor and Description |
---|
PartitionUpdateCounterTrackingImpl(CacheGroupContext grp) |
Modifier and Type | Method and Description |
---|---|
CacheGroupContext |
context() |
PartitionUpdateCounter |
copy() |
protected PartitionUpdateCounterTrackingImpl |
createInstance() |
boolean |
empty() |
boolean |
equals(Object o) |
GridLongList |
finalizeUpdateCounters()
Flushes pending update counters closing all possible gaps.
|
long |
get()
Get LWM.
|
@Nullable byte[] |
getBytes() |
protected long |
highestAppliedCounter() |
void |
init(long initUpdCntr,
@Nullable byte[] cntrUpdData)
Restores update counter state.
|
long |
initial() |
Iterator<long[]> |
iterator() |
long |
next()
Increment LWM by 1.
|
long |
next(long delta)
Increment LWM by delta.
|
long |
reserve(long delta)
Increment HWM by delta.
|
long |
reserved()
Returns HWM.
|
void |
reset()
Reset counter internal state to zero.
|
void |
resetInitialCounter()
Reset the initial counter value to zero.
|
boolean |
sequential() |
String |
toString() |
void |
update(long val)
Sets update counter to absolute value.
|
boolean |
update(long start,
long delta)
Applies counter update out of range.
|
void |
updateInitial(long start,
long delta) |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public static final int MAX_MISSED_UPDATES
protected NavigableMap<Long,org.apache.ignite.internal.processors.cache.PartitionUpdateCounterTrackingImpl.Item> queue
protected final AtomicLong cntr
protected final AtomicLong reserveCntr
protected boolean first
protected final CacheGroupContext grp
@Deprecated protected volatile long initCntr
public PartitionUpdateCounterTrackingImpl(CacheGroupContext grp)
grp
- Group.public void init(long initUpdCntr, @Nullable @Nullable byte[] cntrUpdData)
init
in interface PartitionUpdateCounter
initUpdCntr
- LWM.cntrUpdData
- Counter updates raw data.public long initial()
initial
in interface PartitionUpdateCounter
public long get()
get
in interface PartitionUpdateCounter
protected long highestAppliedCounter()
public long next()
PartitionUpdateCounter
next
in interface PartitionUpdateCounter
DataStreamerImpl
IsolatedUpdater.public void update(long val) throws IgniteCheckedException
update
in interface PartitionUpdateCounter
val
- Absolute value.IgniteCheckedException
- if counter cannot be set to passed value due to incompatibility with current state.public boolean update(long start, long delta)
update
in interface PartitionUpdateCounter
start
- Start (<= lwm).delta
- Delta.True
if update was actually applied.public void updateInitial(long start, long delta)
updateInitial
in interface PartitionUpdateCounter
start
- Counter.delta
- Delta.public GridLongList finalizeUpdateCounters()
finalizeUpdateCounters
in interface PartitionUpdateCounter
public long reserve(long delta)
reserve
in interface PartitionUpdateCounter
delta
- Delta.public long next(long delta)
next
in interface PartitionUpdateCounter
delta
- Delta.public boolean sequential()
sequential
in interface PartitionUpdateCounter
True
if counter has no missed updates.@Nullable public @Nullable byte[] getBytes()
getBytes
in interface PartitionUpdateCounter
public void reset()
reset
in interface PartitionUpdateCounter
public void resetInitialCounter()
resetInitialCounter
in interface PartitionUpdateCounter
public long reserved()
reserved
in interface PartitionUpdateCounter
public boolean empty()
empty
in interface PartitionUpdateCounter
True
if counter has not seen any update.public Iterator<long[]> iterator()
iterator
in interface Iterable<long[]>
iterator
in interface PartitionUpdateCounter
public CacheGroupContext context()
context
in interface PartitionUpdateCounter
public PartitionUpdateCounter copy()
copy
in interface PartitionUpdateCounter
protected PartitionUpdateCounterTrackingImpl createInstance()
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.10.0 Release Date : March 10 2021