Versions Compared

Key

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

...

It is recommended to add the ability to load SnapshotLifecycleListener user extensions that will implement custom checks.

Code Block
languagejava
themeMidnight
titleSnapshotLifecycleListener.java
collapsetrue
/**
 * Snapshot lifecycle listener.
 */
public interface SnapshotLifecycleListener 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 snpName Snapshot name.
     * @throws IgniteCheckedException If failed.
     */
    public default void afterCreate(String snpName) throws IgniteCheckedException {
        // No-op.
    }

    /**
     * Called locally before restore snapshot files.
     *
     * @param snpName Snapshot name.
     * @param consId Consistent snapshot metadata file name.
     * @param grps Cache groups to be restored ({@code null} if all cache groups are restored from the snapshot).
     * @param <T> Type of the result.
     * @return Local node result, or {@code null} if cluster-wide aggregation is not required.
     * @throws IgniteCheckedException If failed.
     */
    @Nullable public default <T> T beforeRestore(
        String snpName,
        String consId,
        @Nullable Collection<String> grps
    ) throws IgniteCheckedException {
        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(List<ComputeJobResult> res) throws IgniteCheckedException {
        // No-op.
    }
}

...