activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject [1/2] git commit: support options on MessageGroupMap types
Date Fri, 11 Oct 2013 10:08:22 GMT
Updated Branches:
  refs/heads/trunk 59af7479b -> 7f17f49d7


support options on MessageGroupMap types


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

Branch: refs/heads/trunk
Commit: cd4b229f222d96c76753249baa323d0a2c89f287
Parents: 59af747
Author: rajdavies <rajdavies@gmail.com>
Authored: Fri Oct 11 11:07:20 2013 +0100
Committer: rajdavies <rajdavies@gmail.com>
Committed: Fri Oct 11 11:07:20 2013 +0100

----------------------------------------------------------------------
 .../region/group/CachedMessageGroupMap.java       | 12 ++++++++++--
 .../group/CachedMessageGroupMapFactory.java       | 14 ++++++++++++--
 .../broker/region/group/GroupFactoryFinder.java   | 18 +++++++++++++++++-
 .../region/group/MessageGroupHashBucket.java      |  4 ++++
 4 files changed, 43 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/cd4b229f/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/CachedMessageGroupMap.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/CachedMessageGroupMap.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/CachedMessageGroupMap.java
index 7829ec4..084e8d0 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/CachedMessageGroupMap.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/CachedMessageGroupMap.java
@@ -29,8 +29,12 @@ import org.apache.activemq.memory.LRUMap;
  * 
  */
 public class CachedMessageGroupMap implements MessageGroupMap {
-    private LRUMap<String, ConsumerId> cache = new LRUMap<String, ConsumerId>(1024);
-    
+    private final LRUMap<String, ConsumerId> cache;
+    private final int maximumCacheSize;
+    CachedMessageGroupMap(int size){
+      cache = new LRUMap<String, ConsumerId>(size);
+      maximumCacheSize = size;
+    }
     public synchronized void put(String groupId, ConsumerId consumerId) {
         cache.put(groupId, consumerId);
     }
@@ -80,6 +84,10 @@ public class CachedMessageGroupMap implements MessageGroupMap {
         return "cached";
     }
 
+    public int getMaximumCacheSize(){
+        return maximumCacheSize;
+    }
+
     public String toString() {
         return "message groups: " + cache.size();
     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/cd4b229f/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/CachedMessageGroupMapFactory.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/CachedMessageGroupMapFactory.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/CachedMessageGroupMapFactory.java
index 7387c5a..b0a0be8 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/CachedMessageGroupMapFactory.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/CachedMessageGroupMapFactory.java
@@ -17,7 +17,7 @@
 package org.apache.activemq.broker.region.group;
 
 /**
- * A factory to create instances of {@link org.apache.activemq.broker.region.group.SimpleMessageGroupMap}
when implementing the
+ * A factory to create instances of {@link org.apache.activemq.broker.region.group.CachedMessageGroupMap}
when implementing the
  * <a href="http://activemq.apache.org/message-groups.html">Message Groups</a>
functionality.
  *
  * @org.apache.xbean.XBean
@@ -26,8 +26,18 @@ package org.apache.activemq.broker.region.group;
  */
 public class CachedMessageGroupMapFactory implements MessageGroupMapFactory {
 
+    private int cacheSize = 1024;
+    public int getCacheSize() {
+        return cacheSize;
+    }
+
+    public void setCacheSize(int cacheSize) {
+        this.cacheSize = cacheSize;
+    }
+
+
     public MessageGroupMap createMessageGroupMap() {
-        return new CachedMessageGroupMap();
+        return new CachedMessageGroupMap(getCacheSize());
     }
 
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/cd4b229f/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/GroupFactoryFinder.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/GroupFactoryFinder.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/GroupFactoryFinder.java
index 168804f..718b37d 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/GroupFactoryFinder.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/GroupFactoryFinder.java
@@ -17,9 +17,12 @@
 package org.apache.activemq.broker.region.group;
 
 import java.io.IOException;
+import java.util.Map;
 
 import org.apache.activemq.util.FactoryFinder;
 import org.apache.activemq.util.IOExceptionSupport;
+import org.apache.activemq.util.IntrospectionSupport;
+import org.apache.activemq.util.URISupport;
 
 public class GroupFactoryFinder {
     private static final FactoryFinder GROUP_FACTORY_FINDER = new FactoryFinder("META-INF/services/org/apache/activemq/groups/");
@@ -29,7 +32,20 @@ public class GroupFactoryFinder {
 
     public static MessageGroupMapFactory createMessageGroupMapFactory(String type) throws
IOException {
         try {
-            return (MessageGroupMapFactory)GROUP_FACTORY_FINDER.newInstance(type);
+            Map<String,String> properties = null;
+            String factoryType = type.trim();
+            int p = factoryType.indexOf('?');
+            if (p >= 0){
+                String propertiesString = factoryType.substring(p+1);
+                factoryType = factoryType.substring(0,p);
+                properties = URISupport.parseQuery(propertiesString);
+            }
+            MessageGroupMapFactory result =  (MessageGroupMapFactory)GROUP_FACTORY_FINDER.newInstance(factoryType);
+            if (properties != null && result != null){
+                IntrospectionSupport.setProperties(result,properties);
+            }
+            return result;
+
         } catch (Throwable e) {
             throw IOExceptionSupport.create("Could not load " + type + " factory:" + e, e);
         }

http://git-wip-us.apache.org/repos/asf/activemq/blob/cd4b229f/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/MessageGroupHashBucket.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/MessageGroupHashBucket.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/MessageGroupHashBucket.java
index c36f949..a18e4d2 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/MessageGroupHashBucket.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/group/MessageGroupHashBucket.java
@@ -92,6 +92,10 @@ public class MessageGroupHashBucket implements MessageGroupMap {
         return "bucket";
     }
 
+    public int getBucketCount(){
+        return bucketCount;
+    }
+
 
     public String toString() {
         int count = 0;


Mime
View raw message