[jboss-cvs] JBoss Messaging SVN: r4882 - in trunk/src/main/org/jboss/messaging/core: management/impl and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 27 11:41:32 EDT 2008


Author: jmesnil
Date: 2008-08-27 11:41:32 -0400 (Wed, 27 Aug 2008)
New Revision: 4882

Removed:
   trunk/src/main/org/jboss/messaging/core/messagecounter/MessageStatistics.java
Modified:
   trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java
   trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
   trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
   trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java
   trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounterManager.java
   trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterManagerImpl.java
Log:
JBMESSAGING-1410: Reenable message counters

- removed unused class MessageStatistics (replaced by MessageCounterInfo)
- exposed message counter's maxDayCount and samplePeriod as attributes of MessagingServerControlMBean

Modified: trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java	2008-08-27 15:07:23 UTC (rev 4881)
+++ trunk/src/main/org/jboss/messaging/core/management/MessagingServerControlMBean.java	2008-08-27 15:41:32 UTC (rev 4882)
@@ -83,6 +83,16 @@
 
    Configuration getConfiguration();
    
+   boolean isEnableMessageCounters();
+
+   int getMessageCounterMaxDayCount();
+
+   void setMessageCounterMaxDayCount(int count);
+
+   long getMessageCounterSamplePeriod();
+
+   void setMessageCounterSamplePeriod(long newPeriod);
+   
    // Operations ----------------------------------------------------
 
    @Operation(desc = "Create a queue with the specified address", impact = ACTION)
@@ -119,5 +129,4 @@
 
    void disableMessageCounters();
 
-   boolean isEnableMessageCounters();
 }

Modified: trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java	2008-08-27 15:07:23 UTC (rev 4881)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/ManagementServiceImpl.java	2008-08-27 15:41:32 UTC (rev 4882)
@@ -157,7 +157,7 @@
          final StorageManager storageManager) throws Exception
    {
       MessageCounter counter = new MessageCounter(queue.getName().toString(), null, queue, false, queue.isDurable(),
-            10);
+            messageCounterManager.getMaxDayCount());
       messageCounterManager.registerMessageCounter(queue.getName().toString(), counter);
       ObjectName objectName = getQueueObjectName(address, queue.getName());
       QueueControlMBean queueControl = new QueueControl(queue, storageManager,

Modified: trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java	2008-08-27 15:07:23 UTC (rev 4881)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControl.java	2008-08-27 15:41:32 UTC (rev 4882)
@@ -391,6 +391,38 @@
       return enableMessageCounters;
    } 
    
+   public synchronized long getMessageCounterSamplePeriod()
+   {
+      return messageCounterManager.getSamplePeriod();
+   }
+
+   public synchronized void setMessageCounterSamplePeriod(long newPeriod)
+   {
+      if (newPeriod < 1000)
+      {
+         throw new IllegalArgumentException("Cannot set MessageCounterSamplePeriod < 1000 ms");
+      }
+
+      if (messageCounterManager != null && newPeriod != messageCounterManager.getSamplePeriod())
+      {
+         messageCounterManager.reschedule(newPeriod);
+      }
+   }
+   
+   public int getMessageCounterMaxDayCount()
+   {
+      return messageCounterManager.getMaxDayCount();
+   }
+   
+   public void setMessageCounterMaxDayCount(int count)
+   {
+      if (count <= 0)
+      {
+         throw new IllegalArgumentException("invalid value: count must be greater than 0");
+      }
+      messageCounterManager.setMaxDayCount(count);
+   }
+   
    // NotificationEmitter implementation ----------------------------
 
    public void removeNotificationListener(final NotificationListener listener,

Modified: trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java	2008-08-27 15:07:23 UTC (rev 4881)
+++ trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounter.java	2008-08-27 15:41:32 UTC (rev 4882)
@@ -26,7 +26,6 @@
 import java.util.Calendar;
 import java.util.Date;
 import java.util.GregorianCalendar;
-import java.util.Iterator;
 import java.util.List;
 
 import org.jboss.logging.Logger;
@@ -68,39 +67,6 @@
    // per hour day counter history
    private int dayCounterMax;
    private ArrayList dayCounter;
-   
-   /**
-    * Get a list of message statistics from a list of message counters
-    * 
-    * @param counter the message counters
-    * @return the message statistics
-    * @throws Exception for any error
-    */
-   public static List getMessageStatistics(List counters) throws Exception
-   {
-      List list = new ArrayList(counters.size());
-      
-      Iterator iter = counters.iterator();
-      
-      while (iter.hasNext())
-      {
-         MessageCounter counter = (MessageCounter)iter.next();
-         
-         MessageStatistics stats = new MessageStatistics();
-         stats.setName(counter.getDestinationName());
-         stats.setSubscriptionID(counter.getDestinationSubscription());
-         stats.setTopic(counter.getDestinationTopic());
-         stats.setDurable(counter.getDestinationDurable());
-         stats.setCount(counter.getCount());
-         stats.setCountDelta(counter.getCountDelta());
-         stats.setDepth(counter.getMessageCount());
-         stats.setDepthDelta(counter.getMessageCountDelta());
-         stats.setTimeLastUpdate(counter.getLastUpdate());
-         
-         list.add(stats);
-      }
-      return list;
-   }
 
    /**
     *    Constructor

Modified: trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounterManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounterManager.java	2008-08-27 15:07:23 UTC (rev 4881)
+++ trunk/src/main/org/jboss/messaging/core/messagecounter/MessageCounterManager.java	2008-08-27 15:41:32 UTC (rev 4882)
@@ -22,27 +22,31 @@
 
 package org.jboss.messaging.core.messagecounter;
 
-
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
- *
+ * 
  * @version <tt>$Revision$</tt>
- *
+ * 
  */
 public interface MessageCounterManager
 {
+   void start();
 
-   public abstract void start();
+   void stop();
 
-   public abstract void stop();
+   void registerMessageCounter(String name, MessageCounter counter);
 
-   public abstract void registerMessageCounter(String name,
-         MessageCounter counter);
+   MessageCounter unregisterMessageCounter(String name);
 
-   public abstract MessageCounter unregisterMessageCounter(String name);
+   void resetAllCounters();
 
-   public abstract void resetAllCounters();
+   void resetAllCounterHistories();
 
-   public abstract void resetAllCounterHistories();
+   void reschedule(long newPeriod);
 
+   long getSamplePeriod();
+
+   int getMaxDayCount();
+
+   void setMaxDayCount(int count);
 }
\ No newline at end of file

Deleted: trunk/src/main/org/jboss/messaging/core/messagecounter/MessageStatistics.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/messagecounter/MessageStatistics.java	2008-08-27 15:07:23 UTC (rev 4881)
+++ trunk/src/main/org/jboss/messaging/core/messagecounter/MessageStatistics.java	2008-08-27 15:41:32 UTC (rev 4882)
@@ -1,338 +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.io.Serializable;
-import java.text.DateFormat;
-import java.util.Date;
-
-/**
- * Message statistics
- * 
- * @author <a href="mailto:adrian at jboss.org">Adrian Brock</a>
- * @version <tt>$Revision: 1.3 $</tt>
- */
-public class MessageStatistics implements Serializable
-{
-   // Constants -----------------------------------------------------
-
-   /** The serialVersionUID */
-   static final long serialVersionUID = 8056884098781414022L;
-
-   // Attributes ----------------------------------------------------
-
-   /** Whether we are topic */
-   private boolean topic;
-
-   /** Whether we are durable */
-   private boolean durable;
-
-   /** The name */
-   private String name;
-
-   /** The subscription id */
-   private String subscriptionID;
-
-   /** The message count */
-   private int count;
-
-   /** The message count delta */
-   private int countDelta;
-
-   /** The message depth */
-   private int depth;
-
-   /** The message depth delta */
-   private int depthDelta;
-
-   /** The last update */
-   private long timeLastUpdate;
-
-   // Static --------------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   /**
-    * Construct a new Message Statistics
-    */
-   public MessageStatistics()
-   {
-   }
-
-   // Public --------------------------------------------------------
-
-   /**
-    * Get the count.
-    * 
-    * @return Returns the count.
-    */
-   public int getCount()
-   {
-      return count;
-   }
-
-   /**
-    * Set the count.
-    * 
-    * @param count The count to set.
-    */
-   public void setCount(int count)
-   {
-      this.count = count;
-   }
-
-   /**
-    * Get the countDelta.
-    * 
-    * @return Returns the countDelta.
-    */
-   public int getCountDelta()
-   {
-      return countDelta;
-   }
-
-   /**
-    * Set the countDelta.
-    * 
-    * @param countDelta The countDelta to set.
-    */
-   public void setCountDelta(int countDelta)
-   {
-      this.countDelta = countDelta;
-   }
-
-   /**
-    * 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.
-    */
-   public boolean isDurable()
-   {
-      return durable;
-   }
-
-   /**
-    * Set the durable.
-    * 
-    * @param durable The durable to set.
-    */
-   public void setDurable(boolean durable)
-   {
-      this.durable = durable;
-   }
-
-   /**
-    * Get the name.
-    * 
-    * @return Returns the name.
-    */
-   public String getName()
-   {
-      return name;
-   }
-
-   /**
-    * Set the name.
-    * 
-    * @param name The name to set.
-    */
-   public void setName(String name)
-   {
-      this.name = name;
-   }
-
-   /**
-    * Get the subscriptionID.
-    * 
-    * @return Returns the subscriptionID.
-    */
-   public String getSubscriptionID()
-   {
-      return subscriptionID;
-   }
-
-   /**
-    * Set the subscriptionID.
-    * 
-    * @param subscriptionID The subscriptionID to set.
-    */
-   public void setSubscriptionID(String subscriptionID)
-   {
-      this.subscriptionID = subscriptionID;
-   }
-
-   /**
-    * Get the timeLastUpdate.
-    * 
-    * @return Returns the timeLastUpdate.
-    */
-   public long getTimeLastUpdate()
-   {
-      return timeLastUpdate;
-   }
-
-   /**
-    * Set the timeLastUpdate.
-    * 
-    * @param timeLastUpdate The timeLastUpdate to set.
-    */
-   public void setTimeLastUpdate(long timeLastUpdate)
-   {
-      this.timeLastUpdate = timeLastUpdate;
-   }
-
-   /**
-    * Get the topic.
-    * 
-    * @return Returns the topic.
-    */
-   public boolean isTopic()
-   {
-      return topic;
-   }
-
-   /**
-    * Set the topic.
-    * 
-    * @param topic The topic to set.
-    */
-   public void setTopic(boolean topic)
-   {
-      this.topic = topic;
-   }
-
-   /**
-    * Get message data as string in format
-    *
-    *  "Topic/Queue, Name, Subscription, Durable, Count, CountDelta,
-    *  Depth, DepthDelta, Timestamp Last Increment"  
-    *
-    * @return  String data as a string
-    */
-   public String getAsString()
-   {
-      StringBuffer buffer = new StringBuffer(50);
-
-      // Topic/Queue
-      if (topic)
-         buffer.append("Topic,");
-      else
-         buffer.append("Queue,");
-
-      // name 
-      buffer.append(name).append(',');
-
-      // subscription
-      if (subscriptionID != null)
-         buffer.append(subscriptionID).append(',');
-      else
-         buffer.append("-,");
-
-      // Durable subscription
-      if (topic)
-      {
-         // Topic
-         if (durable)
-            buffer.append("DURABLE,");
-         else
-            buffer.append("NONDURABLE,");
-      }
-      else
-      {
-         buffer.append("-,");
-      }
-
-      // counter values
-      buffer.append(count).append(',').append(countDelta).append(',').append(depth).append(',').append(depthDelta)
-            .append(',');
-
-      // timestamp last counter update
-      if (timeLastUpdate > 0)
-      {
-         DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
-
-         buffer.append(dateFormat.format(new Date(timeLastUpdate)));
-      }
-      else
-      {
-         buffer.append('-');
-      }
-
-      return buffer.toString();
-   }
-
-   // Object overrides ----------------------------------------------
-
-   public String toString()
-   {
-      return getAsString();
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-
-}
\ No newline at end of file

Modified: trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterManagerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterManagerImpl.java	2008-08-27 15:07:23 UTC (rev 4881)
+++ trunk/src/main/org/jboss/messaging/core/messagecounter/impl/MessageCounterManagerImpl.java	2008-08-27 15:41:32 UTC (rev 4882)
@@ -56,6 +56,8 @@
    private long period;
    
    private PingMessageCountersTask task;
+
+   private int maxDayCount = 10;
           
    public MessageCounterManagerImpl(long period)
    {
@@ -116,6 +118,21 @@
       }
    }
    
+   public long getSamplePeriod()
+   {   
+      return period;
+   }
+   
+   public int getMaxDayCount()
+   {
+      return maxDayCount;
+   }
+   
+   public void setMaxDayCount(int count)
+   {
+      maxDayCount = count;  
+   }
+   
    public void registerMessageCounter(String name, MessageCounter counter)
    {
       synchronized (messageCounters)
@@ -200,4 +217,5 @@
          cancel();
       }
    }
+
 }




More information about the jboss-cvs-commits mailing list