ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [04/12] ignite git commit: IGNITE-6513 introduce system property for manage wal serializer version (IGNITE_WAL_SERIALIZER_VERSION)
Date Mon, 02 Oct 2017 09:39:43 GMT
IGNITE-6513 introduce system property for manage wal serializer version (IGNITE_WAL_SERIALIZER_VERSION)

Signed-off-by: Andrey Gura <agura@apache.org>


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

Branch: refs/heads/ignite-3478
Commit: 0749ec45f0af2dbd18a08e5e25b3773a01a16a0e
Parents: c4047b4
Author: Dmitriy Govorukhin <dmitriy.govorukhin@gmail.com>
Authored: Fri Sep 29 16:07:58 2017 +0300
Committer: Andrey Gura <agura@apache.org>
Committed: Fri Sep 29 16:07:58 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/IgniteSystemProperties.java   |  5 +
 .../wal/FileWriteAheadLogManager.java           |  5 +-
 .../db/wal/IgniteWalSerializerVersionTest.java  | 96 ++++++++++++++++++++
 .../ignite/testsuites/IgnitePdsTestSuite2.java  |  3 +
 4 files changed, 108 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0749ec45/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 39e65e1..e1e72f7 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -732,6 +732,11 @@ public final class IgniteSystemProperties {
     public static final String IGNITE_OVERRIDE_WRITE_THROTTLING_ENABLED = "IGNITE_OVERRIDE_WRITE_THROTTLING_ENABLED";
 
     /**
+     * Property for setup WAL serializer version.
+     */
+    public static final String IGNITE_WAL_SERIALIZER_VERSION = "IGNITE_WAL_SERIALIZER_VERSION";
+
+    /**
      * Enforces singleton.
      */
     private IgniteSystemProperties() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/0749ec45/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
index c4582cf..76edcea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/wal/FileWriteAheadLogManager.java
@@ -42,6 +42,7 @@ import java.util.concurrent.locks.ReentrantLock;
 import java.util.regex.Pattern;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.configuration.PersistentStoreConfiguration;
 import org.apache.ignite.configuration.WALMode;
@@ -87,6 +88,7 @@ import org.jetbrains.annotations.Nullable;
 import static java.nio.file.StandardOpenOption.CREATE;
 import static java.nio.file.StandardOpenOption.READ;
 import static java.nio.file.StandardOpenOption.WRITE;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_SERIALIZER_VERSION;
 
 /**
  * File WAL manager.
@@ -164,7 +166,8 @@ public class FileWriteAheadLogManager extends GridCacheSharedManagerAdapter
impl
     private RecordSerializer serializer;
 
     /** Serializer latest version to use. */
-    private int serializerVersion = LATEST_SERIALIZER_VERSION;
+    private final int serializerVersion =
+        IgniteSystemProperties.getInteger(IGNITE_WAL_SERIALIZER_VERSION, LATEST_SERIALIZER_VERSION);
 
     /** */
     private volatile long oldestArchiveSegmentIdx;

http://git-wip-us.apache.org/repos/asf/ignite/blob/0749ec45/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalSerializerVersionTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalSerializerVersionTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalSerializerVersionTest.java
new file mode 100644
index 0000000..6d9d80e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalSerializerVersionTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.processors.cache.persistence.db.wal;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.PersistentStoreConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager;
+import org.apache.ignite.internal.processors.cache.persistence.wal.RecordSerializer;
+import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV1Serializer;
+import org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordV2Serializer;
+import org.apache.ignite.internal.util.typedef.internal.GPC;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_WAL_SERIALIZER_VERSION;
+
+/**
+ *
+ */
+public class IgniteWalSerializerVersionTest extends GridCommonAbstractTest {
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String name) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(name);
+
+        cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration());
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCheckDifferentSerializerVersions() throws Exception {
+        IgniteEx ig0 = (IgniteEx)startGrid();
+
+        IgniteWriteAheadLogManager wal0 = ig0.context().cache().context().wal();
+
+        RecordSerializer ser0 = U.field(wal0, "serializer");
+
+        assertTrue(ser0 instanceof RecordV1Serializer);
+
+        stopGrid();
+
+        System.setProperty(IGNITE_WAL_SERIALIZER_VERSION, "2");
+
+        IgniteEx ig1 = (IgniteEx)startGrid();
+
+        IgniteWriteAheadLogManager wal1 = ig1.context().cache().context().wal();
+
+        RecordSerializer ser1 = U.field(wal1, "serializer");
+
+        assertTrue(ser1 instanceof RecordV2Serializer);
+
+        stopGrid();
+
+        System.setProperty(IGNITE_WAL_SERIALIZER_VERSION, "3");
+
+        GridTestUtils.assertThrowsAnyCause(log, new GPC<Void>() {
+            @Override public Void call() throws Exception {
+                startGrid();
+
+                return null;
+            }
+        }, IgniteCheckedException.class, "Failed to create a serializer with the given version");
+
+        System.setProperty(IGNITE_WAL_SERIALIZER_VERSION, "1");
+
+        IgniteEx ig2 = (IgniteEx)startGrid();
+
+        IgniteWriteAheadLogManager wal2 = ig2.context().cache().context().wal();
+
+        RecordSerializer ser2 = U.field(wal2, "serializer");
+
+        assertTrue(ser2 instanceof RecordV1Serializer);
+
+        stopGrid();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0749ec45/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
index 29ea64c..29f7255 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java
@@ -31,6 +31,7 @@ import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsTrans
 import org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsWholeClusterRestartTest;
 import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalFlushFailoverTest;
 import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalHistoryReservationsTest;
+import org.apache.ignite.internal.processors.cache.persistence.db.wal.IgniteWalSerializerVersionTest;
 import org.apache.ignite.internal.processors.cache.persistence.db.wal.crc.IgniteDataIntegrityTests;
 import org.apache.ignite.internal.processors.cache.persistence.db.wal.reader.IgniteWalReaderTest;
 
@@ -77,6 +78,8 @@ public class IgnitePdsTestSuite2 extends TestSuite {
 
         suite.addTestSuite(IgnitePdsExchangeDuringCheckpointTest.class);
 
+        suite.addTestSuite(IgniteWalSerializerVersionTest.class);
+
         return suite;
     }
 }


Mime
View raw message