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);
}
Aggregations