This is an automated email from the ASF dual-hosted git repository.
namelchev 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 7e1d22444f8 IGNITE-19465 Fixed warning message for snapshot create
operation. (#10712)
7e1d22444f8 is described below
commit 7e1d22444f8716fce07fde6fdc3ce3c45af5b6c7
Author: Vladimir Steshin <[email protected]>
AuthorDate: Mon May 15 22:06:04 2023 +0300
IGNITE-19465 Fixed warning message for snapshot create operation. (#10712)
---
.../snapshot/IgniteSnapshotManager.java | 25 +++++++++++-----
.../snapshot/SnapshotOperationRequest.java | 3 ++
.../IgniteClusterSnapshotStreamerTest.java | 35 ++++++++++++++++++++++
3 files changed, 56 insertions(+), 7 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 54aefb66505..de06c731446 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
/** Snapshot operation finish log message. */
private static final String SNAPSHOT_FINISHED_MSG = "Cluster-wide snapshot
operation finished successfully: ";
+ /** Snapshot operation finish with warnings log message. */
+ public static final String SNAPSHOT_FINISHED_WRN_MSG = "Cluster-wide
snapshot operation finished with warnings: ";
+
/** Snapshot operation fail log message. */
private static final String SNAPSHOT_FAILED_MSG = "Cluster-wide snapshot
operation failed: ";
@@ -1478,17 +1481,21 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
if (clusterSnpFut != null) {
if (endFail.isEmpty() && snpReq.error() == null) {
if (!F.isEmpty(snpReq.warnings())) {
+ String wrnsLst = U.nl() + "\t- " + String.join(U.nl()
+ "\t- ", snpReq.warnings());
+
SnapshotWarningException wrn = new
SnapshotWarningException("Snapshot task '" +
- snpReq.snapshotName() + "' completed with the
warnings:" + U.nl() + "\t- " +
- String.join(U.nl() + "\t- ", snpReq.warnings()));
+ snpReq.snapshotName() + "' completed with the
warnings:" + wrnsLst);
clusterSnpFut.onDone(wrn);
+
+ log.warning(SNAPSHOT_FINISHED_WRN_MSG + snpReq + ".
Warnings:" + wrnsLst);
}
- else
+ else {
clusterSnpFut.onDone();
- if (log.isInfoEnabled())
- log.info(SNAPSHOT_FINISHED_MSG + snpReq);
+ if (log.isInfoEnabled())
+ log.info(SNAPSHOT_FINISHED_MSG + snpReq);
+ }
}
else if (snpReq.error() == null) {
clusterSnpFut.onDone(new IgniteCheckedException("Snapshot
creation has been finished with an error. " +
@@ -2221,8 +2228,12 @@ public class IgniteSnapshotManager extends
GridCacheSharedManagerAdapter
snpFut0.listen(f -> {
if (f.error() == null)
recordSnapshotEvent(name, SNAPSHOT_FINISHED_MSG + grps,
EVT_CLUSTER_SNAPSHOT_FINISHED);
- else
- recordSnapshotEvent(name, SNAPSHOT_FAILED_MSG +
f.error().getMessage(), EVT_CLUSTER_SNAPSHOT_FAILED);
+ else {
+ String errMsgPref = f.error() instanceof
SnapshotWarningException ? SNAPSHOT_FINISHED_WRN_MSG
+ : SNAPSHOT_FAILED_MSG;
+
+ recordSnapshotEvent(name, errMsgPref +
f.error().getMessage(), EVT_CLUSTER_SNAPSHOT_FAILED);
+ }
});
Set<UUID> bltNodeIds =
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 b9283a84154..05008820bf4 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
@@ -24,6 +24,7 @@ import java.util.Set;
import java.util.UUID;
import org.apache.ignite.internal.util.distributed.DistributedProcess;
import
org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -66,11 +67,13 @@ public class SnapshotOperationRequest implements
Serializable {
private volatile List<String> warnings;
/** Snapshot metadata. */
+ @GridToStringExclude
private transient SnapshotMetadata meta;
/**
* Warning flag of concurrent inconsistent-by-nature streamer updates.
*/
+ @GridToStringExclude
private transient volatile boolean streamerWrn;
/** Flag indicating that the {@link DistributedProcessType#START_SNAPSHOT}
phase has completed. */
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotStreamerTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotStreamerTest.java
index 2bc9ce9eea5..7b91fd5ebfb 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotStreamerTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteClusterSnapshotStreamerTest.java
@@ -18,9 +18,11 @@
package org.apache.ignite.internal.processors.cache.persistence.snapshot;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
@@ -34,6 +36,7 @@ import
org.apache.ignite.configuration.DataRegionConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.EventType;
+import org.apache.ignite.events.SnapshotEvent;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.TestRecordingCommunicationSpi;
@@ -47,9 +50,11 @@ import org.junit.Assume;
import org.junit.Test;
import static org.apache.ignite.cluster.ClusterState.ACTIVE;
+import static org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_FAILED;
import static
org.apache.ignite.internal.IgniteNodeAttributes.ATTR_DATA_STREAMER_POOL_SIZE;
import static org.apache.ignite.testframework.GridTestUtils.assertThrows;
import static org.apache.ignite.testframework.GridTestUtils.runAsync;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
/**
* Tests snapshot is consistent or snapshot process produces proper warning
with concurrent streaming.
@@ -64,6 +69,12 @@ public class IgniteClusterSnapshotStreamerTest extends
AbstractSnapshotSelfTest
/** Non-baseline.*/
private IgniteEx nonBaseline;
+ /** Node log listeners. */
+ private final Map<String, ListeningTestLogger> logLsnrs = new HashMap<>();
+
+ /** */
+ private final List<SnapshotEvent> snpEvts = new CopyOnWriteArrayList<>();
+
/** {@inheritDoc} */
@Override public void beforeTestSnapshot() throws Exception {
super.beforeTestSnapshot();
@@ -96,6 +107,12 @@ public class IgniteClusterSnapshotStreamerTest extends
AbstractSnapshotSelfTest
if (cfg.isClientMode())
return cfg;
+ ListeningTestLogger logLsnr = new
ListeningTestLogger(cfg.getGridLogger());
+
+ logLsnrs.put(igniteInstanceName, logLsnr);
+
+ cfg.setGridLogger(logLsnr);
+
// In-memory data region.
DataRegionConfiguration inMemDr = new DataRegionConfiguration();
inMemDr.setPersistenceEnabled(false);
@@ -156,6 +173,8 @@ public class IgniteClusterSnapshotStreamerTest extends
AbstractSnapshotSelfTest
assert U.isLocalNodeCoordinator(nonBaseline.context().discovery());
+ nonBaseline.events().localListen(e -> snpEvts.add((SnapshotEvent)e),
EVT_CLUSTER_SNAPSHOT_FAILED);
+
doTestDataStreamerWhileSnapshot(nonBaseline, false);
}
@@ -435,6 +454,17 @@ public class IgniteClusterSnapshotStreamerTest extends
AbstractSnapshotSelfTest
if (expWrn == null)
snp(snpHnd).createSnapshot(SNAPSHOT_NAME, null, false,
onlyPrimary).get();
else {
+ LogListener logLsnr =
LogListener.matches(IgniteSnapshotManager.SNAPSHOT_FINISHED_WRN_MSG)
+ .andMatches(expWrn).times(1).build();
+
+ Ignite realOpNode = snpHnd.localNode().isClient() ?
G.allGrids().stream()
+ .filter(g ->
U.isLocalNodeCoordinator(((IgniteEx)g).context().discovery()))
+ .findFirst().get() : snpHnd;
+
+ realOpNode.events().localListen(e ->
snpEvts.add((SnapshotEvent)e), EVT_CLUSTER_SNAPSHOT_FAILED);
+
+ logLsnrs.get(realOpNode.name()).registerListener(logLsnr);
+
Throwable snpWrn = assertThrows(
null,
() -> snp(snpHnd).createSnapshot(SNAPSHOT_NAME, null,
false, onlyPrimary).get(),
@@ -444,6 +474,11 @@ public class IgniteClusterSnapshotStreamerTest extends
AbstractSnapshotSelfTest
if (notExpWrn != null)
assertTrue(!snpWrn.getMessage().contains(notExpWrn));
+
+ logLsnr.check(getTestTimeout());
+
+ waitForCondition(() -> snpEvts.removeIf(e ->
e.snapshotName().equals(SNAPSHOT_NAME) &&
+
e.message().contains(IgniteSnapshotManager.SNAPSHOT_FINISHED_WRN_MSG)),
getTestTimeout());
}
}