Details
Description
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:
/** 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; }
Attachments
Issue Links
- relates to
-
IGNITE-13805 Add support for cache group restore from a snapshot on the same topology
- Resolved
- links to