org.apache.ignite.internal.processors.localtask

## Class DurableBackgroundTasksProcessor

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.processors.localtask.DurableBackgroundTasksProcessor

All Implemented Interfaces:
  GridComponent, CheckpointListener, MetastorageLifecycleListener, GridProcessor

    public class DurableBackgroundTasksProcessor
    extends GridProcessorAdapter
    implements MetastorageLifecycleListener, CheckpointListener

Processor that is responsible for durable background tasks that are executed on local node.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointListener

`CheckpointListener.Context`

### 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
`DurableBackgroundTasksProcessor(GridKernalContext ctx)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `afterCheckpointEnd(CheckpointListener.Context ctx)` Do some actions after checkpoint end.
`void` `beforeCheckpointBegin(CheckpointListener.Context ctx)` Do some actions before checkpoint write lock.
`<R> IgniteInternalFuture<R>` `executeAsync(DurableBackgroundTask<R> task, boolean save)` Asynchronous execution of a durable background task.
`<R> IgniteInternalFuture<R>` `executeAsync(DurableBackgroundTask<R> t, CacheConfiguration cacheCfg)` Overloading the `executeAsync(DurableBackgroundTask, boolean)`.
`void` `onCheckpointBegin(CheckpointListener.Context ctx)`
`void` `onKernalStop(boolean cancel)` Callback to notify that kernal is about to stop.
`void` `onMarkCheckpointBegin(CheckpointListener.Context ctx)`
`void` `onReadyForRead(ReadOnlyMetastorage metastorage)` Is called when metastorage is made ready for read-only operations very early on node startup phase.
`void` `onReadyForReadWrite(ReadWriteMetastorage metastorage)` Fully functional metastore capable of performing reading and writing operations.
`void` `onStateChangeFinish(ChangeGlobalStateFinishMessage msg)` Callback on finish of a global state change.
`void` `onStateChangeStarted(ChangeGlobalStateMessage msg)` Callback at the start of a global state change.
`void` `start()` Starts grid component.

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

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

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

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

### Constructor Detail

#### DurableBackgroundTasksProcessor

    public DurableBackgroundTasksProcessor(GridKernalContext ctx)

Constructor.

Parameters:
  `ctx` - Kernal 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.

#### 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.

#### onReadyForRead

    public void onReadyForRead(ReadOnlyMetastorage metastorage)

Is called when metastorage is made ready for read-only operations very early on node startup phase. Reference for read-only metastorage should be used only within this method and shouldn't be stored to any field.

Specified by:
  `onReadyForRead` in interface `MetastorageLifecycleListener`
Parameters:
  `metastorage` - Read-only meta storage.

#### onReadyForReadWrite

    public void onReadyForReadWrite(ReadWriteMetastorage metastorage)

Fully functional metastore capable of performing reading and writing operations. Components interested in using metastore are allowed to keep reference passed into the method in their fields.

Specified by:
  `onReadyForReadWrite` in interface `MetastorageLifecycleListener`
Parameters:
  `metastorage` - Fully functional meta storage.

#### beforeCheckpointBegin

    public void beforeCheckpointBegin(CheckpointListener.Context ctx)

Do some actions before checkpoint write lock.

Specified by:
  `beforeCheckpointBegin` in interface `CheckpointListener`

#### onMarkCheckpointBegin

    public void onMarkCheckpointBegin(CheckpointListener.Context ctx)

Specified by:
  `onMarkCheckpointBegin` in interface `CheckpointListener`

#### onCheckpointBegin

    public void onCheckpointBegin(CheckpointListener.Context ctx)

Specified by:
  `onCheckpointBegin` in interface `CheckpointListener`

#### afterCheckpointEnd

    public void afterCheckpointEnd(CheckpointListener.Context ctx)

Do some actions after checkpoint end.

Specified by:
  `afterCheckpointEnd` in interface `CheckpointListener`

#### onStateChangeStarted

    public void onStateChangeStarted(ChangeGlobalStateMessage msg)

Callback at the start of a global state change.

Parameters:
  `msg` - Message for change cluster global state.

#### onStateChangeFinish

    public void onStateChangeFinish(ChangeGlobalStateFinishMessage msg)

Callback on finish of a global state change.

Parameters:
  `msg` - Finish message for change cluster global state.

#### executeAsync

    public <R> IgniteInternalFuture<R> executeAsync(DurableBackgroundTask<R> task,
                                                    boolean save)

Asynchronous execution of a durable background task. A new task will be added for execution either if there is no task with the same `name` or it (previous) will be completed. If the task is required to be completed after restarting the node, then it must be saved to the MetaStorage. If the task is saved to the Metastorage, then it will be deleted from it only after its completion and at the end of the checkpoint. Otherwise, it will be removed as soon as it is completed.

Parameters:
  `task` - Durable background task.
  `save` - Save task to MetaStorage.
Returns:
  Futures that will complete when the task is completed.

#### executeAsync

    public <R> IgniteInternalFuture<R> executeAsync(DurableBackgroundTask<R> t,
                                                    CacheConfiguration cacheCfg)

Overloading the `executeAsync(DurableBackgroundTask, boolean)`. If task is applied to persistent cache, saves it to MetaStorage.

Parameters:
  `t` - Durable background task.
  `cacheCfg` - Cache configuration.
Returns:
  Futures that will complete when the task is completed.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

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