camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [4/5] camel git commit: CAMEL-8856 Camel-Hazelcast: Add evict and evictAll operation to hazelcast map
Date Thu, 11 Jun 2015 15:18:24 GMT
CAMEL-8856 Camel-Hazelcast: Add evict and evictAll operation to hazelcast map


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

Branch: refs/heads/master
Commit: 076585fc76fb0bc09d34d16eb6e4495694ecf329
Parents: 3055801
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Thu Jun 11 10:31:04 2015 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Thu Jun 11 17:14:36 2015 +0200

----------------------------------------------------------------------
 .../camel/component/hazelcast/HazelcastConstants.java    |  3 ++-
 .../component/hazelcast/map/HazelcastMapProducer.java    | 11 +++++++++++
 .../component/hazelcast/HazelcastMapProducerTest.java    | 10 ++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/076585fc/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 b005047..3da468f 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
@@ -66,7 +66,8 @@ public final class HazelcastConstants {
     public static final int REMOVE_ALL_OPERATION = 10;
     public static final int RETAIN_ALL_OPERATION = 11;
     public static final int EVICT_OPERATION = 12;
-
+    public static final int EVICT_ALL_OPERATION = 13;
+    
     // multimap
     public static final int REMOVEVALUE_OPERATION = 14;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/076585fc/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 ba459b0..3d2abf2 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
@@ -121,6 +121,10 @@ public class HazelcastMapProducer extends HazelcastDefaultProducer {
         case HazelcastConstants.EVICT_OPERATION:
             this.evict(oid);
             break;
+
+        case HazelcastConstants.EVICT_ALL_OPERATION:
+            this.evictAll();
+            break;
             
         default:
             throw new IllegalArgumentException(String.format("The value '%s' is not allowed
for parameter '%s' on the MAP cache.", operation, HazelcastConstants.OPERATION));
@@ -230,4 +234,11 @@ public class HazelcastMapProducer extends HazelcastDefaultProducer {
     private void evict(Object oid) {
         this.cache.evict(oid);
     }
+    
+    /**
+     * Evict All operation 
+     */
+    private void evictAll() {
+        this.cache.evictAll();
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/076585fc/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 c848142..0652ce9 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
@@ -206,6 +206,13 @@ public class HazelcastMapProducerTest extends HazelcastCamelTestSupport
implemen
     }
     
     @Test
+    public void testEvictAll() throws InterruptedException {
+        Map<String, Object> headers = new HashMap<String, Object>();
+        template.sendBodyAndHeaders("direct:evictAll", "", headers);
+        verify(map).evictAll();
+    }
+    
+    @Test
     public void testClear() throws InterruptedException {
         template.sendBody("direct:clear", "test");
         verify(map).clear();
@@ -241,6 +248,9 @@ public class HazelcastMapProducerTest extends HazelcastCamelTestSupport
implemen
  
                 from("direct:evict").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.EVICT_OPERATION)).to(String.format("hazelcast:%sfoo",
HazelcastConstants.MAP_PREFIX))
                         .to("seda:out");
+
+                from("direct:evictAll").setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.EVICT_ALL_OPERATION)).to(String.format("hazelcast:%sfoo",
HazelcastConstants.MAP_PREFIX))
+                        .to("seda:out");                
                 
                 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);


Mime
View raw message