ARTEMIS-3601 expose acceptors via management
This commit is contained in:
parent
1b32004c29
commit
fac7f1692a
|
@ -2910,4 +2910,19 @@ public interface AuditLogger extends BasicLogger {
|
|||
@Message(id = 601755, value = "User {0} is unblocking target resource: {1}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void unBlock(String user, Object source);
|
||||
|
||||
static void getAcceptors(Object source) {
|
||||
BASE_LOGGER.getAcceptors(getCaller(), source);
|
||||
}
|
||||
|
||||
@LogMessage(level = Logger.Level.INFO)
|
||||
@Message(id = 601756, value = "User {0} is getting acceptors on target resource: {1} {2}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void getAcceptors(String user, Object source, Object... args);
|
||||
|
||||
static void getAcceptorsAsJSON(Object source) {
|
||||
BASE_LOGGER.getAcceptorsAsJSON(getCaller(), source);
|
||||
}
|
||||
|
||||
@LogMessage(level = Logger.Level.INFO)
|
||||
@Message(id = 601757, value = "User {0} is getting acceptors as json on target resource: {1} {2}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void getAcceptorsAsJSON(String user, Object source, Object... args);
|
||||
}
|
||||
|
|
|
@ -408,6 +408,18 @@ public interface ActiveMQServerControl {
|
|||
@Attribute(desc = "Connectors configured for this server using JSON serialization")
|
||||
String getConnectorsAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* Returns the acceptors configured for this server.
|
||||
*/
|
||||
@Attribute(desc = "Connectors configured for this server")
|
||||
Object[] getAcceptors() throws Exception;
|
||||
|
||||
/**
|
||||
* Returns the acceptors configured for this server using JSON serialization.
|
||||
*/
|
||||
@Attribute(desc = "Acceptors configured for this server using JSON serialization")
|
||||
String getAcceptorsAsJSON() throws Exception;
|
||||
|
||||
/**
|
||||
* Returns the number of addresses created on this server.
|
||||
*/
|
||||
|
|
|
@ -2740,16 +2740,26 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
|||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.getConnectors(this.server);
|
||||
}
|
||||
return getNetworkConfigs(configuration.getConnectorConfigurations().values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getAcceptors() throws Exception {
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.getAcceptors(this.server);
|
||||
}
|
||||
return getNetworkConfigs(configuration.getAcceptorConfigurations());
|
||||
}
|
||||
|
||||
private Object[] getNetworkConfigs(Collection<TransportConfiguration> configs) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
Collection<TransportConfiguration> connectorConfigurations = configuration.getConnectorConfigurations().values();
|
||||
|
||||
Object[] ret = new Object[connectorConfigurations.size()];
|
||||
Object[] ret = new Object[configs.size()];
|
||||
|
||||
int i = 0;
|
||||
for (TransportConfiguration config : connectorConfigurations) {
|
||||
for (TransportConfiguration config : configs) {
|
||||
Object[] tc = new Object[3];
|
||||
|
||||
tc[0] = config.getName();
|
||||
|
@ -2769,13 +2779,27 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
|
|||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.getConnectorsAsJSON(this.server);
|
||||
}
|
||||
|
||||
return getNetworkConfigsAsJSON(configuration.getConnectorConfigurations().values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAcceptorsAsJSON() throws Exception {
|
||||
if (AuditLogger.isBaseLoggingEnabled()) {
|
||||
AuditLogger.getAcceptorsAsJSON(this.server);
|
||||
}
|
||||
|
||||
return getNetworkConfigsAsJSON(configuration.getAcceptorConfigurations());
|
||||
}
|
||||
|
||||
private String getNetworkConfigsAsJSON(Collection<TransportConfiguration> configs) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
try {
|
||||
JsonArrayBuilder array = JsonLoader.createArrayBuilder();
|
||||
|
||||
for (TransportConfiguration config : configuration.getConnectorConfigurations().values()) {
|
||||
for (TransportConfiguration config : configs) {
|
||||
array.add(config.toJson());
|
||||
}
|
||||
|
||||
|
|
|
@ -239,6 +239,21 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
|||
Assert.assertEquals(connectorConfig.getName(), config[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAcceptors() throws Exception {
|
||||
ActiveMQServerControl serverControl = createManagementControl();
|
||||
|
||||
Object[] acceptors = serverControl.getAcceptors();
|
||||
Assert.assertNotNull(acceptors);
|
||||
Assert.assertEquals(2, acceptors.length);
|
||||
|
||||
for (int i = 0; i < acceptors.length; i++) {
|
||||
Object[] acceptor = (Object[]) acceptors[i];
|
||||
String name = (String) acceptor[0];
|
||||
assertTrue(name.equals("netty") || name.equals("invm"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsReplicaSync() throws Exception {
|
||||
Assert.assertFalse(createManagementControl().isReplicaSync());
|
||||
|
@ -258,6 +273,20 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
|
|||
Assert.assertEquals(connectorConfig.getParams().size(), data.getJsonObject("params").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAcceptorsAsJSON() throws Exception {
|
||||
ActiveMQServerControl serverControl = createManagementControl();
|
||||
|
||||
String jsonString = serverControl.getAcceptorsAsJSON();
|
||||
Assert.assertNotNull(jsonString);
|
||||
JsonArray array = JsonUtil.readJsonArray(jsonString);
|
||||
Assert.assertEquals(2, array.size());
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
String name = ((JsonObject)array.get(i)).getString("name");
|
||||
assertTrue(name.equals("netty") || name.equals("invm"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndDestroyQueue() throws Exception {
|
||||
SimpleString address = RandomUtil.randomSimpleString();
|
||||
|
|
|
@ -367,6 +367,16 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
|
|||
return (String) proxy.retrieveAttributeValue("connectorsAsJSON");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getAcceptors() throws Exception {
|
||||
return (Object[]) proxy.retrieveAttributeValue("acceptors");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAcceptorsAsJSON() throws Exception {
|
||||
return (String) proxy.retrieveAttributeValue("acceptorsAsJSON");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAddressCount() {
|
||||
return (Integer) proxy.retrieveAttributeValue("addressCount", Integer.class);
|
||||
|
|
Loading…
Reference in New Issue