You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/09/19 20:18:43 UTC

[GitHub] [ignite] Sega76 opened a new pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Sega76 opened a new pull request #9422:
URL: https://github.com/apache/ignite/pull/9422


   Thank you for submitting the pull request to the Apache Ignite.
   
   In order to streamline the review of the contribution 
   we ask you to ensure the following steps have been taken:
   
   ### The Contribution Checklist
   - [ ] There is a single JIRA ticket related to the pull request. 
   - [ ] The web-link to the pull request is attached to the JIRA ticket.
   - [ ] The JIRA ticket has the _Patch Available_ state.
   - [ ] The pull request body describes changes that have been made. 
   The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
   - [ ] The pull request title is treated as the final commit message. 
   The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
   - [ ] A reviewer has been mentioned through the JIRA comments 
   (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) 
   - [ ] The pull request has been checked by the Teamcity Bot and 
   the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
   
   ### Notes
   - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
   - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
   - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
   - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
   
   If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
   


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712591281



##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -899,3 +899,17 @@ Note, lock will be shown on the non parent node only after initial usage on that
 |GROUP_ID | int | Cache group id to store data structure
 |REMOVED | boolean | `True` if removed
 |===
+
+== SNAPSHOTS
+
+The SNAPSHOTS view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_CONSISTENT_ID | VARCHAR | Node consistent ID.
+| CACHE_GROUP | VARCHAR | Name of cache group.
+| LOCAL_PARTITIONS | VARCHAR | Numbers of local partitions for cache group.

Review comment:
       `Partition numbers of the cache group stored in the snapshot.` ?
   or at least I suggest `for cache group.` -> `of the cache group.`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795643076



##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -949,3 +949,17 @@ The STATISTICS_PARTITION_DATA view contains information about link:SQL/sql-stati
 |VERSION |BIGINT |Statistics version.
 |LAST_UPDATE_TIME |VARCHAR |Maximum time of all partition statistics which was used to generate local one.
 |===
+
+== SNAPSHOT
+
+The SNAPSHOT view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_ID | VARCHAR | Consistent ID of a node to which snapshot data relates.
+| BASELINE_NODES | VARCHAR | Baseline nodes affected by snapshot.
+| CACHE_GROUPS | VARCHAR | Cache group names that were included in the snapshot.
+

Review comment:
       remove this line




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795643076



##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -949,3 +949,17 @@ The STATISTICS_PARTITION_DATA view contains information about link:SQL/sql-stati
 |VERSION |BIGINT |Statistics version.
 |LAST_UPDATE_TIME |VARCHAR |Maximum time of all partition statistics which was used to generate local one.
 |===
+
+== SNAPSHOT
+
+The SNAPSHOT view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_ID | VARCHAR | Consistent ID of a node to which snapshot data relates.
+| BASELINE_NODES | VARCHAR | Baseline nodes affected by snapshot.
+| CACHE_GROUPS | VARCHAR | Cache group names that were included in the snapshot.
+

Review comment:
       remove this extra line




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795734111



##########
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 testSnapshot() throws Exception {
+        cleanPersistenceDir();

Review comment:
       here it is needed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712940989



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,43 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(meta.consistentId()))
+                            return Collections.emptyList();
+
+                    List<String> cacheCrps = snapshotCacheDirectories(snpName, meta.folderName()).stream()

Review comment:
       Thanks, fixed.
   asked Maxim Muzafarov, he believes that the metastorage is included from the view




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712592880



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.Set;
+import org.apache.ignite.internal.managers.systemview.walker.Filtrable;
+import org.apache.ignite.internal.managers.systemview.walker.Order;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final String consistentId;
+
+    /** Cache group name. */
+    private final String cacheGrp;
+
+    /** Cache group local partitions. */
+    private final String locPartitions;
+
+    /**
+     * @param name Snapshot name.
+     * @param consistentId Node consistent id.
+     * @param cacheGrp Cache group.
+     * @param locPartitions Cache group local partitions.
+     */
+    public SnapshotView(String name, String consistentId, String cacheGrp, @Nullable Set<Integer> locPartitions) {
+        this.name = name;
+        this.consistentId = consistentId;
+        this.cacheGrp = cacheGrp;
+        this.locPartitions = locPartitions != null ? String.valueOf(locPartitions) : "[]";
+    }
+
+    /**
+     * @return Snapshot name.
+     */
+    @Order
+    @Filtrable
+    public String snapshotName() {
+        return name;
+    }
+
+    /**
+     * @return Node consistent id.
+     */
+    @Order(1)
+    @Filtrable
+    public String consistentId() {
+        return consistentId;
+    }
+
+    /**
+     * @return Cache group name.
+     */
+    @Order(2)
+    public String cacheGroup() {
+        return cacheGrp;
+    }
+
+    /**
+     * @return Numbers of local partitions for cache group.

Review comment:
       I suggest using the same comment for the same member throughout the file - `Cache group local partitions.` or `Numbers of local partitions for the cache group.`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795394916



##########
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:
       removed it




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r715508916



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -2468,4 +2515,67 @@ public IgniteSnapshotFutureImpl(IgniteInternalFuture<Void> fut) {
                 return new IgniteException("Snapshot has not been created", U.convertException(e));
         }
     }
+
+    /** Get the snapshot view of a cluster. */
+    @GridInternal
+    private static class SnapshotViewTask extends VisorMultiNodeTask<String, Set<SnapshotView>, List<SnapshotView>> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** {@inheritDoc} */
+        @Override protected SnapshotViewJob job(String arg) {
+            return new SnapshotViewJob(arg, debug);
+        }
+
+        /**  */
+        private static class SnapshotViewJob extends VisorJob<String, List<SnapshotView>> {
+            /** */
+            private static final long serialVersionUID = 0L;
+
+            /**
+             * Create job without specified argument.
+             *
+             * @param arg Job argument.
+             * @param debug Flag indicating whether debug information should be printed into node log.
+             */
+            protected SnapshotViewJob(@Nullable String arg, boolean debug) {
+                super(arg, debug);
+            }
+
+            /** {@inheritDoc} */
+            @Override protected List<SnapshotView> run(@Nullable String snapName) {
+                IgniteSnapshotManager snapMngr = (IgniteSnapshotManager)ignite.snapshot();
+
+                List<SnapshotMetadata> metas;
+
+                if (snapName != null)
+                    metas = snapMngr.readSnapshotMetadatas(snapName);
+                else
+                    metas = snapMngr.localSnapshotNames().stream()
+                        .map(snapMngr::readSnapshotMetadatas)
+                        .flatMap(Collection::stream)
+                        .collect(Collectors.toList());
+
+                return metas.stream().map(meta -> {
+                    Collection<String> cacheGrps = F.viewReadOnly(snapMngr.snapshotCacheDirectories(meta.snapshotName(), meta.folderName()),
+                        FilePageStoreManager::cacheGroupName);
+
+                    return new SnapshotView(meta.snapshotName(),
+                        meta.consistentId(),
+                        String.valueOf(meta.baselineNodes()),
+                        String.valueOf(cacheGrps));
+                }).collect(Collectors.toList());
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override protected Set<SnapshotView> reduce0(List<ComputeJobResult> results)
+            throws IgniteException {
+            return results.stream()
+                .map(ComputeJobResult::getData)

Review comment:
       fixed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712592880



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.Set;
+import org.apache.ignite.internal.managers.systemview.walker.Filtrable;
+import org.apache.ignite.internal.managers.systemview.walker.Order;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final String consistentId;
+
+    /** Cache group name. */
+    private final String cacheGrp;
+
+    /** Cache group local partitions. */
+    private final String locPartitions;
+
+    /**
+     * @param name Snapshot name.
+     * @param consistentId Node consistent id.
+     * @param cacheGrp Cache group.
+     * @param locPartitions Cache group local partitions.
+     */
+    public SnapshotView(String name, String consistentId, String cacheGrp, @Nullable Set<Integer> locPartitions) {
+        this.name = name;
+        this.consistentId = consistentId;
+        this.cacheGrp = cacheGrp;
+        this.locPartitions = locPartitions != null ? String.valueOf(locPartitions) : "[]";
+    }
+
+    /**
+     * @return Snapshot name.
+     */
+    @Order
+    @Filtrable
+    public String snapshotName() {
+        return name;
+    }
+
+    /**
+     * @return Node consistent id.
+     */
+    @Order(1)
+    @Filtrable
+    public String consistentId() {
+        return consistentId;
+    }
+
+    /**
+     * @return Cache group name.
+     */
+    @Order(2)
+    public String cacheGroup() {
+        return cacheGrp;
+    }
+
+    /**
+     * @return Numbers of local partitions for cache group.

Review comment:
       I suggest using the same javadoc description for the same member throughout the file.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795734466



##########
File path: modules/control-utility/src/test/java/org/apache/ignite/util/SystemViewCommandTest.java
##########
@@ -1108,6 +1111,18 @@ public void testDistributedMetastorage() throws Exception {
             getTestTimeout()));
     }
 
+    /** */
+    @Test
+    public void testSnapshotView() throws Exception {
+        int srvCnt = (int)G.allGrids().stream().filter(n -> !n.configuration().isClientMode()).count();

Review comment:
       done




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795907789



##########
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 testSnapshot() 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(SNAPSHOT_SYS_VIEW);
+
+            assertEquals(1, views.size());
+
+            SnapshotView view = F.first(views);
+
+            assertEquals(testSnap0, view.snapshotName());
+            assertEquals(toStringSafe(ignite.localNode().consistentId()), view.nodeId());
+
+            List<?> constIds = ignite.cluster().nodes().stream().map(ClusterNode::consistentId).collect(Collectors.toList());

Review comment:
       fixed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712941107



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.Set;
+import org.apache.ignite.internal.managers.systemview.walker.Filtrable;
+import org.apache.ignite.internal.managers.systemview.walker.Order;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final String consistentId;
+
+    /** Cache group name. */
+    private final String cacheGrp;
+
+    /** Cache group local partitions. */
+    private final String locPartitions;
+
+    /**
+     * @param name Snapshot name.
+     * @param consistentId Node consistent id.
+     * @param cacheGrp Cache group.
+     * @param locPartitions Cache group local partitions.
+     */
+    public SnapshotView(String name, String consistentId, String cacheGrp, @Nullable Set<Integer> locPartitions) {
+        this.name = name;
+        this.consistentId = consistentId;
+        this.cacheGrp = cacheGrp;
+        this.locPartitions = locPartitions != null ? String.valueOf(locPartitions) : "[]";

Review comment:
       done




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r715508684



##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -899,3 +899,17 @@ Note, lock will be shown on the non parent node only after initial usage on that
 |GROUP_ID | int | Cache group id to store data structure
 |REMOVED | boolean | `True` if removed
 |===
+
+== SNAPSHOTS
+
+The SNAPSHOTS view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_ID | VARCHAR | Consistent id of a node to which this metadata relates.

Review comment:
       done

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1773,30 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        Collection<ClusterNode> nodes = cctx.kernalContext().discovery().aliveServerNodes();
+
+        if (nodeConsistentId != null)

Review comment:
       done

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1773,30 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        Collection<ClusterNode> nodes = cctx.kernalContext().discovery().aliveServerNodes();
+
+        if (nodeConsistentId != null)
+             nodes = nodes.stream()
+                 .filter(n -> toStringSafe(n.consistentId()).equals(nodeConsistentId))
+                 .collect(Collectors.toSet());
+
+        List<UUID> ids = nodes.stream().map(ClusterNode::id).collect(Collectors.toList());
+
+        ComputeTaskFuture<Set<SnapshotView>> fut = ((ClusterGroupAdapter)cctx.kernalContext().cluster().get().forServers()).compute()
+            .executeAsync(new SnapshotViewTask(), new VisorTaskArgument<String>(ids, snapshotName, false));
+
+        return fut.get();

Review comment:
       done

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -2468,4 +2515,67 @@ public IgniteSnapshotFutureImpl(IgniteInternalFuture<Void> fut) {
                 return new IgniteException("Snapshot has not been created", U.convertException(e));
         }
     }
+
+    /** Get the snapshot view of a cluster. */
+    @GridInternal
+    private static class SnapshotViewTask extends VisorMultiNodeTask<String, Set<SnapshotView>, List<SnapshotView>> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** {@inheritDoc} */
+        @Override protected SnapshotViewJob job(String arg) {
+            return new SnapshotViewJob(arg, debug);
+        }
+
+        /**  */
+        private static class SnapshotViewJob extends VisorJob<String, List<SnapshotView>> {
+            /** */
+            private static final long serialVersionUID = 0L;
+
+            /**
+             * Create job without specified argument.
+             *
+             * @param arg Job argument.
+             * @param debug Flag indicating whether debug information should be printed into node log.
+             */
+            protected SnapshotViewJob(@Nullable String arg, boolean debug) {
+                super(arg, debug);
+            }
+
+            /** {@inheritDoc} */
+            @Override protected List<SnapshotView> run(@Nullable String snapName) {
+                IgniteSnapshotManager snapMngr = (IgniteSnapshotManager)ignite.snapshot();
+
+                List<SnapshotMetadata> metas;
+
+                if (snapName != null)
+                    metas = snapMngr.readSnapshotMetadatas(snapName);
+                else

Review comment:
       done




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712563140



##########
File path: modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewSelfTest.java
##########
@@ -2044,6 +2047,57 @@ 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.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(dfltCacheGrp, view.cacheGroup());

Review comment:
       I suggest checking local partitions output, too.
   
   something like
   ```
   Collection<Integer> locParts = F.viewReadOnly(
       ignite.cachex(DEFAULT_CACHE_NAME).context().topology().localPartitions(), GridDhtLocalPartition::id);
           
   assertEquals(S.compact(locParts), view.localPartitions());
   ```
   but we should put some values into the cache. I don't think it is worth creating 1024 (+1024 in the snapshot) files every time, so it is better to limit this number in the cache configuration or add an extra predicate to check if partitions were actually created (using IgnitePageStoreManager#exists for example).




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r715644522



##########
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;
+
+    /** The cache groups names which were included into snapshot. */

Review comment:
       done




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795394490



##########
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:
       fixed

##########
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:
       fixed

##########
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:
       fixed

##########
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:
       fixed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r796597277



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.ignite.internal.managers.systemview.walker.Order;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot system view name. */
+    public static final String SNAPSHOT_SYS_VIEW = "snapshot";
+
+    /** Snapshot system view description. */
+    public static final String SNAPSHOT_SYS_VIEW_DESC = "Snapshot";
+
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final String consistentId;
+
+    /** Baseline nodes affected by snapshot. */
+    private final String baselineNodes;
+
+    /** Cache group names that were included in the snapshot. */
+    private final String cacheGrps;
+
+    /**
+     * @param name Snapshot name.
+     * @param consistentId Node consistent id.
+     * @param baselineNodes Baseline nodes affected by snapshot.

Review comment:
       ```suggestion
        * @param baselineNodes Baseline nodes affected by the snapshot.
   ```




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r796597597



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.ignite.internal.managers.systemview.walker.Order;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot system view name. */
+    public static final String SNAPSHOT_SYS_VIEW = "snapshot";
+
+    /** Snapshot system view description. */
+    public static final String SNAPSHOT_SYS_VIEW_DESC = "Snapshot";
+
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final String consistentId;
+
+    /** Baseline nodes affected by snapshot. */
+    private final String baselineNodes;
+
+    /** Cache group names that were included in the snapshot. */
+    private final String cacheGrps;
+
+    /**
+     * @param name Snapshot name.
+     * @param consistentId Node consistent id.

Review comment:
       ```suggestion
        * @param consistentId Node consistent ID.
   ```




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r796597785



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.ignite.internal.managers.systemview.walker.Order;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot system view name. */
+    public static final String SNAPSHOT_SYS_VIEW = "snapshot";
+
+    /** Snapshot system view description. */
+    public static final String SNAPSHOT_SYS_VIEW_DESC = "Snapshot";
+
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */

Review comment:
       ```suggestion
       /** Node consistent ID. */
   ```




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712591281



##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -899,3 +899,17 @@ Note, lock will be shown on the non parent node only after initial usage on that
 |GROUP_ID | int | Cache group id to store data structure
 |REMOVED | boolean | `True` if removed
 |===
+
+== SNAPSHOTS
+
+The SNAPSHOTS view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_CONSISTENT_ID | VARCHAR | Node consistent ID.
+| CACHE_GROUP | VARCHAR | Name of cache group.
+| LOCAL_PARTITIONS | VARCHAR | Numbers of local partitions for cache group.

Review comment:
       `Partition numbers of the cache group stored in the snapshot.` ?
   or at least I suggest `for cache group.` => `for the cache group.`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r722459251



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1766,19 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * @param snpName Snapshot name.
+     */

Review comment:
       Thanks, fixed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795072615



##########
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  `snapshotViewSupplier(SnapshotMetadata meta)`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712073326



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))
+                            return Collections.emptyList();
+
+                        return F.iterator(getCacheGroupsName(meta), cacheGrp -> new SnapshotView(

Review comment:
       Can we use IgniteSnapshotManager#snapshotCacheDirectories (or FilePageStoreManager#cacheDirectories) instead of creating a new one?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795602893



##########
File path: modules/control-utility/src/test/java/org/apache/ignite/util/SystemViewCommandTest.java
##########
@@ -1108,6 +1111,18 @@ public void testDistributedMetastorage() throws Exception {
             getTestTimeout()));
     }
 
+    /** */
+    @Test
+    public void testSnapshotView() throws Exception {
+        int srvCnt = (int)G.allGrids().stream().filter(n -> !n.configuration().isClientMode()).count();

Review comment:
       ```suggestion
           int srvCnt = ignite0.cluster().forServers().nodes().size();
   ```

##########
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 testSnapshot() 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(SNAPSHOT_SYS_VIEW);
+
+            assertEquals(1, views.size());
+
+            SnapshotView view = F.first(views);
+
+            assertEquals(testSnap0, view.snapshotName());
+            assertEquals(toStringSafe(ignite.localNode().consistentId()), view.nodeId());
+
+            List<?> constIds = ignite.cluster().nodes().stream().map(ClusterNode::consistentId).collect(Collectors.toList());

Review comment:
       ```suggestion
               List<?> constIds = F.nodeConsistentIds(ignite.cluster().nodes());
   ```

##########
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 testSnapshot() throws Exception {
+        cleanPersistenceDir();

Review comment:
       redundant call

##########
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 testSnapshot() 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(SNAPSHOT_SYS_VIEW);
+
+            assertEquals(1, views.size());
+
+            SnapshotView view = F.first(views);
+
+            assertEquals(testSnap0, view.snapshotName());
+            assertEquals(toStringSafe(ignite.localNode().consistentId()), view.nodeId());
+
+            List<?> constIds = ignite.cluster().nodes().stream().map(ClusterNode::consistentId).collect(Collectors.toList());
+
+            assertEquals(toStringSafe(constIds), view.baselineNodes());
+            assertEquals(toStringSafe(Arrays.asList(dfltCacheGrp, METASTORAGE_CACHE_NAME)), view.cacheGroups());

Review comment:
       Re-check this test.

##########
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 testSnapshot() 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(SNAPSHOT_SYS_VIEW);
+
+            assertEquals(1, views.size());
+
+            SnapshotView view = F.first(views);
+
+            assertEquals(testSnap0, view.snapshotName());
+            assertEquals(toStringSafe(ignite.localNode().consistentId()), view.nodeId());
+
+            List<?> constIds = ignite.cluster().nodes().stream().map(ClusterNode::consistentId).collect(Collectors.toList());
+
+            assertEquals(toStringSafe(constIds), 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(SNAPSHOT_SYS_VIEW);
+
+            assertEquals(2, views.size());

Review comment:
       ```suggestion
               assertEquals(2, views.size());
   
               List<String> exp = new ArrayList<>(F.asList(testSnap0, testSnap1));
   
               views.forEach(v -> assertTrue(exp.remove(v.snapshotName())));
   
               assertTrue(exp.isEmpty());
   ```

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/managers/systemview/walker/SnapshotViewWalker.java
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.internal.managers.systemview.walker;
+
+import org.apache.ignite.spi.systemview.view.SnapshotView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+
+/**
+ * Generated by {@code org.apache.ignite.codegen.SystemViewRowAttributeWalkerGenerator}.
+ * {@link SnapshotView} attributes walker.
+ *
+ * @see SnapshotView
+ */
+public class SnapshotViewWalker implements SystemViewRowAttributeWalker<SnapshotView> {

Review comment:
       SystemViewRowAttributeWalkerGenerator generates another class, check, please.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712941413



##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -899,3 +899,17 @@ Note, lock will be shown on the non parent node only after initial usage on that
 |GROUP_ID | int | Cache group id to store data structure
 |REMOVED | boolean | `True` if removed
 |===
+
+== SNAPSHOTS
+
+The SNAPSHOTS view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_CONSISTENT_ID | VARCHAR | Node consistent ID.
+| CACHE_GROUP | VARCHAR | Name of cache group.
+| LOCAL_PARTITIONS | VARCHAR | Numbers of local partitions for cache group.

Review comment:
       fixed

##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.Set;
+import org.apache.ignite.internal.managers.systemview.walker.Filtrable;
+import org.apache.ignite.internal.managers.systemview.walker.Order;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final String consistentId;
+
+    /** Cache group name. */
+    private final String cacheGrp;
+
+    /** Cache group local partitions. */
+    private final String locPartitions;
+
+    /**
+     * @param name Snapshot name.
+     * @param consistentId Node consistent id.
+     * @param cacheGrp Cache group.
+     * @param locPartitions Cache group local partitions.
+     */
+    public SnapshotView(String name, String consistentId, String cacheGrp, @Nullable Set<Integer> locPartitions) {
+        this.name = name;
+        this.consistentId = consistentId;
+        this.cacheGrp = cacheGrp;
+        this.locPartitions = locPartitions != null ? String.valueOf(locPartitions) : "[]";
+    }
+
+    /**
+     * @return Snapshot name.
+     */
+    @Order
+    @Filtrable
+    public String snapshotName() {
+        return name;
+    }
+
+    /**
+     * @return Node consistent id.
+     */
+    @Order(1)
+    @Filtrable
+    public String consistentId() {
+        return consistentId;
+    }
+
+    /**
+     * @return Cache group name.
+     */
+    @Order(2)
+    public String cacheGroup() {
+        return cacheGrp;
+    }
+
+    /**
+     * @return Numbers of local partitions for cache group.

Review comment:
       fixed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712941340



##########
File path: modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewSelfTest.java
##########
@@ -2044,6 +2047,57 @@ 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.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(dfltCacheGrp, view.cacheGroup());

Review comment:
       fixed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712591281



##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -899,3 +899,17 @@ Note, lock will be shown on the non parent node only after initial usage on that
 |GROUP_ID | int | Cache group id to store data structure
 |REMOVED | boolean | `True` if removed
 |===
+
+== SNAPSHOTS
+
+The SNAPSHOTS view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_CONSISTENT_ID | VARCHAR | Node consistent ID.
+| CACHE_GROUP | VARCHAR | Name of cache group.
+| LOCAL_PARTITIONS | VARCHAR | Numbers of local partitions for cache group.

Review comment:
       `Partition numbers of the cache group stored in the snapshot.` ?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795072615



##########
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 (in a separate method `readSnapshotMetadatas()`): 
   ```
   () -> localSnapshotNames().stream().map(this::readSnapshotMetadatas).flatMap(List::stream).collect(Collectors.toList()),
   ```
   and replace the current argument of `snapshotViewSupplier(String snpName)` to  `snapshotViewSupplier(SnapshotMetadata meta)`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795907959



##########
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 testSnapshot() 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(SNAPSHOT_SYS_VIEW);
+
+            assertEquals(1, views.size());
+
+            SnapshotView view = F.first(views);
+
+            assertEquals(testSnap0, view.snapshotName());
+            assertEquals(toStringSafe(ignite.localNode().consistentId()), view.nodeId());
+
+            List<?> constIds = ignite.cluster().nodes().stream().map(ClusterNode::consistentId).collect(Collectors.toList());
+
+            assertEquals(toStringSafe(constIds), 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(SNAPSHOT_SYS_VIEW);
+
+            assertEquals(2, views.size());

Review comment:
       done




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712102898



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))

Review comment:
       ok) but toStringSafe can be removed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712592880



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.Set;
+import org.apache.ignite.internal.managers.systemview.walker.Filtrable;
+import org.apache.ignite.internal.managers.systemview.walker.Order;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final String consistentId;
+
+    /** Cache group name. */
+    private final String cacheGrp;
+
+    /** Cache group local partitions. */
+    private final String locPartitions;
+
+    /**
+     * @param name Snapshot name.
+     * @param consistentId Node consistent id.
+     * @param cacheGrp Cache group.
+     * @param locPartitions Cache group local partitions.
+     */
+    public SnapshotView(String name, String consistentId, String cacheGrp, @Nullable Set<Integer> locPartitions) {
+        this.name = name;
+        this.consistentId = consistentId;
+        this.cacheGrp = cacheGrp;
+        this.locPartitions = locPartitions != null ? String.valueOf(locPartitions) : "[]";
+    }
+
+    /**
+     * @return Snapshot name.
+     */
+    @Order
+    @Filtrable
+    public String snapshotName() {
+        return name;
+    }
+
+    /**
+     * @return Node consistent id.
+     */
+    @Order(1)
+    @Filtrable
+    public String consistentId() {
+        return consistentId;
+    }
+
+    /**
+     * @return Cache group name.
+     */
+    @Order(2)
+    public String cacheGroup() {
+        return cacheGrp;
+    }
+
+    /**
+     * @return Numbers of local partitions for cache group.

Review comment:
       I suggest using the same comment for the same member throughout the file - `Cache group local partitions.`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712940989



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,43 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(meta.consistentId()))
+                            return Collections.emptyList();
+
+                    List<String> cacheCrps = snapshotCacheDirectories(snpName, meta.folderName()).stream()

Review comment:
       Thanks, fixed.
   asked Maxim Muzafarov, he believes that the metastorage is excluded from the view




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712102898



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))

Review comment:
       anyway, toStringSafe can be removed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r715434073



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -2468,4 +2515,67 @@ public IgniteSnapshotFutureImpl(IgniteInternalFuture<Void> fut) {
                 return new IgniteException("Snapshot has not been created", U.convertException(e));
         }
     }
+
+    /** Get the snapshot view of a cluster. */
+    @GridInternal
+    private static class SnapshotViewTask extends VisorMultiNodeTask<String, Set<SnapshotView>, List<SnapshotView>> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** {@inheritDoc} */
+        @Override protected SnapshotViewJob job(String arg) {
+            return new SnapshotViewJob(arg, debug);
+        }
+
+        /**  */
+        private static class SnapshotViewJob extends VisorJob<String, List<SnapshotView>> {
+            /** */
+            private static final long serialVersionUID = 0L;
+
+            /**
+             * Create job without specified argument.
+             *
+             * @param arg Job argument.
+             * @param debug Flag indicating whether debug information should be printed into node log.
+             */
+            protected SnapshotViewJob(@Nullable String arg, boolean debug) {
+                super(arg, debug);
+            }
+
+            /** {@inheritDoc} */
+            @Override protected List<SnapshotView> run(@Nullable String snapName) {
+                IgniteSnapshotManager snapMngr = (IgniteSnapshotManager)ignite.snapshot();
+
+                List<SnapshotMetadata> metas;
+
+                if (snapName != null)
+                    metas = snapMngr.readSnapshotMetadatas(snapName);
+                else

Review comment:
       braces required

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -2468,4 +2515,67 @@ public IgniteSnapshotFutureImpl(IgniteInternalFuture<Void> fut) {
                 return new IgniteException("Snapshot has not been created", U.convertException(e));
         }
     }
+
+    /** Get the snapshot view of a cluster. */
+    @GridInternal
+    private static class SnapshotViewTask extends VisorMultiNodeTask<String, Set<SnapshotView>, List<SnapshotView>> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** {@inheritDoc} */
+        @Override protected SnapshotViewJob job(String arg) {
+            return new SnapshotViewJob(arg, debug);
+        }
+
+        /**  */
+        private static class SnapshotViewJob extends VisorJob<String, List<SnapshotView>> {
+            /** */
+            private static final long serialVersionUID = 0L;
+
+            /**
+             * Create job without specified argument.
+             *
+             * @param arg Job argument.
+             * @param debug Flag indicating whether debug information should be printed into node log.
+             */
+            protected SnapshotViewJob(@Nullable String arg, boolean debug) {
+                super(arg, debug);
+            }
+
+            /** {@inheritDoc} */
+            @Override protected List<SnapshotView> run(@Nullable String snapName) {
+                IgniteSnapshotManager snapMngr = (IgniteSnapshotManager)ignite.snapshot();
+
+                List<SnapshotMetadata> metas;
+
+                if (snapName != null)
+                    metas = snapMngr.readSnapshotMetadatas(snapName);
+                else
+                    metas = snapMngr.localSnapshotNames().stream()
+                        .map(snapMngr::readSnapshotMetadatas)
+                        .flatMap(Collection::stream)
+                        .collect(Collectors.toList());
+
+                return metas.stream().map(meta -> {
+                    Collection<String> cacheGrps = F.viewReadOnly(snapMngr.snapshotCacheDirectories(meta.snapshotName(), meta.folderName()),
+                        FilePageStoreManager::cacheGroupName);
+
+                    return new SnapshotView(meta.snapshotName(),
+                        meta.consistentId(),
+                        String.valueOf(meta.baselineNodes()),
+                        String.valueOf(cacheGrps));
+                }).collect(Collectors.toList());
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override protected Set<SnapshotView> reduce0(List<ComputeJobResult> results)
+            throws IgniteException {
+            return results.stream()
+                .map(ComputeJobResult::getData)

Review comment:
       As I see, if job throws an exception  - we can get NPE here

##########
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;
+
+    /** The cache groups names which were included into snapshot. */

Review comment:
       I suggest changing the description to
   `Cache group names that were included in the snapshot.`

##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -899,3 +899,17 @@ Note, lock will be shown on the non parent node only after initial usage on that
 |GROUP_ID | int | Cache group id to store data structure
 |REMOVED | boolean | `True` if removed
 |===
+
+== SNAPSHOTS
+
+The SNAPSHOTS view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_ID | VARCHAR | Consistent id of a node to which this metadata relates.

Review comment:
       I suggest change this description to
   `Consistent ID of a node to which snapshot data relates.`

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1773,30 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        Collection<ClusterNode> nodes = cctx.kernalContext().discovery().aliveServerNodes();
+
+        if (nodeConsistentId != null)
+             nodes = nodes.stream()
+                 .filter(n -> toStringSafe(n.consistentId()).equals(nodeConsistentId))
+                 .collect(Collectors.toSet());
+
+        List<UUID> ids = nodes.stream().map(ClusterNode::id).collect(Collectors.toList());
+
+        ComputeTaskFuture<Set<SnapshotView>> fut = ((ClusterGroupAdapter)cctx.kernalContext().cluster().get().forServers()).compute()
+            .executeAsync(new SnapshotViewTask(), new VisorTaskArgument<String>(ids, snapshotName, false));
+
+        return fut.get();

Review comment:
       can be replaced with sync execution
   `return ((ClusterGroupAdapter)cctx.kernalContext().cluster().get().forServers()).compute()
               .execute(new SnapshotViewTask(), new VisorTaskArgument<>(ids, snapshotName, false))`

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1773,30 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        Collection<ClusterNode> nodes = cctx.kernalContext().discovery().aliveServerNodes();
+
+        if (nodeConsistentId != null)

Review comment:
       braces missed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712591281



##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -899,3 +899,17 @@ Note, lock will be shown on the non parent node only after initial usage on that
 |GROUP_ID | int | Cache group id to store data structure
 |REMOVED | boolean | `True` if removed
 |===
+
+== SNAPSHOTS
+
+The SNAPSHOTS view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_CONSISTENT_ID | VARCHAR | Node consistent ID.
+| CACHE_GROUP | VARCHAR | Name of cache group.
+| LOCAL_PARTITIONS | VARCHAR | Numbers of local partitions for cache group.

Review comment:
       `Partition numbers of the cache group stored in the snapshot.` ?
   or at least I suggest `for cache group.` => `of the cache group.`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712046172



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))

Review comment:
       1. meta.consistentId() is already a string value
   2. it cannot be null
   
   So this condition can be simplified to 
   if (!meta.consistentId().equals(nodeConsistentId))

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))
+                            return Collections.emptyList();
+
+                        return F.iterator(getCacheGroupsName(meta), cacheGrp -> new SnapshotView(

Review comment:
       Can we use IgniteSnapshotManager#snapshotCacheDirectories (or FilePageStoreManager#cacheDirectories) instead of involving new method?

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))
+                            return Collections.emptyList();
+
+                        return F.iterator(getCacheGroupsName(meta), cacheGrp -> new SnapshotView(
+                            meta.snapshotName(),
+                            meta.consistentId(),
+                            cacheGrp,
+                            meta.partitions().get(CU.cacheId(cacheGrp))
+                        ), true);
+                    }, true));
+            }, true));
+    }
+
+    /** */
+    private List<String> getCacheGroupsName(SnapshotMetadata meta) {
+        Path path = Paths.get(snapshotLocalDir(meta.snapshotName()).toString(), "db", meta.folderName());
+
+        List<String> res = new ArrayList<>();
+
+        try (DirectoryStream<Path> ds = Files.newDirectoryStream(path,
+            pth -> pth.getFileName().toString().startsWith(CACHE_DIR_PREFIX))) {

Review comment:
       And how about shared cache groups (CACHE_GRP_DIR_PREFIX)?

##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.Set;
+import org.apache.ignite.internal.managers.systemview.walker.Filtrable;
+import org.apache.ignite.internal.managers.systemview.walker.Order;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.internal.util.IgniteUtils.toStringSafe;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final Object consistentId;

Review comment:
       Is there something preventing us from making consistentId a string? 




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712110868



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.Set;
+import org.apache.ignite.internal.managers.systemview.walker.Filtrable;
+import org.apache.ignite.internal.managers.systemview.walker.Order;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.internal.util.IgniteUtils.toStringSafe;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final Object consistentId;

Review comment:
       Thanks, fixed

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))
+                            return Collections.emptyList();
+
+                        return F.iterator(getCacheGroupsName(meta), cacheGrp -> new SnapshotView(

Review comment:
       fixed

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))
+                            return Collections.emptyList();
+
+                        return F.iterator(getCacheGroupsName(meta), cacheGrp -> new SnapshotView(
+                            meta.snapshotName(),
+                            meta.consistentId(),
+                            cacheGrp,
+                            meta.partitions().get(CU.cacheId(cacheGrp))
+                        ), true);
+                    }, true));
+            }, true));
+    }
+
+    /** */
+    private List<String> getCacheGroupsName(SnapshotMetadata meta) {
+        Path path = Paths.get(snapshotLocalDir(meta.snapshotName()).toString(), "db", meta.folderName());
+
+        List<String> res = new ArrayList<>();
+
+        try (DirectoryStream<Path> ds = Files.newDirectoryStream(path,
+            pth -> pth.getFileName().toString().startsWith(CACHE_DIR_PREFIX))) {

Review comment:
       Thanks, fixed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795072615



##########
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`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r722098222



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1766,19 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * @param snpName Snapshot name.
+     */

Review comment:
       "return" statement is missing in doc.




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r796598021



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,93 @@
+/*
+ * 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 org.apache.ignite.internal.managers.systemview.walker.Order;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot system view name. */
+    public static final String SNAPSHOT_SYS_VIEW = "snapshot";
+
+    /** Snapshot system view description. */
+    public static final String SNAPSHOT_SYS_VIEW_DESC = "Snapshot";
+
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final String consistentId;
+
+    /** Baseline nodes affected by snapshot. */
+    private final String baselineNodes;
+
+    /** Cache group names that were included in the snapshot. */
+    private final String cacheGrps;
+
+    /**
+     * @param name Snapshot name.
+     * @param consistentId Node consistent id.
+     * @param baselineNodes Baseline nodes affected by snapshot.
+     * @param cacheGrps Cache group names that were included in the snapshot.
+     */
+    public SnapshotView(
+        String name,
+        String consistentId,
+        String baselineNodes,
+        String cacheGrps
+    ) {
+        this.name = name;
+        this.consistentId = consistentId;
+        this.baselineNodes = baselineNodes;
+        this.cacheGrps = cacheGrps;
+    }
+
+    /**
+     * @return Snapshot name.
+     */
+    @Order
+    public String name() {
+        return name;
+    }
+
+    /**
+     * @return Node consistent id.

Review comment:
       ```suggestion
        * @return Node consistent ID.
   ```




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern merged pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern merged pull request #9422:
URL: https://github.com/apache/ignite/pull/9422


   


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795734308



##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -949,3 +949,17 @@ The STATISTICS_PARTITION_DATA view contains information about link:SQL/sql-stati
 |VERSION |BIGINT |Statistics version.
 |LAST_UPDATE_TIME |VARCHAR |Maximum time of all partition statistics which was used to generate local one.
 |===
+
+== SNAPSHOT
+
+The SNAPSHOT view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_ID | VARCHAR | Consistent ID of a node to which snapshot data relates.
+| BASELINE_NODES | VARCHAR | Baseline nodes affected by snapshot.
+| CACHE_GROUPS | VARCHAR | Cache group names that were included in the snapshot.
+

Review comment:
       fixed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795627797



##########
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 testSnapshot() 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(SNAPSHOT_SYS_VIEW);
+
+            assertEquals(1, views.size());
+
+            SnapshotView view = F.first(views);
+
+            assertEquals(testSnap0, view.snapshotName());
+            assertEquals(toStringSafe(ignite.localNode().consistentId()), view.nodeId());
+
+            List<?> constIds = ignite.cluster().nodes().stream().map(ClusterNode::consistentId).collect(Collectors.toList());
+
+            assertEquals(toStringSafe(constIds), 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(SNAPSHOT_SYS_VIEW);
+
+            assertEquals(2, views.size());

Review comment:
       ```suggestion
               assertEquals(2, views.size());
   
               List<String> exp = Lists.newArrayList(testSnap0, testSnap1);
   
               views.forEach(v -> assertTrue(exp.remove(v.snapshotName())));
   
               assertTrue(exp.isEmpty());
   ```




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712074057



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))
+                            return Collections.emptyList();
+
+                        return F.iterator(getCacheGroupsName(meta), cacheGrp -> new SnapshotView(
+                            meta.snapshotName(),
+                            meta.consistentId(),
+                            cacheGrp,
+                            meta.partitions().get(CU.cacheId(cacheGrp))
+                        ), true);
+                    }, true));
+            }, true));
+    }
+
+    /** */
+    private List<String> getCacheGroupsName(SnapshotMetadata meta) {
+        Path path = Paths.get(snapshotLocalDir(meta.snapshotName()).toString(), "db", meta.folderName());
+
+        List<String> res = new ArrayList<>();
+
+        try (DirectoryStream<Path> ds = Files.newDirectoryStream(path,
+            pth -> pth.getFileName().toString().startsWith(CACHE_DIR_PREFIX))) {

Review comment:
       And what about shared cache groups (CACHE_GRP_DIR_PREFIX)?




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712591281



##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -899,3 +899,17 @@ Note, lock will be shown on the non parent node only after initial usage on that
 |GROUP_ID | int | Cache group id to store data structure
 |REMOVED | boolean | `True` if removed
 |===
+
+== SNAPSHOTS
+
+The SNAPSHOTS view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_CONSISTENT_ID | VARCHAR | Node consistent ID.
+| CACHE_GROUP | VARCHAR | Name of cache group.
+| LOCAL_PARTITIONS | VARCHAR | Numbers of local partitions for cache group.

Review comment:
       `Partition numbers of the cache group stored in the snapshot.` ?
   or at least I suggest `for cache group.` => `fot **the** cache group.`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712102898



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))

Review comment:
       anyway, toStringSafe can be omitted




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712591281



##########
File path: docs/_docs/monitoring-metrics/system-views.adoc
##########
@@ -899,3 +899,17 @@ Note, lock will be shown on the non parent node only after initial usage on that
 |GROUP_ID | int | Cache group id to store data structure
 |REMOVED | boolean | `True` if removed
 |===
+
+== SNAPSHOTS
+
+The SNAPSHOTS view exposes information about local snapshots.
+
+[{table_opts}]
+|===
+| Column | Data Type | Description
+| SNAPSHOT_NAME | VARCHAR | Snapshot name.
+| NODE_CONSISTENT_ID | VARCHAR | Node consistent ID.
+| CACHE_GROUP | VARCHAR | Name of cache group.
+| LOCAL_PARTITIONS | VARCHAR | Numbers of local partitions for cache group.

Review comment:
       `Partition numbers of the cache group stored in the snapshot.` ?
   or at least I suggest 'for cache group.` -> `of the cache group.`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712537090



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,43 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(meta.consistentId()))
+                            return Collections.emptyList();
+
+                    List<String> cacheCrps = snapshotCacheDirectories(snpName, meta.folderName()).stream()

Review comment:
       can be simplified to
   ```
   Collection<String> cacheCrps = F.viewReadOnly(snapshotCacheDirectories(snpName, meta.folderName(),
       name -> !MetaStorage.METASTORAGE_CACHE_NAME.equals(name)), FilePageStoreManager::cacheGroupName);
   ```
   
   btw, should we include metastorage in this view?

##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.Set;
+import org.apache.ignite.internal.managers.systemview.walker.Filtrable;
+import org.apache.ignite.internal.managers.systemview.walker.Order;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final String consistentId;
+
+    /** Cache group name. */
+    private final String cacheGrp;
+
+    /** Cache group local partitions. */
+    private final String locPartitions;
+
+    /**
+     * @param name Snapshot name.
+     * @param consistentId Node consistent id.
+     * @param cacheGrp Cache group.
+     * @param locPartitions Cache group local partitions.
+     */
+    public SnapshotView(String name, String consistentId, String cacheGrp, @Nullable Set<Integer> locPartitions) {
+        this.name = name;
+        this.consistentId = consistentId;
+        this.cacheGrp = cacheGrp;
+        this.locPartitions = locPartitions != null ? String.valueOf(locPartitions) : "[]";

Review comment:
       I think the UX should be improved by replacing `String.valueOf` with `S.compact`.
   I also suggest checking this value in the test.

##########
File path: modules/core/src/test/java/org/apache/ignite/internal/metric/SystemViewSelfTest.java
##########
@@ -2044,6 +2047,57 @@ 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.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(dfltCacheGrp, view.cacheGroup());

Review comment:
       I suggest checking local partitions output, too.
   
   something like
   ```
   Collection<Integer> locParts = F.viewReadOnly(
       ignite.cachex(DEFAULT_CACHE_NAME).context().topology().localPartitions(), GridDhtLocalPartition::id);
           
   assertEquals(S.compact(locParts), view.localPartitions());
   ```
   but we should add some values into the cache. I don't think it is worth creating 1024 (+1024 in the snapshot) files every time, so it is better to limit this number in the cache configuration or add an extra predicate to check if partitions were actually created (using IgnitePageStoreManager#exists for example).




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712592880



##########
File path: modules/core/src/main/java/org/apache/ignite/spi/systemview/view/SnapshotView.java
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.Set;
+import org.apache.ignite.internal.managers.systemview.walker.Filtrable;
+import org.apache.ignite.internal.managers.systemview.walker.Order;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Snapshot representation for a {@link SystemView}.
+ */
+public class SnapshotView {
+    /** Snapshot name. */
+    private final String name;
+
+    /** Node consistent id. */
+    private final String consistentId;
+
+    /** Cache group name. */
+    private final String cacheGrp;
+
+    /** Cache group local partitions. */
+    private final String locPartitions;
+
+    /**
+     * @param name Snapshot name.
+     * @param consistentId Node consistent id.
+     * @param cacheGrp Cache group.
+     * @param locPartitions Cache group local partitions.
+     */
+    public SnapshotView(String name, String consistentId, String cacheGrp, @Nullable Set<Integer> locPartitions) {
+        this.name = name;
+        this.consistentId = consistentId;
+        this.cacheGrp = cacheGrp;
+        this.locPartitions = locPartitions != null ? String.valueOf(locPartitions) : "[]";
+    }
+
+    /**
+     * @return Snapshot name.
+     */
+    @Order
+    @Filtrable
+    public String snapshotName() {
+        return name;
+    }
+
+    /**
+     * @return Node consistent id.
+     */
+    @Order(1)
+    @Filtrable
+    public String consistentId() {
+        return consistentId;
+    }
+
+    /**
+     * @return Cache group name.
+     */
+    @Order(2)
+    public String cacheGroup() {
+        return cacheGrp;
+    }
+
+    /**
+     * @return Numbers of local partitions for cache group.

Review comment:
       I suggest using the same comment for the same member throughout the file - `Cache group local partitions.` or `Numbers of local partitions for cache group.`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712088568



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))

Review comment:
       nodeConsistentId can be null, then we will get an empty list




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] xtern commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712102898



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))

Review comment:
       got it) but still toStringSafe can be removed




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r712152778



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java
##########
@@ -1750,6 +1768,53 @@ static void copy(FileIOFactory factory, File from, File to, long length) {
         return new IgniteFutureImpl<>(cctx.kernalContext().task().execute(taskCls, snpName));
     }
 
+    /**
+     * Snapshots view supplier.
+     *
+     * @param filter Filter.
+     */
+    private Iterable<SnapshotView> snapshotViewSupplier(Map<String, Object> filter) {
+        List<String> snapshotNames = localSnapshotNames();
+
+        String snapshotName = (String)filter.get(SnapshotViewWalker.SNAPSHOT_NAME_FILTER);
+        String nodeConsistentId = (String)filter.get(SnapshotViewWalker.NODE_CONSISTENT_ID_FILTER);
+
+        return F.flat(F.iterator(snapshotNames, snpName -> {
+                if (snapshotName != null && !snapshotName.equals(snpName))
+                    return Collections.emptyList();
+
+                return F.flat(F.iterator(readSnapshotMetadatas(snpName), meta -> {
+                        if (nodeConsistentId != null && !nodeConsistentId.equals(toStringSafe(meta.consistentId())))

Review comment:
       already removed, just displayed in the discussion




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [ignite] Sega76 commented on a change in pull request #9422: IGNITE-12971: Create snapshot view to show available cluster snapshots.

Posted by GitBox <gi...@apache.org>.
Sega76 commented on a change in pull request #9422:
URL: https://github.com/apache/ignite/pull/9422#discussion_r795845763



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/managers/systemview/walker/SnapshotViewWalker.java
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.internal.managers.systemview.walker;
+
+import org.apache.ignite.spi.systemview.view.SnapshotView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+
+/**
+ * Generated by {@code org.apache.ignite.codegen.SystemViewRowAttributeWalkerGenerator}.
+ * {@link SnapshotView} attributes walker.
+ *
+ * @see SnapshotView
+ */
+public class SnapshotViewWalker implements SystemViewRowAttributeWalker<SnapshotView> {

Review comment:
       fixed, thanks




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org