Interface MaintenanceRegistry
-
public interface MaintenanceRegistryMaintenanceRegistryis a service local to each Ignite node that allows to request performing maintenance actions on that particular node.When a node gets into a situation when some specific actions are required it enters the special mode called maintenance mode. In maintenance mode it doesn't join to the rest of the cluster but still allows to connect to it with control.{sh|bat} script or via JXM interface and perform needed actions.
Implementing new task for maintenance mode requires several pieces of code.
-
First, component requiring Maintenance Mode should be able to register new
MaintenanceTaskwithregisterMaintenanceTask(MaintenanceTask)method. Registration could happen automatically (e.g. if component detects some emergency situation that requires user intervention) or by user request (e.g. for a planned maintenance that requires detaching node from the rest of the cluster). -
Component responsible for handling this
MaintenanceTaskon startup checks if the task is registered (thus it should go to Maintenance Mode). If task is found component provides toMaintenanceRegistryits own implementation ofMaintenanceWorkflowCallbackinterface via methodregisterWorkflowCallback(String, MaintenanceWorkflowCallback). -
MaintenanceWorkflowCallbackshould provideMaintenanceRegistrywithMaintenanceActions that are able to resolve maintenance task, get information about it and so on. Logic of these actions is completely up to the component providing it and depends only on particular maintenance task. -
When maintenance task is fixed, it should be removed from
MaintenanceRegistrywith callunregisterMaintenanceTask(String).
-
First, component requiring Maintenance Mode should be able to register new
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description List<MaintenanceAction<?>>actionsForMaintenanceTask(String maintenanceTaskName)AllMaintenanceActions provided by a component forMaintenanceTaskwith a given name.@Nullable MaintenanceTaskactiveMaintenanceTask(String maintenanceTaskName)Returns activeMaintenanceTaskby its name.booleanisMaintenanceMode()voidprepareAndExecuteMaintenance()Examine all components if they need to execute maintenance actions.@Nullable MaintenanceTaskregisterMaintenanceTask(MaintenanceTask task)Method to registerMaintenanceTasklocally on the node where method is called.voidregisterMaintenanceTask(MaintenanceTask task, UnaryOperator<MaintenanceTask> remappingFunction)Method to registerMaintenanceTasklocally on the node where method is called.voidregisterWorkflowCallback(@NotNull String maintenanceTaskName, @NotNull MaintenanceWorkflowCallback cb)RegistersMaintenanceWorkflowCallbackfor aMaintenanceTaskwith a given name.default voidregisterWorkflowCallbackIfTaskExists(@NotNull String maintenanceTaskName, @NotNull org.apache.ignite.internal.util.lang.IgniteThrowableFunction<MaintenanceTask,MaintenanceWorkflowCallback> workflowCalProvider)Call theregisterWorkflowCallback(String, MaintenanceWorkflowCallback)if the active maintenance task with given name exists.@Nullable MaintenanceTaskrequestedTask(String maintenanceTaskName)booleanunregisterMaintenanceTask(String maintenanceTaskName)DeletesMaintenanceTaskof given ID from maintenance registry.
-
-
-
Method Detail
-
isMaintenanceMode
boolean isMaintenanceMode()
- Returns:
Trueif any maintenance task was found.
-
registerMaintenanceTask
@Nullable @Nullable MaintenanceTask registerMaintenanceTask(MaintenanceTask task) throws IgniteCheckedException
Method to registerMaintenanceTasklocally 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.
- Parameters:
task-MaintenanceTaskobject with maintenance information that needs to be stored to maintenance registry.- Returns:
- Previously registered
MaintenanceTaskwith the same ID or null if no tasks were registered for this ID. - Throws:
IgniteCheckedException- If handling or storing maintenance task failed.
-
registerMaintenanceTask
void registerMaintenanceTask(MaintenanceTask task, UnaryOperator<MaintenanceTask> remappingFunction) throws IgniteCheckedException
Method to registerMaintenanceTasklocally 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 theregisterMaintenanceTask(MaintenanceTask).- Parameters:
task-MaintenanceTaskobject with maintenance information that needs to be stored to maintenance registry.remappingFunction- Function to compute a task if an oldMaintenanceTaskwith the same name exists.- Throws:
IgniteCheckedException- If handling or storing maintenance task failed.
-
unregisterMaintenanceTask
boolean unregisterMaintenanceTask(String maintenanceTaskName)
DeletesMaintenanceTaskof given ID from maintenance registry.- Parameters:
maintenanceTaskName- name ofMaintenanceTaskto be deleted.- Returns:
trueif existing task has been deleted.
-
activeMaintenanceTask
@Nullable @Nullable MaintenanceTask activeMaintenanceTask(String maintenanceTaskName)
Returns activeMaintenanceTaskby its name. There are active tasks only when node entered Maintenance Mode.MaintenanceTaskbecomes active when node enters Maintenance Mode and doesn't resolve the task during maintenance prepare phase.- Parameters:
maintenanceTaskName- Maintenance Task name.- Returns:
MaintenanceTaskobject for given name or null if no maintenance task was found.
-
registerWorkflowCallback
void registerWorkflowCallback(@NotNull @NotNull String maintenanceTaskName, @NotNull @NotNull MaintenanceWorkflowCallback cb)RegistersMaintenanceWorkflowCallbackfor aMaintenanceTaskwith a given name. Component registeredMaintenanceTaskautomatically or by user request is responsible for providingMaintenanceRegistrywith an implementation ofMaintenanceWorkflowCallbackwhere registry obtainsMaintenanceActions to be executed for this task and does a preliminary check before starting maintenance.- Parameters:
maintenanceTaskName- name ofMaintenanceTaskthis callback is registered for.cb-MaintenanceWorkflowCallbackinterface used by MaintenanceRegistry to execute maintenance steps by workflow.
-
actionsForMaintenanceTask
List<MaintenanceAction<?>> actionsForMaintenanceTask(String maintenanceTaskName)
AllMaintenanceActions provided by a component forMaintenanceTaskwith a given name.- Parameters:
maintenanceTaskName- name of Maintenance Task.- Returns:
Listof all availableMaintenanceActions for given Maintenance Task.- Throws:
IgniteException- if no Maintenance Tasks are registered for provided name.
-
prepareAndExecuteMaintenance
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 tasksfor these components are removed and theirmaintenance actionsare not executed.
-
registerWorkflowCallbackIfTaskExists
default void registerWorkflowCallbackIfTaskExists(@NotNull @NotNull String maintenanceTaskName, @NotNull @NotNull org.apache.ignite.internal.util.lang.IgniteThrowableFunction<MaintenanceTask,MaintenanceWorkflowCallback> workflowCalProvider) throws IgniteCheckedExceptionCall theregisterWorkflowCallback(String, MaintenanceWorkflowCallback)if the active maintenance task with given name exists.- Parameters:
maintenanceTaskName- name ofMaintenanceTaskthis callback is registered for.workflowCalProvider- provider ofMaintenanceWorkflowCallbackwhich construct the callback by given task.- Throws:
IgniteCheckedException
-
requestedTask
@Nullable @Nullable MaintenanceTask requestedTask(String maintenanceTaskName)
- Parameters:
maintenanceTaskName- Task's name.- Returns:
- Requested maintenance task or
null.
-
-