nizhikovprivate commented on code in PR #11969:
URL: https://github.com/apache/ignite/pull/11969#discussion_r2108659623
##########
modules/compatibility/src/test/java/org/apache/ignite/compatibility/persistence/SnapshotCompatibilityTest.java:
##########
@@ -336,85 +270,116 @@ public ConfigurationClosure(
cfg.setConsistentId(consId);
- storageCfg.setWalCompactionEnabled(incSnp);
+ storageCfg.setWalCompactionEnabled(true);
if (delIfExist) {
cfg.setCacheConfiguration(
- cacheGrpInfo.cacheNamesList().stream()
- .map(cacheName -> new CacheConfiguration<Integer,
String>(cacheName)
- .setGroupName(cacheGrpInfo.name())
- .setAffinity(new RendezvousAffinityFunction(false,
10))
+ cacheGrpsCfg.cacheGroupInfos().stream()
+ .flatMap(cacheGrpInfo ->
+ cacheGrpInfo.cacheNames().stream()
+ .map(cacheName -> new
CacheConfiguration<Integer, String>(cacheName)
+ .setGroupName(cacheGrpInfo.name())
+ .setAffinity(new
RendezvousAffinityFunction(false, 10))
+ )
)
.toArray(CacheConfiguration[]::new)
);
}
-
- if (customSnpPath) {
- try {
-
cfg.setSnapshotPath(customSnapshotPath(CUSTOM_SNP_RELATIVE_PATH, delIfExist));
- }
- catch (IgniteCheckedException e) {
- throw new RuntimeException(e);
- }
- }
}
}
- /**
- * Snapshot creating closure for old Ignite version.
- */
+ /** Snapshot creating closure both for old and current Ignite version. */
private static class CreateSnapshotClosure implements
IgniteInClosure<Ignite> {
/** */
- private final boolean incSnp;
-
- /** */
- private final boolean cacheDump;
+ private final CacheGroupsConfig cacheGrpsCfg;
/** */
- private final CacheGroupInfo cacheGrpInfo;
-
- /** */
- public CreateSnapshotClosure(boolean incSnp, boolean cacheDump,
CacheGroupInfo cacheGrpInfo) {
- this.incSnp = incSnp;
- this.cacheDump = cacheDump;
- this.cacheGrpInfo = cacheGrpInfo;
+ public CreateSnapshotClosure(CacheGroupsConfig cacheGrpsCfg) {
+ this.cacheGrpsCfg = cacheGrpsCfg;
}
/** {@inheritDoc} */
@Override public void apply(Ignite ign) {
ign.cluster().state(ClusterState.ACTIVE);
- cacheGrpInfo.addItemsToCacheGrp(ign, 0, BASE_CACHE_SIZE);
+ cacheGrpsCfg.cacheGroupInfos().forEach(cacheGrpInfo ->
cacheGrpInfo.addItemsToCacheGrp(ign, 0, BASE_CACHE_SIZE));
- if (cacheDump)
- ign.snapshot().createDump(CACHE_DUMP_NAME,
Collections.singleton(cacheGrpInfo.name())).get();
- else
- ign.snapshot().createSnapshot(SNAPSHOT_NAME).get();
+ ign.snapshot().createSnapshot(SNAPSHOT_NAME).get();
- if (incSnp) {
- cacheGrpInfo.addItemsToCacheGrp(ign, BASE_CACHE_SIZE,
ENTRIES_CNT_FOR_INCREMENT);
+ ign.snapshot().createDump(CACHE_DUMP_NAME,
cacheGrpsCfg.cacheGroupNames()).get();
+
+ // Incremental snapshots require same consistentID
+ // https://issues.apache.org/jira/browse/IGNITE-25096
+ if (ign.configuration().getConsistentId() != null &&
ign.cluster().nodes().size() == 1) {
+ cacheGrpsCfg.cacheGroupInfos().forEach(
+ cacheGrpInfo -> cacheGrpInfo.addItemsToCacheGrp(ign,
BASE_CACHE_SIZE, ENTRIES_CNT_FOR_INCREMENT)
+ );
ign.snapshot().createIncrementalSnapshot(SNAPSHOT_NAME).get();
}
}
}
+ /** */
+ private static class CacheGroupsConfig {
+ /** */
+ private final Map<String, CacheGroupInfo> cacheGrpInfos = new
HashMap<>();
+
+ /** */
+ public CacheGroupsConfig() {
+ // No-op
+ }
+
+ /** */
+ public CacheGroupsConfig(Set<CacheGroupInfo> cacheGrpInfos) {
+ cacheGrpInfos.forEach(cacheGrpInfo ->
this.cacheGrpInfos.put(cacheGrpInfo.name(), cacheGrpInfo));
+ }
+
+ /** */
+ public Collection<CacheGroupInfo> cacheGroupInfos() {
+ return cacheGrpInfos.values();
+ }
+
+ /** */
+ public Set<String> cacheGroupNames() {
+ return new HashSet<>(cacheGrpInfos.keySet());
+ }
+
+ /** */
+ public Set<String> cacheNames() {
Review Comment:
Looks like can be keep as method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]