org.apache.ignite.internal.processors.cache

## 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 and Description
`PartitionUpdateCounterVolatileImpl(CacheGroupContext grp)`

### Method Summary

All Methods Instance Methods Concrete Methods
`CacheGroupContext` `context()`
`PartitionUpdateCounter` `copy()`
`boolean` `empty()`
`boolean` `equals(Object o)`
`GridLongList` `finalizeUpdateCounters()` Flushes pending update counters closing all possible gaps.
`long` `get()` Get LWM.
`@Nullable byte[]` `getBytes()`
`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)`

### 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
                     @Nullable byte[] cntrUpdData)

Restores update counter state.

Specified by:
  `init` in interface `PartitionUpdateCounter`
Parameters:
  `initUpdCntr` - LWM.
  `cntrUpdData` - Counter updates raw data.

#### initial

    public long initial()

Specified by:
  `initial` in interface `PartitionUpdateCounter`

#### get

    public long get()

Get LWM.

Specified by:
  `get` in interface `PartitionUpdateCounter`
Returns:
  Current LWM.

#### next

    public long next()

Increment LWM by 1.

Specified by:
  `next` in interface `PartitionUpdateCounter`
Returns:
  New LWM.

#### update

    public void update(long val)

Sets update counter to absolute value. All missed updates will be discarded.

Specified by:
  `update` in interface `PartitionUpdateCounter`
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:
  `update` in interface `PartitionUpdateCounter`
Parameters:
  `start` - Start (<= lwm).
  `delta` - Delta.
Returns:
  `True` if update was actually applied.

#### updateInitial

    public void updateInitial(long start,
                              long delta)

Specified by:
  `updateInitial` in interface `PartitionUpdateCounter`
Parameters:
  `start` - Counter.
  `delta` - Delta.

#### finalizeUpdateCounters

    public GridLongList finalizeUpdateCounters()

Flushes pending update counters closing all possible gaps.

Specified by:
  `finalizeUpdateCounters` in interface `PartitionUpdateCounter`
Returns:
  Even-length array of pairs [start, end] for each gap.

#### reserve

    public long reserve(long delta)

Increment HWM by delta.

Specified by:
  `reserve` in interface `PartitionUpdateCounter`
Parameters:
  `delta` - Delta.
Returns:
  New HWM.

#### next

    public long next(long delta)

Increment LWM by delta.

Specified by:
  `next` in interface `PartitionUpdateCounter`
Parameters:
  `delta` - Delta.
Returns:
  New LWM.

#### sequential

    public boolean sequential()

Specified by:
  `sequential` in interface `PartitionUpdateCounter`
Returns:
  `True` if counter has no missed updates.

#### getBytes

    @Nullable
    public @Nullable byte[] getBytes()

Specified by:
  `getBytes` in interface `PartitionUpdateCounter`

#### reset

    public void reset()

Reset counter internal state to zero.

Specified by:
  `reset` in interface `PartitionUpdateCounter`

#### resetInitialCounter

    public void resetInitialCounter()

Reset the initial counter value to zero.

Specified by:
  `resetInitialCounter` in interface `PartitionUpdateCounter`

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### reserved

    public long reserved()

Returns HWM.

Specified by:
  `reserved` in interface `PartitionUpdateCounter`
Returns:
  Current HWM.

#### empty

    public boolean empty()

Specified by:
  `empty` in interface `PartitionUpdateCounter`
Returns:
  `True` if counter has not seen any update.

#### iterator

    public Iterator<long[]> iterator()

Specified by:
  `iterator` in interface `Iterable<long[]>`
Specified by:
  `iterator` in interface `PartitionUpdateCounter`
Returns:
  Iterator for pairs [start, range] for each out-of-order update in the update counter sequence.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### context

    public CacheGroupContext context()

Specified by:
  `context` in interface `PartitionUpdateCounter`
Returns:
  Cache group context.

#### copy

    public PartitionUpdateCounter copy()

Specified by:
  `copy` in interface `PartitionUpdateCounter`
Returns:
  A deep copy of current instance.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.9.1
Release Date | : December 9 2020