Search in sources :

Example 1 with MaintenanceWorkflowCallback

use of org.apache.ignite.maintenance.MaintenanceWorkflowCallback in project ignite by apache.

the class MaintenanceProcessor method registerWorkflowCallback.

/**
 * {@inheritDoc}
 */
@Override
public void registerWorkflowCallback(@NotNull String maintenanceTaskName, @NotNull MaintenanceWorkflowCallback cb) {
    if (disabled)
        throw new IgniteException(DISABLED_ERR_MSG);
    List<MaintenanceAction<?>> actions = cb.allActions();
    if (actions == null || actions.isEmpty())
        throw new IgniteException("Maintenance workflow callback should provide at least one maintenance action");
    int size = actions.size();
    long distinctSize = actions.stream().map(MaintenanceAction::name).distinct().count();
    if (distinctSize < size)
        throw new IgniteException("All actions of a single workflow should have unique names: " + actions.stream().map(MaintenanceAction::name).collect(Collectors.joining(", ")));
    Optional<String> wrongActionName = actions.stream().map(MaintenanceAction::name).filter(name -> !U.alphanumericUnderscore(name)).findFirst();
    if (wrongActionName.isPresent())
        throw new IgniteException("All actions' names should contain only alphanumeric and underscore symbols: " + wrongActionName.get());
    workflowCallbacks.put(maintenanceTaskName, cb);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MaintenanceAction(org.apache.ignite.maintenance.MaintenanceAction) U(org.apache.ignite.internal.util.typedef.internal.U) IOException(java.io.IOException) MaintenanceTask(org.apache.ignite.maintenance.MaintenanceTask) Collectors(java.util.stream.Collectors) GridKernalContext(org.apache.ignite.internal.GridKernalContext) MaintenanceWorkflowCallback(org.apache.ignite.maintenance.MaintenanceWorkflowCallback) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) MaintenanceRegistry(org.apache.ignite.maintenance.MaintenanceRegistry) Map(java.util.Map) CU(org.apache.ignite.internal.util.typedef.internal.CU) Optional(java.util.Optional) GridProcessorAdapter(org.apache.ignite.internal.processors.GridProcessorAdapter) NotNull(org.jetbrains.annotations.NotNull) MaintenanceAction(org.apache.ignite.maintenance.MaintenanceAction) IgniteException(org.apache.ignite.IgniteException)

Aggregations

IOException (java.io.IOException)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Collectors (java.util.stream.Collectors)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 GridKernalContext (org.apache.ignite.internal.GridKernalContext)1 GridProcessorAdapter (org.apache.ignite.internal.processors.GridProcessorAdapter)1 CU (org.apache.ignite.internal.util.typedef.internal.CU)1 U (org.apache.ignite.internal.util.typedef.internal.U)1 MaintenanceAction (org.apache.ignite.maintenance.MaintenanceAction)1 MaintenanceRegistry (org.apache.ignite.maintenance.MaintenanceRegistry)1 MaintenanceTask (org.apache.ignite.maintenance.MaintenanceTask)1 MaintenanceWorkflowCallback (org.apache.ignite.maintenance.MaintenanceWorkflowCallback)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1