This is an automated email from the ASF dual-hosted git repository.
nizhikov 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 5901b7f6729 IGNITE-26860 Add configOnly flag to dump (#12476)
5901b7f6729 is described below
commit 5901b7f6729927020d9080d7b63b37778faceb90
Author: Nikolay <[email protected]>
AuthorDate: Fri Oct 31 12:39:39 2025 +0300
IGNITE-26860 Add configOnly flag to dump (#12476)
---
.../java/org/apache/ignite/dump/DumpReader.java | 31 +++++++--------
.../snapshot/IgniteSnapshotManager.java | 37 +++++++++++++-----
.../snapshot/SnapshotOperationRequest.java | 13 ++++++-
.../snapshot/SnapshotPartitionsVerifyHandler.java | 17 +++++++--
.../snapshot/SnapshotRestoreProcess.java | 1 +
.../snapshot/dump/CreateDumpFutureTask.java | 15 +++++++-
.../snapshot/AbstractSnapshotSelfTest.java | 3 +-
.../snapshot/EncryptedSnapshotTest.java | 1 +
.../snapshot/IgniteSnapshotManagerSelfTest.java | 1 +
.../snapshot/dump/AbstractCacheDumpTest.java | 2 +-
.../dump/IgniteCacheDumpDataStructuresTest.java | 2 +-
.../snapshot/dump/IgniteCacheDumpSelf2Test.java | 44 ++++++++++++++++++++--
.../snapshot/dump/IgniteCacheDumpSelfTest.java | 35 +++++++++++++++++
13 files changed, 162 insertions(+), 40 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 1c165ac7d48..1e9243374d6 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
@@ -28,7 +28,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -367,6 +366,7 @@ public class DumpReader implements Runnable {
*/
private GroupsConfigs groupsConfigs(Dump dump) {
Map<Integer, List<String>> grpsToNodes = new HashMap<>();
+ List<StoredCacheData> ccfgs = new ArrayList<>();
Set<Integer> grpIds = cfg.groupNames() != null
?
Arrays.stream(cfg.groupNames()).map(CU::cacheId).collect(Collectors.toSet())
@@ -377,29 +377,24 @@ public class DumpReader implements Runnable {
: null;
for (SnapshotMetadata meta : dump.metadata()) {
- for (Integer grp : meta.partitions().keySet()) {
- if (grpIds == null || grpIds.contains(grp))
- grpsToNodes.computeIfAbsent(grp, key -> new
ArrayList<>()).add(meta.folderName());
- }
- }
+ for (Integer grp : meta.cacheGroupIds()) {
+ if (grpIds != null && !grpIds.contains(grp))
+ continue;
- Iterator<Map.Entry<Integer, List<String>>> grpToNodesIter =
grpsToNodes.entrySet().iterator();
- List<StoredCacheData> ccfgs = new ArrayList<>();
+ // Read all group configs from single node.
+ List<StoredCacheData> grpCaches =
dump.configs(meta.folderName(), grp, cacheIds);
- while (grpToNodesIter.hasNext()) {
- Map.Entry<Integer, List<String>> grpToNodes =
grpToNodesIter.next();
+ if (F.isEmpty(grpCaches))
+ continue;
- // Read all group configs from single node.
- List<StoredCacheData> grpCaches =
dump.configs(F.first(grpToNodes.getValue()), grpToNodes.getKey(), cacheIds);
+ if (!grpsToNodes.containsKey(grp)) {
+ grpsToNodes.put(grp, new ArrayList<>());
- if (grpCaches.isEmpty()) {
- // Remove whole group to skip files read.
- grpToNodesIter.remove();
+ ccfgs.addAll(grpCaches);
+ }
- continue;
+ grpsToNodes.get(grp).add(meta.folderName());
}
-
- ccfgs.addAll(grpCaches);
}
// Optimize - skip whole cache if only one in group!
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 d1bd1c4cb2a..8bee3f96ff0 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
@@ -976,6 +976,9 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
if (!isPersistenceEnabled(cctx.gridConfig()) && req.snapshotPath() ==
null)
ft.mkdirSnapshotsRoot();
+ if (req.configOnly() && !req.dump())
+ throw new IgniteException("Config only flag supported only for
dump");
+
Map<Integer, Set<Integer>> parts = new HashMap<>();
// Prepare collection of pairs group and appropriate cache partition
to be snapshot.
@@ -988,7 +991,7 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
AffinityTopologyVersion topVer = grpCtx.affinity().lastVersion();
- if (req.onlyPrimary()) {
+ if (req.onlyPrimary() && !req.configOnly()) {
Set<Integer> include = new
HashSet<>(grpCtx.affinity().primaryPartitions(cctx.localNodeId(), topVer));
include.remove(INDEX_PARTITION);
@@ -1012,6 +1015,7 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
req.dump(),
req.compress(),
req.encrypt(),
+ req.configOnly(),
locSndrFactory.apply(req.snapshotFileTree())
);
@@ -1639,7 +1643,7 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
/** {@inheritDoc} */
@Override public IgniteFuture<Void> createDump(String name, @Nullable
Collection<String> cacheGrpNames) {
- return createSnapshot(name, null, cacheGrpNames, false, false, true,
false, false, false);
+ return createSnapshot(name, null, cacheGrpNames, false, false, true,
false, false, false, false);
}
/**
@@ -1882,7 +1886,7 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
boolean incremental,
boolean onlyPrimary
) {
- return createSnapshot(name, snpPath, null, incremental, onlyPrimary,
false, false, false, false);
+ return createSnapshot(name, snpPath, null, incremental, onlyPrimary,
false, false, false, false, false);
}
/**
@@ -1902,6 +1906,7 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
* @param compress If {@code true} then compress partition files.
* @param encrypt If {@code true} then content of dump encrypted.
* @param inclDs If {@code true} then data structures caches will be
included in dump.
+ * @param configOnly If {@code true} then only cache config and metadata
included in snapshot.
* @return Future which will be completed when a process ends.
*/
public IgniteFutureImpl<Void> createSnapshot(
@@ -1913,7 +1918,8 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
boolean dump,
boolean compress,
boolean encrypt,
- boolean inclDs
+ boolean inclDs,
+ boolean configOnly
) {
A.notNullOrEmpty(name, "Snapshot name cannot be null or empty.");
A.ensure(U.alphanumericUnderscore(name), "Snapshot name must satisfy
the following name pattern: a-zA-Z0-9_");
@@ -1922,6 +1928,7 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
A.ensure(!(cacheGrpNames != null && !dump), "Cache group names filter
supported only for dump");
A.ensure(!compress || dump, "Compression is supported only for dumps");
A.ensure(!inclDs || dump, "Data structures can't be written into
snapshot");
+ A.ensure(!configOnly || dump, "Config only supported only for dump");
try {
cctx.kernalContext().security().authorize(ADMIN_SNAPSHOT);
@@ -1951,7 +1958,8 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
dump,
compress,
encrypt,
- inclDs
+ inclDs,
+ configOnly
),
options(Collections.singletonList(crd)).withFailoverDisabled()
));
@@ -2072,7 +2080,8 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
onlyPrimary,
dump,
compress,
- encrypt
+ encrypt,
+ configOnly
);
startSnpProc.start(snpFut0.rqId, snpOpReq);
@@ -2363,6 +2372,7 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
* @param dump {@code true} if cache group dump must be created.
* @param compress If {@code true} then compress partition files.
* @param encrypt If {@code true} then content of dump encrypted.
+ * @param configOnly If {@code true} then only cache config and metadata
included in snapshot.
* @param snpSndr Factory which produces snapshot receiver instance.
* @return Snapshot operation task which should be registered on
checkpoint to run.
*/
@@ -2375,6 +2385,7 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
boolean dump,
boolean compress,
boolean encrypt,
+ boolean configOnly,
SnapshotSender snpSndr
) {
AbstractSnapshotFutureTask<?> task = registerTask(sft.name(), dump
@@ -2387,7 +2398,8 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
snpSndr,
parts,
compress,
- encrypt
+ encrypt,
+ configOnly
)
: new SnapshotFutureTask(
cctx,
@@ -4238,6 +4250,9 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
/** If {@code true} then data structures caches will be included in
dump. */
private final boolean inclDs;
+ /** If {@code true} then only cache config and metadata included in
snapshot. */
+ private final boolean configOnly;
+
/** Auto-injected grid instance. */
@IgniteInstanceResource
private transient IgniteEx ignite;
@@ -4251,6 +4266,7 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
* @param comprParts If {@code true} then compress partition files.
* @param encrypt If {@code true} then content of dump encrypted.
* @param inclDs If {@code true} then data structures caches will be
included in dump.
+ * @param configOnly If {@code true} then only cache config and
metadata included in snapshot.
*/
public CreateSnapshotCallable(
String snpName,
@@ -4260,7 +4276,8 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
boolean dump,
boolean comprParts,
boolean encrypt,
- boolean inclDs
+ boolean inclDs,
+ boolean configOnly
) {
this.snpName = snpName;
this.cacheGrpNames = cacheGrpNames;
@@ -4270,6 +4287,7 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
this.comprParts = comprParts;
this.encrypt = encrypt;
this.inclDs = inclDs;
+ this.configOnly = configOnly;
}
/** {@inheritDoc} */
@@ -4286,7 +4304,8 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
dump,
comprParts,
encrypt,
- inclDs
+ inclDs,
+ configOnly
).get();
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotOperationRequest.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotOperationRequest.java
index e1b01b25611..8d3914828a6 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotOperationRequest.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotOperationRequest.java
@@ -82,6 +82,9 @@ public class SnapshotOperationRequest extends
AbstractSnapshotOperationRequest {
/** If {@code true} then content of dump encrypted. */
private final boolean encrypt;
+ /** If {@code true} then only cache config and metadata included in
snapshot. */
+ private final boolean configOnly;
+
/**
* @param reqId Request ID.
* @param opNodeId Operational node ID.
@@ -95,6 +98,7 @@ public class SnapshotOperationRequest extends
AbstractSnapshotOperationRequest {
* @param dump If {@code true} then create dump.
* @param compress If {@code true} then compress partition files.
* @param encrypt If {@code true} then content of dump encrypted.
+ * @param configOnly If {@code true} then only cache config and metadata
included in snapshot.
*/
public SnapshotOperationRequest(
UUID reqId,
@@ -108,7 +112,8 @@ public class SnapshotOperationRequest extends
AbstractSnapshotOperationRequest {
boolean onlyPrimary,
boolean dump,
boolean compress,
- boolean encrypt
+ boolean encrypt,
+ boolean configOnly
) {
super(reqId, snpName, snpPath, grps, incIdx, nodes);
@@ -119,6 +124,7 @@ public class SnapshotOperationRequest extends
AbstractSnapshotOperationRequest {
this.dump = dump;
this.compress = compress;
this.encrypt = encrypt;
+ this.configOnly = configOnly;
}
/**
@@ -172,6 +178,11 @@ public class SnapshotOperationRequest extends
AbstractSnapshotOperationRequest {
return encrypt;
}
+ /** @return If {@code true} then only cache config and metadata included
in snapshot. */
+ public boolean configOnly() {
+ return configOnly;
+ }
+
/**
* @return Flag indicating that the {@link
DistributedProcessType#START_SNAPSHOT} phase has completed.
*/
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
index 7de1479d0db..c12f86e15ef 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsVerifyHandler.java
@@ -112,10 +112,19 @@ public class SnapshotPartitionsVerifyHandler implements
SnapshotHandler<Map<Part
SnapshotMetadata meta = opCtx.metadata();
- Map<Integer, Set<Integer>> grps = F.isEmpty(opCtx.groups())
- ? new HashMap<>(meta.partitions())
- : opCtx.groups().stream().map(CU::cacheId)
- .collect(Collectors.toMap(Function.identity(), grpId ->
meta.partitions().getOrDefault(grpId, Collections.emptySet())));
+ Map<Integer, Set<Integer>> grps;
+
+ if (F.isEmpty(opCtx.groups()))
+ grps = new HashMap<>(meta.partitions());
+ else {
+ grps = opCtx.groups().stream()
+ .map(CU::cacheId)
+ .filter(meta.partitions()::containsKey) // Filter out groups
for which there are no partitions in snapshot.
+ .collect(Collectors.toMap(
+ Function.identity(),
+ grpId -> meta.partitions().get(grpId))
+ );
+ }
if (type() == SnapshotHandlerType.CREATE) {
grps.entrySet().removeIf(e -> {
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
index 8b77b0c845a..70460e3b525 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
@@ -408,6 +408,7 @@ public class SnapshotRestoreProcess {
onlyPrimary,
false,
false,
+ false,
false
);
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
index 45190229fbd..041ccf7b1f8 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/CreateDumpFutureTask.java
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.nio.ByteBuffer;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -92,6 +93,9 @@ public class CreateDumpFutureTask extends
AbstractCreateSnapshotFutureTask imple
/** If {@code true} then compress partition files. */
private final boolean compress;
+ /** If {@code true} then only cache config and metadata included in
snapshot. */
+ private final boolean configOnly;
+
/** Dump transfer rate limiter. */
private final BasicRateLimiter rateLimiter;
@@ -146,6 +150,7 @@ public class CreateDumpFutureTask extends
AbstractCreateSnapshotFutureTask imple
* @param parts Parts to dump.
* @param compress If {@code true} then compress partition files.
* @param encrypt If {@code true} then content of dump encrypted.
+ * @param configOnly If {@code true} then only cache config and metadata
included in snapshot.
*/
public CreateDumpFutureTask(
GridCacheSharedContext<?, ?> cctx,
@@ -157,7 +162,8 @@ public class CreateDumpFutureTask extends
AbstractCreateSnapshotFutureTask imple
SnapshotSender snpSndr,
Map<Integer, Set<Integer>> parts,
boolean compress,
- boolean encrypt
+ boolean encrypt,
+ boolean configOnly
) {
super(
cctx,
@@ -171,6 +177,7 @@ public class CreateDumpFutureTask extends
AbstractCreateSnapshotFutureTask imple
this.ioFactory = compress ? new WriteOnlyZipFileIOFactory(ioFactory) :
new BufferedFileIOFactory(ioFactory);
this.compress = compress;
+ this.configOnly = configOnly;
this.rateLimiter = rateLimiter;
this.encKey = encrypt ? cctx.gridConfig().getEncryptionSpi().create()
: null;
this.encThLocBufs = encrypt ? new ConcurrentHashMap<>() : null;
@@ -199,6 +206,12 @@ public class CreateDumpFutureTask extends
AbstractCreateSnapshotFutureTask imple
/** {@inheritDoc} */
@Override protected void processPartitions() throws IgniteCheckedException
{
+ if (configOnly) {
+ parts.keySet().forEach(grpId -> processed.put(grpId,
Collections.emptySet()));
+
+ return;
+ }
+
super.processPartitions();
processed.values().forEach(parts -> parts.remove(INDEX_PARTITION));
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
index 6afa2fb2ea5..3a490545429 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/AbstractSnapshotSelfTest.java
@@ -792,7 +792,7 @@ public abstract class AbstractSnapshotSelfTest extends
GridCommonAbstractTest {
List<BlockingExecutor> execs = setBlockingSnapshotExecutor(srvs);
IgniteFuture<Void> fut = snp(startCli).createSnapshot(SNAPSHOT_NAME,
null, null, false,
- false, dump, false, false, false);
+ false, dump, false, false, false, false);
for (BlockingExecutor exec : execs)
exec.waitForBlocked(30_000L);
@@ -830,6 +830,7 @@ public abstract class AbstractSnapshotSelfTest extends
GridCommonAbstractTest {
false,
false,
false,
+ false,
snpSndr
);
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/EncryptedSnapshotTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/EncryptedSnapshotTest.java
index 67b6e82c469..f6ae22c2db4 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/EncryptedSnapshotTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/EncryptedSnapshotTest.java
@@ -296,6 +296,7 @@ public class EncryptedSnapshotTest extends
AbstractSnapshotSelfTest {
false,
false,
false,
+ false,
snp(ig).localSnapshotSenderFactory().apply(sft)
).get(TIMEOUT),
IgniteCheckedException.class,
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManagerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManagerSelfTest.java
index a5e9b805885..60b75e45824 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManagerSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManagerSelfTest.java
@@ -162,6 +162,7 @@ public class IgniteSnapshotManagerSelfTest extends
AbstractSnapshotSelfTest {
false,
false,
false,
+ false,
new DelegateSnapshotSender(log, mgr.snapshotExecutorService(),
mgr.localSnapshotSenderFactory().apply(sft)) {
@Override public void sendPart0(File from, File to, @Nullable
String storagePath, GroupPartitionId pair, Long length) {
try {
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/AbstractCacheDumpTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/AbstractCacheDumpTest.java
index a37187468df..571a1dc785d 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/AbstractCacheDumpTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/AbstractCacheDumpTest.java
@@ -526,7 +526,7 @@ public abstract class AbstractCacheDumpTest extends
GridCommonAbstractTest {
/** */
void createDump(IgniteEx ign, String name, @Nullable Collection<String>
cacheGrpNames, boolean comprParts) {
ign.context().cache().context().snapshotMgr()
- .createSnapshot(name, null, cacheGrpNames, false, onlyPrimary,
true, comprParts, encrypted, false).get();
+ .createSnapshot(name, null, cacheGrpNames, false, onlyPrimary,
true, comprParts, encrypted, false, false).get();
}
/** */
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpDataStructuresTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpDataStructuresTest.java
index 4a6b1a9a01b..5f5b687a312 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpDataStructuresTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpDataStructuresTest.java
@@ -311,7 +311,7 @@ public class IgniteCacheDumpDataStructuresTest extends
GridCommonAbstractTest {
IgniteSnapshotManager snpMgr =
ign.context().cache().context().snapshotMgr();
- snpMgr.createSnapshot(DMP_NAME, null, null, false, false, true, false,
false, true).get(getTestTimeout());
+ snpMgr.createSnapshot(DMP_NAME, null, null, false, false, true, false,
false, true, false).get(getTestTimeout());
fut.cancel();
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
index ec03bd66c6c..dfe11664e85 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/IgniteCacheDumpSelf2Test.java
@@ -354,6 +354,7 @@ public class IgniteCacheDumpSelf2Test extends
GridCommonAbstractTest {
true,
false,
false,
+ false,
false
).get();
}
@@ -834,6 +835,7 @@ public class IgniteCacheDumpSelf2Test extends
GridCommonAbstractTest {
true,
false,
false,
+ false,
false
).get();
@@ -924,10 +926,10 @@ public class IgniteCacheDumpSelf2Test extends
GridCommonAbstractTest {
String zipDump = "zipDump";
ign.context().cache().context().snapshotMgr()
- .createSnapshot(rawDump, null, null, false, true, true, false,
false, false).get();
+ .createSnapshot(rawDump, null, null, false, true, true, false,
false, false, false).get();
ign.context().cache().context().snapshotMgr()
- .createSnapshot(zipDump, null, null, false, true, true, true,
false, false).get();
+ .createSnapshot(zipDump, null, null, false, true, true, true,
false, false, false).get();
assertEquals("The check procedure has finished, no conflicts have been
found.\n\n", invokeCheckCommand(ign, rawDump));
@@ -1083,7 +1085,7 @@ public class IgniteCacheDumpSelf2Test extends
GridCommonAbstractTest {
public void testCreateEncryptedFail() throws Exception {
BiConsumer<IgniteEx, String> check = (ign, msg) -> assertThrows(null,
() -> {
ign.context().cache().context().snapshotMgr()
- .createSnapshot(DMP_NAME, null, null, false, false, true,
false, true, false).get(getTestTimeout());
+ .createSnapshot(DMP_NAME, null, null, false, false, true,
false, true, false, false).get(getTestTimeout());
}, IgniteException.class, msg);
try (IgniteEx srv = startGrid()) {
@@ -1113,7 +1115,7 @@ public class IgniteCacheDumpSelf2Test extends
GridCommonAbstractTest {
});
srv.context().cache().context().snapshotMgr()
- .createSnapshot(DMP_NAME, null, null, false, false, true,
false, true, false).get(getTestTimeout());
+ .createSnapshot(DMP_NAME, null, null, false, false, true,
false, true, false, false).get(getTestTimeout());
dumpDir = snapshotFileTree(srv, DMP_NAME).root();
}
@@ -1260,6 +1262,40 @@ public class IgniteCacheDumpSelf2Test extends
GridCommonAbstractTest {
}
}
+ /** */
+ @Test
+ public void testConfigOnlySnapshotThrows() throws Exception {
+ try (IgniteEx ign = startGrid(0)) {
+ ign.cluster().state(ClusterState.ACTIVE);
+
+ IgniteCache<Integer, Integer> c =
ign.createCache(DEFAULT_CACHE_NAME);
+
+ IntStream.range(0, 10).forEach(i -> c.put(i, i));
+
+ IgniteSnapshotManager snpMgr =
ign.context().cache().context().snapshotMgr();
+
+ assertThrows(
+ null,
+ () -> {
+ snpMgr.createSnapshot(
+ DMP_NAME,
+ null,
+ null,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ true
+ );
+ },
+ IgniteException.class,
+ "Config only supported only for dump"
+ );
+ }
+ }
+
/** */
public class TestCacheConflictResolutionManager<K, V> extends
GridCacheManagerAdapter<K, V>
implements CacheConflictResolutionManager<K, V> {
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 f39baa20fdb..8e348875776 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
@@ -53,6 +53,7 @@ import
org.apache.ignite.internal.processors.cache.persistence.file.FileIODecora
import
org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory;
import
org.apache.ignite.internal.processors.cache.persistence.filename.NodeFileTree;
import
org.apache.ignite.internal.processors.cache.persistence.filename.SnapshotFileTree;
+import
org.apache.ignite.internal.processors.cache.persistence.snapshot.SnapshotMetadata;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.T2;
@@ -634,6 +635,40 @@ public class IgniteCacheDumpSelfTest extends
AbstractCacheDumpTest {
cache.put(keyToFail, valToFail);
}
+ /** */
+ @Test
+ public void testOnlyConfigDump() throws Exception {
+ IgniteEx ign = startGridAndFillCaches();
+
+ ign.context().cache().context().snapshotMgr()
+ .createSnapshot(DMP_NAME, null, null, false, onlyPrimary, true,
false, encrypted, false, true).get();
+
+ checkDump(ign, DMP_NAME, null, Set.of(DEFAULT_CACHE_NAME, CACHE_0,
CACHE_1), 0, 0, 0, true, false);
+
+ SnapshotFileTree sft = snapshotFileTree(ign, DMP_NAME);
+ Set<String> expGrps = Set.of(DEFAULT_CACHE_NAME, GRP);
+
+ sft.existingCacheDirs().forEach(cacheDir -> {
+ assertTrue(expGrps.contains(NodeFileTree.cacheName(cacheDir)));
+ assertTrue(F.isEmpty(sft.existingCachePartitionFiles(cacheDir,
true, false)));
+ });
+
+ Dump dump = dump(ign, DMP_NAME);
+
+ for (SnapshotMetadata meta : dump.metadata()) {
+ List<Integer> grpIds =
expGrps.stream().map(CU::cacheId).collect(Collectors.toList());
+
+ assertTrue(grpIds.containsAll(meta.cacheGroupIds()));
+ }
+
+ for (SnapshotFileTree sft0 : dump.fileTrees()) {
+ for (String grp : expGrps) {
+ assertTrue(dump.partitions(sft0.folderName(),
CU.cacheId(grp)).isEmpty());
+ assertFalse(dump.configs(sft0.folderName(), CU.cacheId(grp),
null).isEmpty());
+ }
+ }
+ }
+
/** */
private void checkDumpCleared(IgniteEx ign) throws IgniteCheckedException {
if (persistence)