xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795073799
##########
File path:
modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewSelfTest.java
##########
@@ -2044,6 +2048,53 @@ public void testBaselineNodeAttributes() throws
Exception {
}
}
+ /** */
+ @Test
+ public void testSnapshots() throws Exception {
+ cleanPersistenceDir();
+
+ String dfltCacheGrp = "testGroup";
+
+ String testSnap0 = "testSnap0";
+ String testSnap1 = "testSnap1";
+
+ try (IgniteEx ignite = startGrid(getConfiguration()
+ .setCacheConfiguration(new
CacheConfiguration<>(DEFAULT_CACHE_NAME).setGroupName(dfltCacheGrp))
+ .setDataStorageConfiguration(
+ new
DataStorageConfiguration().setDefaultDataRegionConfiguration(
+ new
DataRegionConfiguration().setName("pds").setPersistenceEnabled(true)
+ )))
+ ) {
+ ignite.cluster().state(ClusterState.ACTIVE);
+
+ ignite.cache(DEFAULT_CACHE_NAME).put(1, 1);
+
+ ignite.snapshot().createSnapshot(testSnap0).get();
+
+ SystemView<SnapshotView> views =
ignite.context().systemView().view(SNAPSHOTS_SYS_VIEW);
+
+ assertEquals(1, F.size(views.iterator()));
+
+ SnapshotView view = views.iterator().next();
+
+ assertEquals(testSnap0, view.snapshotName());
+ assertEquals(toStringSafe(ignite.localNode().consistentId()),
view.nodeId());
+
+ List<?> collect =
ignite.cluster().nodes().stream().map(ClusterNode::consistentId).collect(Collectors.toList());
Review comment:
```suggestion
List<?> constIds =
ignite.cluster().nodes().stream().map(ClusterNode::consistentId).collect(Collectors.toList());
```
##########
File path:
modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.spi.systemview.view;
+
+import java.util.Objects;
+import org.apache.ignite.internal.managers.systemview.walker.Filtrable;
+import org.apache.ignite.internal.managers.systemview.walker.Order;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+ /** Snapshot name. */
+ private final String name;
+
+ /** Node consistent id. */
+ private final String nodeId;
+
+ /** Baseline nodes affected by snapshots. */
+ private final String baselineNodes;
+
+ /** Cache group names that were included in the snapshot. */
+ private final String cacheGrps;
+
+ /**
+ * @param name Snapshot name.
+ * @param nodeId Node consistent id.
+ * @param baselineNodes Baseline nodes affected by snapshots.
+ * @param cacheGrps Cache group names that were included in the snapshot.
+ */
+ public SnapshotView(
+ String name,
+ String nodeId,
+ String baselineNodes,
+ String cacheGrps
+ ) {
+ this.name = name;
+ this.nodeId = nodeId;
+ this.baselineNodes = baselineNodes;
+ this.cacheGrps = cacheGrps;
+ }
+
+ /**
+ * @return Snapshot name.
+ */
+ @Order
+ @Filtrable
+ public String snapshotName() {
+ return name;
+ }
+
+ /**
+ * @return Node consistent id.
+ */
+ @Order(1)
+ @Filtrable
+ public String nodeId() {
+ return nodeId;
+ }
+
+ /**
+ * @return Baseline nodes affected by snapshots.
+ */
+ @Order(2)
+ @Filtrable
+ public String baselineNodes() {
+ return baselineNodes;
+ }
+
+ /**
+ * @return Cache group names that were included in the snapshot.
+ */
+ @Order(3)
+ public String cacheGroups() {
+ return cacheGrps;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
Review comment:
Do we really need equals and hashcode in the view?
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1882,6 +1898,20 @@ static void copy(FileIOFactory factory, File from, File
to, long length) {
return new
IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
}
+ /**
+ * @param snpName Snapshot name.
+ * @return Snapshot view.
+ */
+ private SnapshotView snapshotViewSupplier(String snpName) {
+ SnapshotMetadata meta = readSnapshotMetadata(snpName,
+
toStringSafe(cctx.kernalContext().discovery().localNode().consistentId()));
Review comment:
It is possible that the local node also stores snapshots from another
node, we should display those as well, not just the local one.
My suggestion is to change the data supplier to something like this:
```
() ->
localSnapshotNames().stream().map(this::readSnapshotMetadatas).flatMap(List::stream).collect(Collectors.toList()),
```
and replace the current argument of `snapshotViewSupplier` (`String
snpName`) to `SnapshotMetadata meta`
##########
File path:
modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewSelfTest.java
##########
@@ -2044,6 +2048,53 @@ public void testBaselineNodeAttributes() throws
Exception {
}
}
+ /** */
+ @Test
+ public void testSnapshots() throws Exception {
+ cleanPersistenceDir();
+
+ String dfltCacheGrp = "testGroup";
+
+ String testSnap0 = "testSnap0";
+ String testSnap1 = "testSnap1";
+
+ try (IgniteEx ignite = startGrid(getConfiguration()
+ .setCacheConfiguration(new
CacheConfiguration<>(DEFAULT_CACHE_NAME).setGroupName(dfltCacheGrp))
+ .setDataStorageConfiguration(
+ new
DataStorageConfiguration().setDefaultDataRegionConfiguration(
+ new
DataRegionConfiguration().setName("pds").setPersistenceEnabled(true)
+ )))
+ ) {
+ ignite.cluster().state(ClusterState.ACTIVE);
+
+ ignite.cache(DEFAULT_CACHE_NAME).put(1, 1);
+
+ ignite.snapshot().createSnapshot(testSnap0).get();
+
+ SystemView<SnapshotView> views =
ignite.context().systemView().view(SNAPSHOTS_SYS_VIEW);
+
+ assertEquals(1, F.size(views.iterator()));
Review comment:
Can we use `views.size()` instead of `F.size(views.iterator()`?
##########
File path:
modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewSelfTest.java
##########
@@ -2044,6 +2048,53 @@ public void testBaselineNodeAttributes() throws
Exception {
}
}
+ /** */
+ @Test
+ public void testSnapshots() throws Exception {
+ cleanPersistenceDir();
+
+ String dfltCacheGrp = "testGroup";
+
+ String testSnap0 = "testSnap0";
+ String testSnap1 = "testSnap1";
+
+ try (IgniteEx ignite = startGrid(getConfiguration()
+ .setCacheConfiguration(new
CacheConfiguration<>(DEFAULT_CACHE_NAME).setGroupName(dfltCacheGrp))
+ .setDataStorageConfiguration(
+ new
DataStorageConfiguration().setDefaultDataRegionConfiguration(
+ new
DataRegionConfiguration().setName("pds").setPersistenceEnabled(true)
+ )))
+ ) {
+ ignite.cluster().state(ClusterState.ACTIVE);
+
+ ignite.cache(DEFAULT_CACHE_NAME).put(1, 1);
+
+ ignite.snapshot().createSnapshot(testSnap0).get();
+
+ SystemView<SnapshotView> views =
ignite.context().systemView().view(SNAPSHOTS_SYS_VIEW);
+
+ assertEquals(1, F.size(views.iterator()));
+
+ SnapshotView view = views.iterator().next();
Review comment:
```suggestion
SnapshotView view = F.first(views);
```
##########
File path:
modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewSelfTest.java
##########
@@ -2044,6 +2048,53 @@ public void testBaselineNodeAttributes() throws
Exception {
}
}
+ /** */
+ @Test
+ public void testSnapshots() throws Exception {
+ cleanPersistenceDir();
+
+ String dfltCacheGrp = "testGroup";
+
+ String testSnap0 = "testSnap0";
+ String testSnap1 = "testSnap1";
+
+ try (IgniteEx ignite = startGrid(getConfiguration()
+ .setCacheConfiguration(new
CacheConfiguration<>(DEFAULT_CACHE_NAME).setGroupName(dfltCacheGrp))
+ .setDataStorageConfiguration(
+ new
DataStorageConfiguration().setDefaultDataRegionConfiguration(
+ new
DataRegionConfiguration().setName("pds").setPersistenceEnabled(true)
+ )))
+ ) {
+ ignite.cluster().state(ClusterState.ACTIVE);
+
+ ignite.cache(DEFAULT_CACHE_NAME).put(1, 1);
+
+ ignite.snapshot().createSnapshot(testSnap0).get();
+
+ SystemView<SnapshotView> views =
ignite.context().systemView().view(SNAPSHOTS_SYS_VIEW);
+
+ assertEquals(1, F.size(views.iterator()));
+
+ SnapshotView view = views.iterator().next();
+
+ assertEquals(testSnap0, view.snapshotName());
+ assertEquals(toStringSafe(ignite.localNode().consistentId()),
view.nodeId());
+
+ List<?> collect =
ignite.cluster().nodes().stream().map(ClusterNode::consistentId).collect(Collectors.toList());
+
+ assertEquals(toStringSafe(collect), view.baselineNodes());
+ assertEquals(toStringSafe(Arrays.asList(dfltCacheGrp,
METASTORAGE_CACHE_NAME)), view.cacheGroups());
+
+ ignite.createCache("testCache");
+
+ ignite.snapshot().createSnapshot(testSnap1).get();
+
+ views = ignite.context().systemView().view(SNAPSHOTS_SYS_VIEW);
+
+ assertEquals(2, F.size(views.iterator()));
Review comment:
Can we use `views.size()` instead of `F.size(views.iterator()`?
--
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]