[jboss-cvs] JBoss Messaging SVN: r3830 - in trunk: src/main/org/jboss/messaging/core/messagecounter and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 28 10:21:56 EST 2008
Author: ataylor
Date: 2008-02-28 10:21:56 -0500 (Thu, 28 Feb 2008)
New Revision: 3830
Removed:
trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounterManager.java
Modified:
trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java
trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java
trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
trunk/src/main/org/jboss/messaging/jms/server/MessageStatistics.java
trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java
Log:
management interface more updates
Modified: trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java 2008-02-28 10:58:16 UTC (rev 3829)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java 2008-02-28 15:21:56 UTC (rev 3830)
@@ -340,6 +340,10 @@
public Collection<MessageCounter> getMessageCounters()
{
+ for (String s : currentCounters.keySet())
+ {
+ currentCounters.get(s).sample();
+ }
return currentCounters.values();
}
Modified: trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java 2008-02-28 10:58:16 UTC (rev 3829)
+++ trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java 2008-02-28 15:21:56 UTC (rev 3830)
@@ -58,12 +58,10 @@
private Queue destQueue;
// counter
- private int countTotal;
- private int countTotalLast;
- private int depthLast;
private long timeLastUpdate;
// per hour day counter history
+ private int messageCount;
private int dayCounterMax;
private ArrayList<DayCounter> dayCounter;
@@ -84,7 +82,7 @@
destName = name;
destDurable = durable;
destQueue = queue;
-
+ messageCount = destQueue.getMessageCount();
// initialize counter
resetCounter();
@@ -109,12 +107,7 @@
*/
public synchronized void sample()
{
- int latestMessagesAdded = destQueue.getMessagesAdded();
-
- countTotal += latestMessagesAdded - lastMessagesAdded;
- lastMessagesAdded = latestMessagesAdded;
-
//update timestamp
timeLastUpdate = System.currentTimeMillis();
@@ -143,29 +136,14 @@
return destDurable;
}
- /**
- * Gets the total message count since startup or
- * last counter reset
- *
- * @return int message count
- */
- public int getCount()
+ public int getTotalMessages()
{
- return countTotal;
+ return this.destQueue.getMessagesAdded();
}
- /**
- * Gets the message count delta since last method call
- *
- * @return int message count delta
- */
- public int getCountDelta()
+ public int getCurrentMessageCount()
{
- int delta = countTotal - countTotalLast;
-
- countTotalLast = countTotal;
-
- return delta;
+ return this.destQueue.getMessageCount();
}
/**
@@ -176,25 +154,10 @@
*/
public int getMessageCount()
{
- return destQueue.getMessageCount();
+ return destQueue.getMessagesAdded() - messageCount;
}
- /**
- * Gets the message count delta of pending messages
- * since last method call. Therefore
- *
- * @return int message queue depth delta
- */
- public int getMessageCountDelta()
- {
- int current = destQueue.getMessageCount();
- int delta = current - depthLast;
- depthLast = current;
-
- return delta;
- }
-
/**
* Gets the timestamp of the last message add
*
@@ -210,9 +173,7 @@
*/
public void resetCounter()
{
- countTotal = 0;
- countTotalLast = 0;
- depthLast = 0;
+ messageCount = destQueue.getMessageCount();
timeLastUpdate = 0;
}
@@ -232,7 +193,9 @@
ret.append(destName).append(",");
// counter values
- ret.append("total = ").append(getCount()).append(",").append("total delta = ").append(getCountDelta()).append(",").append("current = ").append(getMessageCount()).append(",").append("current delta = ").append(getMessageCountDelta()).append(",");
+ ret.append("total messages received = ").append(getTotalMessages()).append(",").
+ append("current messages in queue = ").append(getCurrentMessageCount()).append(",").
+ append("current message count = ").append(getMessageCount()).append(",");
// timestamp last counter update
if (timeLastUpdate > 0)
Deleted: trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounterManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounterManager.java 2008-02-28 10:58:16 UTC (rev 3829)
+++ trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounterManager.java 2008-02-28 15:21:56 UTC (rev 3830)
@@ -1,202 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.messaging.core.messagecounter;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.server.MessagingComponent;
-
-/**
- *
- * A MessageCounterManager
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 3465 $</tt>
- *
- * $Id: MessageCounterManager.java 3465 2007-12-10 17:32:22Z ataylor $
- *
- */
-public class MessageCounterManager implements MessagingComponent
-{
- private static final Logger log = Logger.getLogger(MessageCounterManager.class);
-
- private Map messageCounters;
-
- private boolean started;
-
- private Timer timer;
-
- private long period;
-
- private PingMessageCountersTask task;
-
- public MessageCounterManager(long period)
- {
- messageCounters = new HashMap();
-
- this.period = period;
- }
-
- public synchronized void start()
- {
- if (started)
- {
- return;
- }
-
- // Needs to be daemon
- timer = new Timer(true);
-
- task = new PingMessageCountersTask();
-
- timer.schedule(task, 0, period);
-
- started = true;
- }
-
- public synchronized void stop()
- {
- if (!started)
- {
- return;
- }
-
- //Wait for timer task to stop
-
- task.stop();
-
- timer.cancel();
-
- timer = null;
-
- started = false;
- }
-
- public synchronized void reschedule(long newPeriod)
- {
- boolean wasStarted = this.started;
-
- if (wasStarted)
- {
- stop();
- }
-
- period = newPeriod;
-
- if (wasStarted)
- {
- start();
- }
- }
-
- public void registerMessageCounter(String name, MessageCounter counter)
- {
- synchronized (messageCounters)
- {
- messageCounters.put(name, counter);
- }
- }
-
- public MessageCounter unregisterMessageCounter(String name)
- {
- synchronized (messageCounters)
- {
- return (MessageCounter)messageCounters.remove(name);
- }
- }
-
- public Set getMessageCounters()
- {
- synchronized (messageCounters)
- {
- return new HashSet(messageCounters.values());
- }
- }
-
- public MessageCounter getMessageCounter(String name)
- {
- synchronized (messageCounters)
- {
- return (MessageCounter)messageCounters.get(name);
- }
- }
-
- public void resetAllCounters()
- {
- synchronized (messageCounters)
- {
- Iterator iter = messageCounters.values().iterator();
-
- while (iter.hasNext())
- {
- MessageCounter counter = (MessageCounter)iter.next();
-
- counter.resetCounter();
- }
- }
- }
-
- public void resetAllCounterHistories()
- {
- synchronized (messageCounters)
- {
- Iterator iter = messageCounters.values().iterator();
-
- while (iter.hasNext())
- {
- MessageCounter counter = (MessageCounter)iter.next();
-
- counter.resetHistory();
- }
- }
- }
-
- class PingMessageCountersTask extends TimerTask
- {
- public synchronized void run()
- {
- synchronized (messageCounters)
- {
- Iterator iter = messageCounters.values().iterator();
-
- while (iter.hasNext())
- {
- MessageCounter counter = (MessageCounter)iter.next();
-
- counter.sample();
- }
- }
- }
-
- synchronized void stop()
- {
- cancel();
- }
- }
-}
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-02-28 10:58:16 UTC (rev 3829)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java 2008-02-28 15:21:56 UTC (rev 3830)
@@ -21,10 +21,7 @@
*/
package org.jboss.messaging.core.server.impl;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.util.HashSet;
-import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
@@ -34,14 +31,10 @@
import org.jboss.messaging.core.deployers.impl.FileDeploymentManager;
import org.jboss.messaging.core.deployers.DeploymentManager;
import org.jboss.messaging.core.deployers.Deployer;
-import org.jboss.messaging.core.filter.Filter;
import org.jboss.messaging.core.memory.MemoryManager;
import org.jboss.messaging.core.memory.impl.SimpleMemoryManager;
-import org.jboss.messaging.core.message.MessageReference;
-import org.jboss.messaging.core.messagecounter.MessageCounterManager;
import org.jboss.messaging.core.persistence.PersistenceManager;
import org.jboss.messaging.core.persistence.impl.nullpm.NullPersistenceManager;
-import org.jboss.messaging.core.postoffice.Binding;
import org.jboss.messaging.core.postoffice.PostOffice;
import org.jboss.messaging.core.postoffice.impl.PostOfficeImpl;
import org.jboss.messaging.core.remoting.Interceptor;
@@ -56,7 +49,6 @@
import org.jboss.messaging.core.server.Configuration;
import org.jboss.messaging.core.server.ConnectionManager;
import org.jboss.messaging.core.server.MessagingServer;
-import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.QueueFactory;
import org.jboss.messaging.core.server.ServerConnection;
import org.jboss.messaging.core.settings.HierarchicalRepository;
@@ -99,7 +91,6 @@
private SecurityStoreImpl securityStore;
private ConnectionManagerImpl connectionManager;
private MemoryManager memoryManager = new SimpleMemoryManager();
- private MessageCounterManager messageCounterManager;
private PostOffice postOffice;
private Deployer securityDeployer;
private Deployer queueSettingsDeployer;
@@ -175,15 +166,6 @@
queueFactory = new QueueFactoryImpl(queueSettingsRepository, scheduledExecutor);
connectionManager = new ConnectionManagerImpl();
memoryManager = new SimpleMemoryManager();
- messageCounterManager = new MessageCounterManager(configuration.getMessageCounterSamplePeriod());
- configuration.addPropertyChangeListener(new PropertyChangeListener()
- {
- public void propertyChange(PropertyChangeEvent evt)
- {
- if (evt.getPropertyName().equals("messageCounterSamplePeriod"))
- messageCounterManager.reschedule(configuration.getMessageCounterSamplePeriod());
- }
- });
postOffice = new PostOfficeImpl(configuration.getMessagingServerID(),
persistenceManager, queueFactory, configuration.isStrictTck());
queueSettingsDeployer = new QueueSettingsDeployer(postOffice, queueSettingsRepository);
@@ -241,8 +223,6 @@
connectionManager = null;
memoryManager.stop();
memoryManager = null;
- messageCounterManager.stop();
- messageCounterManager = null;
postOffice.stop();
postOffice = null;
scheduledExecutor.shutdown();
Modified: trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2008-02-28 10:58:16 UTC (rev 3829)
+++ trunk/src/main/org/jboss/messaging/jms/server/JMSServerManager.java 2008-02-28 15:21:56 UTC (rev 3830)
@@ -93,17 +93,13 @@
public List<SessionInfo> getSessionsForUser(String user) throws Exception;
- void startGatheringStatistics();
+ void startGatheringStatistics() throws Exception;
- void startGatheringStatisticsForQueue(String queue);
+ void startGatheringStatisticsForQueue(String queue) throws Exception;
- void startGatheringStatisticsForTopic(String topic);
+ List<MessageStatistics> stopGatheringStatistics() throws Exception;
- void stopGatheringStatistics();
+ MessageStatistics stopGatheringStatisticsForQueue(String queue) throws Exception;
- void stopGatheringStatisticsForQueue(String queue);
-
- void stopGatheringStatisticsForTopic(String topic);
-
List<MessageStatistics> getStatistics() throws Exception;
}
Modified: trunk/src/main/org/jboss/messaging/jms/server/MessageStatistics.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/MessageStatistics.java 2008-02-28 10:58:16 UTC (rev 3829)
+++ trunk/src/main/org/jboss/messaging/jms/server/MessageStatistics.java 2008-02-28 15:21:56 UTC (rev 3830)
@@ -57,17 +57,13 @@
/** The message count */
private int count;
- /** The message count delta */
- private int countDelta;
+ private int totalMessageCount;
- /** The message depth */
- private int depth;
- /** The message depth delta */
- private int depthDelta;
/** The last update */
private long timeLastUpdate;
+ private int currentMessageCount;
// Static --------------------------------------------------------
@@ -102,67 +98,17 @@
this.count = count;
}
- /**
- * Get the countDelta.
- *
- * @return Returns the countDelta.
- */
- public int getCountDelta()
+ public int getTotalMessageCount()
{
- return countDelta;
+ return totalMessageCount;
}
- /**
- * Set the countDelta.
- *
- * @param countDelta The countDelta to set.
- */
- public void setCountDelta(int countDelta)
+ public void setTotalMessageCount(int totalMessageCount)
{
- this.countDelta = countDelta;
+ this.totalMessageCount = totalMessageCount;
}
/**
- * Get the depth.
- *
- * @return Returns the depth.
- */
- public int getDepth()
- {
- return depth;
- }
-
- /**
- * Set the depth.
- *
- * @param depth The depth to set.
- */
- public void setDepth(int depth)
- {
- this.depth = depth;
- }
-
- /**
- * Get the depthDelta.
- *
- * @return Returns the depthDelta.
- */
- public int getDepthDelta()
- {
- return depthDelta;
- }
-
- /**
- * Set the depthDelta.
- *
- * @param depthDelta The depthDelta to set.
- */
- public void setDepthDelta(int depthDelta)
- {
- this.depthDelta = depthDelta;
- }
-
- /**
* Get the durable.
*
* @return Returns the durable.
@@ -242,6 +188,17 @@
this.timeLastUpdate = timeLastUpdate;
}
+
+ public int getCurrentMessageCount()
+ {
+ return this.currentMessageCount;
+ }
+
+ public void setCurrentMessageCount(int currentMessageCount)
+ {
+ this.currentMessageCount = currentMessageCount;
+ }
+
/**
* Get the topic.
*
@@ -304,9 +261,9 @@
}
// counter values
- buffer.append(count).append(',').append(countDelta).append(',').append(depth).append(',').append(depthDelta)
- .append(',');
-
+ buffer.append("total messages received = ").append(getTotalMessageCount()).append(",").
+ append("current messages in queue = ").append(getCurrentMessageCount()).append(",").
+ append("current message count = ").append(getCount()).append(",");
// timestamp last counter update
if (timeLastUpdate > 0)
{
Modified: trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2008-02-28 10:58:16 UTC (rev 3829)
+++ trunk/src/main/org/jboss/messaging/jms/server/impl/JMSServerManagerImpl.java 2008-02-28 15:21:56 UTC (rev 3830)
@@ -73,7 +73,7 @@
private InitialContext initialContext;
private final Map<String, List<String>> destinations = new HashMap<String, List<String>>();
-
+
private final Map<String, JBossConnectionFactory> connectionFactories = new HashMap<String, JBossConnectionFactory>();
private final Map<String, List<String>> connectionFactoryBindings = new HashMap<String, List<String>>();
@@ -87,6 +87,7 @@
/**
* lifecycle method
+ *
* @throws Exception ex
*/
public void start() throws Exception
@@ -134,14 +135,13 @@
return true;
}
-
// management operations
public boolean isStarted()
{
return messagingServerManagement.isStarted();
}
-
+
public boolean createQueue(String queueName, String jndiBinding) throws Exception
{
JBossQueue jBossQueue = new JBossQueue(queueName);
@@ -205,7 +205,7 @@
Set<String> availableQueues = new HashSet<String>();
for (String address : availableAddresses)
{
- if(address.startsWith(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX))
+ if (address.startsWith(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX))
{
availableQueues.add(address.replace(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX, ""));
}
@@ -219,7 +219,7 @@
Set<String> availableTopics = new HashSet<String>();
for (String address : availableAddresses)
{
- if(address.startsWith(JBossTopic.JMS_TOPIC_ADDRESS_PREFIX))
+ if (address.startsWith(JBossTopic.JMS_TOPIC_ADDRESS_PREFIX))
{
availableTopics.add(address.replace(JBossTopic.JMS_TOPIC_ADDRESS_PREFIX, ""));
}
@@ -233,7 +233,7 @@
Set<String> tempDests = new HashSet<String>();
for (String address : availableAddresses)
{
- if(address.startsWith(JBossTemporaryTopic.JMS_TOPIC_ADDRESS_PREFIX) || address.startsWith(JBossTemporaryQueue.JMS_QUEUE_ADDRESS_PREFIX))
+ if (address.startsWith(JBossTemporaryTopic.JMS_TOPIC_ADDRESS_PREFIX) || address.startsWith(JBossTemporaryQueue.JMS_QUEUE_ADDRESS_PREFIX))
{
tempDests.add(address.replace(JBossTopic.JMS_TOPIC_ADDRESS_PREFIX, ""));
}
@@ -355,9 +355,9 @@
"JMSMessageID='" + messageId + "'");
}
- public void changeMessagePriority(String queue,String messageId, int priority) throws Exception
+ public void changeMessagePriority(String queue, String messageId, int priority) throws Exception
{
- messagingServerManagement.changeMessagePriority(new JBossQueue(queue).getAddress(),
+ messagingServerManagement.changeMessagePriority(new JBossQueue(queue).getAddress(),
"JMSMessageID='" + messageId + "'", priority);
}
@@ -468,7 +468,7 @@
List<ServerConnection> endpoints = messagingServerManagement.getActiveConnections();
for (ServerConnection endpoint : endpoints)
{
- if(id == null || id.equals(endpoint.getID()))
+ if (id == null || id.equals(endpoint.getID()))
{
Collection<ServerSession> serverSessionEndpoints = endpoint.getSessions();
for (ServerSession serverSessionEndpoint : serverSessionEndpoints)
@@ -487,7 +487,7 @@
List<ServerConnection> endpoints = messagingServerManagement.getActiveConnections();
for (ServerConnection endpoint : endpoints)
{
- if(user == null || user.equals(endpoint.getUsername()))
+ if (user == null || user.equals(endpoint.getUsername()))
{
sessionInfos.addAll(getSessionsForConnection(endpoint.getID()));
}
@@ -495,59 +495,55 @@
return sessionInfos;
}
- public void startGatheringStatistics()
+ public void startGatheringStatistics() throws Exception
{
- //To change body of implemented methods use File | Settings | File Templates.
+ Set<String> availableAddresses = messagingServerManagement.listAvailableAddresses();
+ for (String address : availableAddresses)
+ {
+ if (address.startsWith(JBossQueue.JMS_QUEUE_ADDRESS_PREFIX))
+ {
+ messagingServerManagement.startMessageCounter(address, 0);
+ }
+ }
}
- public void startGatheringStatisticsForQueue(String queue)
+ public void startGatheringStatisticsForQueue(String queue) throws Exception
{
- //To change body of implemented methods use File | Settings | File Templates.
+ JBossQueue jBossQueue = new JBossQueue(queue);
+ messagingServerManagement.startMessageCounter(jBossQueue.getAddress(), 0);
}
- public void startGatheringStatistics(JBossQueue queue)
+ public List<MessageStatistics> stopGatheringStatistics() throws Exception
{
- //To change body of implemented methods use File | Settings | File Templates.
+ List<MessageStatistics> messageStatisticses = createStats(messagingServerManagement.stopAllMessageCounters());
+ messagingServerManagement.unregisterAllMessageCounters();
+ return messageStatisticses;
}
- public void startGatheringStatisticsForTopic(String topic)
+ public MessageStatistics stopGatheringStatisticsForQueue(String queue) throws Exception
{
- //To change body of implemented methods use File | Settings | File Templates.
- }
+ JBossQueue queue1 = new JBossQueue(queue);
+ MessageCounter counter = messagingServerManagement.stopMessageCounter(queue1.getAddress());
- public void startGatheringStatistics(JBossTopic topic)
- {
- //To change body of implemented methods use File | Settings | File Templates.
+ MessageStatistics stats = new MessageStatistics();
+ stats.setName(counter.getDestinationName());
+ stats.setDurable(counter.getDestinationDurable());
+ stats.setCount(counter.getMessageCount());
+ stats.setTotalMessageCount(counter.getTotalMessages());
+ stats.setCurrentMessageCount(counter.getCurrentMessageCount());
+ stats.setTimeLastUpdate(counter.getLastUpdate());
+ messagingServerManagement.unregisterMessageCounter(queue1.getAddress());
+ return stats;
}
- public void stopGatheringStatistics()
+ public List<MessageStatistics> getStatistics() throws Exception
{
- //To change body of implemented methods use File | Settings | File Templates.
+ Collection<MessageCounter> counters = messagingServerManagement.getMessageCounters();
+ return createStats(counters);
}
- public void stopGatheringStatisticsForQueue(String queue)
+ private List<MessageStatistics> createStats(Collection<MessageCounter> counters)
{
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void stopGatheringStatistics(JBossQueue queue)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void stopGatheringStatisticsForTopic(String topic)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public void stopGatheringStatistics(JBossTopic topic)
- {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-
- public List<MessageStatistics> getStatistics() throws Exception
- {
- Collection<MessageCounter> counters = messagingServerManagement.getMessageCounters();
List<MessageStatistics> list = new ArrayList<MessageStatistics>(counters.size());
for (Object counter1 : counters)
{
@@ -556,10 +552,9 @@
MessageStatistics stats = new MessageStatistics();
stats.setName(counter.getDestinationName());
stats.setDurable(counter.getDestinationDurable());
- stats.setCount(counter.getCount());
- stats.setCountDelta(counter.getCountDelta());
- stats.setDepth(counter.getMessageCount());
- stats.setDepthDelta(counter.getMessageCountDelta());
+ stats.setCount(counter.getMessageCount());
+ stats.setTotalMessageCount(counter.getTotalMessages());
+ stats.setCurrentMessageCount(counter.getCurrentMessageCount());
stats.setTimeLastUpdate(counter.getLastUpdate());
list.add(stats);
@@ -640,9 +635,9 @@
if (queue.isDurable())
{
- Pair<String, String> pair = JBossTopic.decomposeQueueNameForDurableSubscription(queue.getName());
- clientID = pair.a;
- subName = pair.b;
+ Pair<String, String> pair = JBossTopic.decomposeQueueNameForDurableSubscription(queue.getName());
+ clientID = pair.a;
+ subName = pair.b;
}
SubscriptionInfo info = new SubscriptionInfo(queue.getName(), queue.isDurable(), subName, clientID,
Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java 2008-02-28 10:58:16 UTC (rev 3829)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/JMSServerManagerTest.java 2008-02-28 15:21:56 UTC (rev 3830)
@@ -28,6 +28,7 @@
import org.jboss.messaging.jms.server.ConnectionInfo;
import org.jboss.messaging.jms.server.JMSServerManager;
import org.jboss.messaging.jms.server.SubscriptionInfo;
+import org.jboss.messaging.jms.server.MessageStatistics;
import javax.jms.*;
import javax.naming.NameNotFoundException;
@@ -825,7 +826,6 @@
{
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = sess.createProducer(queue1);
- Message messageToMove = null;
TextMessage message = sess.createTextMessage();
message.setStringProperty("MyString", "12345");
@@ -872,4 +872,74 @@
}
}
+
+ public void testMessageStatistics() throws Exception
+ {
+ Connection conn = getConnectionFactory().createConnection("guest", "guest");
+ try
+ {
+ jmsServerManager.createQueue("CountQueue", "/queue/CountQueue");
+ Queue queue1 = (Queue) getInitialContext().lookup("/queue/CountQueue");
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = sess.createProducer(queue1);
+
+ TextMessage message = sess.createTextMessage();
+ for(int i = 0; i < 100; i++)
+ {
+ producer.send(message);
+ }
+ jmsServerManager.startGatheringStatisticsForQueue("CountQueue");
+ for(int i = 0; i < 100; i++)
+ {
+ producer.send(message);
+ }
+ List<MessageStatistics> messageStatistics = jmsServerManager.getStatistics();
+ assertTrue(messageStatistics != null && messageStatistics.size() ==1);
+ assertEquals(messageStatistics.get(0).getCount(), 100);
+ assertEquals(messageStatistics.get(0).getTotalMessageCount(), 200);
+ assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 200);
+ MessageConsumer consumer = sess.createConsumer(queue1);
+ conn.start();
+ for(int i = 0; i < 50; i++)
+ {
+ consumer.receive();
+ }
+ messageStatistics = jmsServerManager.getStatistics();
+ assertEquals(messageStatistics.get(0).getCount(), 100);
+ assertEquals(messageStatistics.get(0).getTotalMessageCount(), 200);
+ assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 150);
+ consumer.close();
+ for(int i = 0; i < 50; i++)
+ {
+ producer.send(message);
+ }
+ messageStatistics = jmsServerManager.getStatistics();
+ assertEquals(messageStatistics.get(0).getCount(), 150);
+ assertEquals(messageStatistics.get(0).getTotalMessageCount(), 250);
+ assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 200);
+
+ consumer = sess.createConsumer(queue1);
+ conn.start();
+ for(int i = 0; i < 200; i++)
+ {
+ consumer.receive();
+ }
+ messageStatistics = jmsServerManager.getStatistics();
+ assertEquals(messageStatistics.get(0).getCount(), 150);
+ assertEquals(messageStatistics.get(0).getTotalMessageCount(), 250);
+ assertEquals(messageStatistics.get(0).getCurrentMessageCount(), 0);
+ consumer.close();
+ jmsServerManager.stopGatheringStatisticsForQueue("CountQueue");
+ messageStatistics = jmsServerManager.getStatistics();
+ assertTrue(messageStatistics != null && messageStatistics.size() == 0);
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+
+ }
}
More information about the jboss-cvs-commits
mailing list