This closes #3347
This commit is contained in:
commit
e527b5645e
|
@ -2770,7 +2770,6 @@ public interface AuditLogger extends BasicLogger {
|
|||
@Message(id = 601739, value = "User {0} is requesting to stop broker connection {1}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void stopBrokerConnection(String user, String name);
|
||||
|
||||
|
||||
static void startBrokerConnection(String name) {
|
||||
LOGGER.startBrokerConnection(getCaller(), name);
|
||||
}
|
||||
|
@ -2779,4 +2778,19 @@ public interface AuditLogger extends BasicLogger {
|
|||
@Message(id = 601740, value = "User {0} is requesting to start broker connection {1}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void startBrokerConnection(String user, String name);
|
||||
|
||||
static void getAddressCount(Object source) {
|
||||
LOGGER.getAddressCount(getCaller(), source);
|
||||
}
|
||||
|
||||
@LogMessage(level = Logger.Level.INFO)
|
||||
@Message(id = 601741, value = "User {0} is getting address count on target resource: {1} {2}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void getAddressCount(String user, Object source, Object... args);
|
||||
|
||||
static void getQueueCount(Object source) {
|
||||
LOGGER.getQueueCount(getCaller(), source);
|
||||
}
|
||||
|
||||
@LogMessage(level = Logger.Level.INFO)
|
||||
@Message(id = 601742, value = "User {0} is getting the queue count on target resource: {1} {2}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void getQueueCount(String user, Object source, Object... args);
|
||||
}
|
||||
|
|
|
@ -394,11 +394,23 @@ public interface ActiveMQServerControl {
|
|||
String getConnectorsAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* Returns the addresses created on this server.
|
||||
* Returns the number of addresses created on this server.
|
||||
*/
|
||||
@Attribute(desc = "Addresses created on this server")
|
||||
@Attribute(desc = "Number of addresses created on this server")
|
||||
int getAddressCount();
|
||||
|
||||
/**
|
||||
* Returns the names of the addresses created on this server.
|
||||
*/
|
||||
@Attribute(desc = "Names of the addresses created on this server")
|
||||
String[] getAddressNames();
|
||||
|
||||
/**
|
||||
* Returns the number of queues created on this server.
|
||||
*/
|
||||
@Attribute(desc = "Number of queues created on this server")
|
||||
int getQueueCount();
|
||||
|
||||
/**
|
||||
* Returns the names of the queues created on this server.
|
||||
*/
|
||||
|
|
|
@ -1395,6 +1395,22 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getQueueCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getQueueCount(this.server);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
Object[] queueControls = server.getManagementService().getResources(QueueControl.class);
|
||||
return queueControls.length;
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQueueNames() {
|
||||
return getQueueNames(null);
|
||||
|
@ -1493,6 +1509,22 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAddressCount() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getAddressCount(this.server);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
Object[] addresses = server.getManagementService().getResources(AddressControl.class);
|
||||
return addresses.length;
|
||||
} finally {
|
||||
blockOnIO();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAddressNames() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
|
|
|
@ -661,6 +661,32 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
|||
serverControl.destroyQueue(name.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetQueueCount() throws Exception {
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
SimpleString name = RandomUtil.randomSimpleString();
|
||||
|
||||
ActiveMQServerControl serverControl = createManagementControl();
|
||||
|
||||
// due to replication, there can be another queue created for replicating
|
||||
// management operations
|
||||
Assert.assertFalse(ActiveMQServerControlTest.contains(name.toString(), serverControl.getQueueNames()));
|
||||
|
||||
int countBeforeCreate = serverControl.getQueueCount();
|
||||
|
||||
serverControl.createAddress(address.toString(), "ANYCAST");
|
||||
if (legacyCreateQueue) {
|
||||
serverControl.createQueue(address.toString(), "ANYCAST", name.toString(), null, true, -1, false, false);
|
||||
} else {
|
||||
serverControl.createQueue(new QueueConfiguration(name).setAddress(address).setRoutingType(RoutingType.ANYCAST).setDurable(true).setAutoCreateAddress(false).toJSON());
|
||||
}
|
||||
|
||||
Assert.assertTrue(countBeforeCreate < serverControl.getQueueCount());
|
||||
|
||||
serverControl.destroyQueue(name.toString());
|
||||
Assert.assertFalse(ActiveMQServerControlTest.contains(name.toString(), serverControl.getQueueNames()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetQueueNames() throws Exception {
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
|
@ -741,6 +767,31 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
|||
Assert.assertTrue(ActiveMQServerControlTest.contains(clusterConnection2, serverControl.getClusterConnectionNames()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAddressCount() throws Exception {
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
SimpleString name = RandomUtil.randomSimpleString();
|
||||
|
||||
ActiveMQServerControl serverControl = createManagementControl();
|
||||
|
||||
// due to replication, there can be another queue created for replicating
|
||||
// management operations
|
||||
Assert.assertFalse(ActiveMQServerControlTest.contains(address.toString(), serverControl.getAddressNames()));
|
||||
|
||||
int countBeforeCreate = serverControl.getAddressCount();
|
||||
|
||||
if (legacyCreateQueue) {
|
||||
serverControl.createQueue(address.toString(), "ANYCAST", name.toString(), null, true, -1, false, true);
|
||||
} else {
|
||||
serverControl.createQueue(new QueueConfiguration(name).setAddress(address).setRoutingType(RoutingType.ANYCAST).toJSON());
|
||||
}
|
||||
|
||||
Assert.assertTrue(countBeforeCreate < serverControl.getAddressCount());
|
||||
|
||||
serverControl.destroyQueue(name.toString(), true, true);
|
||||
Assert.assertFalse(ActiveMQServerControlTest.contains(address.toString(), serverControl.getAddressNames()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAddressNames() throws Exception {
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
|
|
|
@ -375,11 +375,21 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
|||
return (String) proxy.retrieveAttributeValue("connectorsAsJSON");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAddressCount() {
|
||||
return (Integer) proxy.retrieveAttributeValue("addressCount", Integer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAddressNames() {
|
||||
return (String[]) proxy.retrieveAttributeValue("addressNames", String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getQueueCount() {
|
||||
return (Integer) proxy.retrieveAttributeValue("queueCount", Integer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQueueNames() {
|
||||
return (String[]) proxy.retrieveAttributeValue("queueNames", String.class);
|
||||
|
|
Loading…
Reference in New Issue