Skip to content

Commit c544600

Browse files
committed
IGNITE-17617 Fixed NPE in the snapshot restore status command on client nodes and non-persistent cluster. (#10234)
(cherry picked from commit c511252)
1 parent c8b1ca7 commit c544600

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

modules/control-utility/src/test/java/org/apache/ignite/util/GridCommandHandlerTest.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3475,6 +3475,16 @@ public void testSnapshotRestoreCancelAndStatus() throws Exception {
34753475
assertNull(ig.cache(DEFAULT_CACHE_NAME));
34763476
}
34773477

3478+
/** @throws Exception If fails. */
3479+
@Test
3480+
public void testSnapshotStatusInMemory() throws Exception {
3481+
persistenceEnable(false);
3482+
3483+
startGrid();
3484+
3485+
checkSnapshotStatus(false, false, null);
3486+
}
3487+
34783488
/** @throws Exception If fails. */
34793489
@Test
34803490
public void testSnapshotStatus() throws Exception {
@@ -3483,6 +3493,8 @@ public void testSnapshotStatus() throws Exception {
34833493

34843494
IgniteEx srv = startGrids(3);
34853495

3496+
startClientGrid("client");
3497+
34863498
srv.cluster().state(ACTIVE);
34873499

34883500
createCacheAndPreload(srv, keysCnt);
@@ -3528,7 +3540,9 @@ public void testSnapshotStatus() throws Exception {
35283540
* @param expName Expected snapshot name.
35293541
*/
35303542
private void checkSnapshotStatus(boolean isCreating, boolean isRestoring, String expName) throws Exception {
3531-
assertTrue(waitForCondition(() -> G.allGrids().stream().allMatch(
3543+
Collection<Ignite> srvs = F.view(G.allGrids(), n -> !n.cluster().localNode().isLocal());
3544+
3545+
assertTrue(waitForCondition(() -> srvs.stream().allMatch(
35323546
ignite -> {
35333547
IgniteSnapshotManager mgr = ((IgniteEx)ignite).context().cache().context().snapshotMgr();
35343548

@@ -3557,7 +3571,7 @@ private void checkSnapshotStatus(boolean isCreating, boolean isRestoring, String
35573571

35583572
assertContains(log, out, "Snapshot name: " + expName);
35593573

3560-
G.allGrids().forEach(srv -> assertContains(log, out, srv.cluster().localNode().id().toString()));
3574+
srvs.forEach(srv -> assertContains(log, out, srv.cluster().localNode().id().toString()));
35613575
}
35623576

35633577
/** @throws Exception If failed. */

modules/core/src/main/java/org/apache/ignite/internal/visor/snapshot/VisorSnapshotStatusTask.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.ignite.internal.processors.task.GridInternal;
3333
import org.apache.ignite.internal.util.typedef.F;
3434
import org.apache.ignite.internal.util.typedef.T2;
35+
import org.apache.ignite.internal.util.typedef.internal.CU;
3536
import org.apache.ignite.internal.visor.VisorJob;
3637
import org.apache.ignite.internal.visor.VisorMultiNodeTask;
3738
import org.apache.ignite.internal.visor.VisorTaskArgument;
@@ -58,7 +59,7 @@ public class VisorSnapshotStatusTask extends VisorMultiNodeTask<Void, VisorSnaps
5859

5960
/** {@inheritDoc} */
6061
@Override protected Collection<UUID> jobNodes(VisorTaskArgument<Void> arg) {
61-
return F.nodeIds(ignite.cluster().nodes());
62+
return F.nodeIds(ignite.cluster().forServers().nodes());
6263
}
6364

6465
/** {@inheritDoc} */
@@ -106,6 +107,9 @@ protected VisorSnapshotStatusJob(@Nullable Void arg, boolean debug) {
106107

107108
/** {@inheritDoc} */
108109
@Override protected SnapshotStatus run(@Nullable Void arg) throws IgniteException {
110+
if (!CU.isPersistenceEnabled(ignite.context().config()))
111+
return null;
112+
109113
IgniteSnapshotManager snpMgr = ignite.context().cache().context().snapshotMgr();
110114

111115
SnapshotOperationRequest req = snpMgr.currentCreateRequest();

0 commit comments

Comments
 (0)