GG-11860 Implement snapshot status on platform level -refactoring (moving messages, new mechanism of registration, etc.)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4c97f43b Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4c97f43b Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4c97f43b Branch: refs/heads/ignite-gg-8.0.3.ea6-clients-test Commit: 4c97f43be8b608f20f2a5a3d40280233cffd46e8 Parents: 0384b66 Author: EdShangGG <[email protected]> Authored: Tue Feb 21 16:03:05 2017 +0300 Committer: EdShangGG <[email protected]> Committed: Tue Feb 21 16:03:05 2017 +0300 ---------------------------------------------------------------------- .../communication/GridIoMessageFactory.java | 15 +- .../pagemem/snapshot/SnapshotOperation.java | 30 +++ .../SnapshotOperationFinishedMessage.java | 181 ------------------- .../pagemem/snapshot/SnapshotOperationType.java | 4 +- .../snapshot/SnapshotProgressMessage.java | 135 -------------- .../GridChangeGlobalStateMessageResponse.java | 2 +- 6 files changed, 36 insertions(+), 331 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/4c97f43b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java index 1574909..6f73682 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java @@ -33,8 +33,6 @@ import org.apache.ignite.internal.managers.deployment.GridDeploymentInfoBean; import org.apache.ignite.internal.managers.deployment.GridDeploymentRequest; import org.apache.ignite.internal.managers.deployment.GridDeploymentResponse; import org.apache.ignite.internal.managers.eventstorage.GridEventStorageMessage; -import org.apache.ignite.internal.pagemem.snapshot.SnapshotOperationFinishedMessage; -import org.apache.ignite.internal.pagemem.snapshot.SnapshotProgressMessage; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.GridChangeGlobalStateMessageResponse; import org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection; @@ -174,19 +172,9 @@ public class GridIoMessageFactory implements MessageFactory { Message msg = null; switch (type) { - case -47: - msg = new SnapshotProgressMessage(); - - break; - - - case -46: - msg = new GridChangeGlobalStateMessageResponse(); - - break; case -45: - msg = new SnapshotOperationFinishedMessage(); + msg = new GridChangeGlobalStateMessageResponse(); break; @@ -848,6 +836,7 @@ public class GridIoMessageFactory implements MessageFactory { // [-3..119] [124..127] [-23..-27] [-36..-47]- this // [120..123] - DR // [-4..-22, -30..-35] - SQL + // [-46..-50] - Snapshots default: if (ext != null) { for (MessageFactory factory : ext) { http://git-wip-us.apache.org/repos/asf/ignite/blob/4c97f43b/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 3e13f95..3f84b97 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 @@ -17,7 +17,9 @@ */ package org.apache.ignite.internal.pagemem.snapshot; +import java.io.File; import java.io.Serializable; +import java.util.Collection; import java.util.Set; /** @@ -98,6 +100,34 @@ public class SnapshotOperation implements Serializable { return extraParam; } + + /** + * @param op Op. + */ + public static Collection<File> getOptionalPathsParameter(SnapshotOperation op) { + assert op.type() == SnapshotOperationType.CHECK || op.extraParameter() instanceof Collection; + + return (Collection<File>)op.extraParameter(); + } + + /** + * @param op Op. + */ + public static Boolean getFullSnapshotParameter(SnapshotOperation op) { + assert op.type() == SnapshotOperationType.CREATE && op.extraParameter() instanceof Boolean; + + return (Boolean)op.extraParameter(); + } + + /** + * @param op Op. + */ + public static File getMovingPathParameter(SnapshotOperation op) { + assert op.type() == SnapshotOperationType.MOVE && op.extraParameter() instanceof File; + + return (File)op.extraParameter(); + } + @Override public boolean equals(Object o) { if (this == o) return true; http://git-wip-us.apache.org/repos/asf/ignite/blob/4c97f43b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperationFinishedMessage.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperationFinishedMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperationFinishedMessage.java deleted file mode 100644 index 8986e5c..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperationFinishedMessage.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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.nio.ByteBuffer; -import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.plugin.extensions.communication.MessageReader; -import org.apache.ignite.plugin.extensions.communication.MessageWriter; - -/** - * Message indicating that snapshot has been finished on a single node. - */ -public class SnapshotOperationFinishedMessage implements Message { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private long snapshotId; - - /** Operation type. */ - private int operationType; - - /** */ - private boolean success; - - /** Error message. */ - private String errorMsg; - - /** */ - public SnapshotOperationFinishedMessage() { - } - - /** - * @param snapshotId Snapshot ID. - * @param errorMsg - */ - public SnapshotOperationFinishedMessage(long snapshotId, SnapshotOperationType type, boolean success, String errorMsg) { - this.snapshotId = snapshotId; - this.operationType = type.ordinal(); - this.success = success; - this.errorMsg = errorMsg; - } - - /** - * @return Snapshot ID. - */ - public long snapshotId() { - return snapshotId; - } - - /** */ - public SnapshotOperationType operationType() { - return SnapshotOperationType.values()[operationType]; - } - - /** */ - public boolean success() { - return success; - } - - /** */ - public String errorMessage() { - return errorMsg; - } - - /** {@inheritDoc} */ - @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) { - writer.setBuffer(buf); - - if (!writer.isHeaderWritten()) { - if (!writer.writeHeader(directType(), fieldsCount())) - return false; - - writer.onHeaderWritten(); - } - - switch (writer.state()) { - case 0: - if (!writer.writeLong("snapshotId", snapshotId)) - return false; - - writer.incrementState(); - - case 1: - if (!writer.writeInt("operationType", operationType)) - return false; - - writer.incrementState(); - - case 2: - if (!writer.writeBoolean("success", success)) - return false; - - writer.incrementState(); - - case 3: - if (!writer.writeString("errorMsg", errorMsg)) - return false; - - writer.incrementState(); - - } - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) { - reader.setBuffer(buf); - - if (!reader.beforeMessageRead()) - return false; - - switch (reader.state()) { - case 0: - snapshotId = reader.readLong("snapshotId"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - - case 1: - operationType = reader.readInt("operationType"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - - case 2: - success = reader.readBoolean("success"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - - case 3: - errorMsg = reader.readString("errorMsg"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - } - - return reader.afterMessageRead(SnapshotOperationFinishedMessage.class); - } - - /** {@inheritDoc} */ - @Override public byte directType() { - return -45; - } - - /** {@inheritDoc} */ - @Override public byte fieldsCount() { - return 4; - } - - /** {@inheritDoc} */ - @Override public void onAckReceived() { - // No-op - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/4c97f43b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperationType.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperationType.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperationType.java index 8866bdb..3fa6d2a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperationType.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperationType.java @@ -26,5 +26,7 @@ public enum SnapshotOperationType { /** Move. */ MOVE, /** Delete. */ - DELETE + DELETE, + /** Check. */ + CHECK } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4c97f43b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotProgressMessage.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotProgressMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotProgressMessage.java deleted file mode 100644 index 70ea6a9..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotProgressMessage.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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.nio.ByteBuffer; -import org.apache.ignite.plugin.extensions.communication.Message; -import org.apache.ignite.plugin.extensions.communication.MessageReader; -import org.apache.ignite.plugin.extensions.communication.MessageWriter; - -/** - * Message for exchange of snapshot creation/restoration progress between nodes. - */ -public class SnapshotProgressMessage implements Message { - /** */ - private static final long serialVersionUID = 0L; - - /** */ - private long snapshotId; - - /** */ - private double progress; - - /** */ - public SnapshotProgressMessage() { - } - - /** */ - public SnapshotProgressMessage(long snapshotId, double progress) { - this.snapshotId = snapshotId; - this.progress = progress; - } - - /** - * @return Snapshot ID. - */ - public long snapshotId() { - return snapshotId; - } - - /** - * @return Snapshot creation/restoration progress. - */ - public double progress() { - return progress; - } - - /** {@inheritDoc} */ - @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) { - writer.setBuffer(buf); - - if (!writer.isHeaderWritten()) { - if (!writer.writeHeader(directType(), fieldsCount())) - return false; - - writer.onHeaderWritten(); - } - - switch (writer.state()) { - case 0: - if (!writer.writeDouble("progress", progress)) - return false; - - writer.incrementState(); - - case 1: - if (!writer.writeLong("snapshotId", snapshotId)) - return false; - - writer.incrementState(); - - } - - return true; - } - - /** {@inheritDoc} */ - @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) { - reader.setBuffer(buf); - - if (!reader.beforeMessageRead()) - return false; - - switch (reader.state()) { - case 0: - progress = reader.readDouble("progress"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - - case 1: - snapshotId = reader.readLong("snapshotId"); - - if (!reader.isLastRead()) - return false; - - reader.incrementState(); - - } - - return reader.afterMessageRead(SnapshotProgressMessage.class); - } - - /** {@inheritDoc} */ - @Override public byte directType() { - return -47; - } - - /** {@inheritDoc} */ - @Override public byte fieldsCount() { - return 2; - } - - /** {@inheritDoc} */ - @Override public void onAckReceived() { - // No-op - } -} http://git-wip-us.apache.org/repos/asf/ignite/blob/4c97f43b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridChangeGlobalStateMessageResponse.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridChangeGlobalStateMessageResponse.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridChangeGlobalStateMessageResponse.java index fafc71f..3ad4ef4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridChangeGlobalStateMessageResponse.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridChangeGlobalStateMessageResponse.java @@ -157,7 +157,7 @@ public class GridChangeGlobalStateMessageResponse extends GridCacheMessage { /** {@inheritDoc} */ @Override public byte directType() { - return -46; + return -45; } /** {@inheritDoc} */
