You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2017/08/23 08:48:53 UTC

[1/3] camel git commit: CAMEL-11694 - Camel-Hazelcast: Add more operation to queue - Take operation

Repository: camel
Updated Branches:
  refs/heads/master 4848bc6a9 -> efd7d3750


CAMEL-11694 - Camel-Hazelcast: Add more operation to queue - Take operation


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/04a8a844
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/04a8a844
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/04a8a844

Branch: refs/heads/master
Commit: 04a8a8448c9052d49d8bb423b29ade8f9a8a1c31
Parents: 4848bc6
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed Aug 23 10:26:44 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Aug 23 10:26:44 2017 +0200

----------------------------------------------------------------------
 .../camel/component/hazelcast/HazelcastOperation.java       | 2 ++
 .../component/hazelcast/queue/HazelcastQueueProducer.java   | 8 ++++++++
 .../component/hazelcast/HazelcastQueueProducerTest.java     | 9 +++++++++
 3 files changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/04a8a844/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastOperation.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastOperation.java
index 9a49ccf..bb33b9d 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastOperation.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastOperation.java
@@ -56,6 +56,8 @@ public enum HazelcastOperation {
     REMAINING_CAPACITY("remainingCapacity"),
     DRAIN_TO("drainTo"),
     REMOVE_IF("removeIf"),
+    TAKE("take"),
+    
 
     // topic
     PUBLISH("publish"),

http://git-wip-us.apache.org/repos/asf/camel/blob/04a8a844/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java
index 2cc71b9..b8350d3 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java
@@ -96,6 +96,10 @@ public class HazelcastQueueProducer extends HazelcastDefaultProducer {
         case DRAIN_TO:
             this.drainTo((Collection) drainToCollection, exchange);
             break;
+            
+        case TAKE:
+            this.take(exchange);
+            break;
 
         default:
             throw new IllegalArgumentException(String.format("The value '%s' is not allowed for parameter '%s' on the QUEUE cache.", operation, HazelcastConstants.OPERATION));
@@ -156,4 +160,8 @@ public class HazelcastQueueProducer extends HazelcastDefaultProducer {
         Predicate filter = exchange.getIn().getBody(Predicate.class);
         exchange.getOut().setBody(this.queue.removeIf(filter));
     }
+    
+    private void take(Exchange exchange) throws InterruptedException {
+        exchange.getOut().setBody(this.queue.take());
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/04a8a844/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastQueueProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastQueueProducerTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastQueueProducerTest.java
index a098bf8..b88aa18 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastQueueProducerTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastQueueProducerTest.java
@@ -147,6 +147,12 @@ public class HazelcastQueueProducerTest extends HazelcastCamelTestSupport {
     }
     
     @Test
+    public void take() throws InterruptedException {
+        template.sendBody("direct:take", "foo");
+        verify(queue).take();
+    }
+    
+    @Test
     public void drainTo() throws InterruptedException {
         Map<String, Object> headers = new HashMap<String, Object>();
         Collection l = new ArrayList<>();
@@ -188,6 +194,9 @@ public class HazelcastQueueProducerTest extends HazelcastCamelTestSupport {
                 from("direct:REMAINING_CAPACITY").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.REMAINING_CAPACITY)).to(
                         String.format("hazelcast-%sbar", HazelcastConstants.QUEUE_PREFIX));
                 
+                from("direct:take").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.TAKE)).to(
+                        String.format("hazelcast-%sbar", HazelcastConstants.QUEUE_PREFIX));
+                
                 from("direct:drainTo").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DRAIN_TO)).to(
                         String.format("hazelcast-%sbar", HazelcastConstants.QUEUE_PREFIX));
                 


[3/3] camel git commit: CAMEL-11694 - Camel-Hazelcast: Add more operation to queue - Docs updated

Posted by ac...@apache.org.
CAMEL-11694 - Camel-Hazelcast: Add more operation to queue - Docs updated


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

Branch: refs/heads/master
Commit: efd7d3750d20f4a5a0e9c6054ca0995454c69170
Parents: a9f4c55
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed Aug 23 10:37:29 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Aug 23 10:37:29 2017 +0200

----------------------------------------------------------------------
 .../src/main/docs/hazelcast-queue-component.adoc  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/efd7d375/components/camel-hazelcast/src/main/docs/hazelcast-queue-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/docs/hazelcast-queue-component.adoc b/components/camel-hazelcast/src/main/docs/hazelcast-queue-component.adoc
index 3389551..20a3bb4 100644
--- a/components/camel-hazelcast/src/main/docs/hazelcast-queue-component.adoc
+++ b/components/camel-hazelcast/src/main/docs/hazelcast-queue-component.adoc
@@ -70,6 +70,8 @@ The queue producer provides 10 operations:
 * remove all
 * remove if
 * drain to
+* take
+* retain all
 
 #### Sample for *add*:
 
@@ -157,6 +159,22 @@ from("direct:drainTo").setHeader(HazelcastConstants.OPERATION, constant(Hazelcas
 String.format("hazelcast-%sbar", HazelcastConstants.QUEUE_PREFIX));
 --------------------------------------------------------------------------------------------
 
+#### Sample for *take*:
+
+[source,java]
+--------------------------------------------------------------------------------------------
+from("direct:take").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.TAKE)).to(
+String.format("hazelcast-%sbar", HazelcastConstants.QUEUE_PREFIX));
+--------------------------------------------------------------------------------------------
+
+#### Sample for *retain all*:
+
+[source,java]
+--------------------------------------------------------------------------------------------
+from("direct:retainAll").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.RETAIN_ALL)).to(
+String.format("hazelcast-%sbar", HazelcastConstants.QUEUE_PREFIX));
+--------------------------------------------------------------------------------------------
+
 ### Queue consumer – from(“hazelcast-queue:foo”)
 
 The queue consumer provides 2 operations:


[2/3] camel git commit: CAMEL-11694 - Camel-Hazelcast: Add more operation to queue - Retain All operation

Posted by ac...@apache.org.
CAMEL-11694 - Camel-Hazelcast: Add more operation to queue - Retain All operation


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

Branch: refs/heads/master
Commit: a9f4c55e00c7d5999945428a84c51ee93ca4a72d
Parents: 04a8a84
Author: Andrea Cosentino <an...@gmail.com>
Authored: Wed Aug 23 10:35:50 2017 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Wed Aug 23 10:35:50 2017 +0200

----------------------------------------------------------------------
 .../hazelcast/queue/HazelcastQueueProducer.java          |  9 +++++++++
 .../component/hazelcast/HazelcastQueueProducerTest.java  | 11 +++++++++++
 2 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a9f4c55e/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java
index b8350d3..7649362 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/queue/HazelcastQueueProducer.java
@@ -100,6 +100,10 @@ public class HazelcastQueueProducer extends HazelcastDefaultProducer {
         case TAKE:
             this.take(exchange);
             break;
+            
+        case RETAIN_ALL:
+            this.retainAll(exchange);
+            break;
 
         default:
             throw new IllegalArgumentException(String.format("The value '%s' is not allowed for parameter '%s' on the QUEUE cache.", operation, HazelcastConstants.OPERATION));
@@ -164,4 +168,9 @@ public class HazelcastQueueProducer extends HazelcastDefaultProducer {
     private void take(Exchange exchange) throws InterruptedException {
         exchange.getOut().setBody(this.queue.take());
     }
+    
+    private void retainAll(Exchange exchange) {
+        Collection body = exchange.getIn().getBody(Collection.class);
+        this.queue.retainAll(body);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/a9f4c55e/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastQueueProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastQueueProducerTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastQueueProducerTest.java
index b88aa18..60b3c2a 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastQueueProducerTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastQueueProducerTest.java
@@ -153,6 +153,14 @@ public class HazelcastQueueProducerTest extends HazelcastCamelTestSupport {
     }
     
     @Test
+    public void retainAll() throws InterruptedException {
+        Collection c = new HashSet<>();
+        c.add("foo2");
+        template.sendBody("direct:retainAll", c);
+        verify(queue).retainAll(c);
+    }
+    
+    @Test
     public void drainTo() throws InterruptedException {
         Map<String, Object> headers = new HashMap<String, Object>();
         Collection l = new ArrayList<>();
@@ -197,6 +205,9 @@ public class HazelcastQueueProducerTest extends HazelcastCamelTestSupport {
                 from("direct:take").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.TAKE)).to(
                         String.format("hazelcast-%sbar", HazelcastConstants.QUEUE_PREFIX));
                 
+                from("direct:retainAll").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.RETAIN_ALL)).to(
+                        String.format("hazelcast-%sbar", HazelcastConstants.QUEUE_PREFIX));
+                
                 from("direct:drainTo").setHeader(HazelcastConstants.OPERATION, constant(HazelcastOperation.DRAIN_TO)).to(
                         String.format("hazelcast-%sbar", HazelcastConstants.QUEUE_PREFIX));