[hornetq-commits] JBoss hornetq SVN: r9684 - in branches/Branch_2_1: src/main/org/hornetq/api/core/management and 2 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Sep 14 04:38:01 EDT 2010


Author: jmesnil
Date: 2010-09-14 04:38:01 -0400 (Tue, 14 Sep 2010)
New Revision: 9684

Modified:
   branches/Branch_2_1/merge-activity.txt
   branches/Branch_2_1/src/main/org/hornetq/api/core/management/AddressControl.java
   branches/Branch_2_1/src/main/org/hornetq/core/management/impl/AddressControlImpl.java
   branches/Branch_2_1/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java
   branches/Branch_2_1/tests/src/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java
Log:
https://jira.jboss.org/browse/HORNETQ-509 Diverts are listed in AddressControl.getQueueNames()
* list only QueueBindings in AddressControl.getQueueNames()
* add AddressControl.getBindingNames() to list *all* bindings
* tests

merge from trunk: svn merge -r 9682:9683 https://svn.jboss.org/repos/hornetq/trunk


Modified: branches/Branch_2_1/merge-activity.txt
===================================================================
--- branches/Branch_2_1/merge-activity.txt	2010-09-14 08:20:09 UTC (rev 9683)
+++ branches/Branch_2_1/merge-activity.txt	2010-09-14 08:38:01 UTC (rev 9684)
@@ -15,4 +15,6 @@
 - 10-sep-2010 - clebert        - merge from this branch to trunk, r9591-9608, r9612-9659, r9660-9662
   trunk is aligned with all the changes from Branch_2_1 up to r9668
 
+- 14-sep-2010 - jmesnil        - merger from trunk -r 9682:9683 - https://jira.jboss.org/browse/HORNETQ-509
+ 
 TODO: Bring changes from HORNETQ-469 as soon as it's stable (remove this line as soon as it's done)

Modified: branches/Branch_2_1/src/main/org/hornetq/api/core/management/AddressControl.java
===================================================================
--- branches/Branch_2_1/src/main/org/hornetq/api/core/management/AddressControl.java	2010-09-14 08:20:09 UTC (rev 9683)
+++ branches/Branch_2_1/src/main/org/hornetq/api/core/management/AddressControl.java	2010-09-14 08:38:01 UTC (rev 9684)
@@ -56,6 +56,11 @@
     */
    long getNumberOfBytesPerPage() throws Exception;
 
+   /**
+    * Returns the names of all bindings (both queues and diverts) bound to this address
+    */
+   String[] getBindingNames() throws Exception;
+
    // Operations ----------------------------------------------------
 
 }

Modified: branches/Branch_2_1/src/main/org/hornetq/core/management/impl/AddressControlImpl.java
===================================================================
--- branches/Branch_2_1/src/main/org/hornetq/core/management/impl/AddressControlImpl.java	2010-09-14 08:20:09 UTC (rev 9683)
+++ branches/Branch_2_1/src/main/org/hornetq/core/management/impl/AddressControlImpl.java	2010-09-14 08:38:01 UTC (rev 9684)
@@ -13,6 +13,8 @@
 
 package org.hornetq.core.management.impl;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Set;
 
 import javax.management.MBeanOperationInfo;
@@ -25,6 +27,7 @@
 import org.hornetq.core.postoffice.Binding;
 import org.hornetq.core.postoffice.Bindings;
 import org.hornetq.core.postoffice.PostOffice;
+import org.hornetq.core.postoffice.QueueBinding;
 import org.hornetq.core.security.CheckType;
 import org.hornetq.core.security.Role;
 import org.hornetq.core.settings.HierarchicalRepository;
@@ -86,13 +89,39 @@
       try
       {
          Bindings bindings = postOffice.getBindingsForAddress(address);
-         String[] queueNames = new String[bindings.getBindings().size()];
+         List<String> queueNames = new ArrayList<String>();
+         for (Binding binding : bindings.getBindings())
+         {
+            if (binding instanceof QueueBinding)
+            {
+               queueNames.add(binding.getUniqueName().toString());
+            }
+         }
+         return (String[])queueNames.toArray(new String[queueNames.size()]);
+      }
+      catch (Throwable t)
+      {
+         throw new IllegalStateException(t.getMessage());
+      }
+      finally
+      {
+         blockOnIO();
+      }
+   }
+   
+   public String[] getBindingNames() throws Exception
+   {
+      clearIO();
+      try
+      {
+         Bindings bindings = postOffice.getBindingsForAddress(address);
+         String[] bindingNames = new String[bindings.getBindings().size()];
          int i = 0;
          for (Binding binding : bindings.getBindings())
          {
-            queueNames[i++] = binding.getUniqueName().toString();
+               bindingNames[i++] = binding.getUniqueName().toString();
          }
-         return queueNames;
+         return bindingNames;
       }
       catch (Throwable t)
       {

Modified: branches/Branch_2_1/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java
===================================================================
--- branches/Branch_2_1/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java	2010-09-14 08:20:09 UTC (rev 9683)
+++ branches/Branch_2_1/tests/src/org/hornetq/tests/integration/management/AddressControlTest.java	2010-09-14 08:38:01 UTC (rev 9684)
@@ -13,6 +13,8 @@
 
 package org.hornetq.tests.integration.management;
 
+import static org.hornetq.tests.util.RandomUtil.randomString;
+
 import java.util.HashSet;
 import java.util.Set;
 
@@ -20,7 +22,11 @@
 
 import org.hornetq.api.core.SimpleString;
 import org.hornetq.api.core.TransportConfiguration;
-import org.hornetq.api.core.client.*;
+import org.hornetq.api.core.client.ClientMessage;
+import org.hornetq.api.core.client.ClientProducer;
+import org.hornetq.api.core.client.ClientSession;
+import org.hornetq.api.core.client.ClientSessionFactory;
+import org.hornetq.api.core.client.HornetQClient;
 import org.hornetq.api.core.management.AddressControl;
 import org.hornetq.api.core.management.RoleInfo;
 import org.hornetq.core.config.Configuration;
@@ -96,7 +102,32 @@
 
       session.deleteQueue(anotherQueue);
    }
+   
+   public void testGetBindingNames() throws Exception
+   {
+      SimpleString address = RandomUtil.randomSimpleString();
+      SimpleString queue = RandomUtil.randomSimpleString();
+      String divertName = RandomUtil.randomString();
+      
+      session.createQueue(address, queue, false);
 
+      AddressControl addressControl = createManagementControl(address);
+      String[] bindingNames = addressControl.getBindingNames();
+      assertEquals(1, bindingNames.length);
+      assertEquals(queue.toString(), bindingNames[0]);
+
+      server.getHornetQServerControl().createDivert(divertName, randomString(), address.toString(), RandomUtil.randomString(), false, null, null);
+
+      bindingNames = addressControl.getBindingNames();
+      Assert.assertEquals(2, bindingNames.length);
+      
+      session.deleteQueue(queue);
+      
+      bindingNames = addressControl.getBindingNames();
+      assertEquals(1, bindingNames.length);
+      assertEquals(divertName.toString(), bindingNames[0]);
+   }
+
    public void testGetRoles() throws Exception
    {
       SimpleString address = RandomUtil.randomSimpleString();

Modified: branches/Branch_2_1/tests/src/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java
===================================================================
--- branches/Branch_2_1/tests/src/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java	2010-09-14 08:20:09 UTC (rev 9683)
+++ branches/Branch_2_1/tests/src/org/hornetq/tests/integration/management/AddressControlUsingCoreTest.java	2010-09-14 08:38:01 UTC (rev 9684)
@@ -13,6 +13,8 @@
 
 package org.hornetq.tests.integration.management;
 
+import static org.hornetq.tests.util.RandomUtil.randomString;
+
 import java.util.HashSet;
 import java.util.Set;
 
@@ -25,7 +27,6 @@
 import org.hornetq.api.core.client.HornetQClient;
 import org.hornetq.api.core.management.AddressControl;
 import org.hornetq.api.core.management.ResourceNames;
-import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
 import org.hornetq.core.config.Configuration;
 import org.hornetq.core.config.impl.ConfigurationImpl;
 import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
@@ -100,7 +101,32 @@
 
       session.deleteQueue(anotherQueue);
    }
+   
+   public void testGetBindingNames() throws Exception
+   {
+      SimpleString address = RandomUtil.randomSimpleString();
+      SimpleString queue = RandomUtil.randomSimpleString();
+      String divertName = RandomUtil.randomString();
+      
+      session.createQueue(address, queue, false);
 
+      CoreMessagingProxy proxy = createProxy(address);
+      Object[] bindingNames = (Object[])proxy.retrieveAttributeValue("bindingNames");
+      assertEquals(1, bindingNames.length);
+      assertEquals(queue.toString(), bindingNames[0]);
+
+      server.getHornetQServerControl().createDivert(divertName, randomString(), address.toString(), RandomUtil.randomString(), false, null, null);
+
+      bindingNames = (Object[])proxy.retrieveAttributeValue("bindingNames");   
+      assertEquals(2, bindingNames.length);
+      
+      session.deleteQueue(queue);
+      
+      bindingNames = (Object[])proxy.retrieveAttributeValue("bindingNames");
+      assertEquals(1, bindingNames.length);
+      assertEquals(divertName.toString(), bindingNames[0]);
+   }
+
    public void testGetRoles() throws Exception
    {
       SimpleString address = RandomUtil.randomSimpleString();



More information about the hornetq-commits mailing list