[prev in list] [next in list] [prev in thread] [next in thread] 

List:       activemq-commits
Subject:    activemq git commit: https://issues.apache.org/jira/browse/AMQ-6109
From:       cshannon () apache ! org
Date:       2015-12-28 16:41:39
Message-ID: 58e56522ed8b49899ef57edb88b2881e () git ! apache ! org
[Download RAW message or body]

Repository: activemq
Updated Branches:
  refs/heads/master 19ea5515c -> 8e2176d93


https://issues.apache.org/jira/browse/AMQ-6109

The chooseValue method in DestinationMap will now always return the
exact match, if there is one, else it will then sort as before.


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

Branch: refs/heads/master
Commit: 8e2176d93c95d847c813f54d54aaf9bafba4d5c4
Parents: 19ea551
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Mon Dec 28 16:40:10 2015 +0000
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Mon Dec 28 16:41:14 2015 +0000

----------------------------------------------------------------------
 .../apache/activemq/filter/DestinationMap.java  | 11 ++++-
 .../activemq/java/JavaPolicyEntryTest.java      | 51 ++++++++++++++++++++
 2 files changed, 60 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/8e2176d9/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMap.java
                
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMap.java \
b/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMap.java index \
                fd07b7a..b361203 100755
--- a/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMap.java
+++ b/activemq-client/src/main/java/org/apache/activemq/filter/DestinationMap.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.filter;
 
+import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -201,12 +202,18 @@ public class DestinationMap {
      * @return the largest matching value or null if no value matches
      */
     @SuppressWarnings({"rawtypes", "unchecked"})
-    public Object chooseValue(ActiveMQDestination destination) {
+    public Object chooseValue(final ActiveMQDestination destination) {
         Set set = get(destination);
         if (set == null || set.isEmpty()) {
             return null;
         }
-        SortedSet sortedSet = new TreeSet(set);
+        SortedSet sortedSet = new TreeSet(new Comparator<DestinationMapEntry>() {
+            @Override
+            public int compare(DestinationMapEntry entry1, DestinationMapEntry \
entry2) { +                return destination.equals(entry1.destination) ? -1 : \
(destination.equals(entry2.destination) ? 1 : entry1.compareTo(entry2)); +            \
} +        });
+        sortedSet.addAll(set);
         return sortedSet.first();
     }
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/8e2176d9/activemq-runtime-config/src/test/java/org/apache/activemq/java/JavaPolicyEntryTest.java
                
----------------------------------------------------------------------
diff --git a/activemq-runtime-config/src/test/java/org/apache/activemq/java/JavaPolicyEntryTest.java \
b/activemq-runtime-config/src/test/java/org/apache/activemq/java/JavaPolicyEntryTest.java
 index 29b655e..9c2df22 100644
--- a/activemq-runtime-config/src/test/java/org/apache/activemq/java/JavaPolicyEntryTest.java
                
+++ b/activemq-runtime-config/src/test/java/org/apache/activemq/java/JavaPolicyEntryTest.java
 @@ -407,6 +407,57 @@ public class JavaPolicyEntryTest extends \
RuntimeConfigTestSupport {  }
 
     @Test
+    public void testModWithMultipleChildPolicies() throws Exception {
+        BrokerService brokerService = new BrokerService();
+        PolicyMap policyMap = new PolicyMap();
+        PolicyEntry entry = new PolicyEntry();
+        entry.setQueue("queue.>");
+        entry.setMemoryLimit(1024);
+        PolicyEntry entry2 = new PolicyEntry();
+        entry2.setQueue("queue.child.>");
+        entry2.setMemoryLimit(2048);
+        PolicyEntry entry3 = new PolicyEntry();
+        entry3.setQueue("queue.child.test");
+        entry3.setMemoryLimit(5000);
+        PolicyEntry entry4 = new PolicyEntry();
+        entry4.setQueue("queue.child.test.test");
+        entry4.setMemoryLimit(5100);
+        PolicyEntry entry5 = new PolicyEntry();
+        entry5.setQueue("queue.child.a");
+        entry5.setMemoryLimit(5200);
+        policyMap.setPolicyEntries(Arrays.asList(entry, entry2, entry3, entry4, \
entry5)); +        brokerService.setDestinationPolicy(policyMap);
+
+        startBroker(brokerService);
+        assertTrue("broker alive", brokerService.isStarted());
+
+        brokerService.getBroker().addDestination(
+                brokerService.getAdminConnectionContext(), new \
ActiveMQQueue("queue.child.>"), false); +        \
brokerService.getBroker().addDestination( +                \
brokerService.getAdminConnectionContext(), new ActiveMQQueue("queue.test"), false); + \
brokerService.getBroker().addDestination( +                \
brokerService.getAdminConnectionContext(), new ActiveMQQueue("queue.child.test2"), \
false); +
+        //check destinations before policy updates
+        verifyQueueLimit("queue.test", 1024);
+        verifyQueueLimit("queue.child.test2", 2048);
+
+        //Reapply new limit to policy 2
+        entry3.setMemoryLimit(4194304);
+        javaConfigBroker.modifyPolicyEntry(entry);
+        TimeUnit.SECONDS.sleep(SLEEP);
+
+        //should be unchanged
+        verifyQueueLimit("queue.child.>", 2048);
+
+        //verify new dest and existing are changed
+        verifyQueueLimit("queue.child.test", 4194304);
+
+        //verify that destination at a higher level policy is not affected
+        verifyQueueLimit("queue.test", 1024);
+    }
+
+    @Test
     public void testModParentPolicy() throws Exception {
         BrokerService brokerService = new BrokerService();
         PolicyMap policyMap = new PolicyMap();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic