GG-12407: Backport [GG-12364] to 8.1.2 - skipCrc flag added
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f4f8562e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f4f8562e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f4f8562e Branch: refs/heads/ignite-2.1 Commit: f4f8562e8b61e09e14aad61d0d5cf98a2c896101 Parents: 68c0281 Author: Ivan Rakov <[email protected]> Authored: Fri Jun 30 20:47:45 2017 +0300 Committer: Ivan Rakov <[email protected]> Committed: Fri Jun 30 20:47:45 2017 +0300 ---------------------------------------------------------------------- .../snapshot/SnapshotCheckParameters.java | 71 ++++++++++++++++++++ .../pagemem/snapshot/SnapshotOperation.java | 26 +++++-- 2 files changed, 93 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/f4f8562e/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotCheckParameters.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotCheckParameters.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotCheckParameters.java new file mode 100644 index 0000000..e95e79d --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotCheckParameters.java @@ -0,0 +1,71 @@ +/* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed with +* this work for additional information regarding copyright ownership. +* The ASF licenses this file to You under the Apache License, Version 2.0 +* (the "License"); you may not use this file except in compliance with +* the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package org.apache.ignite.internal.pagemem.snapshot; + +import java.io.File; +import java.io.Serializable; +import java.util.Collection; +import org.jetbrains.annotations.Nullable; + +/** + * Tuple for passing optional parameters of {@link SnapshotOperationType#CHECK}. + */ +public class SnapshotCheckParameters implements Serializable { + /** Optional paths. */ + private final Collection<File> optionalPaths; + + /** Flag for skipping CRC check. */ + private final boolean skipCrc; + + /** + * Factory method. + * + * @return Tuple with optional parameters or null if parameters are default. + * + * @param optionalPaths Optional paths. + * @param skipCrc Skip crc. + */ + @Nullable public static SnapshotCheckParameters valueOf(Collection<File> optionalPaths, boolean skipCrc) { + if (optionalPaths == null && !skipCrc) + return null; + + return new SnapshotCheckParameters(optionalPaths, skipCrc); + } + + /** + * @param optionalPaths Optional paths. + * @param skipCrc Flag for skipping CRC check. + */ + private SnapshotCheckParameters(Collection<File> optionalPaths, boolean skipCrc) { + this.optionalPaths = optionalPaths; + this.skipCrc = skipCrc; + } + + /** + * @return Optional paths. + */ + public Collection<File> optionalPaths() { + return optionalPaths; + } + + /** + * @return Flag for skipping CRC check. + */ + public boolean skipCrc() { + return skipCrc; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/f4f8562e/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperation.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperation.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperation.java index 2fe9f45d..863107a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperation.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperation.java @@ -134,10 +134,18 @@ public class SnapshotOperation implements Serializable { * @param op Op. */ public static Collection<File> getOptionalPathsParameter(SnapshotOperation op) { - assert (op.type() == SnapshotOperationType.CHECK || - op.type() == SnapshotOperationType.RESTORE || - op.type() == SnapshotOperationType.RESTORE_2_PHASE) - && (op.extraParameter() == null || op.extraParameter() instanceof Collection); + assert (op.type() == SnapshotOperationType.RESTORE || + op.type() == SnapshotOperationType.RESTORE_2_PHASE) + && (op.extraParameter() == null || op.extraParameter() instanceof Collection) + || (op.type() == SnapshotOperationType.CHECK && + (op.extraParameter() == null || op.extraParameter() instanceof SnapshotCheckParameters)); + + if (op.type() == SnapshotOperationType.CHECK) { + if (op.extraParameter() == null) + return null; + else + return ((SnapshotCheckParameters)op.extraParameter()).optionalPaths(); + } return (Collection<File>)op.extraParameter(); } @@ -145,6 +153,16 @@ public class SnapshotOperation implements Serializable { /** * @param op Op. */ + public static boolean getSkipCrcParameter(SnapshotOperation op) { + assert op.type() == SnapshotOperationType.CHECK && + (op.extraParameter() == null | op.extraParameter() instanceof SnapshotCheckParameters); + + return op.extraParameter() != null && ((SnapshotCheckParameters)op.extraParameter()).skipCrc(); + } + + /** + * @param op Op. + */ public static Boolean getFullSnapshotParameter(SnapshotOperation op) { assert op.type() == SnapshotOperationType.CREATE && op.extraParameter() instanceof Boolean;
