Repository: incubator-ignite Updated Branches: refs/heads/ignite-1124 e09657cdd -> 2162de0e5
# ignite-1124 Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/2162de0e Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/2162de0e Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/2162de0e Branch: refs/heads/ignite-1124 Commit: 2162de0e57c6085e869b868b2696e39f4c5603fa Parents: e09657c Author: sboikov <sboi...@gridgain.com> Authored: Fri Jul 17 10:46:09 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Fri Jul 17 11:46:30 2015 +0300 ---------------------------------------------------------------------- .../cache/transactions/IgniteTxManager.java | 4 +- .../IgniteCacheClientReconnectTest.java | 175 +++++++++++++++++++ .../testsuites/IgniteCacheTestSuite2.java | 2 +- .../testsuites/IgniteCacheTestSuite4.java | 2 - .../testsuites/IgniteClientNodesTestSuite.java | 42 +++++ 5 files changed, 220 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2162de0e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java index 82543c2..ee634ab 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java @@ -1984,9 +1984,9 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter { try { cctx.kernalContext().gateway().readLock(); } - catch (IllegalStateException ignore) { + catch (IllegalStateException | IgniteClientDisconnectedException ignore) { if (log.isDebugEnabled()) - log.debug("Failed to acquire kernal gateway (grid is stopping)."); + log.debug("Failed to acquire kernal gateway [err=" + ignore + ']'); return; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2162de0e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java new file mode 100644 index 0000000..c438c39 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java @@ -0,0 +1,175 @@ +/* + * 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.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; +import org.apache.ignite.spi.discovery.tcp.*; +import org.apache.ignite.spi.discovery.tcp.ipfinder.*; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.common.*; + +import java.util.concurrent.*; +import java.util.concurrent.atomic.*; + +import static java.util.concurrent.TimeUnit.*; +import static org.apache.ignite.cache.CacheAtomicityMode.*; +import static org.apache.ignite.cache.CacheMode.*; + +/** + * Test for customer scenario. + */ +public class IgniteCacheClientReconnectTest extends GridCommonAbstractTest { + /** */ + private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + /** */ + private static final int SRV_CNT = 3; + + /** */ + private static final int CACHES = 10; + + /** */ + private static final long TEST_TIME = 60_000; + + /** */ + private boolean client; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + cfg.setPeerClassLoadingEnabled(false); + + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + + if (!client) { + CacheConfiguration[] ccfgs = new CacheConfiguration[CACHES]; + + for (int i = 0; i < CACHES; i++) { + CacheConfiguration ccfg = new CacheConfiguration(); + + ccfg.setCacheMode(PARTITIONED); + ccfg.setAtomicityMode(TRANSACTIONAL); + ccfg.setBackups(1); + ccfg.setName("cache-" + i); + + ccfgs[i] = ccfg; + } + + cfg.setCacheConfiguration(ccfgs); + } + + cfg.setClientMode(client); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + startGrids(SRV_CNT); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + super.afterTestsStopped(); + } + + /** {@inheritDoc} */ + @Override protected long getTestTimeout() { + return TEST_TIME + 60_000; + } + + /** + * @throws Exception If failed. + */ + public void testClientReconnect() throws Exception { + client = true; + + final AtomicBoolean stop = new AtomicBoolean(false); + + final AtomicInteger idx = new AtomicInteger(SRV_CNT); + + final CountDownLatch latch = new CountDownLatch(2); + + IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() { + @Override public Void call() throws Exception { + Ignite ignite = startGrid(idx.getAndIncrement()); + + latch.countDown(); + + assertTrue(ignite.cluster().localNode().isClient()); + + while (!stop.get()) + putGet(ignite); + + return null; + } + }, 2, "client-thread"); + + try { + assertTrue(latch.await(10_000, MILLISECONDS)); + + long end = System.currentTimeMillis() + TEST_TIME; + + int clientIdx = idx.getAndIncrement(); + + int cnt = 0; + + while (System.currentTimeMillis() < end) { + log.info("Iteration: " + cnt++); + + try (Ignite ignite = startGrid(clientIdx)) { + assertTrue(ignite.cluster().localNode().isClient()); + + assertEquals(6, ignite.cluster().nodes().size()); + + putGet(ignite); + } + } + + stop.set(true); + + fut.get(); + } + finally { + stop.set(true); + } + } + + /** + * @param ignite Ignite. + */ + private void putGet(Ignite ignite) { + ThreadLocalRandom rnd = ThreadLocalRandom.current(); + + for (int i = 0; i < CACHES; i++) { + IgniteCache<Object, Object> cache = ignite.cache("cache-" + i); + + assertNotNull(cache); + + Integer key = rnd.nextInt(0, 100_000); + + cache.put(key, key); + + assertEquals(key, cache.get(key)); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2162de0e/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java index 6a59826..741da87 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java @@ -136,7 +136,7 @@ public class IgniteCacheTestSuite2 extends TestSuite { suite.addTest(new TestSuite(IgniteCachePartitionMapUpdateTest.class)); suite.addTest(new TestSuite(IgniteCacheClientNodePartitionsExchangeTest.class)); suite.addTest(new TestSuite(IgniteCacheClientNodeChangingTopologyTest.class)); - suite.addTest(new TestSuite(IgniteCacheClientNodeConcurrentStart.class)); + suite.addTest(new TestSuite(IgniteCacheServerNodeConcurrentStart.class)); return suite; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2162de0e/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java index bde3a72..18b2409 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java @@ -146,8 +146,6 @@ public class IgniteCacheTestSuite4 extends TestSuite { suite.addTestSuite(IgniteStartCacheInTransactionSelfTest.class); suite.addTestSuite(IgniteStartCacheInTransactionAtomicSelfTest.class); - suite.addTestSuite(IgniteCacheManyClientsTest.class); - suite.addTestSuite(CacheReadThroughRestartSelfTest.class); suite.addTestSuite(CacheReadThroughReplicatedRestartSelfTest.class); suite.addTestSuite(CacheReadThroughReplicatedAtomicRestartSelfTest.class); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2162de0e/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java new file mode 100644 index 0000000..5cc4e5a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteClientNodesTestSuite.java @@ -0,0 +1,42 @@ +/* + * 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.testsuites; + +import junit.framework.*; +import org.apache.ignite.internal.processors.cache.distributed.*; + +/** + * + */ +public class IgniteClientNodesTestSuite extends TestSuite { + /** + * @return Test suite. + * @throws Exception In case of error. + */ + public static TestSuite suite() throws Exception { + TestSuite suite = new TestSuite("Ignite Client Nodes Reconnect Test Suite"); + + suite.addTest(IgniteClientReconnectTestSuite.suite()); + + suite.addTestSuite(IgniteCacheManyClientsTest.class); + suite.addTestSuite(IgniteCacheClientNodeConcurrentStart.class); + suite.addTestSuite(IgniteCacheClientReconnectTest.class); + + return suite; + } +}