Repository: activemq-artemis Updated Branches: refs/heads/ARTEMIS-780 a25a8c481 -> 219886931
added missing managament methods Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/d4a54afa Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/d4a54afa Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/d4a54afa Branch: refs/heads/ARTEMIS-780 Commit: d4a54afa568e18b5fd0e5b63c95c65418d264c84 Parents: dca82a6 Author: Andy Taylor <[email protected]> Authored: Mon Nov 14 12:26:29 2016 +0000 Committer: Andy Taylor <[email protected]> Committed: Tue Nov 15 10:47:04 2016 +0000 ---------------------------------------------------------------------- .../core/management/ActiveMQServerControl.java | 13 +++++- .../impl/ActiveMQServerControlImpl.java | 45 ++++++++++++++++++++ .../artemis/core/postoffice/PostOffice.java | 2 +- .../core/postoffice/impl/PostOfficeImpl.java | 10 ++--- .../artemis/core/server/ActiveMQServer.java | 2 +- .../core/server/impl/ActiveMQServerImpl.java | 5 +-- .../ActiveMQServerControlUsingCoreTest.java | 10 +++++ 7 files changed, 76 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d4a54afa/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java ---------------------------------------------------------------------- diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java index f10eb9b..7772459 100644 --- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java +++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.java @@ -297,6 +297,14 @@ public interface ActiveMQServerControl { String getManagementAddress(); /** + * Returns the node ID of this server. + * <br> + * Clients can send management messages to this address to manage this server. + */ + @Attribute(desc = "Node ID of this server") + String getNodeID(); + + /** * Returns the management notification address of this server. * <br> * Clients can bind queues to this address to receive management notifications emitted by this server. @@ -430,7 +438,7 @@ public interface ActiveMQServerControl { @Parameter(name = "defaultDeleteOnNoConsumers", desc = "Whether or not a queue with this address is deleted when it has no consumers") boolean defaultDeleteOnNoConsumers, @Parameter(name = "defaultMaxConsumers", desc = "The maximim number of consumer a queue with this address can have") int defaultMaxConsumers) throws Exception; - @Operation(desc = "create an address", impact = MBeanOperationInfo.ACTION) + @Operation(desc = "delete an address", impact = MBeanOperationInfo.ACTION) void deleteAddress(@Parameter(name = "name", desc = "The name of the address") String name) throws Exception; /** @@ -890,5 +898,8 @@ public interface ActiveMQServerControl { @Operation(desc = "force the server to stop and to scale down to another server", impact = MBeanOperationInfo.UNKNOWN) void scaleDown(@Parameter(name = "name", desc = "The connector to use to scale down, if not provided the first appropriate connector will be used") String connector) throws Exception; + + @Operation(desc = "List the Network Topology", impact = MBeanOperationInfo.INFO) + String listNetworkTopology() throws Exception; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d4a54afa/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java index 4f91317..a183187 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java @@ -50,6 +50,8 @@ import org.apache.activemq.artemis.api.core.management.BridgeControl; import org.apache.activemq.artemis.api.core.management.CoreNotificationType; import org.apache.activemq.artemis.api.core.management.DivertControl; import org.apache.activemq.artemis.api.core.management.QueueControl; +import org.apache.activemq.artemis.core.client.impl.Topology; +import org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl; import org.apache.activemq.artemis.core.config.BridgeConfiguration; import org.apache.activemq.artemis.core.config.Configuration; import org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration; @@ -75,6 +77,8 @@ import org.apache.activemq.artemis.core.server.JournalType; import org.apache.activemq.artemis.core.server.Queue; 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.core.server.cluster.ha.HAPolicy; import org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy; import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy; @@ -1975,6 +1979,42 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } + + @Override + public String listNetworkTopology() throws Exception { + checkStarted(); + + clearIO(); + try { + JsonArrayBuilder brokers = JsonLoader.createArrayBuilder(); + ClusterManager clusterManager = server.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) { + + JsonObjectBuilder obj = JsonLoader.createObjectBuilder(); + TransportConfiguration live = member.getLive(); + if (live != null) { + obj.add("nodeID", member.getNodeId()).add("live", live.getParams().get("host") + ":" + live.getParams().get("port")); + TransportConfiguration backup = member.getBackup(); + if (backup != null) { + obj.add("backup", backup.getParams().get("host") + ":" + backup.getParams().get("port")); + } + } + brokers.add(obj); + } + } + } + return brokers.build().toString(); + } finally { + blockOnIO(); + } + } + + // NotificationEmitter implementation ---------------------------- @Override @@ -2071,6 +2111,11 @@ public class ActiveMQServerControlImpl extends AbstractControl implements Active } @Override + public String getNodeID() { + return server.getNodeID().toString(); + } + + @Override public String getManagementNotificationAddress() { return configuration.getManagementNotificationAddress().toString(); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d4a54afa/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java index 0abd708..f1225c1 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/PostOffice.java @@ -46,7 +46,7 @@ public interface PostOffice extends ActiveMQComponent { AddressInfo addOrUpdateAddressInfo(AddressInfo addressInfo); - AddressInfo removeAddressInfo(SimpleString address); + AddressInfo removeAddressInfo(SimpleString address) throws Exception; AddressInfo getAddressInfo(SimpleString address); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d4a54afa/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java index 135597f..52abcdb 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java @@ -439,12 +439,12 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding } @Override - public AddressInfo removeAddressInfo(SimpleString address) { - try { - getServer().getManagementService().unregisterAddress(address); - } catch (Exception e) { - e.printStackTrace(); + public AddressInfo removeAddressInfo(SimpleString address) throws Exception { + Bindings bindingsForAddress = getBindingsForAddress(address); + if (bindingsForAddress.getBindings().size() > 0) { + throw new IllegalStateException("Address has bindings"); } + managementService.unregisterAddress(address); return addressManager.removeAddressInfo(address); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d4a54afa/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java index 89af2a1..5dc22d6 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServer.java @@ -445,7 +445,7 @@ public interface ActiveMQServer extends ActiveMQComponent { AddressInfo createOrUpdateAddressInfo(AddressInfo addressInfo) throws Exception; - AddressInfo removeAddressInfo(SimpleString address) throws Exception; + void removeAddressInfo(SimpleString address) throws Exception; String getInternalNamingPrefix(); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d4a54afa/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index d119891..28622a5 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -2263,15 +2263,14 @@ public class ActiveMQServerImpl implements ActiveMQServer { } @Override - public AddressInfo removeAddressInfo(SimpleString address) throws Exception { - AddressInfo result = postOffice.removeAddressInfo(address); + public void removeAddressInfo(SimpleString address) throws Exception { + postOffice.removeAddressInfo(address); // TODO: is this the right way to do this? // long txID = storageManager.generateID(); // storageManager.deleteAddressBinding(txID, getAddressInfo(address).getID()); // storageManager.commitBindings(txID); - return result; } @Override http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d4a54afa/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java ---------------------------------------------------------------------- diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java index b606261..ad36598 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ActiveMQServerControlUsingCoreTest.java @@ -279,6 +279,11 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes } @Override + public String getNodeID() { + return (String) proxy.retrieveAttributeValue("nodeID"); + } + + @Override public String getManagementAddress() { return (String) proxy.retrieveAttributeValue("managementAddress"); } @@ -622,6 +627,11 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes } @Override + public String listNetworkTopology() throws Exception { + return (String) proxy.invokeOperation("listNetworkTopology"); + } + + @Override public void removeAddressSettings(String addressMatch) throws Exception { proxy.invokeOperation("removeAddressSettings", addressMatch); }
