This commit is contained in:
Clebert Suconic 2016-02-01 09:56:06 -05:00
commit 7ca42ef352
3 changed files with 64 additions and 0 deletions

View File

@ -52,6 +52,11 @@ public interface JMSServerControl {
*/
String[] getConnectionFactoryNames();
/**
* Returns the servers nodeId
*/
String getNodeID();
// Operations ----------------------------------------------------
/**
@ -343,6 +348,9 @@ public interface JMSServerControl {
@Operation(desc = "List the sessions for the given connectionID", impact = MBeanOperationInfo.INFO)
String listSessionsAsJSON(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID) throws Exception;
@Operation(desc = "List the Network Topology", impact = MBeanOperationInfo.INFO)
String listNetworkTopology() throws Exception;
/**
* List all the prepared transaction, sorted by date,
* oldest first, with details, in text format

View File

@ -27,12 +27,14 @@ import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.management.Parameter;
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
@ -41,11 +43,15 @@ import org.apache.activemq.artemis.api.jms.management.DestinationControl;
import org.apache.activemq.artemis.api.jms.management.JMSQueueControl;
import org.apache.activemq.artemis.api.jms.management.JMSServerControl;
import org.apache.activemq.artemis.api.jms.management.TopicControl;
import org.apache.activemq.artemis.core.client.impl.Topology;
import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl;
import org.apache.activemq.artemis.core.filter.Filter;
import org.apache.activemq.artemis.core.management.impl.AbstractControl;
import org.apache.activemq.artemis.core.management.impl.MBeanInfoHelper;
import org.apache.activemq.artemis.core.server.ServerConsumer;
import org.apache.activemq.artemis.core.server.ServerSession;
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
import org.apache.activemq.artemis.jms.server.ActiveMQJMSServerLogger;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
@ -470,6 +476,11 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
}
}
@Override
public String getNodeID() {
return server.getActiveMQServer().getNodeID().toString();
}
// NotificationEmitter implementation ----------------------------
@Override
@ -809,6 +820,42 @@ public class JMSServerControlImpl extends AbstractControl implements JMSServerCo
return array.toString();
}
@Override
public String listNetworkTopology() throws Exception {
checkStarted();
clearIO();
try {
JSONArray brokers = new JSONArray();
ClusterManager clusterManager = server.getActiveMQServer().getClusterManager();
if (clusterManager != null) {
Set<ClusterConnection> clusterConnections = clusterManager.getClusterConnections();
for (ClusterConnection clusterConnection : clusterConnections) {
Topology topology = clusterConnection.getTopology();
Collection<TopologyMemberImpl> members = topology.getMembers();
for (TopologyMemberImpl member : members) {
JSONObject obj = new JSONObject();
TransportConfiguration live = member.getLive();
if (live != null) {
obj.put("nodeID", member.getNodeId());
obj.put("live", live.getParams().get("host") + ":" + live.getParams().get("port"));
TransportConfiguration backup = member.getBackup();
if (backup != null) {
obj.put("backup", backup.getParams().get("host") + ":" + backup.getParams().get("port"));
}
}
brokers.put(obj);
}
}
}
return brokers.toString();
}
finally {
blockOnIO();
}
}
@Override
public String closeConnectionWithClientID(final String clientID) throws Exception {
return server.getActiveMQServer().destroyConnectionWithSessionMetadata(ClientSession.JMS_SESSION_CLIENT_ID_PROPERTY, clientID);

View File

@ -242,6 +242,11 @@ public class JMSServerControlUsingJMSTest extends JMSServerControlTest {
return JMSServerControlUsingJMSTest.toStringArray((Object[]) proxy.retrieveAttributeValue("connectionFactoryNames"));
}
@Override
public String getNodeID() {
return null;
}
@Override
public String[] listConnectionIDs() throws Exception {
return (String[]) proxy.invokeOperation("listConnectionIDs");
@ -307,6 +312,10 @@ public class JMSServerControlUsingJMSTest extends JMSServerControlTest {
return (String) proxy.invokeOperation("listPreparedTransactionDetailsAsJSON");
}
@Override
public String listNetworkTopology() throws Exception {
return null;
}
@Override
public String listPreparedTransactionDetailsAsHTML() throws Exception {
return (String) proxy.invokeOperation("listPreparedTransactionDetailsAsHTML");