Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-14070

Implement API for custom snapshot lifecycle handlers (extensions).

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.12
    • None
    • Implemented API for custom snapshot lifecycle handlers.
    • Release Notes Required

    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

          Activity

            People

              xtern Pavel Pereslegin
              garus.d.g Denis Garus
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m