You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2015/12/15 12:44:04 UTC

[07/16] ignite git commit: ignite-1.5 Minor test issue in 'testQueueRemoveMultithreadBounded': wait for stated threads

ignite-1.5 Minor test issue in 'testQueueRemoveMultithreadBounded': wait for stated threads


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

Branch: refs/heads/ignite-1.5.1
Commit: 25d3e445381d611a7a6c3afbb784ed88934374c2
Parents: 1100893
Author: sboikov <sb...@gridgain.com>
Authored: Tue Dec 15 09:51:03 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Dec 15 09:51:03 2015 +0300

----------------------------------------------------------------------
 .../GridCacheQueueApiSelfAbstractTest.java      | 86 +++++++++-----------
 1 file changed, 40 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/25d3e445/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java
index 6366f09..5dea3f5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java
@@ -29,6 +29,7 @@ import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteQueue;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.CollectionConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.testframework.GridTestUtils;
@@ -403,59 +404,59 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends IgniteCollection
 
         final CountDownLatch clearLatch = new CountDownLatch(THREAD_NUM);
 
-        for (int t = 0; t < THREAD_NUM; t++) {
-            Thread th = new Thread(new Runnable() {
-                @Override public void run() {
-                    if (log.isDebugEnabled())
-                        log.debug("Thread has been started." + Thread.currentThread().getName());
+        IgniteInternalFuture<?> offerFut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                if (log.isDebugEnabled())
+                    log.debug("Thread has been started." + Thread.currentThread().getName());
 
-                    try {
-                        // Thread must be blocked on put operation.
-                        for (int i = 0; i < (QUEUE_CAPACITY * THREAD_NUM); i++)
-                            queue.offer("anything", 3, TimeUnit.MINUTES);
+                try {
+                    // Thread must be blocked on put operation.
+                    for (int i = 0; i < (QUEUE_CAPACITY * THREAD_NUM); i++)
+                        queue.offer("anything", 3, TimeUnit.MINUTES);
 
-                        fail("Queue failed");
-                    }
-                    catch (IgniteException | IllegalStateException e) {
-                        putLatch.countDown();
+                    fail("Queue failed");
+                }
+                catch (IgniteException | IllegalStateException e) {
+                    putLatch.countDown();
 
-                        assert e.getMessage().contains("removed");
+                    assert e.getMessage().contains("removed");
 
-                        assert queue.removed();
-                    }
+                    assert queue.removed();
+                }
 
-                    if (log.isDebugEnabled())
-                        log.debug("Thread has been stopped." + Thread.currentThread().getName());
+                if (log.isDebugEnabled())
+                    log.debug("Thread has been stopped." + Thread.currentThread().getName());
 
-                }
-            });
-            th.start();
-        }
+                return null;
+            }
+        }, THREAD_NUM, "offer-thread");
 
-        for (int t = 0; t < THREAD_NUM; t++) {
-            Thread th = new Thread(new Runnable() {
-                @Override public void run() {
-                    try {
-                        IgniteQueue<String> queue = grid(0).queue(queueName, 0, null);
+        IgniteInternalFuture<?> closeFut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                try {
+                    IgniteQueue<String> queue = grid(0).queue(queueName, 0, null);
 
-                        if (queue != null)
-                            queue.close();
-                    }
-                    catch (Exception e) {
-                        fail("Unexpected exception: " + e);
-                    }
-                    finally {
-                        clearLatch.countDown();
-                    }
+                    if (queue != null)
+                        queue.close();
                 }
-            });
-            th.start();
-        }
+                catch (Exception e) {
+                    fail("Unexpected exception: " + e);
+                }
+                finally {
+                    clearLatch.countDown();
+                }
+
+                return null;
+            }
+        }, THREAD_NUM, "close-thread");
 
         assert putLatch.await(3, TimeUnit.MINUTES);
 
         assert clearLatch.await(3, TimeUnit.MINUTES);
 
+        offerFut.get();
+        closeFut.get();
+
         try {
             assert queue.isEmpty() : queue.size();
 
@@ -617,13 +618,6 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends IgniteCollection
             this.s = s;
         }
 
-        /**
-         * @return Priority.
-         */
-        String data() {
-            return s;
-        }
-
         /** {@inheritDoc} */
         @Override public int hashCode() {
             return 0;