[jboss-cvs] JBoss Messaging SVN: r5471 - in trunk: src/main/org/jboss/messaging/jms/server/management and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 8 07:29:32 EST 2008
Author: jmesnil
Date: 2008-12-08 07:29:32 -0500 (Mon, 08 Dec 2008)
New Revision: 5471
Modified:
trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java
trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java
trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java
trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java
trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java
Log:
refactored management
replaced in JMSServerControlMBean.createConnectionFactory() operation the use of the DiscoveryGroupConfiguration by explicit group parameters (name, address, port, timeout) so that the method can be invoked from a JMX client and serialized properly when creating the corresponding core message (in ReplicationAwareJMSServerControlWrapper)
Modified: trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java 2008-12-08 04:59:34 UTC (rev 5470)
+++ trunk/src/main/org/jboss/messaging/core/client/management/impl/ManagementHelper.java 2008-12-08 12:29:32 UTC (rev 5471)
@@ -90,7 +90,7 @@
for (int i = 0; i < parameters.length; i++)
{
Object parameter = parameters[i];
- SimpleString key = new SimpleString(HDR_JMX_OPERATION_PREFIX + Integer.toString(i));
+ SimpleString key = new SimpleString(String.format("%s%02d", HDR_JMX_OPERATION_PREFIX, i));
storeTypedProperty(message, key, parameter);
}
}
@@ -179,7 +179,7 @@
}
else if (typedProperty instanceof Double)
{
- message.putDoubleProperty(key, (Character)typedProperty);
+ message.putDoubleProperty(key, (Double)typedProperty);
}
else if (typedProperty instanceof String)
{
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java 2008-12-08 04:59:34 UTC (rev 5470)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/ConnectionFactoryControlMBean.java 2008-12-08 12:29:32 UTC (rev 5471)
@@ -33,6 +33,8 @@
*/
public interface ConnectionFactoryControlMBean
{
+ String getName();
+
List<String> getBindings();
String getClientID();
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2008-12-08 04:59:34 UTC (rev 5470)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/JMSServerControlMBean.java 2008-12-08 12:29:32 UTC (rev 5471)
@@ -28,7 +28,6 @@
import java.util.List;
import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.cluster.DiscoveryGroupConfiguration;
import org.jboss.messaging.core.management.Operation;
import org.jboss.messaging.core.management.Parameter;
import org.jboss.messaging.util.Pair;
@@ -123,8 +122,14 @@
@Operation(desc = "Create a JMS ConnectionFactory specifying a discovery group to obtain list of servers from", impact = ACTION)
void createConnectionFactory(@Parameter(name = "name", desc = "Name of the ConnectionFactory to create")
String name,
- @Parameter(name = "discoveryGroupConfig", desc = "Discovery group configuration")
- DiscoveryGroupConfiguration discoveryGroupConfig,
+ @Parameter(name = "discoveryGroupName", desc = "Name of the Discovery group configuration")
+ String discoveryGroupName,
+ @Parameter(name = "discoveryGroupAddress", desc = "Address of the Discovery group")
+ String discoveryGroupAddress,
+ @Parameter(name = "discoveryGroupPort", desc = "port of the Discovery group")
+ int discoveryGroupPort,
+ @Parameter(name = "discoveryGroupRefreshTimeout", desc = "Refresh timeout of the discovery group")
+ long discoveryGroupRefreshTimeout,
@Parameter(name = "discoveryInitialWait", desc = "The amount of time in ms to wait for initial discovery information to arrive at first using connection factory")
long discoveryInitialWait,
@Parameter(name = "connectionLoadBalancingPolicyClassName", desc = "The name of the class to use for client side connection load-balancing")
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2008-12-08 04:59:34 UTC (rev 5470)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSServerControl.java 2008-12-08 12:29:32 UTC (rev 5471)
@@ -138,36 +138,41 @@
}
}
- public void createConnectionFactory(String name,
- DiscoveryGroupConfiguration discoveryGroupConfig,
- long discoveryInitialWait,
- String connectionLoadBalancingPolicyClassName,
- long pingPeriod,
- long connectionTTL,
- long callTimeout,
- String clientID,
- int dupsOKBatchSize,
- int transactionBatchSize,
- int consumerWindowSize,
- int consumerMaxRate,
- int producerWindowSize,
- int producerMaxRate,
- int minLargeMessageSize,
- boolean blockOnAcknowledge,
- boolean blockOnNonPersistentSend,
- boolean blockOnPersistentSend,
- boolean autoGroup,
- int maxConnections,
- boolean preAcknowledge,
+ public void createConnectionFactory(final String name,
+ final String discoveryGroupName,
+ final String discoveryGroupAddress,
+ final int discoveryGroupPort,
+ final long discoveryGroupRefreshTimeout,
+ final long discoveryInitialWait,
+ final String connectionLoadBalancingPolicyClassName,
+ final long pingPeriod,
+ final long connectionTTL,
+ final long callTimeout,
+ final String clientID,
+ final int dupsOKBatchSize,
+ final int transactionBatchSize,
+ final int consumerWindowSize,
+ final int consumerMaxRate,
+ final int producerWindowSize,
+ final int producerMaxRate,
+ final int minLargeMessageSize,
+ final boolean blockOnAcknowledge,
+ final boolean blockOnNonPersistentSend,
+ final boolean blockOnPersistentSend,
+ final boolean autoGroup,
+ final int maxConnections,
+ final boolean preAcknowledge,
final long retryInterval,
- final double retryIntervalMultiplier,
+ final double retryIntervalMultiplier,
final int maxRetriesBeforeFailover,
final int maxRetriesAfterFailover,
- String jndiBinding) throws Exception
- {
+ final String jndiBinding) throws Exception
+ {
List<String> bindings = new ArrayList<String>();
bindings.add(jndiBinding);
+ DiscoveryGroupConfiguration discoveryGroupConfig = new DiscoveryGroupConfiguration(discoveryGroupName, discoveryGroupAddress, discoveryGroupPort, discoveryGroupRefreshTimeout);
+
boolean created = server.createConnectionFactory(name,
discoveryGroupConfig,
discoveryInitialWait,
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java 2008-12-08 04:59:34 UTC (rev 5470)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareConnectionFactoryControlWrapper.java 2008-12-08 12:29:32 UTC (rev 5471)
@@ -59,6 +59,11 @@
// ConnectionFactoryControlMBean implementation ---------------------------
+ public String getName()
+ {
+ return localControl.getName();
+ }
+
public List<String> getBindings()
{
return localControl.getBindings();
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java 2008-12-08 04:59:34 UTC (rev 5470)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/jmx/impl/ReplicationAwareJMSServerControlWrapper.java 2008-12-08 12:29:32 UTC (rev 5471)
@@ -28,7 +28,6 @@
import javax.management.ObjectName;
import org.jboss.messaging.core.config.TransportConfiguration;
-import org.jboss.messaging.core.config.cluster.DiscoveryGroupConfiguration;
import org.jboss.messaging.core.management.impl.MBeanInfoHelper;
import org.jboss.messaging.core.management.jmx.impl.ReplicationAwareStandardMBeanWrapper;
import org.jboss.messaging.jms.server.management.JMSServerControlMBean;
@@ -123,7 +122,10 @@
}
public void createConnectionFactory(final String name,
- final DiscoveryGroupConfiguration discoveryGroupConfig,
+ final String discoveryGroupName,
+ final String discoveryGroupAddress,
+ final int discoveryGroupPort,
+ final long discoveryGroupRefreshTimeout,
final long discoveryInitialWait,
final String connectionLoadBalancingPolicyClassName,
final long pingPeriod,
@@ -149,10 +151,12 @@
final int maxRetriesAfterFailover,
final String jndiBinding) throws Exception
{
- // FIXME need to store correctly the connector configs
replicationAwareInvoke("createConnectionFactory",
name,
- discoveryGroupConfig,
+ discoveryGroupName,
+ discoveryGroupAddress,
+ discoveryGroupPort,
+ discoveryGroupRefreshTimeout,
discoveryInitialWait,
connectionLoadBalancingPolicyClassName,
pingPeriod,
Modified: trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java 2008-12-08 04:59:34 UTC (rev 5470)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/jms/management/JMSServerControlTest.java 2008-12-08 12:29:32 UTC (rev 5471)
@@ -29,13 +29,16 @@
import java.util.concurrent.TimeUnit;
import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
import javax.jms.ExceptionListener;
import javax.jms.JMSException;
import javax.jms.Session;
import javax.management.MBeanServerInvocationHandler;
+import javax.naming.InitialContext;
import junit.framework.TestCase;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
import org.jboss.messaging.core.config.Configuration;
import org.jboss.messaging.core.config.TransportConfiguration;
import org.jboss.messaging.core.config.impl.ConfigurationImpl;
@@ -48,8 +51,10 @@
import org.jboss.messaging.integration.transports.netty.NettyAcceptorFactory;
import org.jboss.messaging.integration.transports.netty.NettyConnectorFactory;
import org.jboss.messaging.jms.server.impl.JMSServerManagerImpl;
+import org.jboss.messaging.jms.server.management.ConnectionFactoryControlMBean;
import org.jboss.messaging.jms.server.management.JMSServerControlMBean;
import org.jboss.messaging.jms.server.management.impl.JMSManagementServiceImpl;
+import org.jboss.messaging.tests.util.RandomUtil;
/**
* A QueueControlTest
@@ -76,6 +81,15 @@
false);
return control;
}
+
+ private static ConnectionFactoryControlMBean createConnectionFactoryControl(String name) throws Exception
+ {
+ ConnectionFactoryControlMBean control = (ConnectionFactoryControlMBean)MBeanServerInvocationHandler.newProxyInstance(ManagementFactory.getPlatformMBeanServer(),
+ JMSManagementServiceImpl.getConnectionFactoryObjectName(name),
+ ConnectionFactoryControlMBean.class,
+ false);
+ return control;
+ }
private MessagingService startMessagingService(String acceptorFactory) throws Exception
{
@@ -83,6 +97,7 @@
conf.setSecurityEnabled(false);
conf.setJMXManagementEnabled(true);
conf.getAcceptorConfigurations().add(new TransportConfiguration(acceptorFactory));
+ conf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
MessagingService service = MessagingServiceImpl.newNullStorageMessagingServer(conf);
service.start();
@@ -92,7 +107,7 @@
return service;
}
-
+
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@@ -126,7 +141,7 @@
{
doCloseConnectionsForAddress(MinaAcceptorFactory.class.getName(), MinaConnectorFactory.class.getName());
}
-
+
public void testCloseConnectionsForUnknownAddressForInVM() throws Exception
{
doCloseConnectionsForUnknownAddress(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
@@ -141,7 +156,7 @@
{
doCloseConnectionsForUnknownAddress(MinaAcceptorFactory.class.getName(), MinaConnectorFactory.class.getName());
}
-
+
public void testListSessionsForInVM() throws Exception
{
doListSessions(InVMAcceptorFactory.class.getName(), InVMConnectorFactory.class.getName());
@@ -172,6 +187,66 @@
doListConnectionIDs(MinaAcceptorFactory.class.getName(), MinaConnectorFactory.class.getName());
}
+ public void testCreateConnectionFactoryWithDiscoveryGroup() throws Exception
+ {
+ String cfJNDIBinding = randomString();
+ String cfName = randomString();
+ MessagingService service = null;
+ try
+ {
+ service = startMessagingService(NettyAcceptorFactory.class.getName());
+
+ try {
+ ConnectionFactoryControlMBean cfControl = createConnectionFactoryControl(cfName);
+ // invoke an operation on the proxy to check that there is no such mbean
+ cfControl.getName();
+ fail("no CF was created with name " + cfName);
+ } catch (Exception e)
+ {
+ }
+ JMSServerControlMBean control = createJMSServerControl();
+ control.createConnectionFactory(cfName,
+ randomString(),
+ "localhost",
+ 8765,
+ ConfigurationImpl.DEFAULT_BROADCAST_REFRESH_TIMEOUT,
+ ClientSessionFactoryImpl.DEFAULT_DISCOVERY_INITIAL_WAIT,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ ClientSessionFactoryImpl.DEFAULT_PING_PERIOD,
+ ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL,
+ ClientSessionFactoryImpl.DEFAULT_CALL_TIMEOUT,
+ null,
+ ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_SEND_WINDOW_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE,
+ ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE,
+ ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
+ ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND,
+ ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP,
+ ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS,
+ ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL,
+ ClientSessionFactoryImpl.DEFAULT_RETRY_INTERVAL_MULTIPLIER,
+ ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
+ ClientSessionFactoryImpl.DEFAULT_MAX_RETRIES_AFTER_FAILOVER,
+ cfJNDIBinding);
+
+ ConnectionFactoryControlMBean cfControl = createConnectionFactoryControl(cfName);
+ assertEquals(cfName, cfControl.getName());
+ }
+ finally
+ {
+ if (service != null)
+ {
+ service.stop();
+ }
+ }
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@@ -186,13 +261,13 @@
service = startMessagingService(acceptorFactory);
JMSServerControlMBean control = createJMSServerControl();
-
+
assertEquals(0, control.listConnectionIDs().length);
Connection connection = JMSUtil.createConnection(connectorFactory);
connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- String[] connectionIDs = control.listConnectionIDs();
+
+ String[] connectionIDs = control.listConnectionIDs();
assertEquals(1, connectionIDs.length);
Connection connection2 = JMSUtil.createConnection(connectorFactory);
@@ -201,12 +276,12 @@
connection.close();
Thread.sleep(500);
-
+
assertEquals(1, control.listConnectionIDs().length);
connection2.close();
Thread.sleep(500);
-
+
assertEquals(0, control.listConnectionIDs().length);
}
finally
@@ -217,7 +292,7 @@
}
}
}
-
+
private void doListSessions(String acceptorFactory, String connectorFactory) throws Exception
{
MessagingService service = null;
@@ -226,13 +301,13 @@
service = startMessagingService(acceptorFactory);
JMSServerControlMBean control = createJMSServerControl();
-
+
assertEquals(0, control.listConnectionIDs().length);
Connection connection = JMSUtil.createConnection(connectorFactory);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- String[] connectionIDs = control.listConnectionIDs();
+
+ String[] connectionIDs = control.listConnectionIDs();
assertEquals(1, connectionIDs.length);
String connectionID = connectionIDs[0];
@@ -245,9 +320,9 @@
assertEquals(0, sessions.length);
connection.close();
-
+
Thread.sleep(500);
-
+
assertEquals(0, control.listConnectionIDs().length);
}
finally
@@ -258,7 +333,7 @@
}
}
}
-
+
private void doListClientConnections(String acceptorFactory, String connectorFactory) throws Exception
{
MessagingService service = null;
@@ -344,13 +419,13 @@
}
}
}
-
+
private void doCloseConnectionsForUnknownAddress(String acceptorFactory, String connectorFactory) throws Exception
{
String unknownAddress = randomString();
-
+
MessagingService service = null;
-
+
try
{
service = startMessagingService(acceptorFactory);
More information about the jboss-cvs-commits
mailing list