[ 
https://issues.apache.org/jira/browse/IGNITE-14070?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Amelchev Nikita updated IGNITE-14070:
-------------------------------------
    Release Note: Implemented API for custom snapshot lifecycle handlers.

> 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: 0.5h
>  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. */
>     public @Nullable T invoke(SnapshotHandlerContext ctx) throws Exception;
>     /** Processing of results from all nodes. */
>     public default void complete(String name, 
> Collection<SnapshotHandlerResult<T>> results) throws Exception {
>         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 {
>     SnapshotMetadata metadata;
>     Collection<String> grps;
>     ClusterNode 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. */
> public class SnapshotHandlerResult<T> implements Serializable {
>     T data;
>     Exception err;
>     ClusterNode node;
> }
> {code}



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

Reply via email to