GG-11860 Implement snapshot status on platform level
-fixing race with operation finish message


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b51a2f80
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b51a2f80
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b51a2f80

Branch: refs/heads/ignite-gg-8.0.3.ea6-clients-test
Commit: b51a2f8006a13a24e7115c44bcb7124ee20be255
Parents: a62cc45
Author: EdShangGG <[email protected]>
Authored: Thu Mar 2 22:20:08 2017 +0300
Committer: EdShangGG <[email protected]>
Committed: Thu Mar 2 22:20:08 2017 +0300

----------------------------------------------------------------------
 .../StartFullSnapshotDiscoveryMessage.java      | 164 ------------------
 ...artSnapshotOperationAckDiscoveryMessage.java |  12 ++
 .../StartSnapshotOperationDiscoveryMessage.java | 167 +++++++++++++++++++
 .../resources/META-INF/classnames.properties    |   2 +-
 4 files changed, 180 insertions(+), 165 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b51a2f80/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartFullSnapshotDiscoveryMessage.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartFullSnapshotDiscoveryMessage.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartFullSnapshotDiscoveryMessage.java
deleted file mode 100644
index 3a67e49..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartFullSnapshotDiscoveryMessage.java
+++ /dev/null
@@ -1,164 +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.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.lang.IgniteUuid;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Message indicating that a snapshot has been started.
- */
-public class StartFullSnapshotDiscoveryMessage implements 
DiscoveryCustomMessage {
-    /** */
-    private static final long serialVersionUID = 0L;
-
-    /** Custom message ID. */
-    private IgniteUuid id = IgniteUuid.randomUuid();
-
-    /** Snapshot operation. */
-    private SnapshotOperation snapshotOperation;
-
-    /** */
-    private UUID initiatorId;
-
-    /** Error. */
-    private Exception err;
-
-    /** Last full snapshot id for cache. */
-    private Map<Integer, Long> lastFullSnapshotIdForCache = new HashMap<>();
-
-    /** Last snapshot id for cache. */
-    private Map<Integer, Long> lastSnapshotIdForCache = new HashMap<>();
-
-    /**
-     * @param snapshotOperation Snapshot operation
-     * @param initiatorId initiator node id
-     */
-    public StartFullSnapshotDiscoveryMessage(
-        SnapshotOperation snapshotOperation,
-        UUID initiatorId
-    ) {
-        this.snapshotOperation = snapshotOperation;
-        this.initiatorId = initiatorId;
-    }
-
-    /**
-     *
-     */
-    public SnapshotOperation snapshotOperation() {
-        return snapshotOperation;
-    }
-
-    /**
-     * Sets error.
-     *
-     * @param err Error.
-     */
-    public void error(Exception err) {
-        this.err = err;
-    }
-
-    /**
-     * @return {@code True} if message contains error.
-     */
-    public boolean hasError() {
-        return err != null;
-    }
-
-    /**
-     * @return Error.
-     */
-    public Exception error() {
-        return err;
-    }
-
-    /**
-     * @return Initiator node id.
-     */
-    public UUID initiatorId() {
-        return initiatorId;
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteUuid id() {
-        return id;
-    }
-
-    /**
-     * @param cacheId Cache id.
-     */
-    public Long lastFullSnapshotId(int cacheId) {
-        return lastFullSnapshotIdForCache.get(cacheId);
-    }
-
-    /**
-     * @param cacheId Cache id.
-     * @param id Id.
-     */
-    public void lastFullSnapshotId(int cacheId, long id) {
-        lastFullSnapshotIdForCache.put(cacheId, id);
-    }
-
-    /**
-     * @param cacheId Cache id.
-     */
-    public Long lastSnapshotId(int cacheId) {
-        return lastSnapshotIdForCache.get(cacheId);
-    }
-
-    /**
-     * @param cacheId Cache id.
-     * @param id Id.
-     */
-    public void lastSnapshotId(int cacheId, long id) {
-        lastSnapshotIdForCache.put(cacheId, id);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public DiscoveryCustomMessage ackMessage() {
-        return new StartSnapshotOperationAckDiscoveryMessage(
-            snapshotOperation,
-            lastFullSnapshotIdForCache,
-            lastSnapshotIdForCache,
-            err,
-            initiatorId);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isMutable() {
-        return true;
-    }
-
-    /**
-     * @param snapshotOperation new snapshot operation
-     */
-    public void snapshotOperation(SnapshotOperation snapshotOperation) {
-        this.snapshotOperation = snapshotOperation;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(StartFullSnapshotDiscoveryMessage.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b51a2f80/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartSnapshotOperationAckDiscoveryMessage.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartSnapshotOperationAckDiscoveryMessage.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartSnapshotOperationAckDiscoveryMessage.java
index e84b2e8..72defd4 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartSnapshotOperationAckDiscoveryMessage.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartSnapshotOperationAckDiscoveryMessage.java
@@ -38,6 +38,9 @@ public class StartSnapshotOperationAckDiscoveryMessage 
implements DiscoveryCusto
     /** Custom message ID. */
     private IgniteUuid id = IgniteUuid.randomUuid();
 
+    /** Operation id. */
+    private IgniteUuid opId;
+
     /** */
     private Exception err;
 
@@ -55,12 +58,14 @@ public class StartSnapshotOperationAckDiscoveryMessage 
implements DiscoveryCusto
      * @param err Error.
      */
     public StartSnapshotOperationAckDiscoveryMessage(
+        IgniteUuid id,
         SnapshotOperation snapshotOperation,
         Map<Integer, Long> lastFullSnapshotIdForCache,
         Map<Integer, Long> lastSnapshotIdForCache,
         Exception err,
         UUID initiatorNodeId
     ) {
+        this.opId = id;
         this.snapshotOperation = snapshotOperation;
         this.lastFullSnapshotIdForCache = lastFullSnapshotIdForCache;
         this.lastSnapshotIdForCache = lastSnapshotIdForCache;
@@ -74,6 +79,13 @@ public class StartSnapshotOperationAckDiscoveryMessage 
implements DiscoveryCusto
     }
 
     /**
+     *
+     */
+    public IgniteUuid operationId() {
+        return opId;
+    }
+
+    /**
      * @return Initiator node id.
      */
     public UUID initiatorNodeId() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/b51a2f80/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartSnapshotOperationDiscoveryMessage.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartSnapshotOperationDiscoveryMessage.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartSnapshotOperationDiscoveryMessage.java
new file mode 100644
index 0000000..2373a9b
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartSnapshotOperationDiscoveryMessage.java
@@ -0,0 +1,167 @@
+/*
+ * 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.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Message indicating that a snapshot has been started.
+ */
+public class StartSnapshotOperationDiscoveryMessage implements 
DiscoveryCustomMessage {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Custom message ID. */
+    private IgniteUuid id;
+
+    /** Snapshot operation. */
+    private SnapshotOperation snapshotOperation;
+
+    /** */
+    private UUID initiatorId;
+
+    /** Error. */
+    private Exception err;
+
+    /** Last full snapshot id for cache. */
+    private Map<Integer, Long> lastFullSnapshotIdForCache = new HashMap<>();
+
+    /** Last snapshot id for cache. */
+    private Map<Integer, Long> lastSnapshotIdForCache = new HashMap<>();
+
+    /**
+     * @param snapshotOperation Snapshot operation
+     * @param initiatorId initiator node id
+     */
+    public StartSnapshotOperationDiscoveryMessage(
+        IgniteUuid id,
+        SnapshotOperation snapshotOperation,
+        UUID initiatorId
+    ) {
+        this.id = id;
+        this.snapshotOperation = snapshotOperation;
+        this.initiatorId = initiatorId;
+    }
+
+    /**
+     *
+     */
+    public SnapshotOperation snapshotOperation() {
+        return snapshotOperation;
+    }
+
+    /**
+     * Sets error.
+     *
+     * @param err Error.
+     */
+    public void error(Exception err) {
+        this.err = err;
+    }
+
+    /**
+     * @return {@code True} if message contains error.
+     */
+    public boolean hasError() {
+        return err != null;
+    }
+
+    /**
+     * @return Error.
+     */
+    public Exception error() {
+        return err;
+    }
+
+    /**
+     * @return Initiator node id.
+     */
+    public UUID initiatorId() {
+        return initiatorId;
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteUuid id() {
+        return id;
+    }
+
+    /**
+     * @param cacheId Cache id.
+     */
+    public Long lastFullSnapshotId(int cacheId) {
+        return lastFullSnapshotIdForCache.get(cacheId);
+    }
+
+    /**
+     * @param cacheId Cache id.
+     * @param id Id.
+     */
+    public void lastFullSnapshotId(int cacheId, long id) {
+        lastFullSnapshotIdForCache.put(cacheId, id);
+    }
+
+    /**
+     * @param cacheId Cache id.
+     */
+    public Long lastSnapshotId(int cacheId) {
+        return lastSnapshotIdForCache.get(cacheId);
+    }
+
+    /**
+     * @param cacheId Cache id.
+     * @param id Id.
+     */
+    public void lastSnapshotId(int cacheId, long id) {
+        lastSnapshotIdForCache.put(cacheId, id);
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public DiscoveryCustomMessage ackMessage() {
+        return new StartSnapshotOperationAckDiscoveryMessage(
+            id,
+            snapshotOperation,
+            lastFullSnapshotIdForCache,
+            lastSnapshotIdForCache,
+            err,
+            initiatorId);
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean isMutable() {
+        return true;
+    }
+
+    /**
+     * @param snapshotOperation new snapshot operation
+     */
+    public void snapshotOperation(SnapshotOperation snapshotOperation) {
+        this.snapshotOperation = snapshotOperation;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(StartSnapshotOperationDiscoveryMessage.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/b51a2f80/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties 
b/modules/core/src/main/resources/META-INF/classnames.properties
index 13a3bce..1750276 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -329,7 +329,7 @@ 
org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl$Segment
 org.apache.ignite.internal.pagemem.snapshot.SnapshotOperationFinishedMessage
 org.apache.ignite.internal.pagemem.snapshot.SnapshotProgressMessage
 
org.apache.ignite.internal.pagemem.snapshot.StartSnapshotOperationAckDiscoveryMessage
-org.apache.ignite.internal.pagemem.snapshot.StartFullSnapshotDiscoveryMessage
+org.apache.ignite.internal.pagemem.snapshot.StartSnapshotOperationDiscoveryMessage
 org.apache.ignite.internal.pagemem.wal.StorageException
 org.apache.ignite.internal.pagemem.wal.WALIterator
 
org.apache.ignite.internal.pagemem.wal.record.StoreOperationRecord$StoreOperationType

Reply via email to