JBoss hornetq SVN: r8506 - in trunk: src/main/org/hornetq/utils and 2 other directories.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-12-02 15:03:15 -0500 (Wed, 02 Dec 2009)
New Revision: 8506
Added:
trunk/tests/src/org/hornetq/tests/unit/util/MemorySizeTest.java
Modified:
trunk/src/main/org/hornetq/core/server/impl/MessageReferenceImpl.java
trunk/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java
trunk/src/main/org/hornetq/utils/TypedProperties.java
trunk/tests/src/org/hornetq/tests/integration/client/PagingTest.java
trunk/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java
Log:
improved memory estimate
Modified: trunk/src/main/org/hornetq/core/server/impl/MessageReferenceImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/MessageReferenceImpl.java 2009-12-02 16:16:19 UTC (rev 8505)
+++ trunk/src/main/org/hornetq/core/server/impl/MessageReferenceImpl.java 2009-12-02 20:03:15 UTC (rev 8506)
@@ -17,7 +17,7 @@
import org.hornetq.core.server.MessageReference;
import org.hornetq.core.server.Queue;
import org.hornetq.core.server.ServerMessage;
-import org.hornetq.utils.DataConstants;
+import org.hornetq.utils.MemorySize;
/**
* Implementation of a MessageReference
@@ -42,7 +42,26 @@
private final Queue queue;
// Static --------------------------------------------------------
+
+ private static final int memoryOffset;
+ static
+ {
+ // This is an estimate of how much memory a ServerMessageImpl takes up, exclusing body and properties
+ // Note, it is only an estimate, it's not possible to be entirely sure with Java
+ // This figure is calculated using the test utilities in org.hornetq.tests.unit.util.sizeof
+ // The value is somewhat higher on 64 bit architectures, probably due to different alignment
+
+ if (MemorySize.is64bitArch())
+ {
+ memoryOffset = 48;
+ }
+ else
+ {
+ memoryOffset = 32;
+ }
+ }
+
// Constructors --------------------------------------------------
public MessageReferenceImpl()
@@ -78,13 +97,7 @@
public static int getMemoryEstimate()
{
- // from few tests I have done, deliveryCount and scheduledDelivery will use two longs (because of alignment)
- // and each of the references (messages and queue) will use the equivalent to two longs (because of long
- // pointers).
- // Anyway.. this is just an estimate
-
- // TODO - doesn't the object itself have an overhead? - I thought was usually one Long per Object?
- return DataConstants.SIZE_LONG * 4;
+ return memoryOffset;
}
public int getDeliveryCount()
Modified: trunk/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java 2009-12-02 16:16:19 UTC (rev 8505)
+++ trunk/src/main/org/hornetq/core/server/impl/ServerMessageImpl.java 2009-12-02 20:03:15 UTC (rev 8506)
@@ -16,8 +16,6 @@
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicInteger;
-import org.hornetq.core.buffers.HornetQBuffer;
-import org.hornetq.core.buffers.impl.ResetLimitWrappedHornetQBuffer;
import org.hornetq.core.logging.Logger;
import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.paging.PagingStore;
@@ -26,8 +24,8 @@
import org.hornetq.core.server.Queue;
import org.hornetq.core.server.ServerMessage;
import org.hornetq.utils.DataConstants;
+import org.hornetq.utils.MemorySize;
import org.hornetq.utils.SimpleString;
-import org.hornetq.utils.TypedProperties;
/**
*
@@ -49,6 +47,25 @@
private PagingStore pagingStore;
+ private static final int memoryOffset;
+
+ static
+ {
+ // This is an estimate of how much memory a ServerMessageImpl takes up, exclusing body and properties
+ // Note, it is only an estimate, it's not possible to be entirely sure with Java
+ // This figure is calculated using the test utilities in org.hornetq.tests.unit.util.sizeof
+ // The value is somewhat higher on 64 bit architectures, probably due to different alignment
+
+ if (MemorySize.is64bitArch())
+ {
+ memoryOffset = 352;
+ }
+ else
+ {
+ memoryOffset = 232;
+ }
+ }
+
/*
* Constructor for when reading from network
*/
@@ -62,7 +79,7 @@
public ServerMessageImpl(final long messageID, final int initialMessageBufferSize)
{
super(initialMessageBufferSize);
-
+
this.messageID = messageID;
}
@@ -144,44 +161,17 @@
{
return false;
}
-
- private volatile int memoryEstimate = -1;
-// public int getMemoryEstimate()
-// {
-// if (memoryEstimate == -1)
-// {
-// memoryEstimate =
-// DataConstants.SIZE_INT + // Object overhead
-// this.getHeadersAndPropertiesEncodeSize() +
-// buffer.capacity() +
-// DataConstants.SIZE_INT + // PagingStore reference
-// DataConstants.SIZE_INT + // DurableRefCount reference
-// DataConstants.SIZE_INT + // RefCount reference
-// DataConstants.SIZE_INT + // Reference to buffer
-// DataConstants.SIZE_INT + // Reference to bodyBuffer
-// DataConstants.SIZE_BOOLEAN + // bufferValid
-// DataConstants.SIZE_INT + // endOfBodyPosition
-// DataConstants.SIZE_INT + // endOfMessagePosition
-// DataConstants.SIZE_BOOLEAN + // copied
-// DataConstants.SIZE_BOOLEAN + // bufferUsed
-// DataConstants.SIZE_LONG; // A bit more due to alignment and fragmentation
-// }
-//
-// return memoryEstimate;
-// }
+ private volatile int memoryEstimate = -1;
public int getMemoryEstimate()
{
if (memoryEstimate == -1)
{
- // This is just an estimate...
- // due to memory alignments and JVM implementation this could be very
- // different from reality
- memoryEstimate = getEncodeSize() + (16 + 4) * 2 + 1;
+ memoryEstimate = memoryOffset + buffer.capacity() + properties.getMemoryOffset();
}
-
- return memoryEstimate;
+
+ return this.memoryEstimate;
}
public ServerMessage copy(final long newID)
Modified: trunk/src/main/org/hornetq/utils/TypedProperties.java
===================================================================
--- trunk/src/main/org/hornetq/utils/TypedProperties.java 2009-12-02 16:16:19 UTC (rev 8505)
+++ trunk/src/main/org/hornetq/utils/TypedProperties.java 2009-12-02 20:03:15 UTC (rev 8506)
@@ -65,6 +65,15 @@
public TypedProperties()
{
}
+
+ public int getMemoryOffset()
+ {
+ //The estimate is basically the encode size + 2 object references for each entry in the map
+ //Note we don't include the attributes or anything else since they already included in the memory estimate
+ //of the ServerMessage
+
+ return properties == null ? 0 : size + 2 * DataConstants.SIZE_INT * properties.size();
+ }
public TypedProperties(final TypedProperties other)
{
Modified: trunk/tests/src/org/hornetq/tests/integration/client/PagingTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2009-12-02 16:16:19 UTC (rev 8505)
+++ trunk/tests/src/org/hornetq/tests/integration/client/PagingTest.java 2009-12-02 20:03:15 UTC (rev 8506)
@@ -131,10 +131,8 @@
producer.send(message);
}
- log.info("** sent messages");
+ session.close();
- session.close();
-
assertTrue("TotalMemory expected to be > 0 when it was " + server.getPostOffice()
.getPagingManager()
.getTotalMemory(),
@@ -696,15 +694,15 @@
session.start();
- for (int i = 0; i < 9; i++)
+ for (int i = 0; i < 6; i++)
{
ClientMessage message2 = consumer.receive(RECEIVE_TIMEOUT);
-
+
assertNotNull(message2);
message2.acknowledge();
}
-
+
assertNull(consumer.receiveImmediate());
assertEquals(0, server.getPostOffice().getPagingManager().getTotalMemory());
@@ -720,15 +718,15 @@
producer.send(message);
}
- for (int i = 0; i < 9; i++)
- {
+ for (int i = 0; i < 6; i++)
+ {
ClientMessage message2 = consumer.receive(RECEIVE_TIMEOUT);
-
+
assertNotNull(message2);
message2.acknowledge();
}
-
+
assertNull(consumer.receiveImmediate());
session.close();
@@ -753,7 +751,7 @@
session.start();
- for (int i = 0; i < 9; i++)
+ for (int i = 0; i < 6; i++)
{
ClientMessage message2 = consumer.receive(RECEIVE_TIMEOUT);
Modified: trunk/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java 2009-12-02 16:16:19 UTC (rev 8505)
+++ trunk/tests/src/org/hornetq/tests/integration/client/ProducerFlowControlTest.java 2009-12-02 20:03:15 UTC (rev 8506)
@@ -263,8 +263,6 @@
{
handlers[i] = new MyHandler();
- log.info("created consumer");
-
ClientConsumer consumer = session.createConsumer(new SimpleString(queueName + i));
consumer.setMessageHandler(handlers[i]);
@@ -341,7 +339,7 @@
HornetQServer server = createServer(false, isNetty());
AddressSettings addressSettings = new AddressSettings();
- addressSettings.setMaxSizeBytes(1024);
+ addressSettings.setMaxSizeBytes(4000);
addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
HierarchicalRepository<AddressSettings> repos = server.getAddressSettingsRepository();
@@ -351,7 +349,8 @@
ClientSessionFactory sf = createFactory(isNetty());
- sf.setProducerWindowSize(1024);
+ //Make sure the producer grabs all the credits
+ sf.setProducerWindowSize(4000);
sf.setConsumerWindowSize(1024);
sf.setAckBatchSize(1024);
@@ -384,7 +383,7 @@
while (waiting != 1 || (System.currentTimeMillis() - start) > 3000);
assertEquals(1, waiting);
-
+
byte[] bytes = new byte[0];
ClientMessage message = session.createClientMessage(false);
@@ -392,7 +391,7 @@
message.getBodyBuffer().writeBytes(bytes);
producer.send(message);
-
+
class SessionCloser implements Runnable
{
public void run()
@@ -422,9 +421,9 @@
ClientMessage message2 = session.createClientMessage(false);
message2.getBodyBuffer().writeBytes(bytes);
-
+
producer2.send(message2);
-
+
// Make sure it blocked until the first producer was closed
assertTrue(closer.closed);
@@ -448,7 +447,7 @@
HornetQServer server = createServer(false, isNetty());
AddressSettings addressSettings = new AddressSettings();
- addressSettings.setMaxSizeBytes(1024);
+ addressSettings.setMaxSizeBytes(4000);
addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
HierarchicalRepository<AddressSettings> repos = server.getAddressSettingsRepository();
@@ -458,7 +457,8 @@
ClientSessionFactory sf = createFactory(isNetty());
- sf.setProducerWindowSize(1024);
+ //Make sure producer grabs all the credits
+ sf.setProducerWindowSize(4000);
sf.setConsumerWindowSize(1024);
sf.setAckBatchSize(1024);
@@ -526,7 +526,7 @@
HornetQServer server = createServer(false, isNetty());
AddressSettings addressSettings = new AddressSettings();
- addressSettings.setMaxSizeBytes(1024);
+ addressSettings.setMaxSizeBytes(4000);
addressSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.BLOCK);
HierarchicalRepository<AddressSettings> repos = server.getAddressSettingsRepository();
@@ -536,7 +536,8 @@
ClientSessionFactory sf = createFactory(isNetty());
- sf.setProducerWindowSize(1024);
+ //Make sure first producer grabs all the credits
+ sf.setProducerWindowSize(4000);
sf.setConsumerWindowSize(1024);
sf.setAckBatchSize(1024);
Added: trunk/tests/src/org/hornetq/tests/unit/util/MemorySizeTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/util/MemorySizeTest.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/unit/util/MemorySizeTest.java 2009-12-02 20:03:15 UTC (rev 8506)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.unit.util;
+
+import junit.framework.TestCase;
+
+import org.hornetq.core.logging.Logger;
+import org.hornetq.core.server.impl.MessageReferenceImpl;
+import org.hornetq.core.server.impl.ServerMessageImpl;
+import org.hornetq.utils.MemorySize;
+
+/**
+ * A MemorySizeTest
+ *
+ * @author Tim Fox
+ *
+ *
+ */
+public class MemorySizeTest extends TestCase
+{
+ private static final Logger log = Logger.getLogger(MemorySizeTest.class);
+
+ public void testObjectSizes() throws Exception
+ {
+ log.info("Server message size is " + MemorySize.calculateSize(new MemorySize.ObjectFactory()
+ {
+ public Object createObject()
+ {
+ return new ServerMessageImpl(1, 1000);
+ }
+ }));
+
+ log.info("Message reference size is " + MemorySize.calculateSize(new MemorySize.ObjectFactory()
+ {
+ public Object createObject()
+ {
+ return new MessageReferenceImpl();
+ }
+ }));
+ }
+}
+
+
15 years, 1 month
JBoss hornetq SVN: r8505 - trunk/tests/src/org/hornetq/tests/integration/ssl.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2009-12-02 11:16:19 -0500 (Wed, 02 Dec 2009)
New Revision: 8505
Modified:
trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java
trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-234 CoreClientOverSSLTest
* 1 unexpected failure in testPlainConnectionToSSLEndpoint
Modified: trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java 2009-12-02 15:15:34 UTC (rev 8504)
+++ trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSL.java 2009-12-02 16:16:19 UTC (rev 8505)
@@ -49,18 +49,20 @@
log.debug("args = " + Arrays.asList(args));
- if (args.length != 1)
+ if (args.length != 3)
{
- log.fatal("unexpected number of args (should be 1)");
+ log.fatal("unexpected number of args (should be 3)");
System.exit(1);
}
- boolean sslEnabled = Boolean.parseBoolean(args[0]);
-
- System.out.println("ssl enabled is " + sslEnabled);
-
+ boolean sslEnabled = Boolean.parseBoolean(args[0]);
+ String keyStorePath = args[1];
+ String keyStorePassword = args[2];
+
TransportConfiguration tc = new TransportConfiguration("org.hornetq.integration.transports.netty.NettyConnectorFactory");
tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, sslEnabled);
+ tc.getParams().put(TransportConstants.KEYSTORE_PATH_PROP_NAME, keyStorePath);
+ tc.getParams().put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, keyStorePassword);
ClientSessionFactory sf = new ClientSessionFactoryImpl(tc);
ClientSession session = sf.createSession(false, true, true);
ClientProducer producer = session.createProducer(CoreClientOverSSLTest.QUEUE);
Modified: trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java 2009-12-02 15:15:34 UTC (rev 8504)
+++ trunk/tests/src/org/hornetq/tests/integration/ssl/CoreClientOverSSLTest.java 2009-12-02 16:16:19 UTC (rev 8505)
@@ -9,14 +9,27 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
- */
+ */
package org.hornetq.tests.integration.ssl;
+import java.util.HashMap;
+import java.util.Map;
+
import org.hornetq.core.client.ClientConsumer;
import org.hornetq.core.client.ClientSession;
+import org.hornetq.core.client.ClientSessionFactory;
+import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
+import org.hornetq.core.config.TransportConfiguration;
+import org.hornetq.core.config.impl.ConfigurationImpl;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.message.Message;
+import org.hornetq.core.server.HornetQ;
import org.hornetq.core.server.HornetQServer;
+import org.hornetq.integration.transports.netty.NettyAcceptorFactory;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
+import org.hornetq.integration.transports.netty.TransportConstants;
+import org.hornetq.tests.util.SpawnedVMSupport;
import org.hornetq.tests.util.UnitTestCase;
import org.hornetq.utils.SimpleString;
@@ -31,100 +44,93 @@
// Constants -----------------------------------------------------
public static final String MESSAGE_TEXT_FROM_CLIENT = "CoreClientOverSSLTest from client";
+
public static final SimpleString QUEUE = new SimpleString("QueueOverSSL");
+
public static final int SSL_PORT = 5402;
// Static --------------------------------------------------------
- private static final Logger log = Logger
- .getLogger(CoreClientOverSSLTest.class);
+ private static final Logger log = Logger.getLogger(CoreClientOverSSLTest.class);
// Attributes ----------------------------------------------------
- private HornetQServer messagingService;
+ private HornetQServer server;
private ClientSession session;
private ClientConsumer consumer;
-
+
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
- public void testDummy()
+ public void testSSL() throws Exception
{
- //This whole test needs to be rewritten - there's no need for it to be spawning vms
+ final Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class.getName(), Boolean.TRUE.toString(), TransportConstants.DEFAULT_KEYSTORE_PATH, TransportConstants.DEFAULT_KEYSTORE_PASSWORD);
+
+ Message m = consumer.receive(10000);
+ assertNotNull(m);
+ assertEquals(MESSAGE_TEXT_FROM_CLIENT, m.getBodyBuffer().readString());
+
+ log.debug("waiting for the client VM to exit ...");
+ SpawnedVMSupport.assertProcessExits(true, 0, p);
}
-
-// public void testSSL() throws Exception
-// {
-// final Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class
-// .getName(), Boolean.TRUE.toString());
-//
-// Message m = consumer.receive(10000);
-// assertNotNull(m);
-// assertEquals(MESSAGE_TEXT_FROM_CLIENT, m.getBody().getString());
-//
-// log.debug("waiting for the client VM to exit ...");
-// SpawnedVMSupport.assertProcessExits(true, 0, p);
-// }
-//
-// public void testSSLWithIncorrectKeyStorePassword() throws Exception
-// {
-// Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class
-// .getName(), Boolean.TRUE.toString());
-//
-// Message m = consumer.receive(5000);
-// assertNull(m);
-//
-// log.debug("waiting for the client VM to exit ...");
-// SpawnedVMSupport.assertProcessExits(false, 0, p);
-// }
-//
-// public void testPlainConnectionToSSLEndpoint() throws Exception
-// {
-// Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class
-// .getName(), FALSE.toString());
-//
-// Message m = consumer.receive(5000);
-// assertNull(m);
-//
-// log.debug("waiting for the client VM to exit ...");
-// SpawnedVMSupport.assertProcessExits(false, 0, p);
-// }
+ public void testSSLWithIncorrectKeyStorePassword() throws Exception
+ {
+ Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class.getName(), Boolean.TRUE.toString(), TransportConstants.DEFAULT_KEYSTORE_PATH, "invalid pasword");
+
+ Message m = consumer.receive(5000);
+ assertNull(m);
+
+ log.debug("waiting for the client VM to exit ...");
+ SpawnedVMSupport.assertProcessExits(false, 0, p);
+ }
+
+ // see https://jira.jboss.org/jira/browse/HORNETQ-234
+ public void _testPlainConnectionToSSLEndpoint() throws Exception
+ {
+ Process p = SpawnedVMSupport.spawnVM(CoreClientOverSSL.class.getName(), Boolean.FALSE.toString(), TransportConstants.DEFAULT_KEYSTORE_PATH, TransportConstants.DEFAULT_KEYSTORE_PASSWORD);
+
+ Message m = consumer.receive(5000);
+ assertNull(m);
+
+ log.debug("waiting for the client VM to exit ...");
+ SpawnedVMSupport.assertProcessExits(false, 0, p);
+ }
+
// Package protected ---------------------------------------------
-// @Override
-// protected void setUp() throws Exception
-// {
-// ConfigurationImpl config = new ConfigurationImpl();
-// config.setSecurityEnabled(false);
-// Map<String, Object> params = new HashMap<String, Object>();
-// params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
-// config.getAcceptorInfos().add(new TransportConfiguration("org.hornetq.integration.transports.netty.NettyAcceptorFactory", params));
-// server = HornetQServerImpl.newNullStorageHornetQServer(config);
-// server.start();
-// ConnectorFactory cf = new NettyConnectorFactory();
-// ClientSessionFactory sf = new ClientSessionFactoryImpl(cf);
-// sf.setTransportParams(params);
-// session = sf.createSession(false, true, true, -1, false);
-// session.createQueue(QUEUE, QUEUE, null, false, false);
-// consumer = session.createConsumer(QUEUE);
-// session.start();
-// }
-//
-// @Override
-// protected void tearDown() throws Exception
-// {
-// consumer.close();
-// session.close();
-//
-// server.stop();
-//
-// super.tearDown();
-// }
+ @Override
+ protected void setUp() throws Exception
+ {
+ ConfigurationImpl config = new ConfigurationImpl();
+ config.setSecurityEnabled(false);
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
+ config.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName(), params));
+ server = HornetQ.newHornetQServer(config, false);
+ server.start();
+ TransportConfiguration tc = new TransportConfiguration(NettyConnectorFactory.class.getName(), params);
+ ClientSessionFactory sf = new ClientSessionFactoryImpl(tc);
+ session = sf.createSession(false, true, true);
+ session.createQueue(QUEUE, QUEUE, false);
+ consumer = session.createConsumer(QUEUE);
+ session.start();
+ }
+ @Override
+ protected void tearDown() throws Exception
+ {
+ consumer.close();
+ session.close();
+
+ server.stop();
+
+ super.tearDown();
+ }
+
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
15 years, 1 month
JBoss hornetq SVN: r8504 - trunk/tests/src/org/hornetq/tests/stress/failover.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-12-02 10:15:34 -0500 (Wed, 02 Dec 2009)
New Revision: 8504
Added:
trunk/tests/src/org/hornetq/tests/stress/failover/MultiThreadRandomReattachStressTest.java
trunk/tests/src/org/hornetq/tests/stress/failover/RandomReattachStressTest.java
Removed:
trunk/tests/src/org/hornetq/tests/stress/failover/MultiThreadRandomFailoverStressTest.java
trunk/tests/src/org/hornetq/tests/stress/failover/RandomFailoverStressTest.java
Log:
Just Renaming Tests
Deleted: trunk/tests/src/org/hornetq/tests/stress/failover/MultiThreadRandomFailoverStressTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/stress/failover/MultiThreadRandomFailoverStressTest.java 2009-12-02 14:59:36 UTC (rev 8503)
+++ trunk/tests/src/org/hornetq/tests/stress/failover/MultiThreadRandomFailoverStressTest.java 2009-12-02 15:15:34 UTC (rev 8504)
@@ -1,31 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.tests.stress.failover;
-
-import org.hornetq.tests.integration.cluster.reattach.MultiThreadRandomReattachTest;
-
-/**
- * A MultiThreadRandomFailoverStressTest
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- */
-public class MultiThreadRandomFailoverStressTest extends MultiThreadRandomReattachTest
-{
- protected int getNumIterations()
- {
- return 100;
- }
-
-}
Copied: trunk/tests/src/org/hornetq/tests/stress/failover/MultiThreadRandomReattachStressTest.java (from rev 8502, trunk/tests/src/org/hornetq/tests/stress/failover/MultiThreadRandomFailoverStressTest.java)
===================================================================
--- trunk/tests/src/org/hornetq/tests/stress/failover/MultiThreadRandomReattachStressTest.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/stress/failover/MultiThreadRandomReattachStressTest.java 2009-12-02 15:15:34 UTC (rev 8504)
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.stress.failover;
+
+import org.hornetq.tests.integration.cluster.reattach.MultiThreadRandomReattachTest;
+
+/**
+ * A MultiThreadRandomFailoverStressTest
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ */
+public class MultiThreadRandomReattachStressTest extends MultiThreadRandomReattachTest
+{
+ protected int getNumIterations()
+ {
+ return 100;
+ }
+
+}
Deleted: trunk/tests/src/org/hornetq/tests/stress/failover/RandomFailoverStressTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/stress/failover/RandomFailoverStressTest.java 2009-12-02 14:59:36 UTC (rev 8503)
+++ trunk/tests/src/org/hornetq/tests/stress/failover/RandomFailoverStressTest.java 2009-12-02 15:15:34 UTC (rev 8504)
@@ -1,54 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-
-package org.hornetq.tests.stress.failover;
-
-import org.hornetq.tests.integration.cluster.reattach.RandomReattachTest;
-
-/**
- * A RandomFailoverStressTest
- *
- * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- *
- * Created Jan 22, 2009 8:32:59 PM
- *
- *
- */
-public class RandomFailoverStressTest extends RandomReattachTest
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected int getNumIterations()
- {
- return 100;
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Copied: trunk/tests/src/org/hornetq/tests/stress/failover/RandomReattachStressTest.java (from rev 8502, trunk/tests/src/org/hornetq/tests/stress/failover/RandomFailoverStressTest.java)
===================================================================
--- trunk/tests/src/org/hornetq/tests/stress/failover/RandomReattachStressTest.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/stress/failover/RandomReattachStressTest.java 2009-12-02 15:15:34 UTC (rev 8504)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+
+package org.hornetq.tests.stress.failover;
+
+import org.hornetq.tests.integration.cluster.reattach.RandomReattachTest;
+
+/**
+ * A RandomFailoverStressTest
+ *
+ * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ * Created Jan 22, 2009 8:32:59 PM
+ *
+ *
+ */
+public class RandomReattachStressTest extends RandomReattachTest
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected int getNumIterations()
+ {
+ return 100;
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
15 years, 1 month
JBoss hornetq SVN: r8503 - in trunk/tests/src/org/hornetq/tests: util and 1 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-12-02 09:59:36 -0500 (Wed, 02 Dec 2009)
New Revision: 8503
Added:
trunk/tests/src/org/hornetq/tests/util/sizeof/
Removed:
trunk/tests/src/org/hornetq/tests/unit/util/sizeof/
Modified:
trunk/tests/src/org/hornetq/tests/util/sizeof/MessageReferenceSizeOf.java
trunk/tests/src/org/hornetq/tests/util/sizeof/ObjectSizeOf.java
trunk/tests/src/org/hornetq/tests/util/sizeof/ServerMessageSizeOf.java
trunk/tests/src/org/hornetq/tests/util/sizeof/SizeOfBase.java
Log:
Moving sizeof tests to the correct place
Copied: trunk/tests/src/org/hornetq/tests/util/sizeof (from rev 8502, trunk/tests/src/org/hornetq/tests/unit/util/sizeof)
Modified: trunk/tests/src/org/hornetq/tests/util/sizeof/MessageReferenceSizeOf.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/util/sizeof/MessageReferenceSizeOf.java 2009-12-02 14:23:04 UTC (rev 8502)
+++ trunk/tests/src/org/hornetq/tests/util/sizeof/MessageReferenceSizeOf.java 2009-12-02 14:59:36 UTC (rev 8503)
@@ -11,7 +11,7 @@
* permissions and limitations under the License.
*/
-package org.hornetq.tests.unit.util.sizeof;
+package org.hornetq.tests.util.sizeof;
import org.hornetq.core.server.impl.MessageReferenceImpl;
Modified: trunk/tests/src/org/hornetq/tests/util/sizeof/ObjectSizeOf.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/util/sizeof/ObjectSizeOf.java 2009-12-02 14:23:04 UTC (rev 8502)
+++ trunk/tests/src/org/hornetq/tests/util/sizeof/ObjectSizeOf.java 2009-12-02 14:59:36 UTC (rev 8503)
@@ -11,12 +11,10 @@
* permissions and limitations under the License.
*/
-package org.hornetq.tests.unit.util.sizeof;
+package org.hornetq.tests.util.sizeof;
/**
* Calculate the size of objects on the heap
- * based on this article:
- * http://www.javaworld.com/javaworld/javatips/jw-javatip130.html
*
* @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
*
Modified: trunk/tests/src/org/hornetq/tests/util/sizeof/ServerMessageSizeOf.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/util/sizeof/ServerMessageSizeOf.java 2009-12-02 14:23:04 UTC (rev 8502)
+++ trunk/tests/src/org/hornetq/tests/util/sizeof/ServerMessageSizeOf.java 2009-12-02 14:59:36 UTC (rev 8503)
@@ -11,7 +11,7 @@
* permissions and limitations under the License.
*/
-package org.hornetq.tests.unit.util.sizeof;
+package org.hornetq.tests.util.sizeof;
import org.hornetq.core.server.impl.ServerMessageImpl;
Modified: trunk/tests/src/org/hornetq/tests/util/sizeof/SizeOfBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/util/sizeof/SizeOfBase.java 2009-12-02 14:23:04 UTC (rev 8502)
+++ trunk/tests/src/org/hornetq/tests/util/sizeof/SizeOfBase.java 2009-12-02 14:59:36 UTC (rev 8503)
@@ -11,13 +11,16 @@
* permissions and limitations under the License.
*/
-package org.hornetq.tests.unit.util.sizeof;
+package org.hornetq.tests.util.sizeof;
import org.hornetq.tests.util.UnitTestCase;
/**
- * A Base class for tests that are calculating size of objects
- *
+ * A Base class for tests that are calculating size of objects.
+ *
+ * based on this article:
+ * http://www.javaworld.com/javaworld/javatips/jw-javatip130.html
+ *
* @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
*
*
15 years, 1 month
JBoss hornetq SVN: r8502 - in trunk: tests/src/org/hornetq/tests/unit/core/deployers/impl and 1 other directory.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-12-02 09:23:04 -0500 (Wed, 02 Dec 2009)
New Revision: 8502
Modified:
trunk/src/config/common/schema/hornetq-configuration.xsd
trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/AddressSettingsDeployerTest.java
Log:
fixed incomplete test
Modified: trunk/src/config/common/schema/hornetq-configuration.xsd
===================================================================
--- trunk/src/config/common/schema/hornetq-configuration.xsd 2009-12-02 14:01:22 UTC (rev 8501)
+++ trunk/src/config/common/schema/hornetq-configuration.xsd 2009-12-02 14:23:04 UTC (rev 8502)
@@ -437,8 +437,6 @@
<xsd:element name="address-setting">
<xsd:complexType>
<xsd:all>
- <xsd:element maxOccurs="1" minOccurs="0" name="clustered" type="xsd:boolean">
- </xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" name="dead-letter-address" type="xsd:string">
</xsd:element>
<xsd:element maxOccurs="1" minOccurs="0" name="expiry-address" type="xsd:string">
Modified: trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/AddressSettingsDeployerTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/AddressSettingsDeployerTest.java 2009-12-02 14:01:22 UTC (rev 8501)
+++ trunk/tests/src/org/hornetq/tests/unit/core/deployers/impl/AddressSettingsDeployerTest.java 2009-12-02 14:23:04 UTC (rev 8502)
@@ -9,13 +9,14 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
- */
+ */
package org.hornetq.tests.unit.core.deployers.impl;
import org.hornetq.core.deployers.DeploymentManager;
import org.hornetq.core.deployers.impl.AddressSettingsDeployer;
import org.hornetq.core.settings.HierarchicalRepository;
+import org.hornetq.core.settings.impl.AddressFullMessagePolicy;
import org.hornetq.core.settings.impl.AddressSettings;
import org.hornetq.core.settings.impl.HierarchicalObjectRepository;
import org.hornetq.tests.util.UnitTestCase;
@@ -29,13 +30,18 @@
*/
public class AddressSettingsDeployerTest extends UnitTestCase
{
- private String conf = "<address-settings match=\"queues.*\">\n" +
- " <dead-letter-address>DLQtest</dead-letter-address>\n" +
- " <expiry-address>ExpiryQueueTest</expiry-address>\n" +
- " <redelivery-delay>100</redelivery-delay>\n" +
- " <max-size-bytes>-100</max-size-bytes>\n" +
- " <message-counter-history-day-limit>1000</message-counter-history-day-limit>\n" +
- " </address-settings>";
+ private String conf = "<address-setting match=\"queues.*\">\n" + " <dead-letter-address>DLQtest</dead-letter-address>\n"
+ + " <expiry-address>ExpiryQueueTest</expiry-address>\n"
+ + " <redelivery-delay>100</redelivery-delay>\n"
+ + " <max-delivery-attempts>32</max-delivery-attempts>\n"
+ + " <max-size-bytes>182381723</max-size-bytes>\n"
+ + " <page-size-bytes>2387273</page-size-bytes>\n"
+ + " <address-full-policy>DROP</address-full-policy>\n"
+ + " <message-counter-history-day-limit>1000</message-counter-history-day-limit>\n"
+ + " <last-value-queue>true</last-value-queue>\n"
+ + " <redistribution-delay>38383</redistribution-delay>\n"
+ + " <send-to-dla-on-no-route>true</send-to-dla-on-no-route>\n"
+ + " </address-setting>";
private AddressSettingsDeployer addressSettingsDeployer;
@@ -44,7 +50,7 @@
protected void setUp() throws Exception
{
super.setUp();
-
+
repository = new HierarchicalObjectRepository<AddressSettings>();
DeploymentManager deploymentManager = new FakeDeploymentManager();
addressSettingsDeployer = new AddressSettingsDeployer(deploymentManager, repository);
@@ -55,27 +61,27 @@
addressSettingsDeployer.deploy(XMLUtil.stringToElement(conf));
AddressSettings as = repository.getMatch("queues.aq");
assertNotNull(as);
+ assertEquals(new SimpleString("DLQtest"), as.getDeadLetterAddress());
+ assertEquals(new SimpleString("ExpiryQueueTest"), as.getExpiryAddress());
assertEquals(100, as.getRedeliveryDelay());
- assertEquals(-100, as.getMaxSizeBytes());
+ assertEquals(32, as.getMaxDeliveryAttempts());
+ assertEquals(182381723, as.getMaxSizeBytes());
+ assertEquals(2387273, as.getPageSizeBytes());
+ assertEquals(AddressFullMessagePolicy.DROP, as.getAddressFullMessagePolicy());
assertEquals(1000, as.getMessageCounterHistoryDayLimit());
- assertEquals(new SimpleString("DLQtest"), as.getDeadLetterAddress());
- assertEquals(new SimpleString("ExpiryQueueTest"), as.getExpiryAddress());
+ assertTrue(as.isLastValueQueue());
+ assertEquals(38383, as.getRedistributionDelay());
+ assertTrue(as.isSendToDLAOnNoRoute());
+
}
-
+
public void testDeployFromConfigurationFile() throws Exception
{
- String xml = "<configuration xmlns='urn:hornetq'> "
- + "<address-settings>"
- + " <address-setting match=\"queues.*\">"
- + " <dead-letter-address>DLQtest</dead-letter-address>\n"
- + " <expiry-address>ExpiryQueueTest</expiry-address>\n"
- + " <redelivery-delay>100</redelivery-delay>\n"
- + " <max-size-bytes>-100</max-size-bytes>\n"
- + " <message-counter-history-day-limit>1000</message-counter-history-day-limit>"
- + " </address-setting>"
- + "</address-settings>"
- + "</configuration>";
-
+ String xml = "<configuration xmlns='urn:hornetq'> " + "<address-settings>" +
+ conf +
+ "</address-settings>" +
+ "</configuration>";
+
Element rootNode = org.hornetq.utils.XMLUtil.stringToElement(xml);
addressSettingsDeployer.validate(rootNode);
NodeList addressSettingsNode = rootNode.getElementsByTagName("address-setting");
@@ -84,11 +90,17 @@
addressSettingsDeployer.deploy(addressSettingsNode.item(0));
AddressSettings as = repository.getMatch("queues.aq");
assertNotNull(as);
+ assertEquals(new SimpleString("DLQtest"), as.getDeadLetterAddress());
+ assertEquals(new SimpleString("ExpiryQueueTest"), as.getExpiryAddress());
assertEquals(100, as.getRedeliveryDelay());
- assertEquals(-100, as.getMaxSizeBytes());
+ assertEquals(32, as.getMaxDeliveryAttempts());
+ assertEquals(182381723, as.getMaxSizeBytes());
+ assertEquals(2387273, as.getPageSizeBytes());
+ assertEquals(AddressFullMessagePolicy.DROP, as.getAddressFullMessagePolicy());
assertEquals(1000, as.getMessageCounterHistoryDayLimit());
- assertEquals(new SimpleString("DLQtest"), as.getDeadLetterAddress());
- assertEquals(new SimpleString("ExpiryQueueTest"), as.getExpiryAddress());
+ assertTrue(as.isLastValueQueue());
+ assertEquals(38383, as.getRedistributionDelay());
+ assertTrue(as.isSendToDLAOnNoRoute());
}
public void testUndeploy() throws Exception
15 years, 1 month
JBoss hornetq SVN: r8501 - trunk/tests/src/org/hornetq/tests/timing/core/client/impl.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-12-02 09:01:22 -0500 (Wed, 02 Dec 2009)
New Revision: 8501
Removed:
trunk/tests/src/org/hornetq/tests/timing/core/client/impl/ClientConsumerImplTest.java
Log:
deleted old easymock test
Deleted: trunk/tests/src/org/hornetq/tests/timing/core/client/impl/ClientConsumerImplTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/timing/core/client/impl/ClientConsumerImplTest.java 2009-12-02 13:20:31 UTC (rev 8500)
+++ trunk/tests/src/org/hornetq/tests/timing/core/client/impl/ClientConsumerImplTest.java 2009-12-02 14:01:22 UTC (rev 8501)
@@ -1,556 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.hornetq.tests.timing.core.client.impl;
-
-import org.hornetq.core.logging.Logger;
-import org.hornetq.tests.util.UnitTestCase;
-
-/**
- *
- * A ClientConsumerImplTest
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class ClientConsumerImplTest extends UnitTestCase
-{
- private static final Logger log = Logger.getLogger(ClientConsumerImplTest.class);
-
- public void testDummy()
- {
- }
-
-// public void testSetHandlerWhileReceiving() throws Exception
-// {
-// ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
-// ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
-// Channel channel = EasyMock.createStrictMock(Channel.class);
-//
-// final ClientConsumerInternal consumer =
-// new ClientConsumerImpl(session, 123, 67576, false, executor, channel);
-//
-// MessageHandler handler = new MessageHandler()
-// {
-// public void onMessage(ClientMessage msg)
-// {
-// }
-// };
-//
-// Thread t = new Thread()
-// {
-// public void run()
-// {
-// try
-// {
-// consumer.receive(2000);
-// }
-// catch (Exception e)
-// {
-// }
-// }
-// };
-//
-// t.start();
-//
-// Thread.sleep(1000);
-//
-// try
-// {
-// consumer.setMessageHandler(handler);
-//
-// fail("Should throw exception");
-// }
-// catch (HornetQException e)
-// {
-// assertEquals(HornetQException.ILLEGAL_STATE, e.getCode());
-// }
-// finally
-// {
-// t.interrupt();
-// }
-// }
-//
-// public void testCloseWhileReceiving() throws Exception
-// {
-// ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
-// ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
-// Channel channel = EasyMock.createStrictMock(Channel.class);
-//
-// final long clientTargetID = 283748;
-// final long targetID = 12934;
-// final long sessionTargetID = 23847327;
-//
-// final ClientConsumerInternal consumer =
-// new ClientConsumerImpl(session, targetID, clientTargetID, 787, false, pd, executor, cm);
-//
-// pd.unregister(clientTargetID);
-// session.removeConsumer(consumer);
-// EasyMock.expect(cm.sendCommandBlocking(targetID, new PacketImpl(PacketImpl.CLOSE))).andReturn(null);
-//
-// EasyMock.replay(session,cm, executor, pd);
-//
-// class ReceiverThread extends Thread
-// {
-// volatile boolean returned;
-// volatile ClientMessage msg;
-// volatile boolean failed;
-// public void run()
-// {
-// try
-// {
-// msg = consumer.receive();
-// returned = true;
-// }
-// catch (Exception e)
-// {
-// failed = true;
-// }
-// }
-// };
-//
-// ReceiverThread t = new ReceiverThread();
-//
-// t.start();
-//
-// Thread.sleep(2000);
-//
-// consumer.close();
-//
-// Thread.sleep(2000);
-//
-// assertTrue(t.returned);
-// assertNull(t.msg);
-// assertFalse(t.failed);
-//
-// t.join();
-//
-// EasyMock.verify(session, cm, executor, pd);
-// }
-//
-// public void testReceiveHandleMessagesAfterReceiveNoTimeout() throws Exception
-// {
-// testReceiveHandleMessagesAfterReceive(4000);
-// }
-//
-// public void testReceiveHandleMessagesAfterReceiveTimeout() throws Exception
-// {
-// testReceiveHandleMessagesAfterReceive(0);
-// }
-//
-// private void testReceiveHandleMessagesAfterReceive(final int timeout) throws Exception
-// {
-// ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
-// ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
-// PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-// CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//
-// final int numMessages = 10;
-//
-// final List<ClientMessage> msgs = new ArrayList<ClientMessage>();
-//
-// for (int i = 0; i < numMessages; i++)
-// {
-// ClientMessage msg = EasyMock.createStrictMock(ClientMessage.class);
-//
-// msgs.add(msg);
-//
-// EasyMock.expect(msg.getPriority()).andStubReturn((byte)4); //default priority
-//
-// EasyMock.expect(msg.isExpired()).andStubReturn(false);
-//
-// EasyMock.expect(msg.getDeliveryID()).andStubReturn((long)i);
-//
-// session.delivered((long)i, false);
-//
-// EasyMock.expect(msg.getEncodeSize()).andReturn(1);
-// }
-//
-// EasyMock.replay(session, cm, executor, pd);
-// EasyMock.replay(msgs.toArray());
-//
-// final ClientConsumerInternal consumer =
-// new ClientConsumerImpl(session, 675765, 67565, 787, false, pd, executor, cm);
-//
-// final long pause = 2000;
-//
-// class AdderThread extends Thread
-// {
-// volatile boolean failed;
-//
-// public void run()
-// {
-// try
-// {
-// Thread.sleep(pause);
-//
-// for (ClientMessage msg: msgs)
-// {
-// consumer.handleMessage(msg);
-// }
-// }
-// catch (Exception e)
-// {
-// log.error("Failed to add messages", e);
-// failed = true;
-// }
-// }
-// };
-//
-// AdderThread t = new AdderThread();
-//
-// t.start();
-//
-// for (int i = 0; i < numMessages; i++)
-// {
-// ClientMessage msg;
-//
-// if (timeout == 0)
-// {
-// msg = consumer.receive();
-// }
-// else
-// {
-// msg = consumer.receive(timeout);
-// }
-//
-// assertTrue(msg == msgs.get(i));
-// }
-//
-// assertNull(consumer.receiveImmediate());
-//
-// t.join();
-//
-// assertFalse(t.failed);
-//
-// EasyMock.verify(session, cm, executor, pd);
-// EasyMock.verify(msgs.toArray());
-//
-// assertEquals(0, consumer.getBufferSize());
-// }
-//
-// public void testReceiveHandleMessagesAfterReceiveWithTimeout() throws Exception
-// {
-// ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
-// ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
-// PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-// CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//
-// final int numMessages = 10;
-//
-// final List<ClientMessage> msgs = new ArrayList<ClientMessage>();
-//
-// for (int i = 0; i < numMessages; i++)
-// {
-// ClientMessage msg = EasyMock.createStrictMock(ClientMessage.class);
-//
-// msgs.add(msg);
-//
-// EasyMock.expect(msg.getPriority()).andStubReturn((byte)4); //default priority
-// }
-//
-// EasyMock.replay(session, cm, executor, pd);
-// EasyMock.replay(msgs.toArray());
-//
-// final ClientConsumerInternal consumer =
-// new ClientConsumerImpl(session, 675765, 67565, 787, false, pd, executor, cm);
-//
-// final long pause = 2000;
-//
-// final long timeout = 1000;
-//
-// class AdderThread extends Thread
-// {
-// volatile boolean failed;
-//
-// public void run()
-// {
-// try
-// {
-// Thread.sleep(pause);
-//
-// for (ClientMessage msg: msgs)
-// {
-// consumer.handleMessage(msg);
-// }
-// }
-// catch (Exception e)
-// {
-// log.error("Failed to add messages", e);
-// failed = true;
-// }
-// }
-// };
-//
-// AdderThread t = new AdderThread();
-//
-// t.start();
-//
-// ClientMessage msg = consumer.receive(timeout);
-//
-// assertNull(msg);
-//
-// t.join();
-//
-// assertFalse(t.failed);
-//
-// EasyMock.verify(session, cm, executor, pd);
-// EasyMock.verify(msgs.toArray());
-//
-// assertEquals(numMessages, consumer.getBufferSize());
-// }
-//
-// public void testReceiveExpiredWithTimeout() throws Exception
-// {
-// ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
-// CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-// ExecutorService executor = EasyMock.createStrictMock(ExecutorService.class);
-// PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//
-// final int numMessages = 10;
-//
-// List<ClientMessage> msgs = new ArrayList<ClientMessage>();
-//
-// for (int i = 0; i < numMessages; i++)
-// {
-// ClientMessage msg = EasyMock.createStrictMock(ClientMessage.class);
-//
-// msgs.add(msg);
-//
-// EasyMock.expect(msg.getPriority()).andStubReturn((byte)4); //default priority
-//
-// EasyMock.expect(msg.isExpired()).andStubReturn(true);
-//
-// EasyMock.expect(msg.getDeliveryID()).andStubReturn((long)i);
-//
-// session.delivered((long)i, true);
-//
-// EasyMock.expect(msg.getEncodeSize()).andReturn(1);
-// }
-//
-// EasyMock.replay(session, cm, executor, pd);
-// EasyMock.replay(msgs.toArray());
-//
-// ClientConsumerInternal consumer =
-// new ClientConsumerImpl(session, 675765, 67565, 787, false, pd, executor, cm);
-//
-// for (ClientMessage msg: msgs)
-// {
-// consumer.handleMessage(msg);
-// }
-//
-// assertEquals(numMessages, consumer.getBufferSize());
-//
-// for (ClientMessage msg: msgs)
-// {
-// assertNull(consumer.receive(100));
-// }
-//
-// EasyMock.verify(session, cm, executor, pd);
-// EasyMock.verify(msgs.toArray());
-// }
-//
-// public void testWaitForOnMessageToCompleteOnClose() throws Exception
-// {
-// ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
-// ExecutorService executor = Executors.newSingleThreadExecutor();
-// PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-// CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//
-// final long clientTargetID = 283748;
-// final long targetID = 12934;
-//
-// final ClientConsumerInternal consumer =
-// new ClientConsumerImpl(session, targetID, clientTargetID, 787, false, pd, executor, cm);
-//
-// class MyHandler implements MessageHandler
-// {
-// volatile boolean failed;
-// volatile boolean complete;
-// public void onMessage(ClientMessage msg)
-// {
-// try
-// {
-// Thread.sleep(1000);
-// complete = true;
-// }
-// catch (Exception e)
-// {
-// failed = true;
-// }
-// }
-// };
-//
-// MyHandler handler = new MyHandler();
-//
-// consumer.setMessageHandler(handler);
-//
-// ClientMessage msg = EasyMock.createStrictMock(ClientMessage.class);
-//
-// EasyMock.expect(msg.getPriority()).andStubReturn((byte)4); //default priority
-//
-// EasyMock.expect(msg.isExpired()).andStubReturn(false);
-//
-// EasyMock.expect(msg.getDeliveryID()).andStubReturn(0L);
-//
-// session.delivered(0L, false);
-//
-// EasyMock.expect(msg.getEncodeSize()).andReturn(1);
-//
-// pd.unregister(clientTargetID);
-// session.removeConsumer(consumer);
-// EasyMock.expect(cm.sendCommandBlocking(targetID, new PacketImpl(PacketImpl.CLOSE))).andReturn(null);
-// EasyMock.replay(session, cm, pd, msg);
-//
-// consumer.handleMessage(msg);
-//
-// consumer.close();
-//
-// assertTrue(handler.complete);
-//
-// assertFalse(handler.failed);
-//
-// EasyMock.verify(session, cm, pd, msg);
-// }
-//
-// public void testWaitForOnMessageToCompleteOnCloseTimeout() throws Exception
-// {
-// ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
-// CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-// ExecutorService executor = Executors.newSingleThreadExecutor();
-// PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-//
-// final long clientTargetID = 283748;
-// final long targetID = 12934;
-//
-// final ClientConsumerInternal consumer =
-// new ClientConsumerImpl(session, targetID, clientTargetID, 787, false, pd, executor, cm);
-//
-// class MyHandler implements MessageHandler
-// {
-// volatile boolean failed;
-// volatile boolean complete;
-// public void onMessage(ClientMessage msg)
-// {
-// try
-// {
-// Thread.sleep(ClientConsumerImpl.CLOSE_TIMEOUT_MILLISECONDS + 2000);
-// complete = true;
-// }
-// catch (Exception e)
-// {
-// failed = true;
-// }
-// }
-// };
-//
-// MyHandler handler = new MyHandler();
-//
-// consumer.setMessageHandler(handler);
-//
-// ClientMessage msg = EasyMock.createStrictMock(ClientMessage.class);
-//
-// EasyMock.expect(msg.getPriority()).andStubReturn((byte)4); //default priority
-//
-// EasyMock.expect(msg.isExpired()).andStubReturn(false);
-//
-// EasyMock.expect(msg.getDeliveryID()).andStubReturn(0L);
-//
-// session.delivered(0L, false);
-//
-// EasyMock.expect(msg.getEncodeSize()).andReturn(1);
-//
-// pd.unregister(clientTargetID);
-// session.removeConsumer(consumer);
-// EasyMock.expect(cm.sendCommandBlocking(targetID, new PacketImpl(PacketImpl.CLOSE))).andReturn(null);
-// EasyMock.replay(session, cm, pd, msg);
-//
-// consumer.handleMessage(msg);
-//
-// long start = System.currentTimeMillis();
-// consumer.close();
-// long end = System.currentTimeMillis();
-// assertTrue((end - start) >= ClientConsumerImpl.CLOSE_TIMEOUT_MILLISECONDS);
-//
-// assertFalse(handler.complete);
-//
-// assertFalse(handler.failed);
-//
-// EasyMock.verify(session, cm, pd, msg);
-// }
-//
-// public void testWaitForOnMessageToCompleteOnCloseSameThread() throws Exception
-// {
-// ClientSessionInternal session = EasyMock.createStrictMock(ClientSessionInternal.class);
-// ExecutorService executor = new DirectExecutorService();
-// PacketDispatcher pd = EasyMock.createStrictMock(PacketDispatcher.class);
-// CommandManager cm = EasyMock.createStrictMock(CommandManager.class);
-//
-// final long clientTargetID = 283748;
-// final long targetID = 12934;
-//
-// final ClientConsumerInternal consumer =
-// new ClientConsumerImpl(session, targetID, clientTargetID, 787, false, pd, executor, cm);
-//
-// class MyHandler implements MessageHandler
-// {
-// volatile boolean failed;
-// volatile boolean complete;
-// public void onMessage(ClientMessage msg)
-// {
-// try
-// {
-// Thread.sleep(1000);
-// complete = true;
-// }
-// catch (Exception e)
-// {
-// failed = true;
-// }
-// }
-// };
-//
-// MyHandler handler = new MyHandler();
-//
-// consumer.setMessageHandler(handler);
-//
-// ClientMessage msg = EasyMock.createStrictMock(ClientMessage.class);
-//
-// EasyMock.expect(msg.getPriority()).andStubReturn((byte)4); //default priority
-//
-// EasyMock.expect(msg.isExpired()).andStubReturn(false);
-//
-// EasyMock.expect(msg.getDeliveryID()).andStubReturn(0L);
-//
-// session.delivered(0L, false);
-//
-// EasyMock.expect(msg.getEncodeSize()).andReturn(1);
-//
-// pd.unregister(clientTargetID);
-// session.removeConsumer(consumer);
-// EasyMock.expect(cm.sendCommandBlocking(targetID, new PacketImpl(PacketImpl.CLOSE))).andReturn(null);
-// EasyMock.replay(session, cm, pd, msg);
-//
-// consumer.handleMessage(msg);
-//
-// consumer.close();
-//
-// assertTrue(handler.complete);
-//
-// assertFalse(handler.failed);
-//
-// EasyMock.verify(session, cm, pd, msg);
-// }
-
- // Private -----------------------------------------------------------------------------------------------------------
-
-}
15 years, 1 month
JBoss hornetq SVN: r8500 - in trunk: src/main/org/hornetq/core/postoffice and 4 other directories.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-12-02 08:20:31 -0500 (Wed, 02 Dec 2009)
New Revision: 8500
Modified:
trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
trunk/src/main/org/hornetq/core/postoffice/PostOffice.java
trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
trunk/src/main/org/hornetq/core/server/RoutingContext.java
trunk/src/main/org/hornetq/core/server/impl/RoutingContextImpl.java
trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
trunk/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java
Log:
small optimisation to routing
Modified: trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-12-02 13:20:31 UTC (rev 8500)
@@ -739,7 +739,7 @@
notificationMessage.putTypedProperties(notifProps);
- postOffice.route(notificationMessage, null);
+ postOffice.route(notificationMessage);
}
}
}
Modified: trunk/src/main/org/hornetq/core/postoffice/PostOffice.java
===================================================================
--- trunk/src/main/org/hornetq/core/postoffice/PostOffice.java 2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/postoffice/PostOffice.java 2009-12-02 13:20:31 UTC (rev 8500)
@@ -56,6 +56,8 @@
void route(ServerMessage message, Transaction tx) throws Exception;
+ void route(ServerMessage message, RoutingContext context) throws Exception;
+
MessageReference reroute(ServerMessage message, Queue queue, Transaction tx) throws Exception;
boolean redistribute(ServerMessage message, final Queue originatingQueue, Transaction tx) throws Exception;
Modified: trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-12-02 13:20:31 UTC (rev 8500)
@@ -539,19 +539,22 @@
public void route(final ServerMessage message) throws Exception
{
- route(message, null);
+ route(message, (Transaction)null);
}
-
+
public void route(final ServerMessage message, final Transaction tx) throws Exception
{
+ this.route(message, new RoutingContextImpl(tx));
+ }
+
+ public void route(final ServerMessage message, final RoutingContext context) throws Exception
+ {
// Sanity check
if (message.getRefCount() > 0)
{
throw new IllegalStateException("Message cannot be routed more than once");
}
- RoutingContext context = new RoutingContextImpl(tx);
-
SimpleString address = message.getDestination();
setPagingStore(message);
@@ -661,7 +664,7 @@
message.setDestination(dlaAddress);
- route(message, tx);
+ route(message, context.getTransaction());
}
}
}
Modified: trunk/src/main/org/hornetq/core/server/RoutingContext.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/RoutingContext.java 2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/server/RoutingContext.java 2009-12-02 13:20:31 UTC (rev 8500)
@@ -37,5 +37,7 @@
List<Queue> getDurableQueues();
int getQueueCount();
+
+ void clear();
}
Modified: trunk/src/main/org/hornetq/core/server/impl/RoutingContextImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/RoutingContextImpl.java 2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/server/impl/RoutingContextImpl.java 2009-12-02 13:20:31 UTC (rev 8500)
@@ -42,6 +42,17 @@
this.transaction = transaction;
}
+ public void clear()
+ {
+ transaction = null;
+
+ nonDurableQueues.clear();
+
+ durableQueues.clear();
+
+ queueCount = 0;
+ }
+
public void addQueue(final Queue queue)
{
if (queue.isDurable())
Modified: trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-12-02 13:20:31 UTC (rev 8500)
@@ -91,6 +91,7 @@
import org.hornetq.core.server.LargeServerMessage;
import org.hornetq.core.server.MessageReference;
import org.hornetq.core.server.Queue;
+import org.hornetq.core.server.RoutingContext;
import org.hornetq.core.server.ServerConsumer;
import org.hornetq.core.server.ServerMessage;
import org.hornetq.core.server.ServerSession;
@@ -195,6 +196,8 @@
private boolean closed;
private final Map<SimpleString, CreditManagerHolder> creditManagerHolders = new HashMap<SimpleString, CreditManagerHolder>();
+
+ private final RoutingContext routingContext = new RoutingContextImpl(null);
// Constructors ---------------------------------------------------------------------------------
@@ -1965,15 +1968,18 @@
}
if (tx == null || autoCommitSends)
- {
- postOffice.route(msg);
+ {
}
else
{
- postOffice.route(msg, tx);
+ routingContext.setTransaction(tx);
}
+
+ postOffice.route(msg, routingContext);
+
+ routingContext.clear();
}
-
+
private static final class CreditManagerHolder
{
CreditManagerHolder(final PagingStore store)
Modified: trunk/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java 2009-12-02 11:56:32 UTC (rev 8499)
+++ trunk/tests/src/org/hornetq/tests/unit/core/server/impl/fakes/FakePostOffice.java 2009-12-02 13:20:31 UTC (rev 8500)
@@ -175,6 +175,12 @@
}
+ public void route(ServerMessage message, RoutingContext context) throws Exception
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
\ No newline at end of file
15 years, 1 month
JBoss hornetq SVN: r8499 - trunk/src/main/org/hornetq/core/remoting/impl.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2009-12-02 06:56:32 -0500 (Wed, 02 Dec 2009)
New Revision: 8499
Modified:
trunk/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java
Log:
log any unexpected Throwable thrown when receiving a packet
Modified: trunk/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java 2009-12-02 10:48:11 UTC (rev 8498)
+++ trunk/src/main/org/hornetq/core/remoting/impl/RemotingConnectionImpl.java 2009-12-02 11:56:32 UTC (rev 8499)
@@ -342,7 +342,14 @@
{
public void run()
{
- doBufferReceived(packet);
+ try
+ {
+ doBufferReceived(packet);
+ }
+ catch (Throwable t)
+ {
+ log.error("Unexpected error", t);
+ }
}
});
}
15 years, 1 month
JBoss hornetq SVN: r8498 - trunk/tests/src/org/hornetq/tests/unit/util/sizeof.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-12-02 05:48:11 -0500 (Wed, 02 Dec 2009)
New Revision: 8498
Modified:
trunk/tests/src/org/hornetq/tests/unit/util/sizeof/SizeOfBase.java
Log:
tweak to sizeof calcs
Modified: trunk/tests/src/org/hornetq/tests/unit/util/sizeof/SizeOfBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/util/sizeof/SizeOfBase.java 2009-12-02 10:40:48 UTC (rev 8497)
+++ trunk/tests/src/org/hornetq/tests/unit/util/sizeof/SizeOfBase.java 2009-12-02 10:48:11 UTC (rev 8498)
@@ -41,6 +41,8 @@
public void testCalculateSize()
{
+ System.out.println("os arch" + System.getProperty("os.arch"));
+
getMemorySize();
newObject();
@@ -50,16 +52,16 @@
long totalMemory1 = 0;
long totalMemory2 = 0;
- //First we do a dry run then throw away the results
+ //First we do a dry run with twice as many then throw away the results
- Object[] obj = new Object[numberOfObjects];
+ Object[] obj = new Object[numberOfObjects * 2];
- for (i = 0; i < numberOfObjects; i++)
+ for (i = 0; i < numberOfObjects * 2; i++)
{
obj[i] = newObject();
}
- obj = new Object[numberOfObjects];
+ obj = new Object[numberOfObjects * 2];
heap1 = getMemorySize();
@@ -78,7 +80,8 @@
if (totalMemory1 != totalMemory2)
{
- System.out.println("Warning: JVM allocated more data what would make results invalid");
+ System.out.println("Warning: JVM allocated more data what would make results invalid " +
+ totalMemory1 + ":" + totalMemory2);
}
System.out.println("heap1 = " + heap1 + ", heap2 = " + heap2 + ", size = " + size);
15 years, 1 month
JBoss hornetq SVN: r8497 - trunk/tests/src/org/hornetq/tests/unit/util/sizeof.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-12-02 05:40:48 -0500 (Wed, 02 Dec 2009)
New Revision: 8497
Added:
trunk/tests/src/org/hornetq/tests/unit/util/sizeof/MessageReferenceSizeOf.java
Modified:
trunk/tests/src/org/hornetq/tests/unit/util/sizeof/SizeOfBase.java
Log:
some additions to sizeof tests
Added: trunk/tests/src/org/hornetq/tests/unit/util/sizeof/MessageReferenceSizeOf.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/util/sizeof/MessageReferenceSizeOf.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/unit/util/sizeof/MessageReferenceSizeOf.java 2009-12-02 10:40:48 UTC (rev 8497)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.unit.util.sizeof;
+
+import org.hornetq.core.server.impl.MessageReferenceImpl;
+
+
+/**
+ *
+ * A MessageReferenceSizeOf
+ *
+ * @author Tim Fox
+ *
+ *
+ */
+public class MessageReferenceSizeOf extends SizeOfBase
+{
+
+ @Override
+ protected Object newObject()
+ {
+ return new MessageReferenceImpl();
+ }
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/hornetq/tests/unit/util/sizeof/SizeOfBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/util/sizeof/SizeOfBase.java 2009-12-02 10:36:54 UTC (rev 8496)
+++ trunk/tests/src/org/hornetq/tests/unit/util/sizeof/SizeOfBase.java 2009-12-02 10:40:48 UTC (rev 8497)
@@ -50,10 +50,17 @@
long totalMemory1 = 0;
long totalMemory2 = 0;
-
- final Object obj[] = new Object[numberOfObjects];
- // make sure we load the classes before
-
+ //First we do a dry run then throw away the results
+
+ Object[] obj = new Object[numberOfObjects];
+
+ for (i = 0; i < numberOfObjects; i++)
+ {
+ obj[i] = newObject();
+ }
+
+ obj = new Object[numberOfObjects];
+
heap1 = getMemorySize();
totalMemory1 = runtime.totalMemory();
15 years, 1 month