This is an automated email from the ASF dual-hosted git repository.
timoninmaxim 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 5145c80f38e IGNITE-21656: Fix cache dump check fails on a cache with a
node filter (#11276)
5145c80f38e is described below
commit 5145c80f38edd8a62307b2ab14cbbdaa68a76b56
Author: Vladimir Steshin <[email protected]>
AuthorDate: Fri Apr 5 15:40:46 2024 +0300
IGNITE-21656: Fix cache dump check fails on a cache with a node filter
(#11276)
---
.../java/org/apache/ignite/dump/DumpReader.java | 2 +-
.../snapshot/IgniteSnapshotManager.java | 34 +++++------
.../snapshot/dump/IgniteCacheDumpSelfTest.java | 69 ++++++++++++++++++++++
3 files changed, 85 insertions(+), 20 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java
b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java
index 2d8596ee657..6dcfbb7cce7 100644
--- a/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/dump/DumpReader.java
@@ -97,7 +97,7 @@ public class DumpReader implements Runnable {
: null;
for (SnapshotMetadata meta : dump.metadata()) {
- for (Integer grp : meta.cacheGroupIds()) {
+ for (Integer grp : meta.partitions().keySet()) {
if (cacheGrpIds == null || cacheGrpIds.contains(grp))
grpToNodes.computeIfAbsent(grp, key -> new
ArrayList<>()).add(meta.folderName());
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
index f0bd25b5e73..7e2b0eb03d7 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
@@ -1181,27 +1181,23 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
parts.put(grpId, null);
}
- IgniteInternalFuture<?> task0;
+ IgniteInternalFuture<?> task0 =
registerSnapshotTask(req.snapshotName(),
+ req.snapshotPath(),
+ req.operationalNodeId(),
+ req.requestId(),
+ parts,
+ withMetaStorage,
+ req.dump(),
+ req.compress(),
+ req.encrypt(),
+ locSndrFactory.apply(req.snapshotName(), req.snapshotPath())
+ );
- if (parts.isEmpty() && !withMetaStorage)
- task0 = new GridFinishedFuture<>(Collections.emptySet());
- else {
- task0 = registerSnapshotTask(req.snapshotName(),
- req.snapshotPath(),
- req.operationalNodeId(),
- req.requestId(),
- parts,
- withMetaStorage,
- req.dump(),
- req.compress(),
- req.encrypt(),
- locSndrFactory.apply(req.snapshotName(), req.snapshotPath())
- );
+ if (withMetaStorage) {
+ assert task0 instanceof SnapshotFutureTask;
- if (withMetaStorage && task0 instanceof SnapshotFutureTask) {
-
((DistributedMetaStorageImpl)cctx.kernalContext().distributedMetastorage())
- .suspend(((SnapshotFutureTask)task0).started());
- }
+
((DistributedMetaStorageImpl)cctx.kernalContext().distributedMetastorage())
+ .suspend(((SnapshotFutureTask)task0).started());
}
return task0.chain(() -> {
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelfTest.java
index 741e797d904..0a44519c776 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelfTest.java
@@ -29,15 +29,19 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
+import java.util.stream.Collectors;
import java.util.stream.IntStream;
+import java.util.stream.Stream;
import javax.cache.expiry.Duration;
import javax.cache.expiry.ExpiryPolicy;
import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cluster.ClusterState;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.dump.DumpEntry;
@@ -52,8 +56,10 @@ import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.platform.model.Key;
+import org.apache.ignite.platform.model.User;
import org.apache.ignite.platform.model.Value;
import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.util.AttributeNodeFilter;
import org.junit.Test;
import static java.lang.Boolean.FALSE;
@@ -63,6 +69,7 @@ import static
org.apache.ignite.internal.processors.cache.persistence.snapshot.I
import static
org.apache.ignite.internal.processors.cache.persistence.snapshot.dump.CreateDumpFutureTask.DUMP_FILE_EXT;
import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
import static org.junit.Assume.assumeFalse;
+import static org.junit.Assume.assumeTrue;
/** */
public class IgniteCacheDumpSelfTest extends AbstractCacheDumpTest {
@@ -110,6 +117,68 @@ public class IgniteCacheDumpSelfTest extends
AbstractCacheDumpTest {
return cfg;
}
+ /** */
+ @Test
+ public void testDumpWithNodeFilterCache() throws Exception {
+ assumeTrue(nodes > 1);
+
+ CacheConfiguration<?, ?> ccfg0 =
cacheConfiguration(getConfiguration(getTestIgniteInstanceName()),
DEFAULT_CACHE_NAME)
+ .setNodeFilter(new AttributeNodeFilter(DEFAULT_CACHE_NAME, null));
+
+ CacheConfiguration<?, ?> ccfg1 =
cacheConfiguration(getConfiguration(getTestIgniteInstanceName()), CACHE_0)
+ .setNodeFilter(ccfg0.getNodeFilter());
+
+ for (int i = 0; i <= nodes; ++i) {
+ IgniteConfiguration cfg =
getConfiguration(getTestIgniteInstanceName(i));
+
+ if (i == 0)
+ cfg.setUserAttributes(F.asMap(DEFAULT_CACHE_NAME, ""));
+
+ cfg.setCacheConfiguration(null);
+
+ cfg.setClientMode(i == nodes);
+
+ IgniteEx ig = startGrid(cfg);
+
+ cli = i == nodes ? ig : null;
+ }
+
+ cli.cluster().state(ClusterState.ACTIVE);
+
+ cli.createCache(ccfg0);
+ cli.createCache(ccfg1);
+
+ try (IgniteDataStreamer<Integer, Integer> ds0 =
cli.dataStreamer(DEFAULT_CACHE_NAME);
+ IgniteDataStreamer<Integer, User> ds1 =
cli.dataStreamer(CACHE_0)) {
+ IgniteCache<Integer, Integer> cache0 =
cli.cache(DEFAULT_CACHE_NAME);
+ IgniteCache<Integer, User> cache1 = cli.cache(CACHE_0);
+
+ for (int i = 0; i < KEYS_CNT; ++i) {
+ if (useDataStreamer) {
+ ds0.addData(i, i);
+ ds1.addData(i, USER_FACTORY.apply(i));
+ }
+ else {
+ cache0.put(i, i);
+ cache1.put(i, USER_FACTORY.apply(i));
+ }
+ }
+ }
+
+ createDump(cli, DMP_NAME, null);
+
+ checkDump(cli,
+ DMP_NAME,
+ new String[] {DEFAULT_CACHE_NAME, GRP},
+ Stream.of(DEFAULT_CACHE_NAME, CACHE_0).collect(Collectors.toSet()),
+ KEYS_CNT + (onlyPrimary ? 0 : KEYS_CNT * backups),
+ KEYS_CNT + (onlyPrimary ? 0 : KEYS_CNT * backups),
+ 0,
+ false,
+ false
+ );
+ }
+
/** */
@Test
public void testCacheDump() throws Exception {