Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
themeMidnight
titleSnapshotLifecycleListener.java
collapsetrue
/**
 * Snapshot lifecycle listener.
 */
public interface SnapshotLifecycleListenerSnapshotLifecycleListener<T extends Serializable> extends Extension {
    /** Default listener priority. */
    public static final int DEFAULT_PRIORITY = 0;

    /** Listener name (must be unique). */
    public String name();

    /** Listener invocation priority (ascending order is used). */
    public default int priority() {
        return DEFAULT_PRIORITY;
    }

    /**
     * Called locally after the snapshot files have been created on the node.
     *
     * @param snpNamename Snapshot name.
     * @param @throwsmetadata IgniteCheckedExceptionSnapshot Ifmetadata failedfile.
     */
 @param binaryDir Snapshot binary publicmetadata defaultdirectory.
 void afterCreate(String snpName) throws IgniteCheckedException* {
@param marshallerDir Snapshot marshaller data directory.
   // No-op.
 * @param cacheDir }

Snapshot cache   /**data directory.
     * Called@throws locallyIgniteCheckedException before restore snapshot filesIf failed.
     */
    public * @param snpName Snapshot name.default void afterCreate(String name, File metadata,
     * @param consId ConsistentPath snapshotbinaryDir, metadataPath file name.
     * @param grps Cache groups to be restored ({@code null} if all cache groups are restored from the snapshot).marshallerDir, Path cacheDir) throws IgniteCheckedException {
        // No-op.
    }

    /**
     * @paramCalled <T>locally Typebefore ofrestore thesnapshot resultfiles.
     *
 @return Local node result, or* {@code@param null}name if cluster-wide aggregation is not requiredSnapshot name.
     * @throws@param IgniteCheckedExceptiongrps IfCache failed.
groups to be restored  */
    @Nullable public default <T> T beforeRestore(({@code null} if all cache groups are restored from the snapshot).
     * @param metadata StringSnapshot snpName,
 metadata file.
     * @param StringbinaryDir consId,
Snapshot binary metadata directory.
     @Nullable* Collection<String>@param grps
marshallerDir Snapshot marshaller data )directory.
 throws IgniteCheckedException {
  * @param cacheDir Snapshot cache  return null;
 data directory.
   }

    /**
     * Process@return theLocal resultsnode ofresult, a pre-restore operation across the clusteror {@code null} if cluster-wide aggregation is not required.
     * @throws IgniteCheckedException If failed.
     */
 @param res Results from@Nullable allpublic nodes.
default T beforeRestore(String name, @Nullable *Collection<String> @throwsgrps, IgniteCheckedException If failed.File metadata,
     */
   Path publicbinaryDir, defaultPath void handlePreRestoreResults(List<ComputeJobResult> resmarshallerDir, Path cacheDir) throws IgniteCheckedException {
        // No-op.return null;
    }

    /**
     * Process the results of a pre-restore operation across the cluster.
     *
     * @param res Results from all nodes.
     * @throws IgniteCheckedException If failed.
     */
    public default void handlePreRestoreResults(
        String snapshotName,
        @Nullable Collection<String> grps,
        Map<ClusterNode, T> res,
        Map<ClusterNode, Exception> errs
    ) throws IgniteCheckedException {
        Map.Entry<ClusterNode, Exception> exEntry = F.first(errs.entrySet());

        if (exEntry == null)
            return;

        throw new IgniteCheckedException("Snapshot restore handler " + getClass().getSimpleName() +
            " has failed on node " + exEntry.getKey().id() + '.', exEntry.getValue());
    }
}


Snapshot requirements

  1. Users must have the ability to create a snapshot of persisted user data (in-memory is out of the scope).
  2. Users must have the ability to create a snapshot from the cluster under the load without cluster deactivation.
  3. The snapshot process must not block for a long time any of the user transactions (short-time blocks are acceptable).
  4. The snapshot process must allow creating a data snapshot on each node and transfer it to any of the remote nodes for internal cluster needs.
  5. The created snapshot at the cluster-level must be fully consistent from cluster-wide terms, there should not be any incomplete transactions inside.
  6. The snapshot of each node must be consistent – cache partitions, binary meta, etc. must not have unnecessary changes.

...