ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [31/50] [abbrv] ignite git commit: ignite-4176 IgniteQueue not functioning as expected after remove()
Date Thu, 17 Nov 2016 10:51:54 GMT
ignite-4176 IgniteQueue not functioning as expected after remove()


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

Branch: refs/heads/ignite-2693
Commit: 51e96d614de1588843ef4374cbbb91c426297c3e
Parents: 703957d
Author: Amir Akhmedov <amir.akhmedov@gmail.com>
Authored: Wed Nov 9 13:07:13 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Wed Nov 9 13:07:13 2016 +0300

----------------------------------------------------------------------
 .../datastructures/GridCacheQueueAdapter.java   |  2 +-
 .../GridCacheQueueApiSelfAbstractTest.java      | 66 ++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/51e96d61/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
index caf3ba3..6e087e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheQueueAdapter.java
@@ -834,7 +834,7 @@ public abstract class GridCacheQueueAdapter<T> extends AbstractCollection<T>
imp
                 return hdr.head();
             }
 
-            long next = hdr.head() + 1;
+            long next = hdr.head();
 
             rmvdIdxs = new HashSet<>(rmvdIdxs);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/51e96d61/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 f9499a1..93d0989 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
@@ -534,6 +534,72 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends IgniteCollection
     }
 
     /**
+     * JUnit.
+     *
+     * @throws Exception If failed.
+     */
+    public void testPutRemovePeekPollUnbounded() throws Exception {
+        // Random queue name.
+        String queueName = UUID.randomUUID().toString();
+
+        IgniteQueue<String> queue = grid(0).queue(queueName, 0, config(false));
+
+        for (int i = 0; i < QUEUE_CAPACITY; i++)
+            queue.put("Item-" + i);
+
+        assertEquals(QUEUE_CAPACITY, queue.size());
+
+        queue.remove("Item-1");
+
+        assertEquals(QUEUE_CAPACITY - 1, queue.size());
+
+        assertEquals("Item-0", queue.peek());
+        assertEquals("Item-0", queue.poll());
+        assertEquals("Item-2", queue.poll());
+
+        assertEquals(0, queue.size());
+
+        queue.clear();
+
+        assertTrue(queue.isEmpty());
+    }
+
+    /**
+     * JUnit.
+     *
+     * @throws Exception If failed.
+     */
+    public void testRemovePeek() throws Exception {
+        // Random queue name.
+        String queueName = UUID.randomUUID().toString();
+
+        IgniteQueue<String> queue = grid(0).queue(queueName, 0, config(false));
+
+        for (int i = 0; i < 5; i++)
+            queue.put("Item-" + i);
+
+        queue.remove("Item-1");
+
+        assertEquals("Item-0", queue.peek());
+
+        queue.remove("Item-2");
+
+        assertEquals("Item-0", queue.peek());
+
+        queue.remove("Item-0");
+
+        assertEquals("Item-3", queue.peek());
+
+        queue.remove("Item-4");
+
+        assertEquals("Item-3", queue.peek());
+
+        queue.remove("Item-3");
+
+        assertNull(queue.peek());
+    }
+
+    /**
      * @throws Exception If failed.
      */
     public void testReuseCache() throws Exception {


Mime
View raw message