ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject ignite git commit: IGNITE-6356 - Fixed overflow when using number of partitions greater than Short.MAX_VALUE
Date Wed, 13 Sep 2017 10:42:47 GMT
Repository: ignite
Updated Branches:
  refs/heads/master fdfd47367 -> 1aa59a69f


IGNITE-6356 - Fixed overflow when using number of partitions greater than Short.MAX_VALUE


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

Branch: refs/heads/master
Commit: 1aa59a69fa7e6a38938090ca9dfdaba3dfa307d5
Parents: fdfd473
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Wed Sep 13 13:42:31 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Wed Sep 13 13:42:31 2017 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       |  2 +-
 .../dht/preloader/GridDhtPartitionMap.java      |  4 +-
 .../distributed/Cache64kPartitionsTest.java     | 86 ++++++++++++++++++++
 .../testsuites/IgniteCacheTestSuite5.java       |  4 +-
 4 files changed, 92 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1aa59a69/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 2b4ec1d..6c43d13 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -77,7 +77,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K,
V> {
     private static final long serialVersionUID = 0L;
 
     /** Maximum number of partitions. */
-    public static final int MAX_PARTITIONS_COUNT = 0xFFFF;
+    public static final int MAX_PARTITIONS_COUNT = 65000;
 
     /** Default size of rebalance thread pool. */
     @Deprecated

http://git-wip-us.apache.org/repos/asf/ignite/blob/1aa59a69/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java
index 5173a01..cb69714 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionMap.java
@@ -293,8 +293,8 @@ public class GridDhtPartitionMap implements Comparable<GridDhtPartitionMap>,
Ext
         map = new GridPartitionStateMap();
 
         for (int i = 0; i < size; i++) {
-            int ordinal = in.readByte();
-            int part = in.readShort();
+            int ordinal = in.readUnsignedByte();
+            int part = in.readUnsignedShort();
 
             put(part, GridDhtPartitionState.fromOrdinal(ordinal));
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/1aa59a69/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/Cache64kPartitionsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/Cache64kPartitionsTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/Cache64kPartitionsTest.java
new file mode 100644
index 0000000..fe139ba
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/Cache64kPartitionsTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.distributed;
+
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.PersistentStoreConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class Cache64kPartitionsTest extends GridCommonAbstractTest {
+    /** */
+    private boolean persistenceEnabled;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws
Exception {
+        IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+        CacheConfiguration ccfg = new CacheConfiguration("default");
+
+        ccfg.setAffinity(new RendezvousAffinityFunction(false, CacheConfiguration.MAX_PARTITIONS_COUNT));
+
+        cfg.setCacheConfiguration(ccfg);
+
+        cfg.setActiveOnStart(false);
+
+        if (persistenceEnabled)
+            cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration());
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testManyPartitionsNoPersistence() throws Exception {
+        checkManyPartitions();
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testManyPartitionsWithPersistence() throws Exception {
+        persistenceEnabled = true;
+
+        checkManyPartitions();
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    private void checkManyPartitions() throws Exception {
+        try {
+            startGrids(4);
+
+            grid(0).active(true);
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        GridTestUtils.deleteDbFiles();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/1aa59a69/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
index 953c789..38ffb4c 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite5.java
@@ -35,9 +35,9 @@ import org.apache.ignite.internal.processors.cache.IgniteCachePutStackOverflowSe
 import org.apache.ignite.internal.processors.cache.IgniteCacheReadThroughEvictionsVariationsSuite;
 import org.apache.ignite.internal.processors.cache.IgniteCacheStoreCollectionTest;
 import org.apache.ignite.internal.processors.cache.PartitionsExchangeOnDiscoveryHistoryOverflowTest;
+import org.apache.ignite.internal.processors.cache.distributed.Cache64kPartitionsTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheLateAffinityAssignmentNodeJoinValidationTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheLateAffinityAssignmentTest;
-import org.apache.ignite.internal.processors.cache.distributed.GridCachePartitionEvictionDuringReadThroughSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheGroupsPartitionLossPolicySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.IgniteCachePartitionLossPolicySelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.IgniteCacheTxIteratorSelfTest;
@@ -96,6 +96,8 @@ public class IgniteCacheTestSuite5 extends TestSuite {
 
         suite.addTestSuite(NotMappedPartitionInTxTest.class);
 
+        suite.addTestSuite(Cache64kPartitionsTest.class);
+
         return suite;
     }
 }


Mime
View raw message