[jboss-cvs] JBoss Messaging SVN: r7725 - in trunk: src/main/org/jboss/messaging/core/config and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 14 09:08:08 EDT 2009


Author: jmesnil
Date: 2009-08-14 09:08:07 -0400 (Fri, 14 Aug 2009)
New Revision: 7725

Added:
   trunk/src/main/org/jboss/messaging/core/server/impl/ServerInfo.java
Modified:
   trunk/src/config/common/schema/jbm-configuration.xsd
   trunk/src/main/org/jboss/messaging/core/config/Configuration.java
   trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
   trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
   trunk/src/main/org/jboss/messaging/core/management/MessagingServerControl.java
   trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControlImpl.java
   trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java
   trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
   trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlUsingCoreTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/QueueDeployerTest.java
Log:
JBMESSAGING-1711: Add periodic dump of server info for debugging

* added ServerInfo class to dump server info (memory, # of threads, # of connections)
* the server logs the dump at regular interval
* interval can be specified using Configuration.setServerDumpInterval()
  or using <server-dump-interval> in jbm-configuration. 
  Default is 0 (i.e. never dump), value is in milliseconds
* added pagingTotalMemory attribute to MessagingServerControl

Modified: trunk/src/config/common/schema/jbm-configuration.xsd
===================================================================
--- trunk/src/config/common/schema/jbm-configuration.xsd	2009-08-13 17:49:22 UTC (rev 7724)
+++ trunk/src/config/common/schema/jbm-configuration.xsd	2009-08-14 13:08:07 UTC (rev 7725)
@@ -162,6 +162,8 @@
 				</xsd:element>
 				<xsd:element maxOccurs="1" minOccurs="0" name="perf-blast-pages" type="xsd:int">
 				</xsd:element>
+				<xsd:element maxOccurs="1" minOccurs="0" name="server-dump-interval" type="xsd:long">
+				</xsd:element>
 				<xsd:element maxOccurs="1" minOccurs="0" name="large-messages-directory" type="xsd:string">
 				</xsd:element>
                 <xsd:element maxOccurs="1" minOccurs="0" name="security-settings">

Modified: trunk/src/main/org/jboss/messaging/core/config/Configuration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/Configuration.java	2009-08-13 17:49:22 UTC (rev 7724)
+++ trunk/src/main/org/jboss/messaging/core/config/Configuration.java	2009-08-14 13:08:07 UTC (rev 7725)
@@ -230,7 +230,10 @@
    
    void setJournalPerfBlastPages(int pages);
 
+   long getServerDumpInterval();
 
+   void getServerDumpInterval(long interval);
+
    // Paging Properties --------------------------------------------------------------------
 
    String getPagingDirectory();

Modified: trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java	2009-08-13 17:49:22 UTC (rev 7724)
+++ trunk/src/main/org/jboss/messaging/core/config/impl/ConfigurationImpl.java	2009-08-14 13:08:07 UTC (rev 7725)
@@ -153,6 +153,8 @@
 
    public static final int DEFAULT_BRIDGE_RECONNECT_ATTEMPTS = -1;
 
+   public static final long DEFAULT_SERVER_DUMP_INTERVAL = 0;
+
    // Attributes -----------------------------------------------------------------------------
 
    protected boolean clustered = DEFAULT_CLUSTERED;
@@ -274,6 +276,8 @@
 
    protected long managementRequestTimeout = DEFAULT_MANAGEMENT_REQUEST_TIMEOUT;
 
+   protected long serverDumpInterval = DEFAULT_SERVER_DUMP_INTERVAL;
+
    // MessagingComponent implementation ----------------------------------------------
 
    public void start() throws Exception
@@ -861,35 +865,33 @@
              cother.getManagementAddress().equals(getManagementAddress());
    }
 
-   /* (non-Javadoc)
-    * @see org.jboss.messaging.core.config.Configuration#getJournalCompactMinFiles()
-    */
    public int getJournalCompactMinFiles()
    {
       return journalCompactMinFiles;
    }
 
-   /* (non-Javadoc)
-    * @see org.jboss.messaging.core.config.Configuration#getJournalCompactPercentage()
-    */
    public int getJournalCompactPercentage()
    {
       return journalCompactPercentage;
    }
    
-   /* (non-Javadoc)
-    * @see org.jboss.messaging.core.config.Configuration#setJournalCompactMinFiles()
-    */
    public void setJournalCompactMinFiles(int minFiles)
    {
       this.journalCompactMinFiles = minFiles;
    }
 
-   /* (non-Javadoc)
-    * @see org.jboss.messaging.core.config.Configuration#setJournalCompactPercentage()
-    */
    public void setJournalCompactPercentage(int percentage)
    {
       this.journalCompactPercentage = percentage;
    }
+   
+   public long getServerDumpInterval()
+   {
+      return serverDumpInterval;
+   }
+   
+   public void getServerDumpInterval(long intervalInMilliseconds)
+   {
+      this.serverDumpInterval = intervalInMilliseconds;
+   }
 }

Modified: trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java	2009-08-13 17:49:22 UTC (rev 7724)
+++ trunk/src/main/org/jboss/messaging/core/config/impl/FileConfiguration.java	2009-08-14 13:08:07 UTC (rev 7725)
@@ -331,6 +331,8 @@
 
       messageCounterMaxDayHistory = getInteger(e, "message-counter-max-day-history", messageCounterMaxDayHistory, GT_ZERO);
       
+      serverDumpInterval = getLong(e, "server-dump-interval", serverDumpInterval, GE_ZERO); // in milliseconds
+
       started = true;
    }
    

Modified: trunk/src/main/org/jboss/messaging/core/management/MessagingServerControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/MessagingServerControl.java	2009-08-13 17:49:22 UTC (rev 7724)
+++ trunk/src/main/org/jboss/messaging/core/management/MessagingServerControl.java	2009-08-14 13:08:07 UTC (rev 7725)
@@ -39,6 +39,8 @@
    String getVersion();
 
    int getConnectionCount();
+   
+   long getPagingTotalMemory();
 
    boolean isStarted();
 

Modified: trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControlImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControlImpl.java	2009-08-13 17:49:22 UTC (rev 7724)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerControlImpl.java	2009-08-14 13:08:07 UTC (rev 7725)
@@ -272,6 +272,11 @@
    {
       return server.getConnectionCount();
    }
+   
+   public long getPagingTotalMemory()
+   {
+      return server.getPagingTotalMemory();
+   }
 
    public void enableMessageCounters()
    {

Modified: trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java	2009-08-13 17:49:22 UTC (rev 7724)
+++ trunk/src/main/org/jboss/messaging/core/management/jmx/impl/ReplicationAwareMessagingServerControlWrapper.java	2009-08-14 13:08:07 UTC (rev 7725)
@@ -80,6 +80,11 @@
    {
       return localControl.getConnectionCount();
    }
+   
+   public long getPagingTotalMemory()
+   {
+      return localControl.getPagingTotalMemory();
+   }
 
    public String[] getInterceptorClassNames()
    {

Modified: trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java	2009-08-13 17:49:22 UTC (rev 7724)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java	2009-08-14 13:08:07 UTC (rev 7725)
@@ -112,6 +112,8 @@
 
    int getConnectionCount();
 
+   long getPagingTotalMemory();
+
    PostOffice getPostOffice();
 
    QueueFactory getQueueFactory();
@@ -145,4 +147,5 @@
    void destroyQueue(SimpleString queueName, ServerSession session) throws Exception;
 
    void handleReplicateRedistribution(final SimpleString queueName, final long messageID) throws Exception;
+
 }

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2009-08-13 17:49:22 UTC (rev 7724)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2009-08-14 13:08:07 UTC (rev 7725)
@@ -636,6 +636,11 @@
    {
       return remotingService.getConnections().size();
    }
+   
+   public long getPagingTotalMemory()
+   {
+      return pagingManager.getTotalMemory();
+   }
 
    public PostOffice getPostOffice()
    {
@@ -873,7 +878,7 @@
 
       managementService = new ManagementServiceImpl(mbeanServer, configuration, managementConnectorID);
       
-      remotingService = new RemotingServiceImpl(configuration, this, managementService, threadPool, scheduledPool, managementConnectorID);
+      remotingService = new RemotingServiceImpl(configuration, this, managementService, threadPool, scheduledPool, managementConnectorID);      
    }
    
    private void initialisePart2() throws Exception
@@ -1030,6 +1035,19 @@
 
       pagingManager.resumeDepages();
 
+      final ServerInfo dumper = new ServerInfo(this);
+      long dumpInfoInterval = configuration.getServerDumpInterval();
+      if (dumpInfoInterval > 0)
+      {
+         scheduledPool.scheduleWithFixedDelay(new Runnable()
+         {
+
+            public void run()
+            {
+               log.info(dumper.dump());
+            }
+         }, 0, dumpInfoInterval, TimeUnit.MILLISECONDS);
+      }
       initialised = true;
 
       started = true;

Added: trunk/src/main/org/jboss/messaging/core/server/impl/ServerInfo.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerInfo.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerInfo.java	2009-08-14 13:08:07 UTC (rev 7725)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2009, Red Hat Middleware LLC, and individual contributors
+ * 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.server.impl;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryMXBean;
+import java.lang.management.MemoryUsage;
+import java.lang.management.ThreadMXBean;
+import java.util.Date;
+
+import org.jboss.messaging.core.server.MessagingServer;
+
+/**
+ * A ServerInfo
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class ServerInfo
+{
+   private final MessagingServer server;
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   public ServerInfo(final MessagingServer server)
+   {
+      this.server = server;
+   }
+
+   // Public --------------------------------------------------------
+
+   public String dump()
+   {
+      MemoryMXBean memory = ManagementFactory.getMemoryMXBean();
+      MemoryUsage heapMemory = memory.getHeapMemoryUsage();
+      MemoryUsage nonHeapMemory = memory.getHeapMemoryUsage();
+      ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
+      String info = "\n**** Server Dump ****\n";
+      info += String.format("date:            %s\n", new Date());
+      info += String.format("heap memory:     used=%s, max=%s\n",
+                            sizeof(heapMemory.getUsed()),
+                            sizeof(heapMemory.getMax()));
+      info += String.format("non-heap memory: used=%s, max=%s\n",
+                            sizeof(nonHeapMemory.getUsed()),
+                            sizeof(nonHeapMemory.getMax()));
+      info += String.format("paging memory:   %s\n", sizeof(server.getPagingTotalMemory()));
+      info += String.format("# of thread:     %d\n", threadMXBean.getThreadCount());
+      info += String.format("# of conns:      %d\n", server.getConnectionCount());
+      info += "********************\n";
+      return info;
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   private static long oneKB = 1024;
+
+   private static long oneMB = oneKB * 1024;
+
+   private static long oneGB = oneMB * 1024;
+
+   private static String sizeof(long size)
+   {
+      double s = Long.valueOf(size).doubleValue();
+      String suffix = "B";
+      if (s > oneGB)
+      {
+         s /= oneGB;
+         suffix = "GB";
+      }
+      else if (s > oneMB)
+      {
+         s /= oneMB;
+         suffix = "MB";
+      }
+      else if (s > oneKB)
+      {
+         s /= oneKB;
+         suffix = "kB";
+      }
+      return String.format("%.2f %s", s, suffix);
+   }
+
+   // Inner classes -------------------------------------------------
+
+}

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlUsingCoreTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlUsingCoreTest.java	2009-08-13 17:49:22 UTC (rev 7724)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/management/MessagingServerControlUsingCoreTest.java	2009-08-14 13:08:07 UTC (rev 7725)
@@ -146,6 +146,11 @@
             return (Integer)proxy.retrieveAttributeValue("connectionCount");
          }
 
+         public long getPagingTotalMemory()
+         {
+            return (Integer)proxy.retrieveAttributeValue("pagingTotalMemory");
+         }
+
          public long getConnectionTTLOverride()
          {
             return (Long)proxy.retrieveAttributeValue("connectionTTLOverride", Long.class);

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/QueueDeployerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/QueueDeployerTest.java	2009-08-13 17:49:22 UTC (rev 7724)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/deployers/impl/QueueDeployerTest.java	2009-08-14 13:08:07 UTC (rev 7725)
@@ -218,6 +218,11 @@
 
          return 0;
       }
+      
+      public long getPagingTotalMemory()
+      {
+         return 0;
+      }
 
       public long getConnectionTTLOverride()
       {




More information about the jboss-cvs-commits mailing list