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 2015/09/02 14:10:16 UTC
ignite git commit: Added test,
more debug info for GridDhtTxPrepareFuture.
Repository: ignite
Updated Branches:
refs/heads/ignite-1.4 ba4a582ce -> 3aa9ea363
Added test, more debug info for GridDhtTxPrepareFuture.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3aa9ea36
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3aa9ea36
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3aa9ea36
Branch: refs/heads/ignite-1.4
Commit: 3aa9ea36354c76fa9bf958bdbf17b26951696ea9
Parents: ba4a582
Author: sboikov <sb...@gridgain.com>
Authored: Wed Sep 2 15:10:04 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Sep 2 15:10:04 2015 +0300
----------------------------------------------------------------------
.../distributed/dht/GridDhtTxPrepareFuture.java | 15 ++++-
.../CachePutAllFailoverAbstractTest.java | 60 +++++++++++++++++---
.../CachePutAllFailoverAtomicTest.java | 30 ++++++++++
.../IgniteCacheFailoverTestSuite2.java | 2 +
4 files changed, 99 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3aa9ea36/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index b5211ee..f1771d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -64,6 +64,7 @@ import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.CIX1;
import org.apache.ignite.internal.util.typedef.F;
@@ -174,6 +175,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
private Collection<IgniteTxKey> filterFailedKeys;
/** Keys that should be locked. */
+ @GridToStringInclude
private GridConcurrentHashSet<IgniteTxKey> lockKeys = new GridConcurrentHashSet<>();
/** Force keys future for correct transforms. */
@@ -1249,7 +1251,18 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(GridDhtTxPrepareFuture.class, this, "xid", tx.xidVersion(), "super", super.toString());
+ Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() {
+ @Override public String apply(IgniteInternalFuture<?> f) {
+ return "[node=" + ((MiniFuture)f).node().id() +
+ ", loc=" + ((MiniFuture)f).node().isLocal() +
+ ", done=" + f.isDone() + "]";
+ }
+ });
+
+ return S.toString(GridDhtTxPrepareFuture.class, this,
+ "xid", tx.xidVersion(),
+ "innerFuts", futs,
+ "super", super.toString());
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/3aa9ea36/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
index ea81680..62fddda 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAbstractTest.java
@@ -25,10 +25,13 @@ import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.cache.GridCacheAbstractSelfTest;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.NotNull;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.TreeMap;
import java.util.concurrent.Callable;
import java.util.concurrent.ThreadLocalRandom;
@@ -44,7 +47,7 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS
private static final int NODE_CNT = 2;
/** */
- private static final long TEST_TIME = 2 * 60_000;
+ private static final long TEST_TIME = 60_000;
/** {@inheritDoc} */
@Override protected int gridCount() {
@@ -82,6 +85,21 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS
* @throws Exception If failed.
*/
public void testPutAllFailover() throws Exception {
+ testPutAllFailover(false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutAllFailoverAsync() throws Exception {
+ testPutAllFailover(true);
+ }
+
+ /**
+ * @param async If {@code true} tests asynchronous operation.
+ * @throws Exception If failed.
+ */
+ private void testPutAllFailover(final boolean async) throws Exception {
final AtomicBoolean finished = new AtomicBoolean();
final long endTime = System.currentTimeMillis() + TEST_TIME;
@@ -103,7 +121,9 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS
});
try {
- final IgniteCache<TestKey, TestValue> cache = ignite(0).cache(null);
+ IgniteCache<TestKey, TestValue> cache0 = ignite(0).cache(null);
+
+ final IgniteCache<TestKey, TestValue> cache = async ? cache0.withAsync() : cache0;
GridTestUtils.runMultiThreaded(new Callable<Object>() {
@Override public Object call() throws Exception {
@@ -116,15 +136,41 @@ public abstract class CachePutAllFailoverAbstractTest extends GridCacheAbstractS
long lastInfo = 0;
while ((time = System.currentTimeMillis()) < endTime) {
- if (time - lastInfo > 5000)
+ if (time - lastInfo > 5000) {
log.info("Do putAll [iter=" + iter + ']');
- TreeMap<TestKey, TestValue> map = new TreeMap<>();
+ lastInfo = time;
+ }
+
+ if (async) {
+ Collection<IgniteFuture<?>> futs = new ArrayList<>();
+
+ for (int i = 0 ; i < 10; i++) {
+ TreeMap<TestKey, TestValue> map = new TreeMap<>();
+
+ for (int k = 0; k < 100; k++)
+ map.put(new TestKey(rnd.nextInt(200)), new TestValue(iter));
+
+ cache.putAll(map);
+
+ IgniteFuture<?> fut = cache.future();
+
+ assertNotNull(fut);
+
+ futs.add(fut);
+ }
+
+ for (IgniteFuture<?> fut : futs)
+ fut.get();
+ }
+ else {
+ TreeMap<TestKey, TestValue> map = new TreeMap<>();
- for (int k = 0; k < 100; k++)
- map.put(new TestKey(rnd.nextInt(200)), new TestValue(iter));
+ for (int k = 0; k < 100; k++)
+ map.put(new TestKey(rnd.nextInt(200)), new TestValue(iter));
- cache.putAll(map);
+ cache.putAll(map);
+ }
iter++;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3aa9ea36/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAtomicTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAtomicTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAtomicTest.java
new file mode 100644
index 0000000..351633f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CachePutAllFailoverAtomicTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.CacheAtomicityMode;
+
+/**
+ *
+ */
+public class CachePutAllFailoverAtomicTest extends CachePutAllFailoverAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicityMode() {
+ return CacheAtomicityMode.ATOMIC;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/3aa9ea36/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
index a8b2d65..20cc6b6 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
@@ -21,6 +21,7 @@ import junit.framework.TestSuite;
import org.apache.ignite.internal.processors.cache.CacheGetFromJobTest;
import org.apache.ignite.internal.processors.cache.distributed.CacheAsyncOperationsFailoverAtomicTest;
import org.apache.ignite.internal.processors.cache.distributed.CacheAsyncOperationsFailoverTxTest;
+import org.apache.ignite.internal.processors.cache.distributed.CachePutAllFailoverAtomicTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedFailoverSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheCrossCacheTxFailoverTest;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicFailoverSelfTest;
@@ -56,6 +57,7 @@ public class IgniteCacheFailoverTestSuite2 {
suite.addTestSuite(CacheAsyncOperationsFailoverAtomicTest.class);
suite.addTestSuite(CacheAsyncOperationsFailoverTxTest.class);
+ suite.addTestSuite(CachePutAllFailoverAtomicTest.class);
return suite;
}