[jboss-cvs] JBoss Messaging SVN: r5516 - in trunk: src/main/org/jboss/messaging/core/management and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 11 10:13:49 EST 2008
Author: jmesnil
Date: 2008-12-11 10:13:49 -0500 (Thu, 11 Dec 2008)
New Revision: 5516
Added:
trunk/src/main/org/jboss/messaging/core/management/BroadcastGroupConfigurationInfo.java
trunk/src/main/org/jboss/messaging/core/management/DiscoveryGroupConfigurationInfo.java
trunk/src/main/org/jboss/messaging/core/management/MessageFlowConfigurationInfo.java
trunk/src/main/org/jboss/messaging/core/management/PairsInfo.java
trunk/src/main/org/jboss/messaging/core/management/TransportConfigurationInfo.java
trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlTest.java
Modified:
trunk/src/main/org/jboss/messaging/core/config/cluster/MessageFlowConfiguration.java
trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java
trunk/src/main/org/jboss/messaging/core/management/PropertiesInfo.java
trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/ManagementServiceImplTest.java
Log:
added methods to MessagingControlMBean to get the configuration for the acceptors, connectors, message flow, discovery groups, and broadcast group
Modified: trunk/src/main/org/jboss/messaging/core/config/cluster/MessageFlowConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/cluster/MessageFlowConfiguration.java 2008-12-11 14:04:14 UTC (rev 5515)
+++ trunk/src/main/org/jboss/messaging/core/config/cluster/MessageFlowConfiguration.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -173,11 +173,6 @@
return this.discoveryGroupName;
}
- public List<Pair<String, String>> getStaticConnectorNamePairs()
- {
- return staticConnectorNamePairs;
- }
-
public long getRetryInterval()
{
return retryInterval;
Added: trunk/src/main/org/jboss/messaging/core/management/BroadcastGroupConfigurationInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/BroadcastGroupConfigurationInfo.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/BroadcastGroupConfigurationInfo.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -0,0 +1,185 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.management;
+
+import static javax.management.openmbean.SimpleType.INTEGER;
+import static javax.management.openmbean.SimpleType.LONG;
+import static javax.management.openmbean.SimpleType.STRING;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+import org.jboss.messaging.core.config.cluster.BroadcastGroupConfiguration;
+import org.jboss.messaging.util.Pair;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class BroadcastGroupConfigurationInfo
+{
+ // Constants -----------------------------------------------------
+
+ public static final CompositeType TYPE;
+
+ private static final String MESSAGE_TYPE_NAME = "BroadcastGroupConfigurationInfo";
+
+ private static final String MESSAGE_TABULAR_TYPE_NAME = "BroadcastGroupConfigurationTabularInfo";
+
+ private static final String[] ITEM_NAMES = new String[] { "name",
+ "localBindAddress",
+ "localBindPort",
+ "groupAddress",
+ "groupPort",
+ "broadcastPeriod",
+ "connectorInfos" };
+
+ private static final String[] ITEM_DESCRIPTIONS = new String[] { "Name of the broadcast group",
+ "Address of local bind",
+ "port of local bind",
+ "Address of the broadcast group",
+ "Port of the broadcast group",
+ "Period of broadcast",
+ "Name of the connectors" };
+
+ private static final OpenType[] TYPES;
+
+ private static final TabularType TABULAR_TYPE;
+
+ static
+ {
+ try
+ {
+ TYPES = new OpenType[] { STRING, STRING, INTEGER, STRING, INTEGER, LONG, PairsInfo.TABULAR_TYPE };
+ TYPE = new CompositeType(MESSAGE_TYPE_NAME,
+ "Information for a BroadcastGroupConfigurationInfo",
+ ITEM_NAMES,
+ ITEM_DESCRIPTIONS,
+ TYPES);
+ TABULAR_TYPE = new TabularType(MESSAGE_TABULAR_TYPE_NAME,
+ "Information for tabular BroadcastGroupConfigurationInfo",
+ TYPE,
+ new String[] { "name" });
+ }
+ catch (OpenDataException e)
+ {
+ e.printStackTrace();
+ throw new IllegalStateException(e);
+ }
+ }
+
+ // Attributes ----------------------------------------------------
+
+ private final BroadcastGroupConfiguration config;
+
+ // Static --------------------------------------------------------
+
+ public static TabularData toTabularData(final Collection<BroadcastGroupConfiguration> configs) throws OpenDataException
+ {
+ TabularData data = new TabularDataSupport(TABULAR_TYPE);
+ for (BroadcastGroupConfiguration config : configs)
+ {
+ data.put(new BroadcastGroupConfigurationInfo(config).toCompositeData());
+ }
+ return data;
+ }
+
+ public static BroadcastGroupConfiguration[] from(TabularData msgs)
+ {
+ Collection values = msgs.values();
+ List<BroadcastGroupConfiguration> infos = new ArrayList<BroadcastGroupConfiguration>();
+ for (Object object : values)
+ {
+ CompositeData compositeData = (CompositeData)object;
+ String name = (String)compositeData.get("name");
+ String localBindAddress = (String)compositeData.get("localBindAddress");
+ int localBindPort = (Integer)compositeData.get("localBindPort");
+ String groupAddress = (String)compositeData.get("groupAddress");
+ int groupPort = (Integer)compositeData.get("groupPort");
+ long broadcastPeriod = (Long)compositeData.get("broadcastPeriod");
+
+ TabularData connectorData = (TabularData)compositeData.get("connectorInfos");
+ List<Pair<String, String>> connectorInfos = PairsInfo.from(connectorData);
+ if (connectorInfos.size() == 0)
+ {
+ connectorInfos = null;
+ }
+
+ infos.add(new BroadcastGroupConfiguration(name,
+ localBindAddress,
+ localBindPort,
+ groupAddress,
+ groupPort,
+ broadcastPeriod,
+ connectorInfos));
+ }
+
+ return (BroadcastGroupConfiguration[])infos.toArray(new BroadcastGroupConfiguration[infos.size()]);
+ }
+
+ // Constructors --------------------------------------------------
+
+ public BroadcastGroupConfigurationInfo(final BroadcastGroupConfiguration config)
+ {
+ this.config = config;
+ }
+
+ // Public --------------------------------------------------------
+
+ public CompositeData toCompositeData()
+ {
+ try
+ {
+ return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] { config.getName(),
+ config.getLocalBindAddress(),
+ config.getLocalBindPort(),
+ config.getGroupAddress(),
+ config.getGroupPort(),
+ config.getBroadcastPeriod(),
+ PairsInfo.toTabularData(config.getConnectorInfos()) });
+ }
+ catch (OpenDataException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "BroadcastGroupConfigurationInfo[config=" + config.toString() + "]";
+ }
+}
Added: trunk/src/main/org/jboss/messaging/core/management/DiscoveryGroupConfigurationInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/DiscoveryGroupConfigurationInfo.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/DiscoveryGroupConfigurationInfo.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.management;
+
+import static javax.management.openmbean.SimpleType.INTEGER;
+import static javax.management.openmbean.SimpleType.LONG;
+import static javax.management.openmbean.SimpleType.STRING;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+import org.jboss.messaging.core.config.cluster.DiscoveryGroupConfiguration;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class DiscoveryGroupConfigurationInfo
+{
+ // Constants -----------------------------------------------------
+
+ public static final CompositeType TYPE;
+
+ private static final String MESSAGE_TYPE_NAME = "DiscoveryGroupConfigurationInfo";
+
+ private static final String MESSAGE_TABULAR_TYPE_NAME = "DiscoveryGroupConfigurationTabularInfo";
+
+ private static final String[] ITEM_NAMES = new String[] { "name", "groupAddress", "groupPort", "refreshTimeout" };
+
+ private static final String[] ITEM_DESCRIPTIONS = new String[] { "Name of the discovery group",
+ "Address of the discovery group",
+ "Port of the discovery group",
+ "Timeout to refresh" };
+
+ private static final OpenType[] TYPES;
+
+ private static final TabularType TABULAR_TYPE;
+
+ static
+ {
+ try
+ {
+ TYPES = new OpenType[] { STRING, STRING, INTEGER, LONG };
+ TYPE = new CompositeType(MESSAGE_TYPE_NAME,
+ "Information for a DiscoveryGroupConfiguration",
+ ITEM_NAMES,
+ ITEM_DESCRIPTIONS,
+ TYPES);
+ TABULAR_TYPE = new TabularType(MESSAGE_TABULAR_TYPE_NAME,
+ "Information for tabular DiscoveryGroupConfiguration",
+ TYPE,
+ new String[] { "name" });
+ }
+ catch (OpenDataException e)
+ {
+ e.printStackTrace();
+ throw new IllegalStateException(e);
+ }
+ }
+
+ // Attributes ----------------------------------------------------
+
+ private final DiscoveryGroupConfiguration config;
+
+ // Static --------------------------------------------------------
+
+ public static TabularData toTabularData(final Collection<DiscoveryGroupConfiguration> configs) throws OpenDataException
+ {
+ TabularData data = new TabularDataSupport(TABULAR_TYPE);
+ for (DiscoveryGroupConfiguration config : configs)
+ {
+ data.put(new DiscoveryGroupConfigurationInfo(config).toCompositeData());
+ }
+ return data;
+ }
+
+ public static DiscoveryGroupConfiguration[] from(TabularData msgs)
+ {
+ Collection values = msgs.values();
+ List<DiscoveryGroupConfiguration> infos = new ArrayList<DiscoveryGroupConfiguration>();
+ for (Object object : values)
+ {
+ CompositeData compositeData = (CompositeData)object;
+ String name = (String)compositeData.get("name");
+ String groupAddress = (String)compositeData.get("groupAddress");
+ int groupPort = (Integer)compositeData.get("groupPort");
+ long refreshTimeout = (Long)compositeData.get("refreshTimeout");
+
+ infos.add(new DiscoveryGroupConfiguration(name, groupAddress, groupPort, refreshTimeout));
+ }
+
+ return (DiscoveryGroupConfiguration[])infos.toArray(new DiscoveryGroupConfiguration[infos.size()]);
+ }
+
+ // Constructors --------------------------------------------------
+
+ public DiscoveryGroupConfigurationInfo(final DiscoveryGroupConfiguration config)
+ {
+ this.config = config;
+ }
+
+ // Public --------------------------------------------------------
+
+ public CompositeData toCompositeData()
+ {
+ try
+ {
+ return new CompositeDataSupport(TYPE, ITEM_NAMES, new Object[] { config.getName(),
+ config.getGroupAddress(),
+ config.getGroupPort(),
+ config.getRefreshTimeout() });
+ }
+ catch (OpenDataException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "DiscoveryGroupConfiguration[config=" + config.toString() + "]";
+ }
+}
Modified: trunk/src/main/org/jboss/messaging/core/management/ManagementService.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2008-12-11 14:04:14 UTC (rev 5515)
+++ trunk/src/main/org/jboss/messaging/core/management/ManagementService.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -36,6 +36,7 @@
import org.jboss.messaging.core.security.Role;
import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.cluster.ClusterManager;
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.core.transaction.ResourceManager;
Added: trunk/src/main/org/jboss/messaging/core/management/MessageFlowConfigurationInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/MessageFlowConfigurationInfo.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/MessageFlowConfigurationInfo.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -0,0 +1,256 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.management;
+
+import static javax.management.openmbean.SimpleType.BOOLEAN;
+import static javax.management.openmbean.SimpleType.DOUBLE;
+import static javax.management.openmbean.SimpleType.INTEGER;
+import static javax.management.openmbean.SimpleType.LONG;
+import static javax.management.openmbean.SimpleType.STRING;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+import org.jboss.messaging.core.config.cluster.MessageFlowConfiguration;
+import org.jboss.messaging.util.Pair;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class MessageFlowConfigurationInfo
+{
+ // Constants -----------------------------------------------------
+
+ public static final CompositeType TYPE;
+
+ private static final String MESSAGE_TYPE_NAME = "MessageFlowConfigurationInfo";
+
+ private static final String MESSAGE_TABULAR_TYPE_NAME = "MessageFlowConfigurationTabularInfo";
+
+ private static final String[] ITEM_NAMES = new String[] { "name",
+ "address",
+ "filter",
+ "fanout",
+ "maxBatchSize",
+ "maxBatchTime",
+ "transformerClassName",
+ "retryInterval",
+ "retryIntervalMultiplier",
+ "maxRetriesBeforeFailover",
+ "maxRetriesAfterFailover",
+ "useDuplicateDetection",
+ "discoveryGroupName",
+ "staticConnectorNamePairs" };
+
+ private static final String[] ITEM_DESCRIPTIONS = new String[] { "Name",
+ "Address",
+ "Filter",
+ "Does the flow fanout messages?",
+ "Maximum size of a batch",
+ "Maximum time before sending a batch",
+ "Name of the Transformer class",
+ "Interval to retry",
+ "Multiplier of the interval to retry",
+ "Maximum number of retries before a failover",
+ "Maximum number of retries after a failover",
+ "Use duplicate detection?",
+ "Name of the discovery group",
+ "Static pairs of connectors" };
+
+ private static final OpenType[] TYPES;
+
+ private static final TabularType TABULAR_TYPE;
+
+ static
+ {
+ try
+ {
+ TYPES = new OpenType[] { STRING,
+ STRING,
+ STRING,
+ BOOLEAN,
+ INTEGER,
+ LONG,
+ STRING,
+ LONG,
+ DOUBLE,
+ INTEGER,
+ INTEGER,
+ BOOLEAN,
+ STRING,
+ PairsInfo.TABULAR_TYPE };
+ TYPE = new CompositeType(MESSAGE_TYPE_NAME,
+ "Information for a MessageFlowConfiguration",
+ ITEM_NAMES,
+ ITEM_DESCRIPTIONS,
+ TYPES);
+ TABULAR_TYPE = new TabularType(MESSAGE_TABULAR_TYPE_NAME,
+ "Information for tabular MessageFlowConfiguration",
+ TYPE,
+ new String[] { "name" });
+ }
+ catch (OpenDataException e)
+ {
+ e.printStackTrace();
+ throw new IllegalStateException(e);
+ }
+ }
+
+ // Attributes ----------------------------------------------------
+
+ private MessageFlowConfiguration config;
+
+ // Static --------------------------------------------------------
+
+ public static TabularData toTabularData(final Collection<MessageFlowConfiguration> configs) throws OpenDataException
+ {
+ TabularData data = new TabularDataSupport(TABULAR_TYPE);
+
+ for (MessageFlowConfiguration config : configs)
+ {
+ data.put(new MessageFlowConfigurationInfo(config).toCompositeData());
+ }
+ return data;
+ }
+
+ public static MessageFlowConfiguration[] from(TabularData msgs)
+ {
+ Collection values = msgs.values();
+ List<MessageFlowConfiguration> infos = new ArrayList<MessageFlowConfiguration>();
+ for (Object object : values)
+ {
+ CompositeData compositeData = (CompositeData)object;
+ String name = (String)compositeData.get("name");
+ String address = (String)compositeData.get("address");
+ String filter = (String)compositeData.get("filter");
+ boolean fanout = (Boolean)compositeData.get("fanout");
+ int maxBatchSize = (Integer)compositeData.get("maxBatchSize");
+ long maxBatchTime = (Long)compositeData.get("maxBatchTime");
+ String transformerClassName = (String)compositeData.get("transformerClassName");
+ long retryInterval = (Long)compositeData.get("retryInterval");
+ double retryIntervalMultiplier = (Double)compositeData.get("retryIntervalMultiplier");
+ int maxRetriesBeforeFailover = (Integer)compositeData.get("maxRetriesBeforeFailover");
+ int maxRetriesAfterFailover = (Integer)compositeData.get("maxRetriesAfterFailover");
+ boolean useDuplicateDetection = (Boolean)compositeData.get("useDuplicateDetection");
+ String discoveryGroupName = (String)compositeData.get("discoveryGroupName");
+
+ TabularData connectorData = (TabularData)compositeData.get("staticConnectorNamePairs");
+ List<Pair<String, String>> connectorInfos = PairsInfo.from(connectorData);
+ if (connectorInfos.size() == 0)
+ {
+ connectorInfos = null;
+ }
+
+ if (connectorInfos == null)
+ {
+ infos.add(new MessageFlowConfiguration(name,
+ address,
+ filter,
+ fanout,
+ maxBatchSize,
+ maxBatchTime,
+ transformerClassName,
+ retryInterval,
+ retryIntervalMultiplier,
+ maxRetriesBeforeFailover,
+ maxRetriesAfterFailover,
+ useDuplicateDetection,
+ discoveryGroupName));
+ }
+ else
+ {
+ infos.add(new MessageFlowConfiguration(name,
+ address,
+ filter,
+ fanout,
+ maxBatchSize,
+ maxBatchTime,
+ transformerClassName,
+ retryInterval,
+ retryIntervalMultiplier,
+ maxRetriesBeforeFailover,
+ maxRetriesAfterFailover,
+ useDuplicateDetection,
+ connectorInfos));
+ }
+ }
+
+ return (MessageFlowConfiguration[])infos.toArray(new MessageFlowConfiguration[infos.size()]);
+ }
+
+ // Constructors --------------------------------------------------
+
+ public MessageFlowConfigurationInfo(MessageFlowConfiguration config)
+ {
+ this.config = config;
+ }
+
+ // Public --------------------------------------------------------
+
+ public CompositeData toCompositeData()
+ {
+ try
+ {
+ return new CompositeDataSupport(TYPE,
+ ITEM_NAMES,
+ new Object[] { config.getName(),
+ config.getAddress(),
+ config.getFilterString(),
+ config.isFanout(),
+ config.getMaxBatchSize(),
+ config.getMaxBatchTime(),
+ config.getTransformerClassName(),
+ config.getRetryInterval(),
+ config.getRetryIntervalMultiplier(),
+ config.getMaxRetriesBeforeFailover(),
+ config.getMaxRetriesAfterFailover(),
+ config.isUseDuplicateDetection(),
+ config.getDiscoveryGroupName(),
+ PairsInfo.toTabularData(config.getConnectorNamePairs()) });
+ }
+ catch (OpenDataException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "MessageInfo[config=" + config.toString() + "]";
+ }
+}
Modified: trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java 2008-12-11 14:04:14 UTC (rev 5515)
+++ trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -28,6 +28,8 @@
import java.util.List;
import java.util.Map;
+import javax.management.openmbean.TabularData;
+
import org.jboss.messaging.core.config.Configuration;
/**
@@ -165,5 +167,14 @@
@Operation(desc = "List the sessions for the given connectionID", impact = INFO)
String[] listSessions(@Parameter(desc = "a connection ID", name = "connectionID") String connectionID);
+
+ TabularData getMessageFlows() throws Exception;
+ TabularData getDiscoveryGroups() throws Exception;
+
+ TabularData getBroadcastGroups() throws Exception;
+
+ TabularData getAcceptors() throws Exception;
+
+ TabularData getConnectors() throws Exception;
}
Added: trunk/src/main/org/jboss/messaging/core/management/PairsInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/PairsInfo.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/PairsInfo.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.management;
+
+import static javax.management.openmbean.SimpleType.STRING;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+import org.jboss.messaging.util.Pair;
+
+/**
+ * Info for a Message property.
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class PairsInfo
+{
+ // Constants -----------------------------------------------------
+
+ public static final TabularType TABULAR_TYPE;
+
+ private static CompositeType ROW_TYPE;
+
+ static
+ {
+ try
+ {
+ ROW_TYPE = new CompositeType("Pair",
+ "Pair",
+ new String[] { "a", "b" },
+ new String[] { "First item of the pair", "Second item of the pair" },
+ new OpenType[] { STRING, STRING });
+ TABULAR_TYPE = new TabularType("PairInfo", "Pair", ROW_TYPE, new String[] { "a" });
+ }
+ catch (OpenDataException e)
+ {
+ e.printStackTrace();
+ throw new IllegalStateException(e);
+ }
+ }
+
+ public static List<Pair<String, String>> from(TabularData connectorInfos)
+ {
+ List<Pair<String, String>> pairs = new ArrayList<Pair<String, String>>();
+ Collection values = connectorInfos.values();
+ for (Object object : values)
+ {
+ CompositeData compositeData = (CompositeData)object;
+ pairs.add(new Pair<String, String>((String)compositeData.get("a"), (String)compositeData.get("b")));
+ }
+ return pairs;
+ }
+
+ public static TabularData toTabularData(List<Pair<String, String>> pairs)
+ {
+ PairsInfo info = new PairsInfo(pairs);
+ return info.toTabularData();
+ }
+
+ // Attributes ----------------------------------------------------
+
+ private final List<Pair<String, String>> pairs = new ArrayList<Pair<String, String>>();
+
+ // Private -------------------------------------------------------
+
+ private PairsInfo(List<Pair<String, String>> pairs)
+ {
+ if (pairs != null)
+ {
+ for (Pair<String, String> pair : pairs)
+ {
+ this.pairs.add(pair);
+ }
+ }
+ }
+
+ private TabularData toTabularData()
+ {
+ try
+ {
+ TabularDataSupport data = new TabularDataSupport(TABULAR_TYPE);
+ for (Pair<String, String> pair : pairs)
+ {
+ data.put(new CompositeDataSupport(ROW_TYPE, new String[] { "a", "b" }, new Object[] { pair.a, pair.b }));
+ }
+ return data;
+ }
+ catch (OpenDataException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+}
\ No newline at end of file
Modified: trunk/src/main/org/jboss/messaging/core/management/PropertiesInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/PropertiesInfo.java 2008-12-11 14:04:14 UTC (rev 5515)
+++ trunk/src/main/org/jboss/messaging/core/management/PropertiesInfo.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -24,10 +24,14 @@
import static javax.management.openmbean.SimpleType.STRING;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.CompositeType;
import javax.management.openmbean.OpenDataException;
@@ -36,6 +40,8 @@
import javax.management.openmbean.TabularDataSupport;
import javax.management.openmbean.TabularType;
+import org.jboss.messaging.core.config.cluster.BroadcastGroupConfiguration;
+
/**
* Info for a Message property.
*
@@ -67,6 +73,18 @@
}
}
+ public static PropertiesInfo from(TabularData connectorInfos)
+ {
+ PropertiesInfo info = new PropertiesInfo();
+ Collection values = connectorInfos.values();
+ for (Object object : values)
+ {
+ CompositeData compositeData = (CompositeData)object;
+ info.put((String)compositeData.get("key"), (String)compositeData.get("value"));
+ }
+ return info;
+ }
+
// Attributes ----------------------------------------------------
private final Map<String, String> properties = new HashMap<String, String>();
@@ -104,4 +122,14 @@
return null;
}
}
+
+ public static TabularData toTabularData(Map<String, Object> params)
+ {
+ PropertiesInfo info = new PropertiesInfo();
+ for (Entry<String, Object> entry : params.entrySet())
+ {
+ info.put(entry.getKey(), entry.getValue().toString());
+ }
+ return info.toTabularData();
+ }
}
\ No newline at end of file
Added: trunk/src/main/org/jboss/messaging/core/management/TransportConfigurationInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/TransportConfigurationInfo.java (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/management/TransportConfigurationInfo.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.core.management;
+
+import static javax.management.openmbean.SimpleType.STRING;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+import javax.management.openmbean.TabularType;
+
+import org.jboss.messaging.core.config.TransportConfiguration;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class TransportConfigurationInfo
+{
+ // Constants -----------------------------------------------------
+
+ public static final CompositeType TYPE;
+
+ private static final String MESSAGE_TYPE_NAME = "TransportConfigurationInfo";
+
+ private static final String MESSAGE_TABULAR_TYPE_NAME = "TransportConfigurationTabularInfo";
+
+ private static final String[] ITEM_NAMES = new String[] { "name", "factoryClassName", "parameters" };
+
+ private static final String[] ITEM_DESCRIPTIONS = new String[] { "Name of the connector",
+ "Name of the Transport factory class",
+ "Parameters" };
+
+ private static final OpenType[] TYPES;
+
+ private static final TabularType TABULAR_TYPE;
+
+ static
+ {
+ try
+ {
+ TYPES = new OpenType[] { STRING, STRING, PropertiesInfo.TABULAR_TYPE };
+ TYPE = new CompositeType(MESSAGE_TYPE_NAME,
+ "Information for a TransportConfigurationInfo",
+ ITEM_NAMES,
+ ITEM_DESCRIPTIONS,
+ TYPES);
+ TABULAR_TYPE = new TabularType(MESSAGE_TABULAR_TYPE_NAME,
+ "Information for tabular TransportConfigurationInfo",
+ TYPE,
+ new String[] { "name", "factoryClassName" });
+ }
+ catch (OpenDataException e)
+ {
+ e.printStackTrace();
+ throw new IllegalStateException(e);
+ }
+ }
+
+ // Attributes ----------------------------------------------------
+
+ private final TransportConfiguration config;
+
+ // Static --------------------------------------------------------
+
+ public static TabularData toTabularData(final Collection<TransportConfiguration> configs) throws OpenDataException
+ {
+ TabularData data = new TabularDataSupport(TABULAR_TYPE);
+ for (TransportConfiguration config : configs)
+ {
+ data.put(new TransportConfigurationInfo(config).toCompositeData());
+ }
+ return data;
+ }
+
+ public static TransportConfiguration[] from(TabularData msgs)
+ {
+ Collection values = msgs.values();
+ List<TransportConfiguration> infos = new ArrayList<TransportConfiguration>();
+ for (Object object : values)
+ {
+ CompositeData compositeData = (CompositeData)object;
+ String name = (String)compositeData.get("name");
+ String factoryClassName = (String)compositeData.get("factoryClassName");
+
+ TabularData connectorData = (TabularData)compositeData.get("parameters");
+ PropertiesInfo params = PropertiesInfo.from(connectorData);
+
+ Map<String, Object> p = new HashMap<String, Object>(params.entries());
+ infos.add(new TransportConfiguration(factoryClassName, p, name));
+ }
+
+ return (TransportConfiguration[])infos.toArray(new TransportConfiguration[infos.size()]);
+ }
+
+ // Constructors --------------------------------------------------
+
+ public TransportConfigurationInfo(final TransportConfiguration config)
+ {
+ this.config = config;
+ }
+
+ // Public --------------------------------------------------------
+
+ public CompositeData toCompositeData()
+ {
+ try
+ {
+ return new CompositeDataSupport(TYPE,
+ ITEM_NAMES,
+ new Object[] { config.getName(),
+ config.getFactoryClassName(),
+ PropertiesInfo.toTabularData(config.getParams()) });
+ }
+ catch (OpenDataException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return "BroadcastGroupConfigurationInfo[config=" + config.toString() + "]";
+ }
+}
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java 2008-12-11 14:04:14 UTC (rev 5515)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -24,6 +24,7 @@
import java.text.DateFormat;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
@@ -39,15 +40,23 @@
import javax.management.NotificationEmitter;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
+import javax.management.openmbean.TabularData;
import javax.transaction.xa.Xid;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.config.cluster.BroadcastGroupConfiguration;
+import org.jboss.messaging.core.config.cluster.DiscoveryGroupConfiguration;
+import org.jboss.messaging.core.config.cluster.MessageFlowConfiguration;
import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.filter.Filter;
import org.jboss.messaging.core.filter.impl.FilterImpl;
+import org.jboss.messaging.core.management.BroadcastGroupConfigurationInfo;
+import org.jboss.messaging.core.management.DiscoveryGroupConfigurationInfo;
+import org.jboss.messaging.core.management.MessageFlowConfigurationInfo;
import org.jboss.messaging.core.management.MessagingServerControlMBean;
import org.jboss.messaging.core.management.NotificationType;
+import org.jboss.messaging.core.management.TransportConfigurationInfo;
import org.jboss.messaging.core.messagecounter.MessageCounterManager;
import org.jboss.messaging.core.persistence.StorageManager;
import org.jboss.messaging.core.postoffice.Binding;
@@ -58,6 +67,7 @@
import org.jboss.messaging.core.server.MessagingServer;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.ServerSession;
+import org.jboss.messaging.core.server.cluster.ClusterManager;
import org.jboss.messaging.core.server.impl.ServerSessionImpl;
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.QueueSettings;
@@ -545,7 +555,37 @@
}
return sessionIDs;
}
+
+ public TabularData getMessageFlows() throws Exception
+ {
+ Set<MessageFlowConfiguration> messageFlowConfigurations = configuration.getMessageFlowConfigurations();
+ return MessageFlowConfigurationInfo.toTabularData(messageFlowConfigurations);
+ }
+
+ public TabularData getDiscoveryGroups() throws Exception
+ {
+ Collection<DiscoveryGroupConfiguration> discoveryGroupConfigurations = configuration.getDiscoveryGroupConfigurations().values();
+ return DiscoveryGroupConfigurationInfo.toTabularData(discoveryGroupConfigurations);
+ }
+
+ public TabularData getBroadcastGroups() throws Exception
+ {
+ Set<BroadcastGroupConfiguration> broadcastGroupConfigurations = configuration.getBroadcastGroupConfigurations();
+ return BroadcastGroupConfigurationInfo.toTabularData(broadcastGroupConfigurations);
+ }
+ public TabularData getAcceptors() throws Exception
+ {
+ Set<TransportConfiguration> acceptorConfigurations = configuration.getAcceptorConfigurations();
+ return TransportConfigurationInfo.toTabularData(acceptorConfigurations);
+ }
+
+ public TabularData getConnectors() throws Exception
+ {
+ Collection<TransportConfiguration> connectorConfigurations = configuration.getConnectorConfigurations().values();
+ return TransportConfigurationInfo.toTabularData(connectorConfigurations);
+ }
+
// NotificationEmitter implementation ----------------------------
public void removeNotificationListener(final NotificationListener listener,
Modified: trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java 2008-12-11 14:04:14 UTC (rev 5515)
+++ trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -27,6 +27,7 @@
import javax.management.MBeanInfo;
import javax.management.ObjectName;
+import javax.management.openmbean.TabularData;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.management.MessagingServerControlMBean;
@@ -238,6 +239,31 @@
return localControl.listSessions(connectionID);
}
+ public TabularData getMessageFlows() throws Exception
+ {
+ return localControl.getMessageFlows();
+ }
+
+ public TabularData getDiscoveryGroups() throws Exception
+ {
+ return localControl.getDiscoveryGroups();
+ }
+
+ public TabularData getBroadcastGroups() throws Exception
+ {
+ return localControl.getBroadcastGroups();
+ }
+
+ public TabularData getAcceptors() throws Exception
+ {
+ return localControl.getAcceptors();
+ }
+
+ public TabularData getConnectors() throws Exception
+ {
+ return localControl.getConnectors();
+ }
+
public boolean addAddress(String address) throws Exception
{
return (Boolean)replicationAwareInvoke("addAddress", address);
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-12-11 14:04:14 UTC (rev 5515)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -241,14 +241,6 @@
securityRepository.setDefault(new HashSet<Role>());
securityStore.setSecurityRepository(securityRepository);
securityStore.setSecurityManager(securityManager);
- serverManagement = managementService.registerServer(postOffice,
- storageManager,
- configuration,
- queueSettingsRepository,
- securityRepository,
- resourceManager,
- remotingService,
- this);
postOffice.start();
@@ -303,7 +295,17 @@
clusterManager.start();
}
+
+ serverManagement = managementService.registerServer(postOffice,
+ storageManager,
+ configuration,
+ queueSettingsRepository,
+ securityRepository,
+ resourceManager,
+ remotingService,
+ this);
+
log.info("Started messaging server");
started = true;
Added: trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlTest.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -0,0 +1,301 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.integration.management;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomDouble;
+import static org.jboss.messaging.tests.util.RandomUtil.randomPositiveInt;
+import static org.jboss.messaging.tests.util.RandomUtil.randomPositiveLong;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.openmbean.TabularData;
+
+import junit.framework.TestCase;
+
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.config.cluster.BroadcastGroupConfiguration;
+import org.jboss.messaging.core.config.cluster.DiscoveryGroupConfiguration;
+import org.jboss.messaging.core.config.cluster.MessageFlowConfiguration;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.management.BroadcastGroupConfigurationInfo;
+import org.jboss.messaging.core.management.DiscoveryGroupConfigurationInfo;
+import org.jboss.messaging.core.management.MessageFlowConfigurationInfo;
+import org.jboss.messaging.core.management.MessagingServerControlMBean;
+import org.jboss.messaging.core.management.TransportConfigurationInfo;
+import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
+import org.jboss.messaging.core.remoting.impl.invm.InVMAcceptorFactory;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
+import org.jboss.messaging.core.server.MessagingService;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
+import org.jboss.messaging.util.Pair;
+
+/**
+ * A QueueControlTest
+ *
+ * @author jmesnil
+ *
+ * Created 26 nov. 2008 14:18:48
+ *
+ *
+ */
+public class MessagingServerControlTest extends TestCase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private MessagingService service;
+
+ // Static --------------------------------------------------------
+
+ private static MessagingServerControlMBean createServerControl() throws Exception
+ {
+ MessagingServerControlMBean control = (MessagingServerControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+ ManagementServiceImpl.getMessagingServerObjectName(),
+ MessagingServerControlMBean.class,
+ false);
+ return control;
+ }
+
+ public static MessageFlowConfiguration randomMessageFlowConfigurationWithStaticConnectors()
+ {
+ ArrayList<Pair<String, String>> connectorInfos = new ArrayList<Pair<String, String>>();
+ connectorInfos.add(randomPair());
+ connectorInfos.add(randomPair());
+
+ return new MessageFlowConfiguration(randomString(),
+ randomString(),
+ randomString(),
+ randomBoolean(),
+ randomPositiveInt(),
+ randomPositiveLong(),
+ randomString(),
+ randomPositiveLong(),
+ randomDouble(),
+ randomPositiveInt(),
+ randomPositiveInt(),
+ randomBoolean(),
+ connectorInfos);
+ }
+
+ public static MessageFlowConfiguration randomMessageFlowConfigurationWithDiscoveryGroup()
+ {
+ String discoveryGroupName = randomString();
+
+ return new MessageFlowConfiguration(randomString(),
+ randomString(),
+ randomString(),
+ randomBoolean(),
+ randomPositiveInt(),
+ randomPositiveLong(),
+ randomString(),
+ randomPositiveLong(),
+ randomDouble(),
+ randomPositiveInt(),
+ randomPositiveInt(),
+ randomBoolean(),
+ discoveryGroupName);
+ }
+
+ public static DiscoveryGroupConfiguration randomDiscoveryGroupConfiguration()
+ {
+ return new DiscoveryGroupConfiguration(randomString(), randomString(), randomPositiveInt(), randomPositiveLong());
+ }
+
+ public static BroadcastGroupConfiguration randomBroadcastGroupConfiguration()
+ {
+ ArrayList<Pair<String, String>> connectorInfos = new ArrayList<Pair<String, String>>();
+ connectorInfos.add(randomPair());
+ connectorInfos.add(randomPair());
+
+ return new BroadcastGroupConfiguration(randomString(),
+ randomString(),
+ randomPositiveInt(),
+ randomString(),
+ randomPositiveInt(),
+ randomPositiveLong(),
+ connectorInfos);
+ }
+
+ public static Pair<String, String> randomPair()
+ {
+ return new Pair<String, String>(randomString(), randomString());
+ }
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public void testGetMessageFlows() throws Exception
+ {
+ MessageFlowConfiguration flowConfig_1 = randomMessageFlowConfigurationWithDiscoveryGroup();
+ MessageFlowConfiguration flowConfig_2 = randomMessageFlowConfigurationWithStaticConnectors();
+
+ Configuration conf = new ConfigurationImpl();
+ conf.setSecurityEnabled(false);
+ conf.setJMXManagementEnabled(true);
+ conf.getMessageFlowConfigurations().add(flowConfig_1);
+ conf.getMessageFlowConfigurations().add(flowConfig_2);
+
+ service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+ service.start();
+
+ MessagingServerControlMBean serverControl = createServerControl();
+ TabularData messageFlowData = serverControl.getMessageFlows();
+ assertNotNull(messageFlowData);
+ assertEquals(2, messageFlowData.size());
+
+ MessageFlowConfiguration[] messageFlowConfigurations = MessageFlowConfigurationInfo.from(messageFlowData);
+ assertEquals(2, messageFlowConfigurations.length);
+ if (flowConfig_1.getName().equals(messageFlowConfigurations[0].getName()))
+ {
+ assertEquals(flowConfig_2.getName(), messageFlowConfigurations[1].getName());
+ }
+ else if (flowConfig_1.getName().equals(messageFlowConfigurations[1].getName()))
+ {
+ assertEquals(flowConfig_2.getName(), messageFlowConfigurations[0].getName());
+ }
+ else
+ {
+ fail("configuration is not identical");
+ }
+ }
+
+ public void testGetDiscoveryGroups() throws Exception
+ {
+ DiscoveryGroupConfiguration discoveryGroupConfig = randomDiscoveryGroupConfiguration();
+
+ Configuration conf = new ConfigurationImpl();
+ conf.setSecurityEnabled(false);
+ conf.setJMXManagementEnabled(true);
+ conf.getDiscoveryGroupConfigurations().put(discoveryGroupConfig.getName(), discoveryGroupConfig);
+ service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+ service.start();
+
+ MessagingServerControlMBean serverControl = createServerControl();
+ TabularData discoveryGroupData = serverControl.getDiscoveryGroups();
+ assertNotNull(discoveryGroupData);
+ assertEquals(1, discoveryGroupData.size());
+
+ DiscoveryGroupConfiguration[] discoveryGroupConfigurations = DiscoveryGroupConfigurationInfo.from(discoveryGroupData);
+ assertEquals(1, discoveryGroupConfigurations.length);
+ assertEquals(discoveryGroupConfig.getName(), discoveryGroupConfigurations[0].getName());
+ }
+
+ public void testGetBroadcastGroups() throws Exception
+ {
+ BroadcastGroupConfiguration broadcastGroupConfig = randomBroadcastGroupConfiguration();
+
+ Configuration conf = new ConfigurationImpl();
+ conf.setSecurityEnabled(false);
+ conf.setJMXManagementEnabled(true);
+ conf.getBroadcastGroupConfigurations().add(broadcastGroupConfig);
+ service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+ service.start();
+
+ MessagingServerControlMBean serverControl = createServerControl();
+ TabularData broadcastGroupData = serverControl.getBroadcastGroups();
+ assertNotNull(broadcastGroupData);
+ assertEquals(1, broadcastGroupData.size());
+
+ BroadcastGroupConfiguration[] broadcastGroupConfigurations = BroadcastGroupConfigurationInfo.from(broadcastGroupData);
+ assertEquals(1, broadcastGroupConfigurations.length);
+
+ assertEquals(broadcastGroupConfig.getName(), broadcastGroupConfigurations[0].getName());
+ }
+
+ public void testGetAcceptors() throws Exception
+ {
+ TransportConfiguration acceptorConfig = new TransportConfiguration(InVMAcceptorFactory.class.getName(),
+ new HashMap<String, Object>(),
+ randomString());
+
+ Configuration conf = new ConfigurationImpl();
+ conf.setSecurityEnabled(false);
+ conf.setJMXManagementEnabled(true);
+ conf.getAcceptorConfigurations().add(acceptorConfig);
+ service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+ service.start();
+
+ MessagingServerControlMBean serverControl = createServerControl();
+ TabularData acceptorData = serverControl.getAcceptors();
+ assertNotNull(acceptorData);
+ assertEquals(1, acceptorData.size());
+
+ TransportConfiguration[] acceptorConfigurations = TransportConfigurationInfo.from(acceptorData);
+ assertEquals(1, acceptorConfigurations.length);
+
+ assertEquals(acceptorConfig.getName(), acceptorConfigurations[0].getName());
+ }
+
+ public void testGetConnectors() throws Exception
+ {
+ TransportConfiguration connectorConfig = new TransportConfiguration(InVMConnectorFactory.class.getName(),
+ new HashMap<String, Object>(),
+ randomString());
+
+ Configuration conf = new ConfigurationImpl();
+ conf.setSecurityEnabled(false);
+ conf.setJMXManagementEnabled(true);
+ conf.getConnectorConfigurations().put(connectorConfig.getName(), connectorConfig);
+ service = MessagingServiceImpl.newNullStorageMessagingService(conf);
+ service.start();
+
+ MessagingServerControlMBean serverControl = createServerControl();
+ TabularData acceptorData = serverControl.getConnectors();
+ assertNotNull(acceptorData);
+ assertEquals(1, acceptorData.size());
+
+ TransportConfiguration[] connectorConfigurations = TransportConfigurationInfo.from(acceptorData);
+ assertEquals(1, connectorConfigurations.length);
+
+ assertEquals(connectorConfig.getName(), connectorConfigurations[0].getName());
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ if (service != null)
+ {
+ service.stop();
+ }
+
+ super.tearDown();
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/ManagementServiceImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/ManagementServiceImplTest.java 2008-12-11 14:04:14 UTC (rev 5515)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/management/impl/ManagementServiceImplTest.java 2008-12-11 15:13:49 UTC (rev 5516)
@@ -40,10 +40,7 @@
import junit.framework.TestCase;
import org.jboss.messaging.core.config.Configuration;
-import org.jboss.messaging.core.management.AddressControlMBean;
import org.jboss.messaging.core.management.ManagementService;
-import org.jboss.messaging.core.management.MessagingServerControlMBean;
-import org.jboss.messaging.core.management.QueueControlMBean;
import org.jboss.messaging.core.management.impl.AddressControl;
import org.jboss.messaging.core.management.impl.ManagementServiceImpl;
import org.jboss.messaging.core.management.impl.MessagingServerControl;
@@ -57,7 +54,6 @@
import org.jboss.messaging.core.settings.HierarchicalRepository;
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.core.transaction.ResourceManager;
-import org.jboss.messaging.tests.util.RandomUtil;
import org.jboss.messaging.util.SimpleString;
/**
More information about the jboss-cvs-commits
mailing list