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 87a22b17e34 IGNITE-23344 Fix wrong log message while creating full 
snapshot (#11588)
87a22b17e34 is described below

commit 87a22b17e349928a52c3cf75f00096dc04989d7d
Author: Vladislav Novikov <[email protected]>
AuthorDate: Tue Oct 15 23:44:17 2024 +0300

    IGNITE-23344 Fix wrong log message while creating full snapshot (#11588)
---
 .../snapshot/IgniteSnapshotManager.java            | 38 ++++++++--------
 .../snapshot/IgniteSnapshotManagerSelfTest.java    | 50 ++++++++++++++++++++++
 2 files changed, 70 insertions(+), 18 deletions(-)

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 dc893677f01..1b1f07d748c 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
@@ -328,6 +328,9 @@ public class IgniteSnapshotManager extends 
GridCacheSharedManagerAdapter
     @Deprecated
     private static final String SNP_RUNNING_KEY = "snapshot-running";
 
+    /** Snapshot operation start log message. */
+    private static final String SNAPSHOT_STARTED_MSG = "Cluster-wide snapshot 
operation started: ";
+
     /** Snapshot operation finish log message. */
     private static final String SNAPSHOT_FINISHED_MSG = "Cluster-wide snapshot 
operation finished successfully: ";
 
@@ -2289,25 +2292,24 @@ public class IgniteSnapshotManager extends 
GridCacheSharedManagerAdapter
             Set<UUID> bltNodeIds =
                 new HashSet<>(F.viewReadOnly(srvNodes, F.node2id(), (node) -> 
CU.baselineNode(node, clusterState)));
 
-            startSnpProc.start(snpFut0.rqId, new SnapshotOperationRequest(
-                snpFut0.rqId,
-                cctx.localNodeId(),
-                name,
-                snpPath,
-                grps,
-                bltNodeIds,
-                incremental,
-                incIdx,
-                onlyPrimary,
-                dump,
-                compress,
-                encrypt
-            ));
+            SnapshotOperationRequest snpOpReq = new SnapshotOperationRequest(
+                    snpFut0.rqId,
+                    cctx.localNodeId(),
+                    name,
+                    snpPath,
+                    grps,
+                    bltNodeIds,
+                    incremental,
+                    incIdx,
+                    onlyPrimary,
+                    dump,
+                    compress,
+                    encrypt
+            );
+
+            startSnpProc.start(snpFut0.rqId, snpOpReq);
 
-            String msg =
-                "Cluster-wide snapshot operation started [snpName=" + name + 
", grps=" + grps +
-                    (incremental ? "" : (", incremental=true, incrementIndex=" 
+ incIdx)) +
-                ']';
+            String msg = SNAPSHOT_STARTED_MSG + snpOpReq;
 
             recordSnapshotEvent(name, msg, EVT_CLUSTER_SNAPSHOT_STARTED);
 
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 f8c3ab02720..eff31d2e2a1 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
@@ -72,6 +72,7 @@ import static 
org.apache.ignite.internal.processors.cache.persistence.snapshot.I
 import static 
org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_RUNNER_THREAD_PREFIX;
 import static 
org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause;
 import static org.apache.ignite.testframework.GridTestUtils.setFieldValue;
+import static org.junit.Assume.assumeFalse;
 
 /**
  * Default snapshot manager test.
@@ -581,6 +582,55 @@ public class IgniteSnapshotManagerSelfTest extends 
AbstractSnapshotSelfTest {
         assertEquals(snapshotThreadPoolSize.longValue(), snpRunningThreads);
     }
 
+    /**
+     * Tests that full-copy and incremental snapshots log correctly.
+     *
+     * @throws Exception If fails.
+     * */
+    @Test
+    public void testFullSnapshotCreationLog() throws Exception {
+        assumeFalse("https://issues.apache.org/jira/browse/IGNITE-17819";, 
encryption);
+
+        listenLog = new ListeningTestLogger(log);
+
+        final int entriesCnt = 4;
+
+        LogListener matchStart = LogListener.matches("Cluster-wide snapshot 
operation started: ").times(entriesCnt).build();
+        listenLog.registerListener(matchStart);
+
+        LogListener matchFinish = LogListener.matches("Cluster-wide snapshot 
operation finished successfully: ").times(entriesCnt).build();
+        listenLog.registerListener(matchFinish);
+
+        LogListener matchFullParams = LogListener.matches("incremental=false, 
incIdx=-1").times(2).build();
+        listenLog.registerListener(matchFullParams);
+
+        LogListener matchIncParams = 
LogListener.matches("incremental=true").times(2 * (entriesCnt - 1)).build();
+        listenLog.registerListener(matchIncParams);
+
+        LogListener noMatchParams = LogListener.matches("incremental=true, 
incIdx=-1").build();
+        listenLog.registerListener(noMatchParams);
+
+        IgniteEx ignite = startGrid(getConfiguration().setConsistentId(null));
+        ignite.cluster().state(ClusterState.ACTIVE);
+
+        IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(new 
CacheConfiguration<>(DEFAULT_CACHE_NAME));
+
+        cache.put(0, 0);
+        ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get();
+        for (int i = 1; i < entriesCnt; i++) {
+            cache.put(i, i);
+            ignite.snapshot().createIncrementalSnapshot(SNAPSHOT_NAME).get();
+        }
+
+        ignite.close();
+
+        assertTrue(matchStart.check());
+        assertTrue(matchFinish.check());
+        assertTrue(matchFullParams.check());
+        assertTrue(matchIncParams.check());
+        assertFalse(noMatchParams.check());
+    }
+
     /**
      * @param ignite Ignite instance to set factory.
      * @param factory New factory to use.

Reply via email to