activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-378 - expose some Network info via the management interfaces
Date Mon, 01 Feb 2016 14:56:33 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 37845ebe3 -> 7ca42ef35


ARTEMIS-378 - expose some Network info via the management interfaces

https://issues.apache.org/jira/browse/ARTEMIS-378


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/ecfa1fec
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/ecfa1fec
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/ecfa1fec

Branch: refs/heads/master
Commit: ecfa1fecc2263d2e26e84677112844ce3acb2226
Parents: 37845eb
Author: Andy Taylor <andy.tayls67@gmail.com>
Authored: Mon Feb 1 12:11:28 2016 +0000
Committer: Andy Taylor <andy.tayls67@gmail.com>
Committed: Mon Feb 1 12:11:28 2016 +0000

----------------------------------------------------------------------
 .../api/jms/management/JMSServerControl.java    |  8 ++++
 .../management/impl/JMSServerControlImpl.java   | 47 ++++++++++++++++++++
 .../JMSServerControlUsingJMSTest.java           |  9 ++++
 3 files changed, 64 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ecfa1fec/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSServerControl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSServerControl.java
b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSServerControl.java
index 2fd03fc..0c7ab71 100644
--- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSServerControl.java
+++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/api/jms/management/JMSServerControl.java
@@ -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

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ecfa1fec/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
index 8cb54f7..f464251 100644
--- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
+++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/management/impl/JMSServerControlImpl.java
@@ -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
@@ -810,6 +821,42 @@ public class JMSServerControlImpl extends AbstractControl implements
JMSServerCo
    }
 
    @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);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ecfa1fec/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
index c2ee227..992b20b 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/server/management/JMSServerControlUsingJMSTest.java
@@ -243,6 +243,11 @@ public class JMSServerControlUsingJMSTest extends JMSServerControlTest
{
          }
 
          @Override
+         public String getNodeID() {
+            return null;
+         }
+
+         @Override
          public String[] listConnectionIDs() throws Exception {
             return (String[]) proxy.invokeOperation("listConnectionIDs");
          }
@@ -308,6 +313,10 @@ public class JMSServerControlUsingJMSTest extends JMSServerControlTest
{
          }
 
          @Override
+         public String listNetworkTopology() throws Exception {
+            return null;
+         }
+         @Override
          public String listPreparedTransactionDetailsAsHTML() throws Exception {
             return (String) proxy.invokeOperation("listPreparedTransactionDetailsAsHTML");
          }


Mime
View raw message