IGNITE-3326 Map-reduce query waits for rebalancing forever when it's disabled. - Fixes #813.
Signed-off-by: Sergi Vladykin <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d33f4db1 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d33f4db1 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d33f4db1 Branch: refs/heads/ignite-1232 Commit: d33f4db130d4379fa3ab7320ccf118a94c17b889 Parents: 583ef2e Author: ascherbakoff <[email protected]> Authored: Tue Jun 21 08:25:56 2016 +0300 Committer: Alexei Scherbakov <[email protected]> Committed: Tue Jul 5 09:07:56 2016 +0100 ---------------------------------------------------------------------- .../ignite/internal/GridGetOrStartSelfTest.java | 70 +++++++++++++++++ .../query/h2/twostep/GridMapQueryExecutor.java | 2 +- .../IgniteCacheQueryNoRebalanceSelfTest.java | 82 ++++++++++++++++++++ .../IgniteCacheQuerySelfTestSuite.java | 2 + 4 files changed, 155 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/d33f4db1/modules/core/src/test/java/org/apache/ignite/internal/GridGetOrStartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridGetOrStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridGetOrStartSelfTest.java new file mode 100644 index 0000000..26d98ba --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/GridGetOrStartSelfTest.java @@ -0,0 +1,70 @@ +/* + * 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; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.testframework.junits.common.*; + +/** + * The GirdGetOrStartSelfTest tests get or start semantics. See IGNITE-2941 + */ + +@GridCommonTest(group = "Kernal Self") +public class GridGetOrStartSelfTest extends GridCommonAbstractTest { + /** + * Default constructor. + */ + public GridGetOrStartSelfTest() { + super(false); + } + + /** + * Tests default grid + */ + public void testDefaultGridGetOrStart() throws Exception { + IgniteConfiguration cfg = getConfiguration(null); + try(Ignite ignite = Ignition.getOrStart(cfg)) { + try { + Ignition.start(cfg); + fail("Expected exception after grid started"); + } + catch (IgniteException ignored) { + } + Ignite ignite2 = Ignition.getOrStart(cfg); + assertEquals("Must return same instance", ignite, ignite2); + } + } + + /** + * Tests named grid + */ + public void testNamedGridGetOrStart() throws Exception { + IgniteConfiguration cfg = getConfiguration("test"); + try(Ignite ignite = Ignition.getOrStart(cfg)) { + try { + Ignition.start(cfg); + fail("Expected exception after grid started"); + } + catch (IgniteException ignored) { + } + Ignite ignite2 = Ignition.getOrStart(cfg); + assertEquals("Must return same instance", ignite, ignite2); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/d33f4db1/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java index 3d226e5..580058c 100644 --- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java +++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java @@ -277,7 +277,7 @@ public class GridMapQueryExecutor { if (cctx == null) // Cache was not found, probably was not deployed yet. return false; - if (cctx.isLocal()) + if (cctx.isLocal() || !cctx.rebalanceEnabled()) continue; // For replicated cache topology version does not make sense. http://git-wip-us.apache.org/repos/asf/ignite/blob/d33f4db1/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNoRebalanceSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNoRebalanceSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNoRebalanceSelfTest.java new file mode 100644 index 0000000..ac96cc5 --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNoRebalanceSelfTest.java @@ -0,0 +1,82 @@ +/* + * 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.near; + +import javax.cache.Cache; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.CacheRebalanceMode; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.SqlQuery; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +/** + * Test added to check for https://issues.apache.org/jira/browse/IGNITE-3326. + */ +public class IgniteCacheQueryNoRebalanceSelfTest extends GridCommonAbstractTest { + /** */ + private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + /** + * + */ + public IgniteCacheQueryNoRebalanceSelfTest() { + super(true); + } + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration() throws Exception { + IgniteConfiguration cfg = super.getConfiguration(); + + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + + CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(); + ccfg.setBackups(0); + ccfg.setIndexedTypes(Integer.class, Integer.class); + ccfg.setRebalanceMode(CacheRebalanceMode.NONE); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + + super.afterTestsStopped(); + } + + /** + * Tests correct query execution with disabled re-balancing. + */ + public void testQueryNoRebalance() { + IgniteCache<Object, Object> cache = grid().cache(null); + + cache.put(1, 1); + + QueryCursor<Cache.Entry<Integer, Integer>> qry = + cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= 0")); + + assertEquals("Bad results count", 1, qry.getAll().size()); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/d33f4db1/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java index 7b39453..1b1908d 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java +++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java @@ -47,6 +47,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheC import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQueryP2PDisabledSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQuerySelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedSnapshotEnabledQuerySelfTest; +import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNoRebalanceSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeFailTest; import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartSelfTest; import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartSelfTest2; @@ -113,6 +114,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite { suite.addTestSuite(IgniteBinaryObjectFieldsQuerySelfTest.class); suite.addTestSuite(IgniteBinaryWrappedObjectFieldsQuerySelfTest.class); suite.addTestSuite(IgniteCacheQueryH2IndexingLeakTest.class); + suite.addTestSuite(IgniteCacheQueryNoRebalanceSelfTest.class); return suite; }
