ARTEMIS-784 Add new JMX methods and update JMX API

This commit is contained in:
Andy Taylor 2016-11-30 13:56:37 +00:00 committed by Martyn Taylor
parent 3abfd9f552
commit 74d0a1a818
11 changed files with 33 additions and 18 deletions

View File

@ -436,7 +436,7 @@ public interface ActiveMQServerControl {
@Operation(desc = "delete an address", impact = MBeanOperationInfo.ACTION)
void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
@Parameter(name = "deliveryMode", desc = "The delivery modes enabled for this address'") Object[] routingTypes) throws Exception;
@Parameter(name = "routingType", desc = "Comma separated list of Routing Typles (anycast/multicast)") String routingTypes) throws Exception;
@Operation(desc = "delete an address", impact = MBeanOperationInfo.ACTION)
void deleteAddress(@Parameter(name = "name", desc = "The name of the address") String name) throws Exception;

View File

@ -20,6 +20,7 @@ import javax.management.ObjectName;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.RoutingType;
/**
* Helper class to build ObjectNames for ActiveMQ Artemis resources.
@ -98,10 +99,20 @@ public final class ObjectNameBuilder {
*
* @see QueueControl
*/
public ObjectName getQueueObjectName(final SimpleString address, final SimpleString name) throws Exception {
return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "parentType=%s,parentName=%s," + getObjectType() + "=%s,name=%s", domain, "Address", ObjectName.quote(address.toString()), "Queue", ObjectName.quote(name.toString())));
public ObjectName getQueueObjectName(final SimpleString address, final SimpleString name, RoutingType routingType) throws Exception {
return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "parentType=%s,parentName=%s," + getObjectType() + "=%s, routingType=%s,name=%s", domain, "Address", ObjectName.quote(address.toString()), "Queue", routingType.toString(), ObjectName.quote(name.toString())));
}
/**
* Returns the ObjectName used by QueueControl.
*
* @see QueueControl
*/
public ObjectName getQueueObjectName(final SimpleString address, final SimpleString name) throws Exception {
return ObjectName.getInstance(String.format("%s:" + getBrokerProperties() + "parentType=%s,parentName=%s," + getObjectType() + "=%s, routingType=%s,name=%s", domain, "Address", ObjectName.quote(address.toString()), "Queue", ActiveMQDefaultConfiguration.getDefaultRoutingType(), ObjectName.quote(name.toString())));
}
/**
* Returns the ObjectName used by DivertControl.
*
@ -165,7 +176,7 @@ public final class ObjectNameBuilder {
* Returns the ObjectName used by JMSQueueControl.
*/
public ObjectName getJMSQueueObjectName(final String name) throws Exception {
return getQueueObjectName(SimpleString.toSimpleString(name), SimpleString.toSimpleString(name));
return getQueueObjectName(SimpleString.toSimpleString(name), SimpleString.toSimpleString(name), RoutingType.ANYCAST);
}
/**

View File

@ -52,7 +52,6 @@ import org.apache.activemq.artemis.api.core.management.AddressControl;
import org.apache.activemq.artemis.api.core.management.BridgeControl;
import org.apache.activemq.artemis.api.core.management.CoreNotificationType;
import org.apache.activemq.artemis.api.core.management.DivertControl;
import org.apache.activemq.artemis.api.core.management.Parameter;
import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.core.client.impl.Topology;
import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl;
@ -563,14 +562,13 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
}
@Override
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
@Parameter(name = "routingType", desc = "The delivery modes enabled for this address'") Object[] routingTypes) throws Exception {
public void createAddress(String name, String routingTypes) throws Exception {
checkStarted();
clearIO();
try {
Set<RoutingType> set = new HashSet<>();
for (Object routingType : routingTypes) {
for (Object routingType : toList(routingTypes)) {
set.add(RoutingType.valueOf(routingType.toString()));
}
server.createAddressInfo(new AddressInfo(new SimpleString(name), set));

View File

@ -539,7 +539,8 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
}
if (binding.getType() == BindingType.LOCAL_QUEUE) {
managementService.unregisterQueue(uniqueName, binding.getAddress());
Queue queue = (Queue) binding.getBindable();
managementService.unregisterQueue(uniqueName, binding.getAddress(), queue.getRoutingType());
} else if (binding.getType() == BindingType.DIVERT) {
managementService.unregisterDivert(uniqueName, binding.getAddress());
}

View File

@ -41,6 +41,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.Divert;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.QueueFactory;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.cluster.Bridge;
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
@ -96,7 +97,7 @@ public interface ManagementService extends NotificationService, ActiveMQComponen
void registerQueue(Queue queue, SimpleString address, StorageManager storageManager) throws Exception;
void unregisterQueue(SimpleString name, SimpleString address) throws Exception;
void unregisterQueue(SimpleString name, SimpleString address, RoutingType routingType) throws Exception;
void registerAcceptor(Acceptor acceptor, TransportConfiguration configuration) throws Exception;

View File

@ -71,6 +71,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
import org.apache.activemq.artemis.core.server.Divert;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.QueueFactory;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.cluster.Bridge;
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
@ -241,7 +242,7 @@ public class ManagementServiceImpl implements ManagementService {
queueControl.setMessageCounter(counter);
messageCounterManager.registerMessageCounter(queue.getName().toString(), counter);
}
ObjectName objectName = objectNameBuilder.getQueueObjectName(address, queue.getName());
ObjectName objectName = objectNameBuilder.getQueueObjectName(address, queue.getName(),queue.getRoutingType());
registerInJMX(objectName, queueControl);
registerInRegistry(ResourceNames.QUEUE + queue.getName(), queueControl);
@ -251,8 +252,8 @@ public class ManagementServiceImpl implements ManagementService {
}
@Override
public synchronized void unregisterQueue(final SimpleString name, final SimpleString address) throws Exception {
ObjectName objectName = objectNameBuilder.getQueueObjectName(address, name);
public synchronized void unregisterQueue(final SimpleString name, final SimpleString address, RoutingType routingType) throws Exception {
ObjectName objectName = objectNameBuilder.getQueueObjectName(address, name, routingType);
unregisterFromJMX(objectName);
unregisterFromRegistry(ResourceNames.QUEUE + name);
messageCounterManager.unregisterMessageCounter(name.toString());

View File

@ -43,6 +43,7 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.Divert;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.QueueFactory;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.core.server.cluster.Bridge;
import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
@ -261,7 +262,7 @@ public class ClusteredResetMockTest extends ActiveMQTestBase {
}
@Override
public void unregisterQueue(SimpleString name, SimpleString address) throws Exception {
public void unregisterQueue(SimpleString name, SimpleString address, RoutingType routingType) throws Exception {
}

View File

@ -268,7 +268,7 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
serverControl.createQueue(address.toString(), RoutingType.ANYCAST.toString(), name.toString(), null, durable, maxConsumers, deleteOnNoConsumers, autoCreateAddress);
checkResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name));
checkResource(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, RoutingType.ANYCAST));
QueueControl queueControl = ManagementControlHelper.createQueueControl(address, name, mbeanServer);
Assert.assertEquals(address.toString(), queueControl.getAddress());
Assert.assertEquals(name.toString(), queueControl.getName());

View File

@ -566,7 +566,7 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
@Override
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
@Parameter(name = "routingType", desc = "The delivery modes enabled for this address'") Object[] routingTypes) throws Exception {
@Parameter(name = "routingType", desc = "The delivery modes enabled for this address'") String routingTypes) throws Exception {
}

View File

@ -20,6 +20,7 @@ import javax.management.MBeanServer;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.management.AcceptorControl;
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
@ -69,7 +70,7 @@ public class ManagementControlHelper {
public static QueueControl createQueueControl(final SimpleString address,
final SimpleString name,
final MBeanServer mbeanServer) throws Exception {
return (QueueControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name), QueueControl.class, mbeanServer);
return (QueueControl) ManagementControlHelper.createProxy(ObjectNameBuilder.DEFAULT.getQueueObjectName(address, name, ActiveMQDefaultConfiguration.getDefaultRoutingType()), QueueControl.class, mbeanServer);
}
public static AddressControl createAddressControl(final SimpleString address,

View File

@ -55,6 +55,7 @@ import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.jms.bridge.ConnectionFactoryFactory;
import org.apache.activemq.artemis.jms.bridge.DestinationFactory;
import org.apache.activemq.artemis.jms.bridge.QualityOfServiceMode;
@ -470,7 +471,7 @@ public class JMSBridgeImplTest extends ActiveMQTestBase {
sourceConn.close();
SimpleString add = new SimpleString(JMSBridgeImplTest.SOURCE);
QueueControl jmsQueueControl = MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(), ObjectNameBuilder.DEFAULT.getQueueObjectName(add, add), QueueControl.class, false);
QueueControl jmsQueueControl = MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(), ObjectNameBuilder.DEFAULT.getQueueObjectName(add, add, RoutingType.ANYCAST), QueueControl.class, false);
assertNotEquals(jmsQueueControl.getDeliveringCount(), numMessages);
bridge.stop();