Skip to content

Commit 8716b82

Browse files
IGNITE-22662 Snapshot check bases on DistributedProcess (#11897)
Co-authored-by: Vladimir Steshin <vladsz83@gmail.com>
1 parent 70b0e36 commit 8716b82

27 files changed

Lines changed: 2114 additions & 1065 deletions

modules/clients/src/test/java/org/apache/ignite/common/ComputeTaskPermissionsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import org.apache.ignite.configuration.IgniteConfiguration;
4949
import org.apache.ignite.configuration.ThinClientConfiguration;
5050
import org.apache.ignite.internal.IgniteEx;
51-
import org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotMetadataVerificationTask;
51+
import org.apache.ignite.internal.management.cache.VerifyBackupPartitionsTask;
5252
import org.apache.ignite.internal.processors.security.AbstractSecurityTest;
5353
import org.apache.ignite.internal.processors.security.OperationSecurityContext;
5454
import org.apache.ignite.internal.processors.security.PublicAccessJob;
@@ -108,7 +108,7 @@ public class ComputeTaskPermissionsTest extends AbstractSecurityTest {
108108
private static final IgniteClosure SYSTEM_CLOSURE = new ToStringClosure<>();
109109

110110
/** */
111-
private static final ComputeTask SYSTEM_TASK = new SnapshotMetadataVerificationTask();
111+
private static final ComputeTask SYSTEM_TASK = new VerifyBackupPartitionsTask();
112112

113113
/** */
114114
private static final AtomicInteger EXECUTED_TASK_CNTR = new AtomicInteger();

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
import static org.apache.ignite.internal.processors.diagnostic.DiagnosticProcessor.DEFAULT_TARGET_FOLDER;
188188
import static org.apache.ignite.internal.processors.job.GridJobProcessor.JOBS_VIEW;
189189
import static org.apache.ignite.internal.processors.task.GridTaskProcessor.TASKS_VIEW;
190+
import static org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.RESTORE_CACHE_GROUP_SNAPSHOT_PREPARE;
190191
import static org.apache.ignite.testframework.GridTestUtils.assertContains;
191192
import static org.apache.ignite.testframework.GridTestUtils.assertNotContains;
192193
import static org.apache.ignite.testframework.GridTestUtils.runAsync;
@@ -759,7 +760,7 @@ public void testState() throws Exception {
759760
final String newTag = "new_tag";
760761

761762
Ignite ignite = startGrids(2);
762-
763+
763764
startClientGrid("client");
764765

765766
assertFalse(ignite.cluster().state().active());
@@ -3740,7 +3741,8 @@ public void testSnapshotStatus() throws Exception {
37403741

37413742
awaitPartitionMapExchange();
37423743

3743-
spi.blockMessages((node, msg) -> msg instanceof SingleNodeMessage);
3744+
spi.blockMessages((node, msg) -> msg instanceof SingleNodeMessage
3745+
&& ((SingleNodeMessage)msg).type() == RESTORE_CACHE_GROUP_SNAPSHOT_PREPARE.ordinal());
37443746

37453747
fut = srv.snapshot().restoreSnapshot(snapshotName, F.asList(DEFAULT_CACHE_NAME));
37463748

@@ -3759,7 +3761,8 @@ public void testSnapshotStatus() throws Exception {
37593761

37603762
awaitPartitionMapExchange();
37613763

3762-
spi.blockMessages((node, msg) -> msg instanceof SingleNodeMessage);
3764+
spi.blockMessages((node, msg) -> msg instanceof SingleNodeMessage
3765+
&& ((SingleNodeMessage)msg).type() == RESTORE_CACHE_GROUP_SNAPSHOT_PREPARE.ordinal());
37633766

37643767
fut = srv.snapshot().restoreSnapshot(snapshotName, F.asList(DEFAULT_CACHE_NAME), 1);
37653768

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.internal.processors.cache.persistence.snapshot;
19+
20+
import java.io.Serializable;
21+
import java.util.Collection;
22+
import java.util.HashSet;
23+
import java.util.Set;
24+
import java.util.UUID;
25+
import org.apache.ignite.internal.util.distributed.DistributedProcess;
26+
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
27+
import org.apache.ignite.internal.util.typedef.internal.S;
28+
import org.jetbrains.annotations.Nullable;
29+
30+
/**
31+
* Snapshot operation start request for {@link DistributedProcess} initiate message.
32+
*/
33+
abstract class AbstractSnapshotOperationRequest implements Serializable {
34+
/** Serial version uid. */
35+
private static final long serialVersionUID = 0L;
36+
37+
/** Request ID. */
38+
@GridToStringInclude
39+
private final UUID reqId;
40+
41+
/** Snapshot name. */
42+
@GridToStringInclude
43+
private final String snpName;
44+
45+
/** Snapshot directory path. */
46+
@GridToStringInclude
47+
private final String snpPath;
48+
49+
/** Collection of cache group names. */
50+
@GridToStringInclude
51+
private final Collection<String> grps;
52+
53+
/** Start time. */
54+
@GridToStringInclude
55+
private final long startTime;
56+
57+
/** IDs of the nodes that must be alive to complete the operation. */
58+
@GridToStringInclude
59+
private final Set<UUID> nodes;
60+
61+
/**
62+
* @param reqId Request ID.
63+
* @param snpName Snapshot name.
64+
* @param snpPath Snapshot directory path.
65+
* @param grps Collection of cache group names.
66+
* @param incIdx Incremental snapshot index.
67+
* @param nodes IDs of the nodes that must be alive to complete the operation.
68+
*/
69+
protected AbstractSnapshotOperationRequest(
70+
UUID reqId,
71+
String snpName,
72+
String snpPath,
73+
@Nullable Collection<String> grps,
74+
int incIdx,
75+
Collection<UUID> nodes
76+
) {
77+
this.reqId = reqId;
78+
this.snpName = snpName;
79+
this.grps = grps;
80+
this.snpPath = snpPath;
81+
this.nodes = new HashSet<>(nodes);
82+
this.startTime = System.currentTimeMillis();
83+
}
84+
85+
/** @return Request ID. */
86+
@Nullable public UUID requestId() {
87+
return reqId;
88+
}
89+
90+
/** @return Snapshot name. */
91+
public String snapshotName() {
92+
return snpName;
93+
}
94+
95+
/** @return Snapshot directory path. */
96+
public String snapshotPath() {
97+
return snpPath;
98+
}
99+
100+
/** @return List of cache group names. */
101+
public @Nullable Collection<String> groups() {
102+
return grps;
103+
}
104+
105+
/** @return Start time. */
106+
public long startTime() {
107+
return startTime;
108+
}
109+
110+
/** @return IDs of the nodes that must be alive to complete the operation. */
111+
public Set<UUID> nodes() {
112+
return nodes;
113+
}
114+
115+
/** {@inheritDoc} */
116+
@Override public String toString() {
117+
return S.toString(AbstractSnapshotOperationRequest.class, this);
118+
}
119+
}

modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotVerificationTask.java

Lines changed: 0 additions & 184 deletions
This file was deleted.

0 commit comments

Comments
 (0)