EgorBaranovEnjoysTyping commented on code in PR #12584:
URL: https://github.com/apache/ignite/pull/12584#discussion_r4771431402


##########
modules/core/src/main/java/org/apache/ignite/internal/maintenance/MaintenanceTaskState.java:
##########
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.maintenance;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import org.apache.ignite.maintenance.MaintenanceTask;
+
+/** Maintenance task state for logging. */
+public class MaintenanceTaskState {
+    /** */
+    public enum State {
+        /** Active {@link org.apache.ignite.maintenance.MaintenanceAction 
Maintenance task action}. */
+        ACTIVE,
+
+        /** {@link org.apache.ignite.maintenance.MaintenanceAction Maintenance 
task action} cancelled. */
+        CANCELLED,
+
+        /** Completed {@link org.apache.ignite.maintenance.MaintenanceAction 
Maintenance task action}. */
+        COMPLETED,
+
+        /** Failed {@link org.apache.ignite.maintenance.MaintenanceAction 
Maintenance task action}. */
+        FAILED,
+
+        /** Skipped {@link org.apache.ignite.maintenance.MaintenanceAction 
Maintenance task stopping action}. */
+        SKIPPED,
+    }
+
+    /** Maintenance task. */
+    private final MaintenanceTask task;
+
+    /** Whether the task is registered in the active maintenance tasks. */
+    private volatile boolean isRegistered = true;
+
+    /** Lifecycles of executed maintenance task actions. */
+    private final List<ActionLifecycle> executedActions = new 
CopyOnWriteArrayList<>();
+
+    /** @param task {@link MaintenanceTask Maintenance task}. */
+    public MaintenanceTaskState(MaintenanceTask task) {
+        this.task = task;
+    }
+
+    /** @return {@link MaintenanceTask Maintenance task}. */
+    public MaintenanceTask task() {
+        return task;
+    }
+
+    /** @return {@code true} if the task is registered in the active tasks. */
+    public boolean isRegistered() {
+        return isRegistered;
+    }
+
+    /** Task unregistered from the active tasks. */
+    public void unregistered() {
+        isRegistered = false;
+    }
+
+    /** @return Executed actions lifecycles. */
+    public List<ActionLifecycle> executedActionsLifecycles() {
+        return new ArrayList<>(executedActions);
+    }
+
+    /**
+     * Add current action lifecycle.
+     * @param lifecycle Current executed action lifecycle.
+     */
+    public void addActionLifecycle(ActionLifecycle lifecycle) {
+        executedActions.add(lifecycle);
+    }
+
+    /** */
+    @Override public String toString() {

Review Comment:
   S.toString(...) could help you here.



##########
modules/core/src/main/java/org/apache/ignite/internal/plugin/IgniteLogInfoProviderImpl.java:
##########
@@ -735,6 +739,16 @@ void ackNodeBasicMetrics(IgniteLogger log, IgniteEx 
ignite, DecimalFormat dblFmt
 
         SB msg = new SB();
 
+        if (mntcProc.isMaintenanceMode()) {
+            List<MaintenanceTaskState> statesList = mntcProc.tasksStates();
+
+            msg.nl()
+                .a("!!! ATTENTION! NODE IS IN MAINTENANCE MODE !!!").nl()
+                .a(statesList.size() == 1 ? "    MaintenanceTask " : "    
MaintenanceTasks");
+
+            statesList.forEach(s -> msg.nl().a(s.toString()));
+        }

Review Comment:
   State class could implement toString method and use S.toString inside, so 
this code may be reduced



##########
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() {

Review Comment:
   1. Make MaintenanceTaskState comparable (move compare operation there)
   2. Call Collections.sort(your list). 
   3. This method is not necessary



-- 
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]

Reply via email to