You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/07/29 14:12:05 UTC
[1/4] ignite git commit: Print debug information on 'waitForRent'
timeout.
Repository: ignite
Updated Branches:
refs/heads/ignite-3547 3691079d2 -> 53d509018
Print debug information on 'waitForRent' timeout.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7cf26d96
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7cf26d96
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7cf26d96
Branch: refs/heads/ignite-3547
Commit: 7cf26d9601f25b96198172f1c8140a0a34687814
Parents: a39770a
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jul 26 15:48:36 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jul 26 15:48:36 2016 +0300
----------------------------------------------------------------------
.../distributed/dht/GridDhtLocalPartition.java | 2 +-
.../dht/GridDhtPartitionTopologyImpl.java | 36 +++++++++++++++++++-
2 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7cf26d96/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 2c33fa2..6ea6159 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -507,7 +507,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
/**
* @return {@code true} If there is a group reservation.
*/
- private boolean groupReserved() {
+ public boolean groupReserved() {
for (GridDhtPartitionsReservation reservation : reservations) {
if (!reservation.invalidate())
return true; // Failed to invalidate reservation -> we are reserved.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7cf26d96/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 501388c..f9344bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -32,8 +32,10 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.DiscoveryEvent;
+import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -51,6 +53,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT;
import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST;
import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.EVICTED;
import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.MOVING;
@@ -171,6 +174,11 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
private boolean waitForRent() throws IgniteCheckedException {
boolean changed = false;
+ final long longOpDumpTimeout =
+ IgniteSystemProperties.getLong(IgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, 60_000);
+
+ int dumpCnt = 0;
+
// Synchronously wait for all renting partitions to complete.
for (Iterator<GridDhtLocalPartition> it = locParts.values().iterator(); it.hasNext();) {
GridDhtLocalPartition p = it.next();
@@ -182,7 +190,33 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
log.debug("Waiting for renting partition: " + p);
// Wait for partition to empty out.
- p.rent(true).get();
+ if (longOpDumpTimeout > 0) {
+ while (true) {
+ try {
+ p.rent(true).get(longOpDumpTimeout);
+
+ break;
+ }
+ catch (IgniteFutureTimeoutCheckedException e) {
+ if (dumpCnt++ < GridDhtPartitionsExchangeFuture.DUMP_PENDING_OBJECTS_THRESHOLD) {
+ U.warn(log, "Failed to wait for partition eviction [" +
+ "topVer=" + topVer +
+ ", cache=" + cctx.name() +
+ ", part=" + p.id() +
+ ", partState=" + p.state() +
+ ", size=" + p.size() +
+ ", reservations=" + p.reservations() +
+ ", grpReservations=" + p.groupReserved() +
+ ", node=" + cctx.localNodeId() + "]");
+
+ if (IgniteSystemProperties.getBoolean(IGNITE_THREAD_DUMP_ON_EXCHANGE_TIMEOUT, false))
+ U.dumpThreads(log);
+ }
+ }
+ }
+ }
+ else
+ p.rent(true).get();
if (log.isDebugEnabled())
log.debug("Finished waiting for renting partition: " + p);
[3/4] ignite git commit: Merge remote-tracking branch
'remotes/community/ignite-1.5.31' into ignite-3547
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/community/ignite-1.5.31' into ignite-3547
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e8f81045
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e8f81045
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e8f81045
Branch: refs/heads/ignite-3547
Commit: e8f810454ea4e4adf05f0e08ac87ac9f526da8f2
Parents: f53d26b 7cf26d9
Author: sboikov <sb...@gridgain.com>
Authored: Fri Jul 29 15:02:45 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Jul 29 15:02:45 2016 +0300
----------------------------------------------------------------------
.../distributed/dht/GridDhtLocalPartition.java | 2 +-
.../dht/GridDhtPartitionTopologyImpl.java | 36 +++++++++++++++++++-
2 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
[4/4] ignite git commit: ignite-3547
Posted by sb...@apache.org.
ignite-3547
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/53d50901
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/53d50901
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/53d50901
Branch: refs/heads/ignite-3547
Commit: 53d5090187639177e9e483de4a4a40bd4d99e62e
Parents: e8f8104
Author: sboikov <sb...@gridgain.com>
Authored: Fri Jul 29 15:09:34 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Jul 29 16:27:58 2016 +0300
----------------------------------------------------------------------
.../communication/tcp/TcpCommunicationSpi.java | 43 +++++----
.../IgniteCacheConnectionRecoveryTest.java | 92 ++++++++++++++++----
2 files changed, 93 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/53d50901/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 7c7da6c..f847bd1 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -353,6 +353,15 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
UUID id = ses.meta(NODE_ID_META);
if (id != null) {
+ GridCommunicationClient client = clients.get(id);
+
+ if (client instanceof GridTcpNioCommunicationClient &&
+ ((GridTcpNioCommunicationClient) client).session() == ses) {
+ client.close();
+
+ clients.remove(id, client);
+ }
+
if (!stopping) {
boolean reconnect = false;
@@ -372,9 +381,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
recoveryData.onNodeLeft();
}
- DisconnectedSessionInfo disconnectData = new DisconnectedSessionInfo(id,
- ses,
- recoveryData,
+ DisconnectedSessionInfo disconnectData = new DisconnectedSessionInfo(recoveryData,
reconnect);
commWorker.addProcessDisconnectRequest(disconnectData);
@@ -1400,6 +1407,14 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
.append(']').append(U.nl());
}
+ sb.append("Communication SPI clients: ").append(U.nl());
+
+ for (Map.Entry<UUID, GridCommunicationClient> entry : clients.entrySet()) {
+ sb.append(" [node=").append(entry.getKey())
+ .append(", client=").append(entry.getValue())
+ .append(']').append(U.nl());
+ }
+
U.warn(log, sb.toString());
}
@@ -3179,12 +3194,6 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
* @param sesInfo Disconnected session information.
*/
private void processDisconnect(DisconnectedSessionInfo sesInfo) {
- GridCommunicationClient client = clients.get(sesInfo.nodeId);
-
- if (client instanceof GridTcpNioCommunicationClient &&
- ((GridTcpNioCommunicationClient) client).session() == sesInfo.ses)
- clients.remove(sesInfo.nodeId, client);
-
if (sesInfo.reconnect) {
GridNioRecoveryDescriptor recoveryDesc = sesInfo.recoveryDesc;
@@ -3197,7 +3206,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
if (log.isDebugEnabled())
log.debug("Recovery reconnect [rmtNode=" + recoveryDesc.node().id() + ']');
- client = reserveClient(node);
+ GridCommunicationClient client = reserveClient(node);
client.release();
}
@@ -3748,29 +3757,17 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
*/
private static class DisconnectedSessionInfo {
/** */
- private final UUID nodeId;
-
- /** */
- private final GridNioSession ses;
-
- /** */
private final GridNioRecoveryDescriptor recoveryDesc;
/** */
private final boolean reconnect;
/**
- * @param nodeId Node ID.
- * @param ses Session.
* @param recoveryDesc Recovery descriptor.
* @param reconnect Reconnect flag.
*/
- public DisconnectedSessionInfo(UUID nodeId,
- GridNioSession ses,
- @Nullable GridNioRecoveryDescriptor recoveryDesc,
+ DisconnectedSessionInfo(@Nullable GridNioRecoveryDescriptor recoveryDesc,
boolean reconnect) {
- this.nodeId = nodeId;
- this.ses = ses;
this.recoveryDesc = recoveryDesc;
this.reconnect = reconnect;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/53d50901/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
index 826b0e7..4a07674 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
@@ -17,16 +17,21 @@
package org.apache.ignite.internal.processors.cache.distributed;
-import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import java.util.concurrent.Callable;
+import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
@@ -51,6 +56,12 @@ public class IgniteCacheConnectionRecoveryTest extends GridCommonAbstractTest {
/** */
private boolean client;
+ /** */
+ private static final int SRVS = 5;
+
+ /** */
+ private static final int CLIENTS = 5;
+
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -59,6 +70,10 @@ public class IgniteCacheConnectionRecoveryTest extends GridCommonAbstractTest {
cfg.setClientMode(client);
+ cfg.setCacheConfiguration(
+ cacheConfiguration("cache1", TRANSACTIONAL),
+ cacheConfiguration("cache2", ATOMIC));
+
return cfg;
}
@@ -66,11 +81,11 @@ public class IgniteCacheConnectionRecoveryTest extends GridCommonAbstractTest {
@Override protected void beforeTestsStarted() throws Exception {
super.beforeTestsStarted();
- startGridsMultiThreaded(5);
+ startGridsMultiThreaded(SRVS);
client = true;
- startGridsMultiThreaded(5, 5);
+ startGridsMultiThreaded(SRVS, CLIENTS);
}
/** {@inheritDoc} */
@@ -84,47 +99,86 @@ public class IgniteCacheConnectionRecoveryTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testConnectionRecovery() throws Exception {
- ignite(0).createCache(cacheConfiguration("cache1", TRANSACTIONAL));
- ignite(0).createCache(cacheConfiguration("cache2", ATOMIC));
-
- final Map<Integer, Integer> data = new HashMap<>();
+ final Map<Integer, Integer> data = new TreeMap<>();
for (int i = 0; i < 500; i++)
data.put(i, i);
final AtomicInteger idx = new AtomicInteger();
- final long stopTime = U.currentTimeMillis() + 10_000;
+ final long stopTime = U.currentTimeMillis() + 30_000;
+
+ final AtomicReference<CyclicBarrier> barrierRef = new AtomicReference<>();
+
+ final int TEST_THREADS = (CLIENTS + SRVS) * 2;
IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
- Ignite node = ignite(idx.incrementAndGet() % 10);
+ int idx0 = idx.getAndIncrement();
+ Ignite node = ignite(idx0 % (SRVS + CLIENTS));
+
+ Thread.currentThread().setName("test-thread-" + idx0 + "-" + node.name());
IgniteCache cache1 = node.cache("cache1").withAsync();
IgniteCache cache2 = node.cache("cache2").withAsync();
- int cnt = 0;
+ int iter = 0;
while (U.currentTimeMillis() < stopTime) {
- cache1.putAll(data);
- cache1.future().get(30, SECONDS);
+ try {
+ cache1.putAll(data);
+ cache1.future().get(15, SECONDS);
+
+ cache2.putAll(data);
+ cache2.future().get(15, SECONDS);
+ CyclicBarrier b = barrierRef.get();
- cache2.putAll(data);
- cache2.future().get(5, SECONDS);
+ if (b != null)
+ b.await(15, SECONDS);
+ }
+ catch (Exception e) {
+ synchronized (IgniteCacheConnectionRecoveryTest.class) {
+ log.error("Failed to execute update, will dump debug information" +
+ " [err=" + e+ ", iter=" + iter + ']', e);
- log.info("Iteration: " + cnt++);
+ List<Ignite> nodes = IgnitionEx.allGridsx();
+
+ for (Ignite node0 : nodes)
+ ((IgniteKernal)node0).dumpDebugInfo();
+
+ U.dumpThreads(log);
+ }
+
+ throw e;
+ }
}
return null;
}
- }, 30, "test-thread");
+ }, TEST_THREADS, "test-thread");
while (System.currentTimeMillis() < stopTime) {
- for (Ignite node : G.allGrids())
- IgniteCacheMessageRecoveryAbstractTest.closeSessions(node);
+ boolean closed = false;
+
+ for (Ignite node : G.allGrids()) {
+ if (IgniteCacheMessageRecoveryAbstractTest.closeSessions(node))
+ closed = true;
+ }
+
+ if (closed) {
+ CyclicBarrier b = new CyclicBarrier(TEST_THREADS + 1, new Runnable() {
+ @Override public void run() {
+ barrierRef.set(null);
+ }
+ });
+
+ barrierRef.set(b);
+
+ b.await();
+ }
- U.sleep(500);
+ U.sleep(50);
}
fut.get();
[2/4] ignite git commit: ignite-3547
Posted by sb...@apache.org.
ignite-3547
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f53d26b9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f53d26b9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f53d26b9
Branch: refs/heads/ignite-3547
Commit: f53d26b931bb99ccbaaeabff8f2544a34fee9d7c
Parents: 3691079
Author: sboikov <sb...@gridgain.com>
Authored: Fri Jul 29 15:02:30 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Jul 29 15:02:30 2016 +0300
----------------------------------------------------------------------
.../IgniteCacheConnectionRecoveryTest.java | 148 +++++++++++++++++++
.../IgniteCacheMessageRecoveryAbstractTest.java | 14 +-
2 files changed, 156 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f53d26b9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
new file mode 100644
index 0000000..826b0e7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheConnectionRecoveryTest.java
@@ -0,0 +1,148 @@
+/*
+ * 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 java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+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.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class IgniteCacheConnectionRecoveryTest extends GridCommonAbstractTest {
+ /** */
+ private static TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private boolean client;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+ cfg.setClientMode(client);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGridsMultiThreaded(5);
+
+ client = true;
+
+ startGridsMultiThreaded(5, 5);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testConnectionRecovery() throws Exception {
+ ignite(0).createCache(cacheConfiguration("cache1", TRANSACTIONAL));
+ ignite(0).createCache(cacheConfiguration("cache2", ATOMIC));
+
+ final Map<Integer, Integer> data = new HashMap<>();
+
+ for (int i = 0; i < 500; i++)
+ data.put(i, i);
+
+ final AtomicInteger idx = new AtomicInteger();
+
+ final long stopTime = U.currentTimeMillis() + 10_000;
+
+ IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ Ignite node = ignite(idx.incrementAndGet() % 10);
+
+ IgniteCache cache1 = node.cache("cache1").withAsync();
+ IgniteCache cache2 = node.cache("cache2").withAsync();
+
+ int cnt = 0;
+
+ while (U.currentTimeMillis() < stopTime) {
+ cache1.putAll(data);
+ cache1.future().get(30, SECONDS);
+
+
+ cache2.putAll(data);
+ cache2.future().get(5, SECONDS);
+
+ log.info("Iteration: " + cnt++);
+ }
+
+ return null;
+ }
+ }, 30, "test-thread");
+
+ while (System.currentTimeMillis() < stopTime) {
+ for (Ignite node : G.allGrids())
+ IgniteCacheMessageRecoveryAbstractTest.closeSessions(node);
+
+ U.sleep(500);
+ }
+
+ fut.get();
+ }
+
+ /**
+ * @param name Cache name.
+ * @param atomicityMode Cache atomicity mode.
+ * @return Configuration.
+ */
+ private CacheConfiguration cacheConfiguration(String name, CacheAtomicityMode atomicityMode) {
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setName(name);
+ ccfg.setAtomicityMode(atomicityMode);
+ ccfg.setCacheMode(REPLICATED);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ return ccfg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f53d26b9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java
index 16d7e5d..0460a8f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheMessageRecoveryAbstractTest.java
@@ -150,7 +150,11 @@ public abstract class IgniteCacheMessageRecoveryAbstractTest extends GridCommonA
for (int i = 0; i < 30; i++) {
Thread.sleep(1000);
- closed |= closeSessions();
+ Ignite node0 = ignite(ThreadLocalRandom.current().nextInt(0, GRID_CNT));
+
+ log.info("Close sessions for: " + ignite.name());
+
+ closed |= closeSessions(node0);
}
assertTrue(closed);
@@ -163,13 +167,11 @@ public abstract class IgniteCacheMessageRecoveryAbstractTest extends GridCommonA
}
/**
+ * @param ignite Node.
* @throws Exception If failed.
+ * @return {@code True} if closed at least one session.
*/
- private boolean closeSessions() throws Exception {
- Ignite ignite = ignite(ThreadLocalRandom.current().nextInt(0, GRID_CNT));
-
- log.info("Close sessions for: " + ignite.name());
-
+ static boolean closeSessions(Ignite ignite) throws Exception {
TcpCommunicationSpi commSpi = (TcpCommunicationSpi)ignite.configuration().getCommunicationSpi();
Map<UUID, GridCommunicationClient> clients = U.field(commSpi, "clients");