You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2017/05/03 07:21:40 UTC
[02/50] [abbrv] ignite git commit: GG-11860 Implement snapshot status
on platform level -refactoring: extracting snapshot operation
GG-11860 Implement snapshot status on platform level
-refactoring: extracting snapshot operation
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/92821167
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/92821167
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/92821167
Branch: refs/heads/ignite-gg-8.0.3.ea6-clients-test
Commit: 92821167ad884266728a2fae83799d1dfa17e07d
Parents: 63e6a21
Author: EdShangGG <es...@gridgain.com>
Authored: Wed Feb 15 21:11:30 2017 +0300
Committer: EdShangGG <es...@gridgain.com>
Committed: Wed Feb 15 21:11:30 2017 +0300
----------------------------------------------------------------------
.../pagemem/snapshot/SnapshotOperation.java | 100 +++++++++++++++++++
.../pagemem/snapshot/SnapshotOperationType.java | 30 ++++++
.../StartFullSnapshotAckDiscoveryMessage.java | 64 ++----------
.../StartFullSnapshotDiscoveryMessage.java | 70 ++++---------
4 files changed, 157 insertions(+), 107 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/92821167/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
new file mode 100644
index 0000000..8163049
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperation.java
@@ -0,0 +1,100 @@
+/*
+ * 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.Serializable;
+import java.util.Set;
+
+/**
+ * Description and parameters of snapshot operation
+ */
+public class SnapshotOperation implements Serializable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final SnapshotOperationType type;
+
+ /**
+ * Snapshot ID (the timestamp of snapshot creation).
+ */
+ private final long snapshotId;
+
+ /** */
+ private final Set<String> cacheNames;
+
+ /** Message. */
+ private final String msg;
+
+ /** Additional parameter. */
+ private final Object extraParam;
+
+ /**
+ * @param type Type.
+ * @param snapshotId Snapshot id.
+ * @param cacheNames Cache names.
+ * @param msg
+ * @param extraParam Additional parameter.
+ */
+ public SnapshotOperation(SnapshotOperationType type, long snapshotId, Set<String> cacheNames, String msg, Object extraParam) {
+ this.type = type;
+ this.snapshotId = snapshotId;
+ this.cacheNames = cacheNames;
+ this.msg = msg;
+ this.extraParam = extraParam;
+ }
+
+ /**
+ *
+ */
+ public SnapshotOperationType type() {
+ return type;
+ }
+
+ /**
+ * Snapshot ID (the timestamp of snapshot creation).
+ *
+ * @return Snapshot ID.
+ */
+ public long id() {
+ return snapshotId;
+ }
+
+ /**
+ * Cache names included to this snapshot.
+ *
+ * @return Cache names.
+ */
+ public Set<String> cacheNames() {
+ return cacheNames;
+ }
+
+ /**
+ * Additional info which was provided by client
+ */
+ public String message() {
+ return msg;
+ }
+
+ /**
+ *
+ */
+ public Object extraParameter() {
+ return extraParam;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/92821167/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
new file mode 100644
index 0000000..8866bdb
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/SnapshotOperationType.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/** */
+public enum SnapshotOperationType {
+ /** Create. */
+ CREATE,
+ /** Restore. */
+ RESTORE,
+ /** Move. */
+ MOVE,
+ /** Delete. */
+ DELETE
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/92821167/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartFullSnapshotAckDiscoveryMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartFullSnapshotAckDiscoveryMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartFullSnapshotAckDiscoveryMessage.java
index 08082de..32a3dae 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartFullSnapshotAckDiscoveryMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/pagemem/snapshot/StartFullSnapshotAckDiscoveryMessage.java
@@ -35,27 +35,18 @@ public class StartFullSnapshotAckDiscoveryMessage implements DiscoveryCustomMess
/** */
private static final long serialVersionUID = 0L;
- /** Message. */
- private final String msg;
+
+ private SnapshotOperation snapshotOperation;
/** Custom message ID. */
private IgniteUuid id = IgniteUuid.randomUuid();
/** */
- private long globalSnapshotId;
-
- /** */
private Exception err;
/** */
- private Collection<String> cacheNames;
-
- /** */
private UUID initiatorNodeId;
- /** Full snapshot. */
- private boolean fullSnapshot;
-
/** Last full snapshot id for cache. */
private Map<Integer, Long> lastFullSnapshotIdForCache;
@@ -63,43 +54,21 @@ public class StartFullSnapshotAckDiscoveryMessage implements DiscoveryCustomMess
private Map<Integer, Long> lastSnapshotIdForCache;
/**
- * @param globalSnapshotId Snapshot ID.
+ * @param snapshotOperation Snapshot Operation.
* @param err Error.
- * @param cacheNames Cache names.
*/
public StartFullSnapshotAckDiscoveryMessage(
- long globalSnapshotId,
- boolean fullSnapshot,
+ SnapshotOperation snapshotOperation,
Map<Integer, Long> lastFullSnapshotIdForCache,
Map<Integer, Long> lastSnapshotIdForCache,
- Collection<String> cacheNames,
Exception err,
- UUID initiatorNodeId,
- String msg
+ UUID initiatorNodeId
) {
- this.globalSnapshotId = globalSnapshotId;
- this.fullSnapshot = fullSnapshot;
+ this.snapshotOperation = snapshotOperation;
this.lastFullSnapshotIdForCache = lastFullSnapshotIdForCache;
this.lastSnapshotIdForCache = lastSnapshotIdForCache;
this.err = err;
- this.cacheNames = cacheNames;
this.initiatorNodeId = initiatorNodeId;
- this.msg = msg;
-
- for (String cacheName : cacheNames) {
- int i = CU.cacheId(cacheName);
-
- if (lastFullSnapshotIdForCache.get(i) == null || lastSnapshotIdForCache.get(i) == null) {
- throw new AssertionError();
- }
- }
- }
-
- /**
- * @return Cache names.
- */
- public Collection<String> cacheNames() {
- return cacheNames;
}
/** {@inheritDoc} */
@@ -128,25 +97,8 @@ public class StartFullSnapshotAckDiscoveryMessage implements DiscoveryCustomMess
return err != null;
}
- /**
- * @return Snapshot ID.
- */
- public long globalSnapshotId() {
- return globalSnapshotId;
- }
-
- /**
- *
- */
- public boolean fullSnapshot() {
- return fullSnapshot;
- }
-
- /**
- *
- */
- public String message() {
- return msg;
+ public SnapshotOperation snapshotOperation() {
+ return snapshotOperation;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/92821167/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
index bd6d97f..2a977f4 100644
--- 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
@@ -35,17 +35,11 @@ public class StartFullSnapshotDiscoveryMessage implements DiscoveryCustomMessage
/** */
private static final long serialVersionUID = 0L;
- /** Message. */
- private final String msg;
-
/** Custom message ID. */
private IgniteUuid id = IgniteUuid.randomUuid();
- /** Snapshot ID. */
- private long globalSnapshotId;
-
- /** */
- private Collection<String> cacheNames;
+ /** Snapshot operation. */
+ private SnapshotOperation snapshotOperation;
/** */
private UUID initiatorId;
@@ -53,9 +47,6 @@ public class StartFullSnapshotDiscoveryMessage implements DiscoveryCustomMessage
/** Error. */
private Exception err;
- /** Full snapshot. */
- private boolean fullSnapshot;
-
/** Last full snapshot id for cache. */
private Map<Integer, Long> lastFullSnapshotIdForCache = new HashMap<>();
@@ -63,21 +54,22 @@ public class StartFullSnapshotDiscoveryMessage implements DiscoveryCustomMessage
private Map<Integer, Long> lastSnapshotIdForCache = new HashMap<>();
/**
- * @param cacheNames Cache names.
- * @param msg message to log
+ * @param snapshotOperation Snapshot operation
+ * @param initiatorId initiator node id
*/
public StartFullSnapshotDiscoveryMessage(
- long globalSnapshotId,
- Collection<String> cacheNames,
- UUID initiatorId,
- boolean fullSnapshot,
- String msg
+ SnapshotOperation snapshotOperation,
+ UUID initiatorId
) {
- this.globalSnapshotId = globalSnapshotId;
- this.cacheNames = cacheNames;
+ this.snapshotOperation = snapshotOperation;
this.initiatorId = initiatorId;
- this.fullSnapshot = fullSnapshot;
- this.msg = msg;
+ }
+
+ /**
+ *
+ */
+ public SnapshotOperation snapshotOperation() {
+ return snapshotOperation;
}
/**
@@ -116,27 +108,6 @@ public class StartFullSnapshotDiscoveryMessage implements DiscoveryCustomMessage
}
/**
- * @return Backup ID.
- */
- public long globalSnapshotId() {
- return globalSnapshotId;
- }
-
- /**
- * @return Cache names.
- */
- public Collection<String> cacheNames() {
- return cacheNames;
- }
-
- /**
- *
- */
- public boolean fullSnapshot() {
- return fullSnapshot;
- }
-
- /**
* @param cacheId Cache id.
*/
public Long lastFullSnapshotId(int cacheId) {
@@ -169,14 +140,11 @@ public class StartFullSnapshotDiscoveryMessage implements DiscoveryCustomMessage
/** {@inheritDoc} */
@Nullable @Override public DiscoveryCustomMessage ackMessage() {
return new StartFullSnapshotAckDiscoveryMessage(
- globalSnapshotId,
- fullSnapshot,
+ snapshotOperation,
lastFullSnapshotIdForCache,
lastSnapshotIdForCache,
- cacheNames,
err,
- initiatorId,
- msg);
+ initiatorId);
}
/** {@inheritDoc} */
@@ -185,10 +153,10 @@ public class StartFullSnapshotDiscoveryMessage implements DiscoveryCustomMessage
}
/**
- * @param full full snapshot.
+ * @param snapshotOperation new snapshot operation
*/
- public void fullSnapshot(boolean full) {
- fullSnapshot = full;
+ public void snapshotOperation(SnapshotOperation snapshotOperation) {
+ this.snapshotOperation = snapshotOperation;
}
/** {@inheritDoc} */