You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Ignite TC Bot (Jira)" <ji...@apache.org> on 2021/08/13 11:35:00 UTC

[jira] [Commented] (IGNITE-14070) Implement API for custom snapshot lifecycle handlers (extensions).

    [ https://issues.apache.org/jira/browse/IGNITE-14070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17398604#comment-17398604 ] 

Ignite TC Bot commented on IGNITE-14070:
----------------------------------------

{panel:title=Branch: [pull/9165/head] Base: [master] : No blockers found!|borderStyle=dashed|borderColor=#ccc|titleBGColor=#D6F7C1}{panel}
{panel:title=Branch: [pull/9165/head] Base: [master] : New Tests (3)|borderStyle=dashed|borderColor=#ccc|titleBGColor=#D6F7C1}
{color:#00008b}Basic 3{color} [[tests 3|https://ci.ignite.apache.org/viewLog.html?buildId=6130775]]
* {color:#013220}IgniteBasicWithPersistenceTestSuite: IgniteClusterSnapshotHandlerTest.testClusterSnapshotHandlerFailure - PASSED{color}
* {color:#013220}IgniteBasicWithPersistenceTestSuite: IgniteClusterSnapshotHandlerTest.testClusterSnapshotHandlers - PASSED{color}
* {color:#013220}IgniteBasicWithPersistenceTestSuite: IgniteClusterSnapshotRestoreSelfTest.testRestoreWithMissedPart - PASSED{color}

{panel}
[TeamCity *--&gt; Run :: All* Results|https://ci.ignite.apache.org/viewLog.html?buildId=6130835&amp;buildTypeId=IgniteTests24Java8_RunAll]

> Implement API for custom snapshot lifecycle handlers (extensions).
> ------------------------------------------------------------------
>
>                 Key: IGNITE-14070
>                 URL: https://issues.apache.org/jira/browse/IGNITE-14070
>             Project: Ignite
>          Issue Type: New Feature
>            Reporter: Denis Garus
>            Assignee: Pavel Pereslegin
>            Priority: Major
>              Labels: iep-43
>             Fix For: 2.12
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> Sometimes the user is faced with the task of adding post-processing to the snapshot operation, for example, calculating the checksum of files, checking the consistency, etc. The same applies to the automatic restore procedure - the user should be able to check the consistency of files, checksums, etc. before restore them. It is impossible to implement pre/post-processing using standard Ignite events. if a custom check detects a problem, the entire operation with the snapshot must be aborted.
> We need to provide the ability to extend snapshot operations (CREATE/RESTORE) using plugin extensions. 
> The API proposal:
> {code:java}
> /** handler */
> public interface SnapshotHandler<T> extends Extension {
>     /** Snapshot handler type. */
>     public SnapshotHandlerType type();
>     /**
>      * Local processing of a snapshot operation.
>      * Called on every node that contains snapshot data.
>      *
>      * @param ctx Snapshot handler context.
>      * @return Result of local processing.
>      * @throws IgniteCheckedException If failed.
>      */
>     public @Nullable T invoke(SnapshotHandlerContext ctx) throws IgniteCheckedException;
>     /**
>      * Processing of results from all nodes.
>      * Called on one of the nodes containing the snapshot data.
>      *
>      * @param name Snapshot name.
>      * @param results Results from all nodes.
>      * @throws IgniteCheckedException If failed.
>      */
>     public default void complete(String name, Collection<SnapshotHandlerResult<T>> results) throws IgniteCheckedException {
>         for (SnapshotHandlerResult<T> res : results) {
>             if (res.error() == null)
>                 continue;;
>             throw new IgniteCheckedException("Snapshot handler has failed " +
>                 "[snapshot=" + name +
>                 ", handler=" + getClass().getName() +
>                 ", nodeId=" + res.node().id() + "].", res.error());
>         }
>     }
> }
> /** type */
> public enum SnapshotHandlerType {
>     /** Handler is called immediately after the snapshot is taken. */
>     CREATE,
>     /** Handler is called just before restore operation is started. */
>     RESTORE
> }
> /** context */
> public class SnapshotHandlerContext {
>     /** Snapshot metadata. */
>     private final SnapshotMetadata metadata;
>     /** The names of the cache groups on which the operation is performed. */
>     private final Collection<String> grps;
>     /** Local node. */
>     private final ClusterNode locNode;
>     /**
>      * @param metadata Snapshot metadata.
>      * @param grps The names of the cache groups on which the operation is performed.
>      * @param locNode Local node.
>      */
>     public SnapshotHandlerContext(SnapshotMetadata metadata, @Nullable Collection<String> grps, ClusterNode locNode) {
>         this.metadata = metadata;
>         this.grps = grps;
>         this.locNode = locNode;
>     }
>     /**
>      * @return Snapshot metadata.
>      */
>     public SnapshotMetadata metadata() {
>         return metadata;
>     }
>     /**
>      * @return The names of the cache groups on which the operation is performed. May be {@code null} if the operation
>      * is performed on all available cache groups.
>      */
>     public @Nullable Collection<String> groups() {
>         return grps;
>     }
>     /**
>      * @return Local node.
>      */
>     public ClusterNode localNode() {
>         return locNode;
>     }
> }
> /**
>  * Result of local processing on the node. In addition to the result received from the handler, it also includes
>  * information about the error (if any) and the node on which this result was received.
>  *
>  * @param <T> Type of the local processing result.
>  */
> public class SnapshotHandlerResult<T> implements Serializable {
>     /** Serial version uid. */
>     private static final long serialVersionUID = 0L;
>     /** Result of local processing. */
>     private final T data;
>     /** Processing error. */
>     private final Exception err;
>     /** Processing node. */
>     private final ClusterNode node;
>     /**
>      * @param data Result of local processing.
>      * @param err Processing error.
>      * @param node Processing node.
>      */
>     public SnapshotHandlerResult(@Nullable T data, @Nullable Exception err, ClusterNode node) {
>         this.data = data;
>         this.err = err;
>         this.node = node;
>     }
>     /** @return Result of local processing. */
>     public @Nullable T data() {
>         return data;
>     }
>     /** @return Processing error. */
>     public @Nullable Exception error() {
>         return err;
>     }
>     /** @return Processing node. */
>     public ClusterNode node() {
>         return node;
>     }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)