org.apache.ignite.internal.maintenance

## Class MaintenanceProcessor

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.maintenance.MaintenanceProcessor

All Implemented Interfaces:
  GridComponent, GridProcessor, MaintenanceRegistry

    public class MaintenanceProcessor
    extends GridProcessorAdapter
    implements MaintenanceRegistry

### 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
`MaintenanceProcessor(GridKernalContext ctx)`

### Method Summary

All Methods Instance Methods Concrete Methods
`List<MaintenanceAction<?>>` `actionsForMaintenanceTask(String maintenanceTaskName)` All `MaintenanceAction`s provided by a component for `MaintenanceTask` with a given name.
`@Nullable MaintenanceTask` `activeMaintenanceTask(String maitenanceTaskName)` Returns active `MaintenanceTask` by its name.
`boolean` `isMaintenanceMode()`
`void` `prepareAndExecuteMaintenance()` Examine all components if they need to execute maintenance actions.
`@Nullable MaintenanceTask` `registerMaintenanceTask(MaintenanceTask task)` Method to register `MaintenanceTask` locally on the node where method is called.
`void` `registerMaintenanceTask(MaintenanceTask task, UnaryOperator<MaintenanceTask> remappingFunction)` Method to register `MaintenanceTask` locally on the node where method is called.
`void` `registerWorkflowCallback(@NotNull String maintenanceTaskName, @NotNull MaintenanceWorkflowCallback cb)` Registers `MaintenanceWorkflowCallback` for a `MaintenanceTask` with a given name.
`@Nullable MaintenanceTask` `requestedTask(String maintenanceTaskName)`
`void` `start()` Starts grid component.
`void` `stop(boolean cancel)` Stops grid component.
`boolean` `unregisterMaintenanceTask(String maintenanceTaskName)` Deletes `MaintenanceTask` of given ID from maintenance registry.

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

`assertParameter, collectGridNodeData, collectJoiningNodeData, discoveryDataType, onDisconnected, onGridDataReceived, onJoiningNodeDataReceived, onKernalStart, onKernalStop, onReconnected, printMemoryStats, toString, validateNode, 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.maintenance.MaintenanceRegistry

`registerWorkflowCallbackIfTaskExists`

### Constructor Detail

#### MaintenanceProcessor

    public MaintenanceProcessor(GridKernalContext ctx)

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### registerMaintenanceTask

    @Nullable
    public @Nullable MaintenanceTask registerMaintenanceTask(MaintenanceTask task)
                                                                throws IgniteCheckedException

Method to register `MaintenanceTask` locally on the node where method is called.

For now it is not allowed to register new Maintenance Tasks in Maintenance Mode so this method should be called only when node operates normally. This may change in the future so it will become possible to create other maintenance tasks on node that is already entered Maintenance Mode.

When task is registered node continues to operate normally and will enter Maintenance Mode only after restart.

Specified by:
  `registerMaintenanceTask` in interface `MaintenanceRegistry`
Parameters:
  `task` - `MaintenanceTask` object with maintenance information that needs to be stored to maintenance registry.
Returns:
  Previously registered `MaintenanceTask` with the same ID or null if no tasks were registered for this ID.
Throws:
  `IgniteCheckedException` - If handling or storing maintenance task failed.

#### registerMaintenanceTask

    public void registerMaintenanceTask(MaintenanceTask task,
                                        UnaryOperator<MaintenanceTask> remappingFunction)
                                 throws IgniteCheckedException

Method to register `MaintenanceTask` locally on the node where method is called. If an old task with the same name exists, applies remapping function to compute a new task. Has the same restrictions as the `MaintenanceRegistry.registerMaintenanceTask(MaintenanceTask)`.

Specified by:
  `registerMaintenanceTask` in interface `MaintenanceRegistry`
Parameters:
  `task` - `MaintenanceTask` object with maintenance information that needs to be stored to maintenance registry.
  `remappingFunction` - Function to compute a task if an old `MaintenanceTask` with the same name exists.
Throws:
  `IgniteCheckedException` - If handling or storing maintenance task failed.

#### stop

    public void stop(boolean cancel)
              throws IgniteCheckedException

Stops grid component.

Specified by:
  `stop` in interface `GridComponent`
Overrides:
  `stop` in class `GridProcessorAdapter`
Parameters:
  `cancel` - If `true`, then all ongoing tasks or jobs for relevant components need to be cancelled.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

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

#### prepareAndExecuteMaintenance

    public void prepareAndExecuteMaintenance()

Examine all components if they need to execute maintenance actions. As user may resolve some maintenance situations by hand when the node was turned off, component may find out that no maintenance is needed anymore. `Maintenance tasks` for these components are removed and their `maintenance actions` are not executed.

Specified by:
  `prepareAndExecuteMaintenance` in interface `MaintenanceRegistry`

#### activeMaintenanceTask

    @Nullable
    public @Nullable MaintenanceTask activeMaintenanceTask(String maitenanceTaskName)

Returns active `MaintenanceTask` by its name. There are active tasks only when node entered Maintenance Mode. `MaintenanceTask` becomes active when node enters Maintenance Mode and doesn't resolve the task during maintenance prepare phase.

Specified by:
  `activeMaintenanceTask` in interface `MaintenanceRegistry`
Parameters:
  `maitenanceTaskName` - Maintenance Task name.
Returns:
  `MaintenanceTask` object for given name or null if no maintenance task was found.

#### isMaintenanceMode

    public boolean isMaintenanceMode()

Specified by:
  `isMaintenanceMode` in interface `MaintenanceRegistry`
Returns:
  `True` if any maintenance task was found.

#### unregisterMaintenanceTask

    public boolean unregisterMaintenanceTask(String maintenanceTaskName)

Deletes `MaintenanceTask` of given ID from maintenance registry.

Specified by:
  `unregisterMaintenanceTask` in interface `MaintenanceRegistry`
Parameters:
  `maintenanceTaskName` - name of `MaintenanceTask` to be deleted.
Returns:
  `true` if existing task has been deleted.

#### registerWorkflowCallback

    public void registerWorkflowCallback(@NotNull
                                         @NotNull String maintenanceTaskName,
                                         @NotNull
                                         @NotNull MaintenanceWorkflowCallback cb)

Registers `MaintenanceWorkflowCallback` for a `MaintenanceTask` with a given name. Component registered `MaintenanceTask` automatically or by user request is responsible for providing `MaintenanceRegistry` with an implementation of `MaintenanceWorkflowCallback` where registry obtains `MaintenanceAction`s to be executed for this task and does a preliminary check before starting maintenance.

Specified by:
  `registerWorkflowCallback` in interface `MaintenanceRegistry`
Parameters:
  `maintenanceTaskName` - name of `MaintenanceTask` this callback is registered for.
  `cb` - `MaintenanceWorkflowCallback` interface used by MaintenanceRegistry to execute maintenance steps by workflow.

#### actionsForMaintenanceTask

    public List<MaintenanceAction<?>> actionsForMaintenanceTask(String maintenanceTaskName)

All `MaintenanceAction`s provided by a component for `MaintenanceTask` with a given name.

Specified by:
  `actionsForMaintenanceTask` in interface `MaintenanceRegistry`
Parameters:
  `maintenanceTaskName` - name of Maintenance Task.
Returns:
  `List` of all available `MaintenanceAction`s for given Maintenance Task.

#### requestedTask

    @Nullable
    public @Nullable MaintenanceTask requestedTask(String maintenanceTaskName)

Specified by:
  `requestedTask` in interface `MaintenanceRegistry`
Parameters:
  `maintenanceTaskName` - Task's name.
Returns:
  Requested maintenance task or `null`.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.16.0
Release Date | : December 15 2023