You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gr...@apache.org on 2010/11/09 15:25:38 UTC
svn commit: r1032991 - in /qpid/branches/0.5.x-dev/qpid/java:
broker/src/main/java/org/apache/qpid/server/
broker/src/main/java/org/apache/qpid/server/information/management/
broker/src/main/java/org/apache/qpid/server/protocol/
broker/src/main/java/or...
Author: grkvlt
Date: Tue Nov 9 14:25:37 2010
New Revision: 1032991
URL: http://svn.apache.org/viewvc?rev=1032991&view=rev
Log:
QPID-2932: Updated tests and documentation
Modified:
qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java
qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/information/management/ServerInformationMBean.java
qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java
qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java
qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsGatherer.java
qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
qpid/branches/0.5.x-dev/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedBroker.java
qpid/branches/0.5.x-dev/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ServerInformation.java
qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageConnectionStatisticsTest.java
qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java
qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java
qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTestCase.java
Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBean.java Tue Nov 9 14:25:37 2010
@@ -395,4 +395,9 @@ public class AMQBrokerManagerMBean exten
{
return _virtualHost.getDataStatistics().getTotal();
}
+
+ public boolean isStatisticsEnabled()
+ {
+ return _virtualHost.isStatisticsEnabled();
+ }
}
Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/information/management/ServerInformationMBean.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/information/management/ServerInformationMBean.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/information/management/ServerInformationMBean.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/information/management/ServerInformationMBean.java Tue Nov 9 14:25:37 2010
@@ -116,4 +116,9 @@ public class ServerInformationMBean exte
{
return registry.getDataStatistics().getTotal();
}
+
+ public boolean isStatisticsEnabled()
+ {
+ return registry.isStatisticsEnabled();
+ }
}
Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java Tue Nov 9 14:25:37 2010
@@ -958,7 +958,6 @@ public class AMQMinaProtocolSession impl
{
if (isStatisticsEnabled())
{
- _logger.info("=== STATS === register " + messageSize);
_messageStats.registerEvent(1L, timestamp);
_dataStats.registerEvent(messageSize, timestamp);
}
@@ -983,7 +982,9 @@ public class AMQMinaProtocolSession impl
public void initialiseStatistics()
{
- setStatisticsEnabled(_registry.getConfiguration().isStatisticsGenerationConnectionsEnabled());
+ setStatisticsEnabled(!StatisticsCounter.DISABLE_STATISTICS &&
+ _registry.getConfiguration().isStatisticsGenerationConnectionsEnabled());
+
_messageStats = new StatisticsCounter("messages-" + getSessionID());
_dataStats = new StatisticsCounter("bytes-" + getSessionID());
}
Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/registry/ApplicationRegistry.java Tue Nov 9 14:25:37 2010
@@ -427,7 +427,9 @@ public abstract class ApplicationRegistr
public void initialiseStatistics()
{
- setStatisticsEnabled(getConfiguration().isStatisticsGenerationBrokerEnabled());
+ setStatisticsEnabled(!StatisticsCounter.DISABLE_STATISTICS &&
+ getConfiguration().isStatisticsGenerationBrokerEnabled());
+
_messageStats = new StatisticsCounter("messages");
_dataStats = new StatisticsCounter("bytes");
}
Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java Tue Nov 9 14:25:37 2010
@@ -32,9 +32,10 @@ public class StatisticsCounter
{
private static final Logger _log = LoggerFactory.getLogger(StatisticsCounter.class);
+ public static final long DEFAULT_SAMPLE_PERIOD = Long.getLong("qpid.statistics.samplePeriod", 1000L); // 1s
+ public static final boolean DISABLE_STATISTICS = Boolean.getBoolean("qpid.statistics.disable");
+
private static final String COUNTER = "counter";
- private static final long DEFAULT_SAMPLE_PERIOD = Long.getLong("qpid.statistics.samplePeriod", 1000L); // 1s
- private static final boolean _disable = Boolean.getBoolean("qpid.statistics.disable");
private static final AtomicLong _counterIds = new AtomicLong(0L);
private final AtomicLong _peak = new AtomicLong(0L);
@@ -76,7 +77,7 @@ public class StatisticsCounter
public void registerEvent(long value, long timestamp)
{
- if (_disable)
+ if (DISABLE_STATISTICS)
{
return;
}
Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsGatherer.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsGatherer.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsGatherer.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsGatherer.java Tue Nov 9 14:25:37 2010
@@ -19,50 +19,74 @@
package org.apache.qpid.server.stats;
/**
- * Statistics gatherer.
+ * This interface is to be implemented by any broker business object that
+ * wishes to gather statistics about messages delivered through it.
+ *
+ * These statistics are exposed using a separate JMX Mbean interface, which
+ * calls these methods to retrieve the underlying {@link StatisticsCounter}s
+ * and return their attributes. This interface gives a standard way for
+ * parts of the broker to set up and configure statistics generation.
+ * <p>
+ * When creating these objects, there should be a parent/child relationship
+ * between them, such that the lowest level gatherer can record staticics if
+ * enabled, and pass on the notification to the parent object to allow higher
+ * level aggregation. When resetting statistics, this works in the opposite
+ * direction, with higher level gatherers also resetting all of their children.
*/
public interface StatisticsGatherer
{
/**
+ * Initialise the statistics gathering for this object.
*
- * @param period
+ * This method is responsible for creating any {@link StatisticsCounter}
+ * objects and for determining whether statistics generation should be
+ * enabled, by checking broker and system configuration.
+ *
+ * @see StatisticsCounter#DISABLE_STATISTICS
*/
void initialiseStatistics();
/**
+ * This method is responsible for registering the delivery of a message
+ * with the counters, and also for passing this notification to any parent
+ * {@link StatisticsGatherer}s. If statistics generation is not enabled,
+ * then this method should simple delegate to the parent gatherer.
*
- * @param messageSize
- * @param timestamp
+ * @param messageSize the size in bytes of the delivered message
+ * @param timestamp the time the message was delivered
*/
void registerMessageDelivery(long messageSize, long timestamp);
/**
+ * Gives access to the {@link StatisticsCounter} that is used to count
+ * message statistics.
*
- * @return
+ * @return the {@link StatisticsCounter} that counts messages
*/
StatisticsCounter getMessageStatistics();
/**
+ * Gives access to the {@link StatisticsCounter} that is used to count
+ * message size statistics.
*
- * @return
+ * @return the {@link StatisticsCounter} that counts bytes
*/
StatisticsCounter getDataStatistics();
/**
- *
- * @return
+ * Reset the counters for this, and any child {@link StatisticsGatherer}s.
*/
void resetStatistics();
/**
+ * Check if this object has statistics generation enabled.
*
- * @return
+ * @return true if statistics generation is enabled
*/
boolean isStatisticsEnabled();
/**
- *
- * @param enabled
+ * Enable or disable statistics generation for this object.
*/
void setStatisticsEnabled(boolean enabled);
}
Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/virtualhost/VirtualHost.java Tue Nov 9 14:25:37 2010
@@ -523,7 +523,9 @@ public class VirtualHost implements Acce
public void initialiseStatistics()
{
- setStatisticsEnabled(_registry.getConfiguration().isStatisticsGenerationVirtualhostsEnabled());
+ setStatisticsEnabled(!StatisticsCounter.DISABLE_STATISTICS &&
+ _registry.getConfiguration().isStatisticsGenerationVirtualhostsEnabled());
+
_messageStats = new StatisticsCounter("messages-" + getName());
_dataStats = new StatisticsCounter("bytes-" + getName());
}
Modified: qpid/branches/0.5.x-dev/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedBroker.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedBroker.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedBroker.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ManagedBroker.java Tue Nov 9 14:25:37 2010
@@ -179,4 +179,12 @@ public interface ManagedBroker
*/
@MBeanAttribute(name="totalData", description=TYPE + " Total Bytes")
long getTotalData();
+
+ /**
+ * Is statistics collection enabled for this connection.
+ *
+ * @since Qpid JMX API 1.9
+ */
+ @MBeanAttribute(name="statisticsEnabled", description=TYPE + " Statistics Enabled")
+ boolean isStatisticsEnabled();
}
Modified: qpid/branches/0.5.x-dev/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ServerInformation.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ServerInformation.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ServerInformation.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/ServerInformation.java Tue Nov 9 14:25:37 2010
@@ -142,4 +142,12 @@ public interface ServerInformation
*/
@MBeanAttribute(name="totalData", description=TYPE + " Total Bytes")
long getTotalData();
+
+ /**
+ * Is statistics collection enabled for this connection.
+ *
+ * @since Qpid JMX API 1.9
+ */
+ @MBeanAttribute(name="statisticsEnabled", description=TYPE + " Statistics Enabled")
+ boolean isStatisticsEnabled();
}
Modified: qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageConnectionStatisticsTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageConnectionStatisticsTest.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageConnectionStatisticsTest.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageConnectionStatisticsTest.java Tue Nov 9 14:25:37 2010
@@ -53,11 +53,12 @@ public class MessageConnectionStatistics
{
assertEquals("Incorrect connection total", 0, mc.getTotalMessages());
assertEquals("Incorrect connection data", 0, mc.getTotalData());
+ assertFalse("Connection statistics should not be enabled", mc.isStatisticsEnabled());
addresses.add(mc.getRemoteAddress());
}
- assertEquals("Incorrect active connection data", 0, vhost.getTotalData());
- assertEquals("Incorrect active connection data", 0, vhost.getTotalMessages());
+ assertEquals("Incorrect vhost total", 0, vhost.getTotalMessages());
+ assertEquals("Incorrect vhost data", 0, vhost.getTotalData());
Connection test = new AMQConnection(_brokerUrl, USER, USER, "clientid", "test");
test.start();
@@ -81,14 +82,17 @@ public class MessageConnectionStatistics
{
assertEquals("Incorrect connection total", 0, mc.getTotalMessages());
assertEquals("Incorrect connection data", 0, mc.getTotalData());
+ assertFalse("Connection statistics should not be enabled", mc.isStatisticsEnabled());
}
else
{
assertEquals("Incorrect connection total", 5, mc.getTotalMessages());
assertEquals("Incorrect connection data", 1000, mc.getTotalData());
+ assertTrue("Connection statistics should be enabled", mc.isStatisticsEnabled());
}
}
- assertEquals("Incorrect active connection data", 0, vhost.getTotalData());
- assertEquals("Incorrect active connection data", 0, vhost.getTotalMessages());
+ assertEquals("Incorrect vhost total", 0, vhost.getTotalMessages());
+ assertEquals("Incorrect vhost data", 0, vhost.getTotalData());
+ assertFalse("Vhost statistics should not be enabled", vhost.isStatisticsEnabled());
}
}
Modified: qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsConfigurationTest.java Tue Nov 9 14:25:37 2010
@@ -47,16 +47,19 @@ public class MessageStatisticsConfigurat
{
assertEquals("Incorrect connection total", 0, mc.getTotalMessages());
assertEquals("Incorrect connection data", 0, mc.getTotalData());
+ assertFalse("Connection statistics should not be enabled", mc.isStatisticsEnabled());
}
ManagedBroker vhost = _jmxUtils.getManagedBroker("test");
assertEquals("Incorrect vhost data", 0, vhost.getTotalMessages());
assertEquals("Incorrect vhost data", 0, vhost.getTotalData());
+ assertFalse("Vhost statistics should not be enabled", vhost.isStatisticsEnabled());
if (!_broker.equals(VM))
{
assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessages());
assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalData());
+ assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
}
}
@@ -72,16 +75,19 @@ public class MessageStatisticsConfigurat
{
assertEquals("Incorrect connection total", 0, mc.getTotalMessages());
assertEquals("Incorrect connection data", 0, mc.getTotalData());
+ assertFalse("Connection statistics should not be enabled", mc.isStatisticsEnabled());
}
ManagedBroker vhost = _jmxUtils.getManagedBroker("test");
assertEquals("Incorrect vhost data", 5, vhost.getTotalMessages());
assertEquals("Incorrect vhost data", 1000, vhost.getTotalData());
+ assertTrue("Vhost statistics should be enabled", vhost.isStatisticsEnabled());
if (!_broker.equals(VM))
{
assertEquals("Incorrect server total messages", 0, _jmxUtils.getServerInformation().getTotalMessages());
assertEquals("Incorrect server total data", 0, _jmxUtils.getServerInformation().getTotalData());
+ assertFalse("Server statistics should not be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
}
}
@@ -97,16 +103,19 @@ public class MessageStatisticsConfigurat
{
assertEquals("Incorrect connection total", 5, mc.getTotalMessages());
assertEquals("Incorrect connection data", 1000, mc.getTotalData());
+ assertTrue("Connection statistics should be enabled", mc.isStatisticsEnabled());
}
ManagedBroker vhost = _jmxUtils.getManagedBroker("test");
assertEquals("Incorrect vhost data", 0, vhost.getTotalMessages());
assertEquals("Incorrect vhost data", 0, vhost.getTotalData());
+ assertFalse("Vhost statistics should not be enabled", vhost.isStatisticsEnabled());
if (!_broker.equals(VM))
{
assertEquals("Incorrect server total messages", 0, _jmxUtils.getServerInformation().getTotalMessages());
assertEquals("Incorrect server total data", 0, _jmxUtils.getServerInformation().getTotalData());
+ assertFalse("Server statistics should not be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
}
}
@@ -122,16 +131,19 @@ public class MessageStatisticsConfigurat
{
assertEquals("Incorrect connection total", 0, mc.getTotalMessages());
assertEquals("Incorrect connection data", 0, mc.getTotalData());
+ assertFalse("Connection statistics should not be enabled", mc.isStatisticsEnabled());
}
ManagedBroker vhost = _jmxUtils.getManagedBroker("test");
assertEquals("Incorrect vhost data", 5, vhost.getTotalMessages());
assertEquals("Incorrect vhost data", 1000, vhost.getTotalData());
+ assertTrue("Vhost statistics should be enabled", vhost.isStatisticsEnabled());
if (!_broker.equals(VM))
{
assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessages());
assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalData());
+ assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
}
}
@@ -147,16 +159,19 @@ public class MessageStatisticsConfigurat
{
assertEquals("Incorrect connection total", 5, mc.getTotalMessages());
assertEquals("Incorrect connection data", 1000, mc.getTotalData());
+ assertTrue("Connection statistics should be enabled", mc.isStatisticsEnabled());
}
ManagedBroker vhost = _jmxUtils.getManagedBroker("test");
assertEquals("Incorrect vhost data", 5, vhost.getTotalMessages());
assertEquals("Incorrect vhost data", 1000, vhost.getTotalData());
+ assertTrue("Vhost statistics should be enabled", vhost.isStatisticsEnabled());
if (!_broker.equals(VM))
{
assertEquals("Incorrect server total messages", 5, _jmxUtils.getServerInformation().getTotalMessages());
assertEquals("Incorrect server total data", 1000, _jmxUtils.getServerInformation().getTotalData());
+ assertTrue("Server statistics should be enabled", _jmxUtils.getServerInformation().isStatisticsEnabled());
}
}
}
Modified: qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTest.java Tue Nov 9 14:25:37 2010
@@ -61,11 +61,11 @@ public class MessageStatisticsTest exten
data += mc.getTotalData();
}
assertEquals("Incorrect connection total", 45, total);
- assertEquals("Incorrect connection data", 45 * 100, data);
+ assertEquals("Incorrect connection data", 4500, data);
if (!_broker.equals(VM))
{
assertEquals("Incorrect server total", 45, _jmxUtils.getServerInformation().getTotalMessages());
- assertEquals("Incorrect server data", 45 * 100, _jmxUtils.getServerInformation().getTotalData());
+ assertEquals("Incorrect server data", 4500, _jmxUtils.getServerInformation().getTotalData());
}
long testTotal = 0;
@@ -77,8 +77,8 @@ public class MessageStatisticsTest exten
}
assertEquals("Incorrect test connection total", 10, testTotal);
assertEquals("Incorrect test vhost total", 10, test.getTotalMessages());
- assertEquals("Incorrect test connection data", 10 * 100, testData);
- assertEquals("Incorrect test vhost data", 10 * 100, test.getTotalData());
+ assertEquals("Incorrect test connection data", 1000, testData);
+ assertEquals("Incorrect test vhost data", 1000, test.getTotalData());
long devTotal = 0;
long devData = 0;
@@ -89,8 +89,8 @@ public class MessageStatisticsTest exten
}
assertEquals("Incorrect test connection total", 20, devTotal);
assertEquals("Incorrect development total", 20, dev.getTotalMessages());
- assertEquals("Incorrect test connection data", 20 * 100, devData);
- assertEquals("Incorrect development data", 20 * 100, dev.getTotalData());
+ assertEquals("Incorrect test connection data", 2000, devData);
+ assertEquals("Incorrect development data", 2000, dev.getTotalData());
long localTotal = 0;
long localData = 0;
@@ -101,8 +101,8 @@ public class MessageStatisticsTest exten
}
assertEquals("Incorrect test connection total", 15, localTotal);
assertEquals("Incorrect localhost total", 15, local.getTotalMessages());
- assertEquals("Incorrect test connection data", 15 * 100, localData);
- assertEquals("Incorrect localhost data", 15 * 100, local.getTotalData());
+ assertEquals("Incorrect test connection data", 1500, localData);
+ assertEquals("Incorrect localhost data", 1500, local.getTotalData());
}
/**
@@ -129,11 +129,11 @@ public class MessageStatisticsTest exten
data += mc.getTotalData();
}
assertEquals("Incorrect active connection total", 20, total);
- assertEquals("Incorrect active connection data", 20 * 100, data);
+ assertEquals("Incorrect active connection data", 2000, data);
if (!_broker.equals(VM))
{
assertEquals("Incorrect server total", 30, _jmxUtils.getServerInformation().getTotalMessages());
- assertEquals("Incorrect server data", 30 * 100, _jmxUtils.getServerInformation().getTotalData());
+ assertEquals("Incorrect server data", 3000, _jmxUtils.getServerInformation().getTotalData());
}
long testTotal = 0;
@@ -161,15 +161,15 @@ public class MessageStatisticsTest exten
ManagedBroker test = _jmxUtils.getManagedBroker("test");
ManagedBroker dev = _jmxUtils.getManagedBroker("development");
- assertEquals("Incorrect test vhost peak messages", 1.0d, test.getPeakMessageRate());
- assertEquals("Incorrect test vhost peak data", 10000.0d, test.getPeakDataRate());
- assertEquals("Incorrect dev vhost peak messages", 10.0d, dev.getPeakMessageRate());
- assertEquals("Incorrect dev vhost peak data", 100.0d, dev.getPeakDataRate());
+ assertApprox("Incorrect test vhost peak messages", 0.2d, 1.0d, test.getPeakMessageRate());
+ assertApprox("Incorrect test vhost peak data", 0.2d, 10000.0d, test.getPeakDataRate());
+ assertApprox("Incorrect dev vhost peak messages", 0.2d, 10.0d, dev.getPeakMessageRate());
+ assertApprox("Incorrect dev vhost peak data", 0.2d, 100.0d, dev.getPeakDataRate());
if (!_broker.equals(VM))
{
- assertEquals("Incorrect server peak messages", 10.0d, _jmxUtils.getServerInformation().getPeakMessageRate());
- assertEquals("Incorrect server peak data", 10000.0d, _jmxUtils.getServerInformation().getPeakDataRate());
+ assertApprox("Incorrect server peak messages", 0.2d, 10.0d, _jmxUtils.getServerInformation().getPeakMessageRate());
+ assertApprox("Incorrect server peak data", 0.2d, 10000.0d, _jmxUtils.getServerInformation().getPeakDataRate());
}
}
Modified: qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTestCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTestCase.java?rev=1032991&r1=1032990&r2=1032991&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTestCase.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/systests/src/main/java/org/apache/qpid/management/jmx/MessageStatisticsTestCase.java Tue Nov 9 14:25:37 2010
@@ -96,4 +96,17 @@ public abstract class MessageStatisticsT
producer.send(msg);
}
}
+
+ /**
+ * Asserts that the actual value is within the expected value plus or
+ * minus the given error.
+ */
+ public void assertApprox(String message, double error, double expected, double actual)
+ {
+ double min = expected * (1.0d - error);
+ double max = expected * (1.0d + error);
+ String assertion = String.format("%s: expected %f +/- %d, actual %f",
+ message, expected, (int) (error * 100.0d), actual);
+ assertTrue(assertion, actual > min && actual < max);
+ }
}
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org