ARTEMIS-2179 mgmnt method to get cluster-cxn names

This commit is contained in:
Justin Bertram 2018-11-20 18:53:01 -06:00 committed by Francesco Nigro
parent 8e4bc48132
commit 3c595f18d5
4 changed files with 57 additions and 0 deletions

View File

@ -1335,5 +1335,11 @@ public interface ActiveMQServerControl {
*/
@Operation(desc = "Names of the queues created on this server with the given routing-type (i.e. ANYCAST or MULTICAST)", impact = MBeanOperationInfo.INFO)
String[] getQueueNames(@Parameter(name = "routingType", desc = "The routing type, MULTICAST or ANYCAST") String routingType);
/**
* Returns the names of the cluster-connections deployed on this server.
*/
@Operation(desc = "Names of the cluster-connections deployed on this server", impact = MBeanOperationInfo.INFO)
String[] getClusterConnectionNames();
}

View File

@ -950,6 +950,24 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active
}
}
@Override
public String[] getClusterConnectionNames() {
checkStarted();
clearIO();
try {
List<String> names = new ArrayList<>();
for (ClusterConnection clusterConnection : server.getClusterManager().getClusterConnections()) {
names.add(clusterConnection.getName().toString());
}
String[] result = new String[names.size()];
return names.toArray(result);
} finally {
blockOnIO();
}
}
@Override
public String getUptime() {
checkStarted();

View File

@ -55,6 +55,7 @@ import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
import org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl;
import org.apache.activemq.artemis.core.client.impl.ClientSessionImpl;
import org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.impl.SecurityConfiguration;
import org.apache.activemq.artemis.core.messagecounter.impl.MessageCounterManagerImpl;
@ -463,6 +464,27 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
Assert.assertFalse(ActiveMQServerControlTest.contains(multicastName.toString(), serverControl.getQueueNames()));
}
@Test
public void testGetClusterConnectionNames() throws Exception {
String clusterConnection1 = RandomUtil.randomString();
String clusterConnection2 = RandomUtil.randomString();
ActiveMQServerControl serverControl = createManagementControl();
Assert.assertFalse(ActiveMQServerControlTest.contains(clusterConnection1, serverControl.getClusterConnectionNames()));
Assert.assertFalse(ActiveMQServerControlTest.contains(clusterConnection2, serverControl.getClusterConnectionNames()));
server.stop();
server
.getConfiguration()
.addClusterConfiguration(new ClusterConnectionConfiguration().setName(clusterConnection1).setConnectorName(connectorConfig.getName()))
.addClusterConfiguration(new ClusterConnectionConfiguration().setName(clusterConnection2).setConnectorName(connectorConfig.getName()));
server.start();
Assert.assertTrue(ActiveMQServerControlTest.contains(clusterConnection1, serverControl.getClusterConnectionNames()));
Assert.assertTrue(ActiveMQServerControlTest.contains(clusterConnection2, serverControl.getClusterConnectionNames()));
}
@Test
public void testGetAddressNames() throws Exception {
SimpleString address = RandomUtil.randomSimpleString();

View File

@ -324,6 +324,17 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
return null;
}
@Override
public String[] getClusterConnectionNames() {
try {
return (String[]) proxy.invokeOperation(String.class, "getClusterConnectionNames");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public String getUptime() {
return null;