org.apache.ignite.internal.processors.cache.mvcc

## Class MvccProcessorImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.processors.cache.mvcc.MvccProcessorImpl

All Implemented Interfaces:
  GridComponent, MvccProcessor, DatabaseLifecycleListener, GridProcessor

    public class MvccProcessorImpl
    extends GridProcessorAdapter
    implements MvccProcessor, DatabaseLifecycleListener

MVCC processor.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent

`GridComponent.DiscoveryDataExchangeType`

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`ctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`MvccProcessorImpl(GridKernalContext ctx)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `ackQueryDone(MvccSnapshot snapshot, long qryId)`
`IgniteInternalFuture<Void>` `ackTxCommit(MvccSnapshot updateVer)`
`void` `ackTxRollback(MvccVersion updateVer)`
`void` `addQueryTracker(MvccQueryTracker tracker)`
`void` `afterBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr, GridCacheDatabaseSharedManager.RestoreBinaryState restoreState)` Callback executed when binary memory has fully restored and WAL logging is resumed.
`void` `beforeBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr)` Callback executed right before node become perform binary recovery.
`void` `beforeResumeWalLogging(IgniteCacheDatabaseSharedManager mgr)` Callback executed when all physical updates are applied and we are ready to write new physical records during logical recovery.
`void` `beforeStop(IgniteCacheDatabaseSharedManager mgr)` Callback executed before shared manager will be stopped.
`Optional<? extends MvccVersion>` `checkWaiting(MvccVersion mvccVer)` Checks whether one tx is waiting for another tx.
`@NotNull MvccCoordinator` `currentCoordinator()`
`void` `dumpDebugInfo(IgniteLogger log, @Nullable IgniteDiagnosticPrepareContext diagCtx)`
`void` `ensureStarted()` Starts MVCC processor (i.e. initialises data structures and vacuum) if it has not been started yet.
`void` `failWaiter(MvccVersion mvccVer, Exception e)` Unfreezes waiter for specific version failing it with passed exception.
`boolean` `hasLocalTransaction(long crd, long cntr)`
`boolean` `mvccEnabled()`
`void` `onCacheStop(GridCacheContext cctx)` Cache stop callback.
`void` `onDisconnected(IgniteFuture<?> reconnectFut)` Client disconnected callback.
`void` `onExchangeDone(DiscoCache discoCache)` Exchange done callback.
`void` `onInitDataRegions(IgniteCacheDatabaseSharedManager mgr)` Callback executed when data regions become to start-up.
`void` `onKernalStop(boolean cancel)` Callback to notify that kernal is about to stop.
`void` `onLocalJoin(DiscoveryEvent evt, DiscoCache discoCache)` Local join callback.
`void` `preProcessCacheConfiguration(CacheConfiguration ccfg)` Pre-processes cache configuration before start.
`void` `registerLocalTransaction(long crd, long cntr)`
`void` `releaseWaiters(MvccVersion locked)`
`void` `removeQueryTracker(Long id)`
`IgniteInternalFuture<MvccSnapshot>` `requestReadSnapshotAsync()` Requests snapshot on Mvcc coordinator.
`void` `requestReadSnapshotAsync(MvccCoordinator crd, MvccSnapshotResponseListener lsnr)` Requests snapshot on Mvcc coordinator.
`MvccSnapshot` `requestReadSnapshotLocal()`
`IgniteInternalFuture<MvccSnapshot>` `requestWriteSnapshotAsync()` Requests snapshot on Mvcc coordinator.
`void` `requestWriteSnapshotAsync(MvccCoordinator crd, MvccSnapshotResponseListener lsnr)` Requests snapshot on Mvcc coordinator.
`MvccSnapshot` `requestWriteSnapshotLocal()`
`void` `start()` Starts grid component.
`byte` `state(long crdVer, long cntr)`
`byte` `state(MvccVersion ver)`
`void` `stopTxLog()` Force txLog stop.
`void` `updateState(MvccVersion ver, byte state)`
`void` `updateState(MvccVersion ver, byte state, boolean primary)`
`void` `validateCacheConfiguration(CacheConfiguration ccfg)` Validates cache configuration before start.
`@Nullable IgniteNodeValidationResult` `validateNode(ClusterNode node)` Validates that new node can join grid topology, this method is called on coordinator node before new node joins topology.
`IgniteInternalFuture<Void>` `waitForLock(GridCacheContext cctx, MvccVersion waiterVer, MvccVersion blockerVer)` Stands in the lock wait queue for the current lock holder.

### Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`assertParameter, collectGridNodeData, collectJoiningNodeData, discoveryDataType, onGridDataReceived, onJoiningNodeDataReceived, onKernalStart, onReconnected, printMemoryStats, stop, toString, validateNode`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.apache.ignite.internal.GridComponent

`collectGridNodeData, collectJoiningNodeData, discoveryDataType, onGridDataReceived, onJoiningNodeDataReceived, onKernalStart, onReconnected, printMemoryStats, stop, validateNode`

### Methods inherited from interface org.apache.ignite.internal.processors.cache.persistence.DatabaseLifecycleListener

`afterInitialise, afterLogicalUpdatesApplied, onBaselineChange`

### Constructor Detail

#### MvccProcessorImpl

    public MvccProcessorImpl(GridKernalContext ctx)

Parameters:
  `ctx` - Context.

### Method Detail

#### start

    public void start()
               throws IgniteCheckedException

Starts grid component.

Specified by:
  `start` in interface `GridComponent`
Overrides:
  `start` in class `GridProcessorAdapter`
Throws:
  `IgniteCheckedException` - Throws in case of any errors.

#### mvccEnabled

    public boolean mvccEnabled()

Specified by:
  `mvccEnabled` in interface `MvccProcessor`
Returns:
  `True` if at least one cache with `CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT` mode is registered.

#### preProcessCacheConfiguration

    public void preProcessCacheConfiguration(CacheConfiguration ccfg)

Pre-processes cache configuration before start.

Specified by:
  `preProcessCacheConfiguration` in interface `MvccProcessor`
Parameters:
  `ccfg` - Cache configuration to pre-process.

#### validateCacheConfiguration

    public void validateCacheConfiguration(CacheConfiguration ccfg)

Validates cache configuration before start.

Specified by:
  `validateCacheConfiguration` in interface `MvccProcessor`
Parameters:
  `ccfg` - Cache configuration to validate.

#### validateNode

    @Nullable
    public @Nullable IgniteNodeValidationResult validateNode(ClusterNode node)

Validates that new node can join grid topology, this method is called on coordinator node before new node joins topology.

Specified by:
  `validateNode` in interface `GridComponent`
Overrides:
  `validateNode` in class `GridProcessorAdapter`
Parameters:
  `node` - Joining node.
Returns:
  Validation result or `null` in case of success.

#### ensureStarted

    public void ensureStarted()
                       throws IgniteCheckedException

Starts MVCC processor (i.e. initialises data structures and vacuum) if it has not been started yet.

Specified by:
  `ensureStarted` in interface `MvccProcessor`
Throws:
  `IgniteCheckedException` - If failed to initialize.

#### onCacheStop

    public void onCacheStop(GridCacheContext cctx)

Cache stop callback.

Specified by:
  `onCacheStop` in interface `MvccProcessor`
Parameters:
  `cctx` - Cache context.

#### beforeStop

    public void beforeStop(IgniteCacheDatabaseSharedManager mgr)

Callback executed before shared manager will be stopped.

Specified by:
  `beforeStop` in interface `DatabaseLifecycleListener`
Parameters:
  `mgr` - Database shared manager.

#### stopTxLog

    public void stopTxLog()

Force txLog stop.

Specified by:
  `stopTxLog` in interface `MvccProcessor`

#### onInitDataRegions

    public void onInitDataRegions(IgniteCacheDatabaseSharedManager mgr)
                           throws IgniteCheckedException

Callback executed when data regions become to start-up.

Specified by:
  `onInitDataRegions` in interface `DatabaseLifecycleListener`
Parameters:
  `mgr` - Database shared manager.
Throws:
  `IgniteCheckedException` - If failed.

#### beforeResumeWalLogging

    public void beforeResumeWalLogging(IgniteCacheDatabaseSharedManager mgr)
                                throws IgniteCheckedException

Callback executed when all physical updates are applied and we are ready to write new physical records during logical recovery.

Specified by:
  `beforeResumeWalLogging` in interface `DatabaseLifecycleListener`
Parameters:
  `mgr` - Database shared manager.
Throws:
  `IgniteCheckedException` - If failed.

#### beforeBinaryMemoryRestore

    public void beforeBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr)
                                   throws IgniteCheckedException

Callback executed right before node become perform binary recovery.

Specified by:
  `beforeBinaryMemoryRestore` in interface `DatabaseLifecycleListener`
Parameters:
  `mgr` - Database shared manager.
Throws:
  `IgniteCheckedException` - If failed.

#### afterBinaryMemoryRestore

    public void afterBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr,
                                         GridCacheDatabaseSharedManager.RestoreBinaryState restoreState)
                                  throws IgniteCheckedException

Callback executed when binary memory has fully restored and WAL logging is resumed.

Specified by:
  `afterBinaryMemoryRestore` in interface `DatabaseLifecycleListener`
  `restoreState` - Result of binary recovery.
Throws:
  `IgniteCheckedException` - If failed.

#### onExchangeDone

    public void onExchangeDone(DiscoCache discoCache)

Exchange done callback.

Specified by:
  `onExchangeDone` in interface `MvccProcessor`
Parameters:
  `discoCache` - Disco cache.

#### onLocalJoin

    public void onLocalJoin(DiscoveryEvent evt,
                            DiscoCache discoCache)

Local join callback.

Specified by:
  `onLocalJoin` in interface `MvccProcessor`
Parameters:
  `evt` - Discovery event.
  `discoCache` - Disco cache.

#### onDisconnected

    public void onDisconnected(IgniteFuture<?> reconnectFut)

Client disconnected callback.

Specified by:
  `onDisconnected` in interface `GridComponent`
Overrides:
  `onDisconnected` in class `GridProcessorAdapter`
Parameters:
  `reconnectFut` - Reconnect future.

#### onKernalStop

    public void onKernalStop(boolean cancel)

Callback to notify that kernal is about to stop.

Specified by:
  `onKernalStop` in interface `GridComponent`
Overrides:
  `onKernalStop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - Flag indicating whether jobs should be canceled.

#### currentCoordinator

    @NotNull
    public @NotNull MvccCoordinator currentCoordinator()

Specified by:
  `currentCoordinator` in interface `MvccProcessor`
Returns:
  Coordinator.

#### state

    public byte state(MvccVersion ver)

Specified by:
  `state` in interface `MvccProcessor`
Parameters:
  `ver` - Version to check.
Returns:
  State for given mvcc version.

#### state

    public byte state(long crdVer,
                      long cntr)

Specified by:
  `state` in interface `MvccProcessor`
Parameters:
  `crdVer` - Mvcc coordinator version.
  `cntr` - Mvcc counter.
Returns:
  State for given mvcc version.

#### updateState

    public void updateState(MvccVersion ver,
                            byte state)

Specified by:
  `updateState` in interface `MvccProcessor`
Parameters:
  `ver` - Version.
  `state` - State.

#### updateState

    public void updateState(MvccVersion ver,
                            byte state,
                            boolean primary)

Specified by:
  `updateState` in interface `MvccProcessor`
Parameters:
  `ver` - Version.
  `state` - State.
  `primary` - Flag if this is primary node.

#### registerLocalTransaction

    public void registerLocalTransaction(long crd,
                                         long cntr)

Specified by:
  `registerLocalTransaction` in interface `MvccProcessor`
Parameters:
  `crd` - Mvcc coordinator version.
  `cntr` - Mvcc counter.

#### hasLocalTransaction

    public boolean hasLocalTransaction(long crd,
                                       long cntr)

Specified by:
  `hasLocalTransaction` in interface `MvccProcessor`
Parameters:
  `crd` - Mvcc coordinator version.
  `cntr` - Mvcc counter.
Returns:
  `True` if there is an active local transaction with given version.

#### waitForLock

    public IgniteInternalFuture<Void> waitForLock(GridCacheContext cctx,
                                                  MvccVersion waiterVer,
                                                  MvccVersion blockerVer)

Stands in the lock wait queue for the current lock holder.

Specified by:
  `waitForLock` in interface `MvccProcessor`
Parameters:
  `cctx` - Cache context.
  `waiterVer` - Version of the waiting tx.
  `blockerVer` - Version the entry is locked by.
Returns:
  Future, which is completed as soon as the lock is released.

#### releaseWaiters

    public void releaseWaiters(MvccVersion locked)

Specified by:
  `releaseWaiters` in interface `MvccProcessor`
Parameters:
  `locked` - Version the entry is locked by.

#### addQueryTracker

    public void addQueryTracker(MvccQueryTracker tracker)

Specified by:
  `addQueryTracker` in interface `MvccProcessor`
Parameters:
  `tracker` - Query tracker.

#### removeQueryTracker

    public void removeQueryTracker(Long id)

Specified by:
  `removeQueryTracker` in interface `MvccProcessor`
Parameters:
  `id` - Query tracker id.

#### requestWriteSnapshotLocal

    public MvccSnapshot requestWriteSnapshotLocal()

Specified by:
  `requestWriteSnapshotLocal` in interface `MvccProcessor`
Returns:
  `MvccSnapshot` if this is a coordinator node and coordinator is initialized. `Null` in other cases.

#### requestReadSnapshotLocal

    public MvccSnapshot requestReadSnapshotLocal()

Specified by:
  `requestReadSnapshotLocal` in interface `MvccProcessor`
Returns:
  `MvccSnapshot` if this is a coordinator node and coordinator is initialized. `Null` in other cases.

#### requestReadSnapshotAsync

    public IgniteInternalFuture<MvccSnapshot> requestReadSnapshotAsync()

Requests snapshot on Mvcc coordinator.

Specified by:
  `requestReadSnapshotAsync` in interface `MvccProcessor`
Returns:
  Result future.

#### requestWriteSnapshotAsync

    public IgniteInternalFuture<MvccSnapshot> requestWriteSnapshotAsync()

Requests snapshot on Mvcc coordinator.

Specified by:
  `requestWriteSnapshotAsync` in interface `MvccProcessor`
Returns:
  Result future.

#### requestReadSnapshotAsync

    public void requestReadSnapshotAsync(MvccCoordinator crd,
                                         MvccSnapshotResponseListener lsnr)

Requests snapshot on Mvcc coordinator.

Specified by:
  `requestReadSnapshotAsync` in interface `MvccProcessor`
Parameters:
  `crd` - Expected coordinator.
  `lsnr` - Request listener.

#### requestWriteSnapshotAsync

    public void requestWriteSnapshotAsync(MvccCoordinator crd,
                                          MvccSnapshotResponseListener lsnr)

Requests snapshot on Mvcc coordinator.

Specified by:
  `requestWriteSnapshotAsync` in interface `MvccProcessor`
Parameters:
  `crd` - Expected coordinator.
  `lsnr` - Request listener.

#### ackTxCommit

    public IgniteInternalFuture<Void> ackTxCommit(MvccSnapshot updateVer)

Specified by:
  `ackTxCommit` in interface `MvccProcessor`
Parameters:
  `updateVer` - Transaction update version.
Returns:
  Acknowledge future.

#### ackTxRollback

    public void ackTxRollback(MvccVersion updateVer)

Specified by:
  `ackTxRollback` in interface `MvccProcessor`
Parameters:
  `updateVer` - Transaction update version.

#### ackQueryDone

    public void ackQueryDone(MvccSnapshot snapshot,
                             long qryId)

Specified by:
  `ackQueryDone` in interface `MvccProcessor`
Parameters:
  `snapshot` - Query version.
  `qryId` - Query tracker ID.

#### dumpDebugInfo

    public void dumpDebugInfo(IgniteLogger log,
                              @Nullable
                              @Nullable IgniteDiagnosticPrepareContext diagCtx)

Specified by:
  `dumpDebugInfo` in interface `MvccProcessor`
Parameters:
  `log` - Logger.
  `diagCtx` - Diagnostic request.

#### checkWaiting

    public Optional<? extends MvccVersion> checkWaiting(MvccVersion mvccVer)

Checks whether one tx is waiting for another tx. It is assumed that locks on data nodes are requested one by one, so tx can wait only for one another tx here.

Specified by:
  `checkWaiting` in interface `MvccProcessor`
Parameters:
  `mvccVer` - Version of transaction which is checked for being waiting.
Returns:
  Version of tx which blocks checked tx.

#### failWaiter

    public void failWaiter(MvccVersion mvccVer,
                           Exception e)

Unfreezes waiter for specific version failing it with passed exception.

Specified by:
  `failWaiter` in interface `MvccProcessor`
Parameters:
  `mvccVer` - Version of a waiter to fail.
  `e` - Exception reflecting failure reason.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022