This is an automated email from the ASF dual-hosted git repository.
namelchev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new c5112528fd0 IGNITE-17617 Fixed NPE in the snapshot restore status
command on client nodes and non-persistent cluster. (#10234)
c5112528fd0 is described below
commit c5112528fd0763a5045cb0e2f7b57bf3745d9d92
Author: Nikita Amelchev <[email protected]>
AuthorDate: Sat Sep 3 16:24:24 2022 +0300
IGNITE-17617 Fixed NPE in the snapshot restore status command on client
nodes and non-persistent cluster. (#10234)
---
.../org/apache/ignite/util/GridCommandHandlerTest.java | 18 ++++++++++++++++--
.../visor/snapshot/VisorSnapshotStatusTask.java | 6 +++++-
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git
a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
index 90ce6cccf2e..fc7c523e629 100644
---
a/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
+++
b/modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java
@@ -3475,6 +3475,16 @@ public class GridCommandHandlerTest extends
GridCommandHandlerClusterPerMethodAb
assertNull(ig.cache(DEFAULT_CACHE_NAME));
}
+ /** @throws Exception If fails. */
+ @Test
+ public void testSnapshotStatusInMemory() throws Exception {
+ persistenceEnable(false);
+
+ startGrid();
+
+ checkSnapshotStatus(false, false, null);
+ }
+
/** @throws Exception If fails. */
@Test
public void testSnapshotStatus() throws Exception {
@@ -3483,6 +3493,8 @@ public class GridCommandHandlerTest extends
GridCommandHandlerClusterPerMethodAb
IgniteEx srv = startGrids(3);
+ startClientGrid("client");
+
srv.cluster().state(ACTIVE);
createCacheAndPreload(srv, keysCnt);
@@ -3528,7 +3540,9 @@ public class GridCommandHandlerTest extends
GridCommandHandlerClusterPerMethodAb
* @param expName Expected snapshot name.
*/
private void checkSnapshotStatus(boolean isCreating, boolean isRestoring,
String expName) throws Exception {
- assertTrue(waitForCondition(() -> G.allGrids().stream().allMatch(
+ Collection<Ignite> srvs = F.view(G.allGrids(), n ->
!n.cluster().localNode().isLocal());
+
+ assertTrue(waitForCondition(() -> srvs.stream().allMatch(
ignite -> {
IgniteSnapshotManager mgr =
((IgniteEx)ignite).context().cache().context().snapshotMgr();
@@ -3557,7 +3571,7 @@ public class GridCommandHandlerTest extends
GridCommandHandlerClusterPerMethodAb
assertContains(log, out, "Snapshot name: " + expName);
- G.allGrids().forEach(srv -> assertContains(log, out,
srv.cluster().localNode().id().toString()));
+ srvs.forEach(srv -> assertContains(log, out,
srv.cluster().localNode().id().toString()));
}
/** @throws Exception If failed. */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotStatusTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotStatusTask.java
index 0cb165c0299..304ec71aaaa 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotStatusTask.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotStatusTask.java
@@ -32,6 +32,7 @@ import
org.apache.ignite.internal.processors.metric.MetricRegistry;
import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.visor.VisorJob;
import org.apache.ignite.internal.visor.VisorMultiNodeTask;
import org.apache.ignite.internal.visor.VisorTaskArgument;
@@ -58,7 +59,7 @@ public class VisorSnapshotStatusTask extends
VisorMultiNodeTask<Void, VisorSnaps
/** {@inheritDoc} */
@Override protected Collection<UUID> jobNodes(VisorTaskArgument<Void> arg)
{
- return F.nodeIds(ignite.cluster().nodes());
+ return F.nodeIds(ignite.cluster().forServers().nodes());
}
/** {@inheritDoc} */
@@ -106,6 +107,9 @@ public class VisorSnapshotStatusTask extends
VisorMultiNodeTask<Void, VisorSnaps
/** {@inheritDoc} */
@Override protected SnapshotStatus run(@Nullable Void arg) throws
IgniteException {
+ if (!CU.isPersistenceEnabled(ignite.context().config()))
+ return null;
+
IgniteSnapshotManager snpMgr =
ignite.context().cache().context().snapshotMgr();
SnapshotOperationRequest req = snpMgr.currentCreateRequest();