ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-1607
Date Fri, 30 Oct 2015 12:32:30 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1607 14564ff12 -> 0b92a36be


ignite-1607


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0b92a36b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0b92a36b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0b92a36b

Branch: refs/heads/ignite-1607
Commit: 0b92a36beadf2aa847c616736e3d1c370f137a43
Parents: 14564ff
Author: sboikov <sboikov@gridgain.com>
Authored: Fri Oct 30 15:32:16 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Fri Oct 30 15:32:16 2015 +0300

----------------------------------------------------------------------
 .../CacheSerializableTransactionsTest.java      | 126 ++++++-------------
 1 file changed, 35 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0b92a36b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
index 958a9f6..ae64bb4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
@@ -2979,25 +2979,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest
{
                     caches.add(client.<Integer, Integer>cache(cacheName));
             }
 
-            IgniteInternalFuture<?> restartFut = null;
-
-            if (restart) {
-                restartFut = GridTestUtils.runAsync(new Callable<Object>() {
-                    @Override public Object call() throws Exception {
-                        while (!stop.get()) {
-                            stopGrid(0);
-
-                            U.sleep(300);
-
-                            Ignite ignite = startGrid(0);
-
-                            assertFalse(ignite.configuration().isClientMode());
-                        }
-
-                        return null;
-                    }
-                });
-            }
+            IgniteInternalFuture<?> restartFut = restart ? restartFuture(stop, null)
: null;
 
             for (int i = 0; i < 30; i++) {
                 final AtomicInteger cntr = new AtomicInteger();
@@ -3102,25 +3084,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest
{
                     caches.add(client.<Integer, Integer>cache(cacheName));
             }
 
-            IgniteInternalFuture<?> restartFut = null;
-
-            if (restart) {
-                restartFut = GridTestUtils.runAsync(new Callable<Object>() {
-                    @Override public Object call() throws Exception {
-                        while (!stop.get()) {
-                            stopGrid(0);
-
-                            U.sleep(300);
-
-                            Ignite ignite = startGrid(0);
-
-                            assertFalse(ignite.configuration().isClientMode());
-                        }
-
-                        return null;
-                    }
-                });
-            }
+            IgniteInternalFuture<?> restartFut = restart ? restartFuture(stop, null)
: null;
 
             for (int i = 0; i < 20; i += 2) {
                 final AtomicInteger cntr = new AtomicInteger();
@@ -3568,25 +3532,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest
{
                 }
             }, THREADS, "tx-thread");
 
-            IgniteInternalFuture<?> restartFut = null;
-
-            if (restart) {
-                restartFut = GridTestUtils.runAsync(new Callable<Object>() {
-                    @Override public Object call() throws Exception {
-                        while (!fut.isDone()) {
-                            stopGrid(0);
-
-                            U.sleep(300);
-
-                            Ignite ignite = startGrid(0);
-
-                            assertFalse(ignite.configuration().isClientMode());
-                        }
-
-                        return null;
-                    }
-                });
-            }
+            IgniteInternalFuture<?> restartFut = restart ? restartFuture(null, fut)
: null;
 
             fut.get(testTime + 30_000);
 
@@ -3705,21 +3651,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest
{
                 cacheNames.add(ccfg.getName());
             }
 
-            IgniteInternalFuture<?> restartFut = GridTestUtils.runAsync(new Callable<Object>()
{
-                @Override public Object call() throws Exception {
-                    while (!finished.get()) {
-                        stopGrid(0);
-
-                        U.sleep(300);
-
-                        Ignite ignite = startGrid(0);
-
-                        assertFalse(ignite.configuration().isClientMode());
-                    }
-
-                    return null;
-                }
-            });
+            IgniteInternalFuture<?> restartFut = restartFuture(finished, null);
 
             List<IgniteInternalFuture<?>> futs = new ArrayList<>();
 
@@ -3932,27 +3864,9 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest
{
 
             final AtomicBoolean finished = new AtomicBoolean();
 
-            IgniteInternalFuture<Object> fut = null;
+            IgniteInternalFuture<?> fut = restart ? restartFuture(finished, null) :
null;
 
             try {
-                if (restart) {
-                    fut = GridTestUtils.runAsync(new Callable<Object>() {
-                        @Override public Object call() throws Exception {
-                            while (!finished.get()) {
-                                stopGrid(0);
-
-                                U.sleep(300);
-
-                                Ignite ignite = startGrid(0);
-
-                                assertFalse(ignite.configuration().isClientMode());
-                            }
-
-                            return null;
-                        }
-                    });
-                }
-
                 for (int i = 0; i < 10; i++) {
                     log.info("Iteration: " + i);
 
@@ -4371,6 +4285,36 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest
{
     }
 
     /**
+     * @param stop Stop flag.
+     * @param fut Future.
+     * @return Restart thread future.
+     */
+    private IgniteInternalFuture<?> restartFuture(final AtomicBoolean stop, final IgniteInternalFuture<?>
fut) {
+        return GridTestUtils.runAsync(new Callable<Object>() {
+            private boolean stop() {
+                if (stop != null)
+                    return stop.get();
+
+                return fut.isDone();
+            }
+
+            @Override public Object call() throws Exception {
+                while (!stop()) {
+                    Ignite ignite = startGrid(SRVS + CLIENTS);
+
+                    assertFalse(ignite.configuration().isClientMode());
+
+                    U.sleep(300);
+
+                    stopGrid(SRVS + CLIENTS);
+                }
+
+                return null;
+            }
+        }, "restart-thread");
+    }
+
+    /**
      *
      */
     private static class TestStoreFactory implements Factory<CacheStore<Integer, Integer>>
{


Mime
View raw message