camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject camel git commit: CAMEL-8731 Camel-Hazelcast: Add clear operation to map and multimap producers
Date Sat, 02 May 2015 14:51:42 GMT
Repository: camel
Updated Branches:
  refs/heads/master 0b3e38a7e -> 9c628c284


CAMEL-8731 Camel-Hazelcast: Add clear operation to map and multimap producers


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

Branch: refs/heads/master
Commit: 9c628c2841daf3b457e1ccfcf69050d5c3c274b7
Parents: 0b3e38a
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Sat May 2 16:50:43 2015 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Sat May 2 16:50:43 2015 +0200

----------------------------------------------------------------------
 .../camel/component/hazelcast/HazelcastConstants.java    |  3 ++-
 .../component/hazelcast/map/HazelcastMapProducer.java    | 11 +++++++++++
 .../hazelcast/multimap/HazelcastMultimapProducer.java    |  7 +++++++
 .../component/hazelcast/HazelcastMapProducerTest.java    |  9 ++++++++-
 .../hazelcast/HazelcastMultimapProducerTest.java         |  8 ++++++++
 5 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9c628c28/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java
b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java
index 7757f74..84521c3 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/HazelcastConstants.java
@@ -49,7 +49,7 @@ public final class HazelcastConstants {
     public static final String CACHE_NAME = "CamelHazelcastCacheName";
     public static final String CACHE_TYPE = "CamelHazelcastCacheType";
 
-    // actions (put, delete, get, getAll, replace, update)
+    // actions (put, delete, get, getAll, replace, update, clear)
     public static final String OPERATION = "CamelHazelcastOperationType";
     public static final int PUT_OPERATION = 1;
     public static final int DELETE_OPERATION = 2;
@@ -58,6 +58,7 @@ public final class HazelcastConstants {
     public static final int QUERY_OPERATION = 5;
     public static final int GET_ALL_OPERATION = 6;
     public static final int REPLACE_OPERATION = 7;
+    public static final int CLEAR_OPERATION = 8;
 
     // multimap
     public static final int REMOVEVALUE_OPERATION = 10;

http://git-wip-us.apache.org/repos/asf/camel/blob/9c628c28/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapProducer.java
b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapProducer.java
index 8b6cd69..ab59a6a 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapProducer.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/map/HazelcastMapProducer.java
@@ -94,6 +94,10 @@ public class HazelcastMapProducer extends HazelcastDefaultProducer {
                 this.replace(oid, ovalue, exchange);
             }
             break;
+
+        case HazelcastConstants.CLEAR_OPERATION:
+            this.clear(exchange);
+            break;
             
         default:
             throw new IllegalArgumentException(String.format("The value '%s' is not allowed
for parameter '%s' on the MAP cache.", operation, HazelcastConstants.OPERATION));
@@ -172,4 +176,11 @@ public class HazelcastMapProducer extends HazelcastDefaultProducer {
         Object body = exchange.getIn().getBody();
         this.cache.replace(oid, ovalue, body);
     }
+    
+    /**
+     * Clear all the entries
+     */
+    private void clear(Exchange exchange) {
+        this.cache.clear();
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/9c628c28/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapProducer.java
b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapProducer.java
index 2bbe5f3..4e9ff53 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapProducer.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/multimap/HazelcastMultimapProducer.java
@@ -66,6 +66,10 @@ public class HazelcastMultimapProducer extends HazelcastDefaultProducer
{
             this.removevalue(oid, exchange);
             break;
 
+        case HazelcastConstants.CLEAR_OPERATION:
+            this.clear(exchange);
+            break;
+            
         default:
             throw new IllegalArgumentException(String.format("The value '%s' is not allowed
for parameter '%s' on the MULTIMAP cache.", operation, HazelcastConstants.OPERATION));
         }
@@ -91,4 +95,7 @@ public class HazelcastMultimapProducer extends HazelcastDefaultProducer
{
         this.cache.remove(oid, exchange.getIn().getBody());
     }
 
+    private void clear(Exchange exchange) {
+        this.cache.clear();
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/9c628c28/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerTest.java
b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerTest.java
index 132c3c0..ff11057 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerTest.java
@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 
 import com.hazelcast.core.HazelcastInstance;
@@ -172,6 +171,12 @@ public class HazelcastMapProducerTest extends HazelcastCamelTestSupport
implemen
         template.sendBodyAndHeaders("direct:replace", "replaced", headers);
         verify(map).replace("4711", "my-foo", "replaced");
     }
+    
+    @Test
+    public void testClear() throws InterruptedException {
+        template.sendBody("direct:clear", "test");
+        verify(map).clear();
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -198,6 +203,8 @@ public class HazelcastMapProducerTest extends HazelcastCamelTestSupport
implemen
                 
                 from("direct:replace").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.REPLACE_OPERATION)).to(String.format("hazelcast:%sfoo",
HazelcastConstants.MAP_PREFIX));
 
+                from("direct:clear").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.CLEAR_OPERATION)).to(String.format("hazelcast:%sfoo",
HazelcastConstants.MAP_PREFIX));
+                
                 from("direct:putWithOperationNumber").toF("hazelcast:%sfoo?operation=%s",
HazelcastConstants.MAP_PREFIX, HazelcastConstants.PUT_OPERATION);
                 from("direct:putWithOperationName").toF("hazelcast:%sfoo?operation=put",
HazelcastConstants.MAP_PREFIX);
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/9c628c28/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMultimapProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMultimapProducerTest.java
b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMultimapProducerTest.java
index ca76c63..95f357f 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMultimapProducerTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMultimapProducerTest.java
@@ -92,6 +92,12 @@ public class HazelcastMultimapProducerTest extends HazelcastCamelTestSupport
{
         template.sendBodyAndHeader("direct:delete", null, HazelcastConstants.OBJECT_ID, 4711);
         verify(map).remove(4711);
     }
+    
+    @Test
+    public void testClear() {
+        template.sendBody("direct:clear", "test");
+        verify(map).clear();
+    }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -111,6 +117,8 @@ public class HazelcastMultimapProducerTest extends HazelcastCamelTestSupport
{
 
                 from("direct:delete").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.DELETE_OPERATION)).to(String.format("hazelcast:%sbar",
HazelcastConstants.MULTIMAP_PREFIX));
 
+                from("direct:clear").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.CLEAR_OPERATION)).to(String.format("hazelcast:%sbar",
HazelcastConstants.MULTIMAP_PREFIX));
+                
                 from("direct:putWithOperationNumber").toF("hazelcast:%sbar?operation=%s",
HazelcastConstants.MULTIMAP_PREFIX, HazelcastConstants.PUT_OPERATION);
                 from("direct:putWithOperationName").toF("hazelcast:%sbar?operation=put",
HazelcastConstants.MULTIMAP_PREFIX);
             }


Mime
View raw message