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/02 15:23:03 UTC

incubator-ignite git commit: # ignite-648: fix tx tests

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-648-failover a56152ce3 -> d0b8b0dd9


# ignite-648: fix tx 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/d0b8b0dd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d0b8b0dd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d0b8b0dd

Branch: refs/heads/ignite-648-failover
Commit: d0b8b0dd94f97aa7966afe060f3ba396894d1a67
Parents: a56152c
Author: ashutak <as...@gridgain.com>
Authored: Thu Jul 2 16:22:58 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Jul 2 16:22:58 2015 +0300

----------------------------------------------------------------------
 .../GridCacheAbstractFailoverSelfTest.java      | 68 ++++++++++++++++++--
 1 file changed, 63 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d0b8b0dd/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
index 3c74674..875459e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
@@ -27,10 +27,12 @@ import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.multijvm.*;
 import org.apache.ignite.transactions.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
+import java.util.*;
 import java.util.concurrent.atomic.*;
 
 import static org.apache.ignite.cache.CacheRebalanceMode.*;
@@ -270,13 +272,45 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac
      * @param isolation Isolation level.
      * @throws IgniteCheckedException If failed.
      */
-    private void put(Ignite ignite,
-        IgniteCache<String, Integer> cache,
+    private void put(final Ignite ignite,
+        final IgniteCache<String, Integer> cache,
         final int cnt,
-        TransactionConcurrency concurrency,
-        TransactionIsolation isolation)
+        final TransactionConcurrency concurrency,
+        final TransactionIsolation isolation)
         throws Exception
     {
+        if (!(ignite instanceof IgniteProcessProxy))
+            put0(ignite, cache, cnt, concurrency, isolation);
+        else {
+            IgniteProcessProxy proxy = (IgniteProcessProxy)ignite;
+
+            final UUID id = proxy.getId();
+
+            final String cacheName = cache.getName();
+
+            proxy.remoteCompute().run(new CAX() {
+                @Override public void applyx() throws IgniteCheckedException {
+                    Ignite ignite = Ignition.ignite(id);
+
+                    IgniteCache<String, Integer> cache = ignite.cache(cacheName);
+
+                    put0(ignite, cache, cnt, concurrency, isolation);
+                }
+            });
+        }
+    }
+
+    /**
+     * @param ignite Ignite.
+     * @param cache Cache.
+     * @param cnt Entry count.
+     * @param concurrency Concurrency control.
+     * @param isolation Isolation level.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void put0(Ignite ignite, IgniteCache<String, Integer> cache, final int cnt,
+        TransactionConcurrency concurrency,
+        TransactionIsolation isolation) throws IgniteCheckedException {
         try {
             info("Putting values to cache [0," + cnt + ')');
 
@@ -321,7 +355,31 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac
      * @throws IgniteCheckedException If failed.
      */
     private void remove(Ignite ignite, IgniteCache<String, Integer> cache, final int cnt,
-        TransactionConcurrency concurrency, TransactionIsolation isolation) throws Exception {
+        final TransactionConcurrency concurrency, final TransactionIsolation isolation) throws Exception {
+        if (!(ignite instanceof IgniteProcessProxy))
+            remove0(ignite, cache, cnt, concurrency, isolation);
+        else {
+            IgniteProcessProxy proxy = (IgniteProcessProxy)ignite;
+
+            final UUID id = proxy.getId();
+
+            final String cacheName = cache.getName();
+
+            proxy.remoteCompute().run(new CAX() {
+                @Override public void applyx() throws IgniteCheckedException {
+                    Ignite ignite = Ignition.ignite(id);
+
+                    IgniteCache<String, Integer> cache = ignite.cache(cacheName);
+
+                    remove0(ignite, cache, cnt, concurrency, isolation);
+                }
+            });
+        }
+    }
+
+    private void remove0(Ignite ignite, IgniteCache<String, Integer> cache, final int cnt,
+        TransactionConcurrency concurrency,
+        TransactionIsolation isolation) throws IgniteCheckedException {
         try {
             info("Removing values form cache [0," + cnt + ')');