EgorBaranovEnjoysTyping commented on code in PR #12584:
URL: https://github.com/apache/ignite/pull/12584#discussion_r4770744168
##########
modules/core/src/main/java/org/apache/ignite/internal/maintenance/MaintenanceProcessor.java:
##########
@@ -332,11 +352,78 @@ private void proceedWithMaintenance() {
throw new IgniteException("Maintenance workflow callback for given
task name not found, " +
"cannot retrieve maintenance actions for it: " +
maintenanceTaskName);
- return workflowCallbacks.get(maintenanceTaskName).allActions();
+ List<MaintenanceAction<?>> actions = new ArrayList<>();
+
+ for (MaintenanceAction<?> action :
workflowCallbacks.get(maintenanceTaskName).allActions()) {
+ actions.add(trackedAction(maintenanceTaskName, action));
+ }
+
+ return actions;
}
/** {@inheritDoc} */
@Nullable @Override public MaintenanceTask requestedTask(String
maintenanceTaskName) {
return requestedTasks.get(maintenanceTaskName);
}
+
+ /** @return List of the current states of {@link MaintenanceTask
maintenance tasks} pending logging. */
+ public List<MaintenanceTaskState> tasksStates() {
+ return tasksStates.values().stream()
+ .sorted(Comparator.comparing(s ->
s.task().name())).collect(Collectors.toList());
+ }
+
+ /** */
+ private <T> MaintenanceAction<T> trackedAction(String taskName,
MaintenanceAction<T> action) {
+ if (!tasksStates.containsKey(taskName))
+ return action;
+
+ MaintenanceTaskState state = tasksStates.get(taskName);
+
+ MaintenanceTaskState.ActionLifecycle lifecycle = new
MaintenanceTaskState.ActionLifecycle(action.name());
+
+ return new MaintenanceAction<>() {
+ @Override public String name() {
+ return action.name();
+ }
+
+ @Override public String description() {
+ return action.description();
+ }
+
+ @Override public T execute() {
+ try {
+ state.addActionLifecycle(lifecycle);
+
+ lifecycle.state(State.ACTIVE);
+
+ T res = action.execute();
+
+ if (res instanceof CompletableFuture<?>) {
+ ((CompletionStage<?>)res).whenComplete((result, error)
-> {
+ if (error != null)
+ lifecycle.state(State.FAILED);
+ else if (Boolean.FALSE.equals(result))
+ lifecycle.state(State.CANCELLED);
+ else
+ lifecycle.state(State.COMPLETED);
+ });
+ }
+ else {
+ if (res instanceof Boolean)
+ lifecycle.state((Boolean)res
+ ? State.COMPLETED :
action.name().toLowerCase().contains("stop")
+ ? State.SKIPPED : State.FAILED);
+ else
+ lifecycle.state(State.COMPLETED);
Review Comment:
res == null suites case
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]