THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
/** * Snapshot lifecycle listener. handler */ public interface SnapshotLifecycleListener<TSnapshotHandler<T> extends Serializable> extends Extension { /** ListenerSnapshot invocation priority (ascending order is used)handler type. */ public defaultSnapshotHandlerType int prioritytype(); { /** Local processing of a return 0;snapshot operation. */ } public @Nullable T invoke(SnapshotHandlerContext ctx) throws Exception; /** Processing of results from all nodes. */ Called locally afterpublic thedefault snapshotvoid files have been created on the node.complete(String name, Collection<SnapshotHandlerResult<T>> results) throws Exception { * for (SnapshotHandlerResult<T> *res @param: name Snapshot name.results) { * @param metadata Snapshot metadata file. if (res.error() * @param binaryDir Snapshot binary metadata directory. == null) * @param marshallerDir Snapshot marshaller data directory. continue;; * @param cacheDir Snapshot cache data directory. throw new IgniteCheckedException("Snapshot handler *has @throwsfailed IgniteCheckedException If failed. " + */ public default void afterCreate( "[snapshot=" + name + String name, File metadata, ", handler=" Path binaryDir,+ getClass().getName() + Path marshallerDir, ", Path cacheDir ) throws IgniteCheckedException { nodeId=" + res.node().id() + "].", res.error()); } } } // No-op. } ** type */ public enum SnapshotHandlerType { /** Handler is called immediately *after Calledthe locallysnapshot beforeis restore snapshot files.taken. */ *CREATE, /** *Handler @paramis namecalled Snapshotjust name. before restore operation is started. */ @param grps Cache groups to be restored ({@code null} if all cache groups are restored from the snapshot). * @param metadata Snapshot metadata file. * @param binaryDir Snapshot binary metadata directory. * @param marshallerDir Snapshot marshaller data directory. * @param cacheDir Snapshot cache data directory. * * @return Local node result, or {@code null} if cluster-wide aggregation is not required. * @throws IgniteCheckedException If failed. */ @Nullable public default T beforeRestore( String name, @Nullable Collection<String> grps, File metadata, Path binaryDir, Path marshallerDir, Path cacheDir ) throws IgniteCheckedException { return null; } /** * Process the results of a pre-restore operation across the cluster. * * @param name Snapshot name. * @param grps Cache groups to be restored ({@code null} if all cache groups are restored from the snapshot). * @param res Results from all nodes. * @param errs Errors from all nodes. * @throws IgniteCheckedException If failed. */ public default void handlePreRestoreResults( String name, @Nullable Collection<String> grps, Map<ClusterNode, T> res, Map<ClusterNode, Exception> errs ) throws IgniteCheckedException { Map.Entry<ClusterNode, Exception> errEntry = F.first(errs.entrySet()); if (errEntry == null) return; throw new IgniteCheckedException("Snapshot restore handler " + name() + " has failed on node " + errEntry.getKey().id() + '.', errEntry.getValue()); } } | ||||||||
Code Block | ||||||||
| ||||||||
/** * Snapshot lifecycle listener. */ public interface SnapshotLifecycleListener extends Extension { /** * Called locally after the snapshot files have been created on the node. * * @param metadata Snapshot metdata. * @throws IgniteCheckedException If failed. */ public void onCreate(SnapshotMetadata metadata) throws IgniteCheckedException; /** * Called locally before performing a snapshot consistency check. * * @param metadata Snapshot metdata. * @param grps Cache groups to be restored ({@code null} if all cache groups are restored from the snapshot). * @throws IgniteCheckedException If failed. */ public void onCheck(SnapshotMetadata metadata, @Nullable Collection<String> grps) throws IgniteCheckedException; /** * Called locally before restoring cache data files from a snapshot. * * @param metadata Snapshot metdata. * @param grps Cache groups to be restored ({@code null} if all cache groups are restored from the snapshot). * @throws IgniteCheckedException If failed. */ public void onRestore(SnapshotMetadata metadata, @Nullable Collection<String> grps) throws IgniteCheckedException; } 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; } |
...