Author: clebert.suconic(a)jboss.com
Date: 2011-01-01 15:25:59 -0500 (Sat, 01 Jan 2011)
New Revision: 10092
Modified:
trunk/tests/src/org/hornetq/tests/stress/client/SendStressTest.java
trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java
Log:
fixing a stress tests
Modified: trunk/tests/src/org/hornetq/tests/stress/client/SendStressTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/stress/client/SendStressTest.java 2010-12-31
00:49:46 UTC (rev 10091)
+++ trunk/tests/src/org/hornetq/tests/stress/client/SendStressTest.java 2011-01-01
20:25:59 UTC (rev 10092)
@@ -53,7 +53,8 @@
public void doTestStressSend(final boolean netty) throws Exception
{
HornetQServer server = createServer(false, netty);
- ServerLocator locator = createFactory(netty);
+ server.start();
+ ServerLocator locator = createNonHALocator(netty);
ClientSessionFactory sf = locator.createSessionFactory();
ClientSession session = null;
Modified: trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java 2010-12-31 00:49:46 UTC
(rev 10091)
+++ trunk/tests/src/org/hornetq/tests/util/ServiceTestBase.java 2011-01-01 20:25:59 UTC
(rev 10092)
@@ -32,7 +32,6 @@
import org.hornetq.api.core.client.ServerLocator;
import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
import org.hornetq.core.config.Configuration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
@@ -84,7 +83,7 @@
}
catch (Exception e)
{
- e.printStackTrace();
+ e.printStackTrace();
}
}
locators.clear();
@@ -92,7 +91,7 @@
checkFreePort(5445);
checkFreePort(5446);
checkFreePort(5447);
- if(InVMRegistry.instance.size() > 0)
+ if (InVMRegistry.instance.size() > 0)
{
System.exit(0);
}
@@ -101,7 +100,7 @@
protected static Map<String, Object> generateParams(final int node, final
boolean netty)
{
Map<String, Object> params = new HashMap<String, Object>();
-
+
if (netty)
{
params.put(org.hornetq.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME,
@@ -111,11 +110,13 @@
{
params.put(org.hornetq.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME,
node);
}
-
+
return params;
}
- protected static TransportConfiguration createTransportConfiguration(boolean netty,
boolean acceptor, Map<String, Object> params)
+ protected static TransportConfiguration createTransportConfiguration(boolean netty,
+ boolean
acceptor,
+ Map<String,
Object> params)
{
String className;
if (netty)
@@ -128,7 +129,8 @@
{
className = NettyConnectorFactory.class.getName();
}
- } else
+ }
+ else
{
if (acceptor)
{
@@ -236,39 +238,47 @@
return createServer(realFiles, configuration, -1, -1, new HashMap<String,
AddressSettings>());
}
- protected HornetQServer createInVMFailoverServer(final boolean realFiles, final
Configuration configuration, NodeManager nodeManager)
+ protected HornetQServer createInVMFailoverServer(final boolean realFiles,
+ final Configuration configuration,
+ NodeManager nodeManager)
{
- return createInVMFailoverServer(realFiles, configuration, -1, -1, new
HashMap<String, AddressSettings>(), nodeManager);
+ return createInVMFailoverServer(realFiles,
+ configuration,
+ -1,
+ -1,
+ new HashMap<String, AddressSettings>(),
+ nodeManager);
}
protected HornetQServer createInVMFailoverServer(final boolean realFiles,
- final Configuration configuration,
- final int pageSize,
- final int maxAddressSize,
- final Map<String, AddressSettings>
settings,
- NodeManager nodeManager)
+ final Configuration configuration,
+ final int pageSize,
+ final int maxAddressSize,
+ final Map<String,
AddressSettings> settings,
+ NodeManager nodeManager)
+ {
+ HornetQServer server;
+ HornetQSecurityManager securityManager = new HornetQSecurityManagerImpl();
+ configuration.setPersistenceEnabled(realFiles);
+ server = new InVMNodeManagerServer(configuration,
+ ManagementFactory.getPlatformMBeanServer(),
+ securityManager,
+ nodeManager);
+
+ for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
{
- HornetQServer server;
- HornetQSecurityManager securityManager = new HornetQSecurityManagerImpl();
- configuration.setPersistenceEnabled(realFiles);
- server = new
InVMNodeManagerServer(configuration,ManagementFactory.getPlatformMBeanServer(),securityManager,
nodeManager);
+ server.getAddressSettingsRepository().addMatch(setting.getKey(),
setting.getValue());
+ }
+ AddressSettings defaultSetting = new AddressSettings();
+ defaultSetting.setPageSizeBytes(pageSize);
+ defaultSetting.setMaxSizeBytes(maxAddressSize);
- for (Map.Entry<String, AddressSettings> setting : settings.entrySet())
- {
- server.getAddressSettingsRepository().addMatch(setting.getKey(),
setting.getValue());
- }
+ server.getAddressSettingsRepository().addMatch("#", defaultSetting);
- AddressSettings defaultSetting = new AddressSettings();
- defaultSetting.setPageSizeBytes(pageSize);
- defaultSetting.setMaxSizeBytes(maxAddressSize);
+ return server;
+ }
- server.getAddressSettingsRepository().addMatch("#", defaultSetting);
-
- return server;
- }
-
-
protected HornetQServer createServer(final boolean realFiles,
final Configuration configuration,
final HornetQSecurityManager securityManager)
@@ -277,14 +287,16 @@
if (realFiles)
{
- server = HornetQServers.newHornetQServer(configuration,
ManagementFactory.getPlatformMBeanServer(), securityManager);
+ server = HornetQServers.newHornetQServer(configuration,
+
ManagementFactory.getPlatformMBeanServer(),
+ securityManager);
}
else
{
server = HornetQServers.newHornetQServer(configuration,
- ManagementFactory.getPlatformMBeanServer(),
- securityManager,
- false);
+
ManagementFactory.getPlatformMBeanServer(),
+ securityManager,
+ false);
}
Map<String, AddressSettings> settings = new HashMap<String,
AddressSettings>();
@@ -348,6 +360,7 @@
new HashMap<String, AddressSettings>());
}
}
+
protected ServerLocator createFactory(final boolean isNetty) throws Exception
{
if (isNetty)
@@ -359,7 +372,7 @@
return createInVMNonHALocator();
}
}
-
+
protected void createQueue(String address, String queue) throws Exception
{
ServerLocator locator = createInVMNonHALocator();
@@ -373,22 +386,26 @@
protected ServerLocator createInVMNonHALocator()
{
- ServerLocator locatorWithoutHA = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(INVM_CONNECTOR_FACTORY));
- locators.add(locatorWithoutHA);
- return locatorWithoutHA;
+ return createNonHALocator(false);
}
protected ServerLocator createNettyNonHALocator()
{
- ServerLocator serverLocatorWithoutHA =
HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(NETTY_CONNECTOR_FACTORY));
- locators.add(serverLocatorWithoutHA);
- return serverLocatorWithoutHA;
+ return createNonHALocator(true);
}
+ protected ServerLocator createNonHALocator(final boolean isNetty)
+ {
+ ServerLocator locatorWithoutHA = isNetty ?
HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(NETTY_CONNECTOR_FACTORY))
+ :
HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(INVM_CONNECTOR_FACTORY));
+ locators.add(locatorWithoutHA);
+ return locatorWithoutHA;
+ }
+
protected ClientSessionFactoryImpl createFactory(final String connectorClass) throws
Exception
{
ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new
TransportConfiguration(connectorClass));
- return (ClientSessionFactoryImpl) locator.createSessionFactory();
+ return (ClientSessionFactoryImpl)locator.createSessionFactory();
}
@@ -406,10 +423,10 @@
protected ClientMessage createTextMessage(final ClientSession session, final String s,
final boolean durable)
{
ClientMessage message = session.createMessage(HornetQTextMessage.TYPE,
- durable,
- 0,
- System.currentTimeMillis(),
- (byte)1);
+ durable,
+ 0,
+ System.currentTimeMillis(),
+ (byte)1);
message.getBodyBuffer().writeString(s);
return message;
}
@@ -417,10 +434,10 @@
protected ClientMessage createBytesMessage(final ClientSession session, final byte[]
b, final boolean durable)
{
ClientMessage message = session.createMessage(HornetQBytesMessage.TYPE,
- durable,
- 0,
- System.currentTimeMillis(),
- (byte)1);
+ durable,
+ 0,
+ System.currentTimeMillis(),
+ (byte)1);
message.getBodyBuffer().writeBytes(b);
return message;
}
@@ -462,6 +479,7 @@
class InVMNodeManagerServer extends HornetQServerImpl
{
final NodeManager nodeManager;
+
public InVMNodeManagerServer(NodeManager nodeManager)
{
super();
@@ -480,13 +498,18 @@
this.nodeManager = nodeManager;
}
- public InVMNodeManagerServer(Configuration configuration, HornetQSecurityManager
securityManager, NodeManager nodeManager)
+ public InVMNodeManagerServer(Configuration configuration,
+ HornetQSecurityManager securityManager,
+ NodeManager nodeManager)
{
super(configuration, securityManager);
this.nodeManager = nodeManager;
}
- public InVMNodeManagerServer(Configuration configuration, MBeanServer mbeanServer,
HornetQSecurityManager securityManager, NodeManager nodeManager)
+ public InVMNodeManagerServer(Configuration configuration,
+ MBeanServer mbeanServer,
+ HornetQSecurityManager securityManager,
+ NodeManager nodeManager)
{
super(configuration, mbeanServer, securityManager);
this.nodeManager = nodeManager;