You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "nizhikov (via GitHub)" <gi...@apache.org> on 2023/05/10 15:41:22 UTC

[GitHub] [ignite] nizhikov opened a new pull request, #10709: IGNITE-15629 Persistence commands implemented

nizhikov opened a new pull request, #10709:
URL: https://github.com/apache/ignite/pull/10709

   Thank you for submitting the pull request to the Apache Ignite.
   
   In order to streamline the review of the contribution 
   we ask you to ensure the following steps have been taken:
   
   ### The Contribution Checklist
   - [ ] There is a single JIRA ticket related to the pull request. 
   - [ ] The web-link to the pull request is attached to the JIRA ticket.
   - [ ] The JIRA ticket has the _Patch Available_ state.
   - [ ] The pull request body describes changes that have been made. 
   The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
   - [ ] The pull request title is treated as the final commit message. 
   The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
   - [ ] A reviewer has been mentioned through the JIRA comments 
   (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) 
   - [ ] The pull request has been checked by the Teamcity Bot and 
   the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
   
   ### Notes
   - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
   - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
   - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
   - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
   
   If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
   


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] sonarcloud[bot] commented on pull request #10709: IGNITE-15629 Persistence commands implemented

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #10709:
URL: https://github.com/apache/ignite/pull/10709#issuecomment-1549251087

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=10709)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10709&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10709&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10709&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=CODE_SMELL) [9 Code Smells](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10709&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10709&metric=new_coverage&view=list)  
   [![7.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/10-16px.png '7.9%')](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10709&metric=new_duplicated_lines_density&view=list) [7.9% Duplication](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10709&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] nizhikov commented on a diff in pull request #10709: IGNITE-15629 Persistence commands implemented

Posted by "nizhikov (via GitHub)" <gi...@apache.org>.
nizhikov commented on code in PR #10709:
URL: https://github.com/apache/ignite/pull/10709#discussion_r1194802938


##########
modules/core/src/main/java/org/apache/ignite/internal/management/persistence/PersistenceAbstractCommand.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.management.persistence;
+
+import java.util.List;
+import java.util.function.Consumer;
+import org.apache.ignite.internal.management.api.ComputeCommand;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceCleanAllTaskArg;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceCleanCorruptedTaskArg;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceTaskArg;
+import org.apache.ignite.internal.visor.persistence.PersistenceTask;
+import org.apache.ignite.internal.visor.persistence.PersistenceTaskResult;
+import org.apache.ignite.lang.IgniteBiTuple;
+import static org.apache.ignite.internal.management.api.CommandUtils.INDENT;
+
+/** */
+public abstract class PersistenceAbstractCommand implements ComputeCommand<PersistenceTaskArg, PersistenceTaskResult> {
+    /** {@inheritDoc} */
+    @Override public Class<PersistenceTask> taskClass() {
+        return PersistenceTask.class;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void printResult(PersistenceTaskArg arg, PersistenceTaskResult res, Consumer<String> printer) {
+        if (!res.inMaintenanceMode())
+            printer.accept("Persistence command can be sent only to node in Maintenance Mode.");
+        //info command

Review Comment:
   Fixed.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] ivandasch commented on a diff in pull request #10709: IGNITE-15629 Persistence commands implemented

Posted by "ivandasch (via GitHub)" <gi...@apache.org>.
ivandasch commented on code in PR #10709:
URL: https://github.com/apache/ignite/pull/10709#discussion_r1194680954


##########
modules/core/src/main/java/org/apache/ignite/internal/management/persistence/PersistenceAbstractCommand.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.management.persistence;
+
+import java.util.List;
+import java.util.function.Consumer;
+import org.apache.ignite.internal.management.api.ComputeCommand;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceCleanAllTaskArg;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceCleanCorruptedTaskArg;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceTaskArg;
+import org.apache.ignite.internal.visor.persistence.PersistenceTask;
+import org.apache.ignite.internal.visor.persistence.PersistenceTaskResult;
+import org.apache.ignite.lang.IgniteBiTuple;
+import static org.apache.ignite.internal.management.api.CommandUtils.INDENT;
+
+/** */
+public abstract class PersistenceAbstractCommand implements ComputeCommand<PersistenceTaskArg, PersistenceTaskResult> {
+    /** {@inheritDoc} */
+    @Override public Class<PersistenceTask> taskClass() {
+        return PersistenceTask.class;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void printResult(PersistenceTaskArg arg, PersistenceTaskResult res, Consumer<String> printer) {
+        if (!res.inMaintenanceMode())
+            printer.accept("Persistence command can be sent only to node in Maintenance Mode.");
+        //info command
+        else if (res.cachesInfo() != null) {
+            printer.accept("Persistent caches found on node:");
+
+            //sort results so corrupted caches occur in the list at the top
+            res.cachesInfo().entrySet().stream().sorted((ci0, ci1) -> {
+                IgniteBiTuple<Boolean, Boolean> t0 = ci0.getValue();
+                IgniteBiTuple<Boolean, Boolean> t1 = ci1.getValue();
+
+                boolean corrupted0 = t0.get1() || t0.get2();
+                boolean corrupted1 = t1.get1() || t1.get2();
+
+                if (corrupted0 && corrupted1)
+                    return 0;
+                else if (!corrupted0 && !corrupted1)
+                    return 0;
+                else if (corrupted0 && !corrupted1)
+                    return -1;
+                else
+                    return 1;
+            }).forEach(
+                e -> {
+                    IgniteBiTuple<Boolean, Boolean> t = e.getValue();
+
+                    String status;
+
+                    if (!t.get1())

Review Comment:
   It seems that there is a bug (the same condition in this `if` and the consequent `else if`



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] nizhikov merged pull request #10709: IGNITE-15629 Persistence commands implemented

Posted by "nizhikov (via GitHub)" <gi...@apache.org>.
nizhikov merged PR #10709:
URL: https://github.com/apache/ignite/pull/10709


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] sonarcloud[bot] commented on pull request #10709: IGNITE-15629 Persistence commands implemented

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #10709:
URL: https://github.com/apache/ignite/pull/10709#issuecomment-1547797533

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache_ignite&pullRequest=10709)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10709&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10709&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_ignite&pullRequest=10709&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=CODE_SMELL) [9 Code Smells](https://sonarcloud.io/project/issues?id=apache_ignite&pullRequest=10709&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10709&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10709&metric=new_coverage&view=list)  
   [![7.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/10-16px.png '7.9%')](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10709&metric=new_duplicated_lines_density&view=list) [7.9% Duplication](https://sonarcloud.io/component_measures?id=apache_ignite&pullRequest=10709&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] ivandasch commented on a diff in pull request #10709: IGNITE-15629 Persistence commands implemented

Posted by "ivandasch (via GitHub)" <gi...@apache.org>.
ivandasch commented on code in PR #10709:
URL: https://github.com/apache/ignite/pull/10709#discussion_r1194279083


##########
modules/core/src/main/java/org/apache/ignite/internal/management/persistence/PersistenceAbstractCommand.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.management.persistence;
+
+import java.util.List;
+import java.util.function.Consumer;
+import org.apache.ignite.internal.management.api.ComputeCommand;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceCleanAllTaskArg;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceCleanCorruptedTaskArg;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceTaskArg;
+import org.apache.ignite.internal.visor.persistence.PersistenceTask;
+import org.apache.ignite.internal.visor.persistence.PersistenceTaskResult;
+import org.apache.ignite.lang.IgniteBiTuple;
+import static org.apache.ignite.internal.management.api.CommandUtils.INDENT;
+
+/** */
+public abstract class PersistenceAbstractCommand implements ComputeCommand<PersistenceTaskArg, PersistenceTaskResult> {
+    /** {@inheritDoc} */
+    @Override public Class<PersistenceTask> taskClass() {
+        return PersistenceTask.class;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void printResult(PersistenceTaskArg arg, PersistenceTaskResult res, Consumer<String> printer) {
+        if (!res.inMaintenanceMode())
+            printer.accept("Persistence command can be sent only to node in Maintenance Mode.");
+        //info command

Review Comment:
   What do you think about moving the comment to the next line after the curly bracket?
   Looks a little bit weird, TBH



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] ivandasch commented on a diff in pull request #10709: IGNITE-15629 Persistence commands implemented

Posted by "ivandasch (via GitHub)" <gi...@apache.org>.
ivandasch commented on code in PR #10709:
URL: https://github.com/apache/ignite/pull/10709#discussion_r1194281214


##########
modules/core/src/main/java/org/apache/ignite/internal/management/persistence/PersistenceCommand.java:
##########
@@ -0,0 +1,111 @@
+/*
+ * 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.management.persistence;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.function.Consumer;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.apache.ignite.internal.management.api.CliPositionalSubcommands;
+import org.apache.ignite.internal.management.api.CommandRegistryImpl;
+import org.apache.ignite.internal.management.api.ComputeCommand;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceTaskArg;
+import org.apache.ignite.internal.visor.persistence.PersistenceTask;
+import org.apache.ignite.internal.visor.persistence.PersistenceTaskResult;
+
+/** */
+@CliPositionalSubcommands
+public class PersistenceCommand
+    extends CommandRegistryImpl<PersistenceTaskArg, PersistenceTaskResult>

Review Comment:
   Is this line break really needed here?



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite] nizhikov commented on a diff in pull request #10709: IGNITE-15629 Persistence commands implemented

Posted by "nizhikov (via GitHub)" <gi...@apache.org>.
nizhikov commented on code in PR #10709:
URL: https://github.com/apache/ignite/pull/10709#discussion_r1194806590


##########
modules/core/src/main/java/org/apache/ignite/internal/management/persistence/PersistenceAbstractCommand.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.management.persistence;
+
+import java.util.List;
+import java.util.function.Consumer;
+import org.apache.ignite.internal.management.api.ComputeCommand;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceCleanAllTaskArg;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceCleanCorruptedTaskArg;
+import org.apache.ignite.internal.management.persistence.PersistenceCommand.PersistenceTaskArg;
+import org.apache.ignite.internal.visor.persistence.PersistenceTask;
+import org.apache.ignite.internal.visor.persistence.PersistenceTaskResult;
+import org.apache.ignite.lang.IgniteBiTuple;
+import static org.apache.ignite.internal.management.api.CommandUtils.INDENT;
+
+/** */
+public abstract class PersistenceAbstractCommand implements ComputeCommand<PersistenceTaskArg, PersistenceTaskResult> {
+    /** {@inheritDoc} */
+    @Override public Class<PersistenceTask> taskClass() {
+        return PersistenceTask.class;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void printResult(PersistenceTaskArg arg, PersistenceTaskResult res, Consumer<String> printer) {
+        if (!res.inMaintenanceMode())
+            printer.accept("Persistence command can be sent only to node in Maintenance Mode.");
+        //info command
+        else if (res.cachesInfo() != null) {
+            printer.accept("Persistent caches found on node:");
+
+            //sort results so corrupted caches occur in the list at the top
+            res.cachesInfo().entrySet().stream().sorted((ci0, ci1) -> {
+                IgniteBiTuple<Boolean, Boolean> t0 = ci0.getValue();
+                IgniteBiTuple<Boolean, Boolean> t1 = ci1.getValue();
+
+                boolean corrupted0 = t0.get1() || t0.get2();
+                boolean corrupted1 = t1.get1() || t1.get2();
+
+                if (corrupted0 && corrupted1)
+                    return 0;
+                else if (!corrupted0 && !corrupted1)
+                    return 0;
+                else if (corrupted0 && !corrupted1)
+                    return -1;
+                else
+                    return 1;
+            }).forEach(
+                e -> {
+                    IgniteBiTuple<Boolean, Boolean> t = e.getValue();
+
+                    String status;
+
+                    if (!t.get1())

Review Comment:
   Fixed



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org