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/07/08 15:18:20 UTC
[06/50] incubator-ignite git commit: # ignite-1055: self-review
# ignite-1055: self-review
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b38f04ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b38f04ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b38f04ff
Branch: refs/heads/ignite-648-failover
Commit: b38f04ff0ee347962c45e955bcec10641bb82e25
Parents: b23a829
Author: ashutak <as...@gridgain.com>
Authored: Fri Jul 3 19:47:48 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Jul 3 19:47:48 2015 +0300
----------------------------------------------------------------------
.../cache/GridCacheAbstractFullApiSelfTest.java | 203 ++++++-------------
...achePartitionedMultiNodeFullApiSelfTest.java | 57 ++----
.../testframework/junits/GridAbstractTest.java | 1 -
.../multijvm/IgniteCacheProcessProxy.java | 4 +
4 files changed, 86 insertions(+), 179 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b38f04ff/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 7db882c..65681dc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -36,7 +36,6 @@ import org.apache.ignite.lang.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.swapspace.inmemory.*;
import org.apache.ignite.testframework.*;
-import org.apache.ignite.testframework.junits.multijvm.*;
import org.apache.ignite.transactions.*;
import org.jetbrains.annotations.*;
@@ -289,35 +288,19 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
}
for (int i = 0; i < gridCount(); i++) {
- if (!isMultiJvmAndNodeIsRemote(i)) {
- GridCacheContext<String, Integer> ctx = context(i);
-
- int sum = 0;
-
- for (String key : map.keySet())
- if (ctx.affinity().localNode(key, new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
- sum++;
-
- assertEquals("Incorrect key size on cache #" + i, sum, jcache(i).localSize(ALL));
- }
- else {
- final int iCopy = i;
-
- ((IgniteProcessProxy)grid(i)).remoteCompute().run(new IgniteRunnable() {
- @Override public void run() {
- GridCacheContext<String, Integer> ctx = context(iCopy);
+ executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
+ @Override public void run(int idx) throws Exception {
+ GridCacheContext<String, Integer> ctx = context(idx);
- int sum = 0;
+ int sum = 0;
- for (String key : map.keySet())
- if (ctx.affinity().localNode(key,
- new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
- sum++;
+ for (String key : map.keySet())
+ if (ctx.affinity().localNode(key, new AffinityTopologyVersion(ctx.discovery().topologyVersion())))
+ sum++;
- assertEquals("Incorrect key size on cache #" + iCopy, sum, jcache(iCopy).localSize(ALL));
- }
- });
- }
+ assertEquals("Incorrect key size on cache #" + idx, sum, jcache(idx).localSize(ALL));
+ }
+ });
}
for (int i = 0; i < gridCount(); i++) {
@@ -2305,7 +2288,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
*/
public void testDeletedEntriesFlag() throws Exception {
if (cacheMode() != LOCAL && cacheMode() != REPLICATED && memoryMode() != OFFHEAP_TIERED) {
- int cnt = 3;
+ final int cnt = 3;
IgniteCache<String, Integer> cache = jcache();
@@ -2316,51 +2299,37 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
cache.remove(String.valueOf(i));
for (int g = 0; g < gridCount(); g++) {
- for (int i = 0; i < cnt; i++) {
- if (!isMultiJvmAndNodeIsRemote(g))
- checkDeletedEntriesFlag(g, i);
- else {
- IgniteProcessProxy proxy = (IgniteProcessProxy)grid(g);
+ executeOnLocalOrRemoteJvm(g, new TestIgniteIdxRunnable() {
+ @Override public void run(int idx) throws Exception {
+ for (int i = 0; i < cnt; i++) {
+ String key = String.valueOf(i);
+
+ GridCacheContext<String, Integer> cctx = context(idx);
- final int idx = g;
- final int key = i;
+ GridCacheEntryEx entry = cctx.isNear() ? cctx.near().dht().peekEx(key) :
+ cctx.cache().peekEx(key);
- proxy.remoteCompute().run(new GridAbsClosureX() {
- @Override public void applyx() throws IgniteCheckedException {
- checkDeletedEntriesFlag(idx, key);
+ if (grid(idx).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(idx).localNode())) {
+ assertNotNull(entry);
+ assertTrue(entry.deleted());
}
- });
+ else
+ assertNull(entry);
+ }
}
- }
+ });
}
}
}
/**
- * @param idx Grid index.
- * @param keyN Key.
- */
- private void checkDeletedEntriesFlag(int idx, int keyN) {
- String key = String.valueOf(keyN);
-
- GridCacheContext<String, Integer> cctx = context(idx);
-
- GridCacheEntryEx entry = cctx.isNear() ? cctx.near().dht().peekEx(key) :
- cctx.cache().peekEx(key);
-
- if (grid(idx).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(idx).localNode())) {
- assertNotNull(entry);
- assertTrue(entry.deleted());
- }
- else
- assertNull(entry);
- }
-
- /**
* @throws Exception If failed.
*/
public void testRemoveLoad() throws Exception {
- final int cnt = 10;
+ if (isMultiJvm())
+ fail("https://issues.apache.org/jira/browse/IGNITE-1088");
+
+ int cnt = 10;
Set<String> keys = new HashSet<>();
@@ -2376,15 +2345,13 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
grid(g).cache(null).localLoadCache(null);
for (int g = 0; g < gridCount(); g++) {
- if (!isMultiJvmAndNodeIsRemote(g)) {
- for (int i = 0; i < cnt; i++) {
- String key = String.valueOf(i);
+ for (int i = 0; i < cnt; i++) {
+ String key = String.valueOf(i);
- if (grid(0).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(g).localNode()))
- assertEquals((Integer)i, peek(jcache(g), key));
- else
- assertNull(peek(jcache(g), key));
- }
+ if (grid(0).affinity(null).mapKeyToPrimaryAndBackups(key).contains(grid(g).localNode()))
+ assertEquals((Integer)i, peek(jcache(g), key));
+ else
+ assertNull(peek(jcache(g), key));
}
}
}
@@ -3187,7 +3154,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @param oldEntry {@code True} to check TTL on old entry, {@code false} on new.
* @throws Exception If failed.
*/
- protected void checkTtl(boolean inTx, boolean oldEntry) throws Exception {
+ private void checkTtl(boolean inTx, boolean oldEntry) throws Exception {
if (isMultiJvm())
fail("https://issues.apache.org/jira/browse/IGNITE-1089");
@@ -3874,57 +3841,30 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
assertEquals(keys.size(), jcache().localSize(CachePeekMode.ALL));
else {
for (int i = 0; i < gridCount(); i++) {
- if (!isMultiJvmAndNodeIsRemote(i)) {
- GridCacheContext<String, Integer> ctx = context(i);
-
- if (ctx.cache().configuration().getMemoryMode() == OFFHEAP_TIERED)
- continue;
-
- int size = 0;
-
- for (String key : keys) {
- if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) {
- GridCacheEntryEx e =
- ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
-
- assert e != null : "Entry is null [idx=" + i + ", key=" + key + ", ctx=" + ctx + ']';
- assert !e.deleted() : "Entry is deleted: " + e;
-
- size++;
- }
- }
-
- assertEquals("Incorrect size on cache #" + i, size, jcache(i).localSize(ALL));
- }
- else {
- final int iCopy = i;
-
- ((IgniteProcessProxy)grid(i)).remoteCompute().run(new IgniteRunnable() {
- @Override public void run() {
- GridCacheContext<String, Integer> ctx = context(iCopy);
+ executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
+ @Override public void run(int idx) throws Exception {
+ GridCacheContext<String, Integer> ctx = context(idx);
- if (ctx.cache().configuration().getMemoryMode() == OFFHEAP_TIERED)
- return;
+ if (ctx.cache().configuration().getMemoryMode() == OFFHEAP_TIERED)
+ return;
- int size = 0;
+ int size = 0;
- for (String key : keys) {
- if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) {
- GridCacheEntryEx e =
- ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
+ for (String key : keys) {
+ if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx())) {
+ GridCacheEntryEx e =
+ ctx.isNear() ? ctx.near().dht().peekEx(key) : ctx.cache().peekEx(key);
- assert e != null : "Entry is null [idx=" + iCopy + ", key=" + key
- + ", ctx=" + ctx + ']';
- assert !e.deleted() : "Entry is deleted: " + e;
+ assert e != null : "Entry is null [idx=" + idx + ", key=" + key + ", ctx=" + ctx + ']';
+ assert !e.deleted() : "Entry is deleted: " + e;
- size++;
- }
+ size++;
}
-
- assertEquals("Incorrect size on cache #" + iCopy, size, jcache(iCopy).localSize(ALL));
}
- });
- }
+
+ assertEquals("Incorrect size on cache #" + idx, size, jcache(idx).localSize(ALL));
+ }
+ });
}
}
}
@@ -3939,34 +3879,19 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
keys.size(), jcache().localSize(ALL));
else {
for (int i = 0; i < gridCount(); i++) {
- if (!isMultiJvmAndNodeIsRemote(i)) {
- GridCacheContext<String, Integer> ctx = context(i);
-
- int size = 0;
-
- for (String key : keys)
- if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
- size++;
+ executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
+ @Override public void run(int idx) throws Exception {
+ GridCacheContext<String, Integer> ctx = context(idx);
- assertEquals("Incorrect key size on cache #" + i, size, jcache(i).localSize(ALL));
- }
- else {
- final int iCopy = i;
-
- ((IgniteProcessProxy)grid(i)).remoteCompute().run(new IgniteRunnable() {
- @Override public void run() {
- GridCacheContext<String, Integer> ctx = context(iCopy);
+ int size = 0;
- int size = 0;
+ for (String key : keys)
+ if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
+ size++;
- for (String key : keys)
- if (ctx.affinity().localNode(key, ctx.discovery().topologyVersionEx()))
- size++;
-
- assertEquals("Incorrect key size on cache #" + iCopy, size, jcache(iCopy).localSize(ALL));
- }
- });
- }
+ assertEquals("Incorrect key size on cache #" + idx, size, jcache(idx).localSize(ALL));
+ }
+ });
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b38f04ff/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
index df29a5a..a5e7a31 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
@@ -26,7 +26,6 @@ import org.apache.ignite.events.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.lang.*;
-import org.apache.ignite.testframework.junits.multijvm.*;
import java.util.*;
@@ -148,17 +147,20 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
}
for (int i = 0; i < gridCount(); i++) {
- if (!isMultiJvmAndNodeIsRemote(i))
- putDebugCheck0(i, size);
- else {
- final int iCopy = i;
-
- ((IgniteProcessProxy)grid(i)).remoteCompute().run(new IgniteRunnable() {
- @Override public void run() {
- putDebugCheck0(iCopy, size);
+ executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
+ @Override public void run(int idx) throws Exception {
+ assertEquals(0, context(idx).tm().idMapSize());
+
+ IgniteCache<Object, Object> cache = grid(idx).cache(null);
+ ClusterNode node = grid(idx).localNode();
+
+ for (int k = 0; k < size; k++) {
+ if (affinity(cache).isPrimaryOrBackup(node, k))
+ assertEquals("Check failed for node: " + node.id(), k,
+ cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
}
- });
- }
+ }
+ });
}
for (int i = 0; i < size; i++) {
@@ -174,23 +176,6 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
}
/**
- * @param gridIdx Grid index.
- * @param size Size.
- */
- private void putDebugCheck0(int gridIdx, int size) {
- assertEquals(0, context(gridIdx).tm().idMapSize());
-
- IgniteCache<Object, Object> cache = grid(gridIdx).cache(null);
- ClusterNode node = grid(gridIdx).localNode();
-
- for (int k = 0; k < size; k++) {
- if (affinity(cache).isPrimaryOrBackup(node, k))
- assertEquals("Check failed for node: " + node.id(), k,
- cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP));
- }
- }
-
- /**
* @throws Exception If failed.
*/
public void testUnswapShort() throws Exception {
@@ -257,17 +242,11 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
boolean nearEnabled = nearEnabled(c);
if (nearEnabled) {
- if (!isMultiJvmAndNodeIsRemote(i))
- assertTrue(((IgniteKernal)ignite(i)).internalCache().context().isNear());
- else {
- final int iCopy = i;
-
- ((IgniteProcessProxy)grid(i)).remoteCompute().run(new IgniteRunnable() {
- @Override public void run() {
- assertTrue(((IgniteKernal)ignite(iCopy)).internalCache().context().isNear());
- }
- });
- }
+ executeOnLocalOrRemoteJvm(i, new TestIgniteIdxRunnable() {
+ @Override public void run(int idx) throws Exception {
+ assertTrue(((IgniteKernal)ignite(idx)).internalCache().context().isNear());
+ }
+ });
}
Integer nearPeekVal = nearEnabled ? 1 : null;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b38f04ff/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 0f34149..3cdced7 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
@@ -803,7 +803,6 @@ public abstract class GridAbstractTest extends TestCase {
finally {
IgniteProcessProxy.killAll(); // In multi jvm case.
}
-
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b38f04ff/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 07ed950..b9b2d6a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -132,6 +132,10 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
throw new UnsupportedOperationException("Method should be supported.");
}
+ @Override public IgniteCache<K, V> withNoRetries() {
+ throw new UnsupportedOperationException("Method should be supported.");
+ }
+
/** {@inheritDoc} */
@Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws CacheException {
throw new UnsupportedOperationException("Method should be supported.");