Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 062FA200D09 for ; Tue, 12 Sep 2017 16:36:02 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 048F41609C7; Tue, 12 Sep 2017 14:36:02 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 233991609C6 for ; Tue, 12 Sep 2017 16:36:00 +0200 (CEST) Received: (qmail 40808 invoked by uid 500); 12 Sep 2017 14:35:59 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 40799 invoked by uid 99); 12 Sep 2017 14:35:59 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Sep 2017 14:35:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 30D70F5724; Tue, 12 Sep 2017 14:35:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agoncharuk@apache.org To: commits@ignite.apache.org Message-Id: <076855d922574321b53bd37fccabd31d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ignite git commit: IGNITE-6356 - Fixed partition ID negative overflow Date: Tue, 12 Sep 2017 14:35:59 +0000 (UTC) archived-at: Tue, 12 Sep 2017 14:36:02 -0000 Repository: ignite Updated Branches: refs/heads/ignite-6356 [created] 7841984d4 IGNITE-6356 - Fixed partition ID negative overflow Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7841984d Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7841984d Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7841984d Branch: refs/heads/ignite-6356 Commit: 7841984d470cb5fd38ac8c6ac63e22791d0d45b5 Parents: 8c23805 Author: Alexey Goncharuk Authored: Tue Sep 12 17:35:46 2017 +0300 Committer: Alexey Goncharuk Committed: Tue Sep 12 17:35:46 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/7841984d/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 extends MutableConfiguration { 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/7841984d/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..3aa982b 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, Ext map = new GridPartitionStateMap(); for (int i = 0; i < size; i++) { - int ordinal = in.readByte(); - int part = in.readShort(); + int ordinal = in.readByte() & 0xFF; + int part = in.readShort() & 0xFFFF; put(part, GridDhtPartitionState.fromOrdinal(ordinal)); } http://git-wip-us.apache.org/repos/asf/ignite/blob/7841984d/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/7841984d/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; } }