# ignite-1124 fixes for atomic cache update, more debug info for hanging tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f0d24f6b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f0d24f6b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f0d24f6b Branch: refs/heads/ignite-884 Commit: f0d24f6b64e308de3170d5e7fb2092cb5b1421b7 Parents: 44043fa Author: sboikov <sboi...@gridgain.com> Authored: Fri Jul 17 12:16:06 2015 +0300 Committer: sboikov <sboi...@gridgain.com> Committed: Fri Jul 17 12:16:06 2015 +0300 ---------------------------------------------------------------------- .../apache/ignite/internal/IgniteKernal.java | 12 ++ .../processors/cache/GridCacheContext.java | 45 +++-- .../processors/cache/GridCacheMvccManager.java | 6 +- .../GridCachePartitionExchangeManager.java | 53 ++++++ .../distributed/dht/GridDhtTopologyFuture.java | 14 -- .../dht/atomic/GridDhtAtomicCache.java | 4 +- .../dht/atomic/GridNearAtomicUpdateFuture.java | 11 +- .../GridDhtPartitionsExchangeFuture.java | 31 +--- .../cache/transactions/IgniteTxManager.java | 4 +- .../distributed/IgniteCache150ClientsTest.java | 1 + .../IgniteCacheClientReconnectTest.java | 175 +++++++++++++++++++ .../IgniteCacheServerNodeConcurrentStart.java | 96 ++++++++++ .../testframework/junits/GridAbstractTest.java | 5 + .../testsuites/IgniteCacheTestSuite2.java | 2 +- .../testsuites/IgniteCacheTestSuite4.java | 2 - .../testsuites/IgniteClientNodesTestSuite.java | 42 +++++ 16 files changed, 439 insertions(+), 64 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java index 0d4ce32..c411f2e 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java @@ -3009,6 +3009,18 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable { return ctx.isDaemon() && U.hasAnnotation(comp.getClass(), SkipDaemon.class); } + /** + * + */ + public void dumpDebugInfo() { + U.warn(log, "Dumping debug info for node [id=" + ctx.localNodeId() + + ", name=" + ctx.gridName() + + ", order=" + ctx.discovery().localNode().order() + + ", client=" + ctx.clientNode() + ']'); + + ctx.cache().context().exchange().dumpDebugInfo(); + } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(IgniteKernal.class, this); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java index aec08c6..5f17746 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java @@ -524,7 +524,21 @@ public class GridCacheContext<K, V> implements Externalizable { * @return {@code True} if entries should not be deleted from cache immediately. */ public boolean deferredDelete() { - return isDht() || isDhtAtomic() || isColocated() || (isNear() && atomic()); + GridCacheAdapter<K, V> cache = this.cache; + + if (cache == null) + throw new IllegalStateException("Cache stopped: " + cacheName); + + return deferredDelete(cache); + } + + /** + * @param cache Cache. + * @return {@code True} if entries should not be deleted from cache immediately. + */ + public boolean deferredDelete(GridCacheAdapter<?, ?> cache) { + return cache.isDht() || cache.isDhtAtomic() || cache.isColocated() || + (cache.isNear() && cache.configuration().getAtomicityMode() == ATOMIC); } /** @@ -765,26 +779,37 @@ public class GridCacheContext<K, V> implements Externalizable { * @return Partition topology. */ public GridDhtPartitionTopology topology() { - assert isNear() || isDht() || isColocated() || isDhtAtomic() : cache; + GridCacheAdapter<K, V> cache = this.cache; - return isNear() ? near().dht().topology() : dht().topology(); + if (cache == null) + throw new IllegalStateException("Cache stopped: " + cacheName); + + assert cache.isNear() || cache.isDht() || cache.isColocated() || cache.isDhtAtomic() : cache; + + return topology(cache); } /** * @return Topology version future. */ public GridDhtTopologyFuture topologyVersionFuture() { - assert isNear() || isDht() || isColocated() || isDhtAtomic() : cache; + GridCacheAdapter<K, V> cache = this.cache; - GridDhtTopologyFuture fut = null; + if (cache == null) + throw new IllegalStateException("Cache stopped: " + cacheName); - if (!isDhtAtomic()) { - GridDhtCacheAdapter<K, V> cache = isNear() ? near().dht() : colocated(); + assert cache.isNear() || cache.isDht() || cache.isColocated() || cache.isDhtAtomic() : cache; - fut = cache.multiUpdateTopologyFuture(); - } + return topology(cache).topologyVersionFuture(); + } - return fut == null ? topology().topologyVersionFuture() : fut; + /** + * @param cache Cache. + * @return Partition topology. + */ + private GridDhtPartitionTopology topology(GridCacheAdapter<K, V> cache) { + return cache.isNear() ? ((GridNearCacheAdapter<K, V>)cache).dht().topology() : + ((GridDhtCacheAdapter<K, V>)cache).topology(); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java index 36e108f..bfb23e8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java @@ -208,8 +208,12 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter { exchLog = cctx.logger(getClass().getName() + ".exchange"); pendingExplicit = GridConcurrentFactory.newMap(); + } - cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_FAILED, EVT_NODE_LEFT); + /** {@inheritDoc} */ + @Override protected void onKernalStart0(boolean reconnect) throws IgniteCheckedException { + if (!reconnect) + cctx.gridEvents().addLocalEventListener(discoLsnr, EVT_NODE_FAILED, EVT_NODE_LEFT); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java index 1f6a8bb..c26f5c3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java @@ -27,6 +27,7 @@ import org.apache.ignite.internal.managers.eventstorage.*; import org.apache.ignite.internal.processors.affinity.*; import org.apache.ignite.internal.processors.cache.distributed.dht.*; import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*; +import org.apache.ignite.internal.processors.cache.transactions.*; import org.apache.ignite.internal.processors.timeout.*; import org.apache.ignite.internal.util.*; import org.apache.ignite.internal.util.future.*; @@ -949,6 +950,58 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana } /** + * + */ + public void dumpDebugInfo() { + U.warn(log, "Ready affinity version: " + readyTopVer.get()); + + U.warn(log, "Last exchange future: " + lastInitializedFut); + + U.warn(log, "Pending exchange futures:"); + + for (GridDhtPartitionsExchangeFuture fut : pendingExchangeFuts) + U.warn(log, ">>> " + fut); + + U.warn(log, "Last 10 exchange futures (total: " + exchFuts.size() + "):"); + + int cnt = 0; + + for (GridDhtPartitionsExchangeFuture fut : exchFuts) { + U.warn(log, ">>> " + fut); + + if (++cnt == 10) + break; + } + + dumpPendingObjects(); + } + + /** + * + */ + public void dumpPendingObjects() { + U.warn(log, "Pending transactions:"); + + for (IgniteInternalTx tx : cctx.tm().activeTransactions()) + U.warn(log, ">>> " + tx); + + U.warn(log, "Pending explicit locks:"); + + for (GridCacheExplicitLockSpan lockSpan : cctx.mvcc().activeExplicitLocks()) + U.warn(log, ">>> " + lockSpan); + + U.warn(log, "Pending cache futures:"); + + for (GridCacheFuture<?> fut : cctx.mvcc().activeFutures()) + U.warn(log, ">>> " + fut); + + U.warn(log, "Pending atomic cache futures:"); + + for (GridCacheFuture<?> fut : cctx.mvcc().atomicFutures()) + U.warn(log, ">>> " + fut); + } + + /** * @param deque Deque to poll from. * @param time Time to wait. * @param w Worker. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java index 8a02ff2..57e3e33 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTopologyFuture.java @@ -17,9 +17,7 @@ package org.apache.ignite.internal.processors.cache.distributed.dht; -import org.apache.ignite.*; import org.apache.ignite.internal.*; -import org.apache.ignite.internal.managers.discovery.*; import org.apache.ignite.internal.processors.affinity.*; import org.apache.ignite.internal.processors.cache.*; @@ -33,18 +31,6 @@ import org.apache.ignite.internal.processors.cache.*; */ public interface GridDhtTopologyFuture extends IgniteInternalFuture<AffinityTopologyVersion> { /** - * Gets a topology snapshot for the topology version represented by the future. Note that by the time - * partition exchange completes some nodes from the snapshot may leave the grid. One should use discovery - * service to check if the node is valid. - * <p/> - * This method will block until the topology future is ready. - * - * @return Topology snapshot for particular topology version. - * @throws IgniteCheckedException If topology future failed. - */ - public GridDiscoveryTopologySnapshot topologySnapshot() throws IgniteCheckedException; - - /** * Gets topology version of this future. * * @return Topology version. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java index 96e6edc..0a21979 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java @@ -1159,7 +1159,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { // Enqueue if necessary after locks release. if (deleted != null) { assert !deleted.isEmpty(); - assert ctx.deferredDelete(); + assert ctx.deferredDelete(this) : this; for (IgniteBiTuple<GridDhtCacheEntry, GridCacheVersion> e : deleted) ctx.onDeferredDelete(e.get1(), e.get2()); @@ -2158,7 +2158,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { */ private void unlockEntries(Collection<GridDhtCacheEntry> locked, AffinityTopologyVersion topVer) { // Process deleted entries before locks release. - assert ctx.deferredDelete() : this; + assert ctx.deferredDelete(this) : this; // Entries to skip eviction manager notification for. // Enqueue entries while holding locks. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java index 751c9ba..4c8a161 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java @@ -338,6 +338,8 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object> /** {@inheritDoc} */ @Override public IgniteInternalFuture<Void> completeFuture(AffinityTopologyVersion topVer) { if (waitForPartitionExchange() && topologyVersion().compareTo(topVer) < 0) { + GridFutureAdapter<Void> fut = null; + synchronized (this) { if (this.topVer == AffinityTopologyVersion.ZERO) return null; @@ -346,9 +348,14 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object> if (topCompleteFut == null) topCompleteFut = new GridFutureAdapter<>(); - return topCompleteFut; + fut = topCompleteFut; } } + + if (fut != null && isDone()) + fut.onDone(); + + return fut; } return null; @@ -582,7 +589,7 @@ public class GridNearAtomicUpdateFuture extends GridFutureAdapter<Object> return; } - GridDhtTopologyFuture fut = cctx.topologyVersionFuture(); + GridDhtTopologyFuture fut = cache.topology().topologyVersionFuture(); if (fut.isDone()) { if (!fut.isCacheTopologyValid(cctx)) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java index 5701749..b3f19f6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java @@ -244,17 +244,6 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT } /** {@inheritDoc} */ - @Override public GridDiscoveryTopologySnapshot topologySnapshot() throws IgniteCheckedException { - get(); - - if (topSnapshot.get() == null) - topSnapshot.compareAndSet(null, new GridDiscoveryTopologySnapshot(discoEvt.topologyVersion(), - discoEvt.topologyNodes())); - - return topSnapshot.get(); - } - - /** {@inheritDoc} */ @Override public AffinityTopologyVersion topologyVersion() { return exchId.topologyVersion(); } @@ -853,25 +842,7 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT U.warn(log, "Failed to wait for partition release future. Dumping pending objects that might be the cause: " + cctx.localNodeId()); - U.warn(log, "Pending transactions:"); - - for (IgniteInternalTx tx : cctx.tm().activeTransactions()) - U.warn(log, ">>> " + tx); - - U.warn(log, "Pending explicit locks:"); - - for (GridCacheExplicitLockSpan lockSpan : cctx.mvcc().activeExplicitLocks()) - U.warn(log, ">>> " + lockSpan); - - U.warn(log, "Pending cache futures:"); - - for (GridCacheFuture<?> fut : cctx.mvcc().activeFutures()) - U.warn(log, ">>> " + fut); - - U.warn(log, "Pending atomic cache futures:"); - - for (GridCacheFuture<?> fut : cctx.mvcc().atomicFutures()) - U.warn(log, ">>> " + fut); + cctx.exchange().dumpPendingObjects(); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/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/f0d24f6b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java index 282c7c8..3fc44c0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java @@ -51,6 +51,7 @@ public class IgniteCache150ClientsTest extends GridCommonAbstractTest { @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); + cfg.setLocalHost("127.0.0.1"); cfg.setNetworkTimeout(30_000); cfg.setConnectorConfiguration(null); cfg.setPeerClassLoadingEnabled(false); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/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/f0d24f6b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.java new file mode 100644 index 0000000..6b5d396 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheServerNodeConcurrentStart.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.distributed; + +import org.apache.ignite.configuration.*; +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.junits.common.*; + +import static org.apache.ignite.cache.CacheMode.*; +import static org.apache.ignite.cache.CacheRebalanceMode.*; + +/** + * + */ +public class IgniteCacheServerNodeConcurrentStart extends GridCommonAbstractTest { + /** */ + private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + /** */ + private static final int ITERATIONS = 2; + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinderCleanFrequency(getTestTimeout() * 2); + + CacheConfiguration ccfg1 = new CacheConfiguration(); + + ccfg1.setName("cache-1"); + ccfg1.setCacheMode(REPLICATED); + ccfg1.setRebalanceMode(SYNC); + + CacheConfiguration ccfg2 = new CacheConfiguration(); + + ccfg2.setName("cache-2"); + ccfg2.setCacheMode(PARTITIONED); + ccfg2.setRebalanceMode(SYNC); + ccfg2.setBackups(2); + + CacheConfiguration ccfg3 = new CacheConfiguration(); + + ccfg3.setName("cache-3"); + ccfg3.setCacheMode(PARTITIONED); + ccfg3.setRebalanceMode(SYNC); + ccfg3.setBackups(0); + + cfg.setCacheConfiguration(ccfg1, ccfg2, ccfg3); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected long getTestTimeout() { + return ITERATIONS * 3 * 60_000; + } + + /** + * @throws Exception If failed. + */ + public void testConcurrentStart() throws Exception { + for (int i = 0; i < ITERATIONS; i++) { + log.info("Iteration: " + i); + + long start = System.currentTimeMillis(); + + startGridsMultiThreaded(10, false); + + startGridsMultiThreaded(10, 10); + + awaitPartitionMapExchange(); + + stopAllGrids(); + + log.info("Iteration finished, time: " + (System.currentTimeMillis() - start) / 1000f); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java index 06a1523..9a55ccf 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java @@ -1577,6 +1577,11 @@ public abstract class GridAbstractTest extends TestCase { "Test has been timed out and will be interrupted (threads dump will be taken before interruption) [" + "test=" + getName() + ", timeout=" + getTestTimeout() + ']'); + List<Ignite> nodes = G.allGrids(); + + for (Ignite node : nodes) + ((IgniteKernal)node).dumpDebugInfo(); + // We dump threads to stdout, because we can loose logs in case // the build is cancelled on TeamCity. U.dumpThreads(null); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f0d24f6b/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/f0d24f6b/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/f0d24f6b/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; + } +}