You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2006/09/06 16:36:04 UTC

svn commit: r440727 - /james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java

Author: noel
Date: Wed Sep  6 07:36:04 2006
New Revision: 440727

URL: http://svn.apache.org/viewvc?view=rev&rev=440727
Log:
Add MEMSTAT command to give some memory statistics, with optionally forced garbage collection.

Modified:
    james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java

Modified: james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
URL: http://svn.apache.org/viewvc/james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java?view=diff&rev=440727&r1=440726&r2=440727
==============================================================================
--- james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java (original)
+++ james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java Wed Sep  6 07:36:04 2006
@@ -1,19 +1,22 @@
-/***********************************************************************
- * Copyright (c) 2000-2006 The Apache Software Foundation.             *
- * All rights reserved.                                                *
- * ------------------------------------------------------------------- *
- * Licensed 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.                      *
- ***********************************************************************/
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF 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.apache.james.remotemanager;
 
@@ -54,6 +57,11 @@
     implements ConnectionHandler, Poolable {
 
     /**
+     * The text string for the MEMSTAT command
+     */
+    private static final String COMMAND_MEMSTAT = "MEMSTAT";
+
+    /**
      * The text string for the ADDUSER command
      */
     private static final String COMMAND_ADDUSER = "ADDUSER";
@@ -417,6 +425,8 @@
             return doUNSETFORWARDING(argument);
         } else if (command.equals(COMMAND_USER)) {
             return doUSER(argument);
+        } else if (command.equals(COMMAND_MEMSTAT)) {
+            return doMEMSTAT(argument);
         } else if (command.equals(COMMAND_QUIT)) {
             return doQUIT(argument);
         } else if (command.equals(COMMAND_SHUTDOWN)) {
@@ -424,6 +434,29 @@
         } else {
             return doUnknownCommand(rawCommand);
         }
+        return true;
+    }
+
+    /**
+     * Handler method called upon receipt of an MEMSTAT command.
+     * Returns whether further commands should be read off the wire.
+     *
+     * @param argument the argument passed in with the command
+     */
+    private boolean doMEMSTAT(String argument) {
+        writeLoggedFlushedResponse("Current memory statistics:");
+        writeLoggedFlushedResponse("\tFree Memory: " + Runtime.getRuntime().freeMemory());
+        writeLoggedFlushedResponse("\tTotal Memory: " + Runtime.getRuntime().totalMemory());
+        writeLoggedFlushedResponse("\tMax Memory: " + Runtime.getRuntime().maxMemory());
+
+        if ("-gc".equalsIgnoreCase(argument)) {
+            System.gc();
+            writeLoggedFlushedResponse("And after System.gc():");
+            writeLoggedFlushedResponse("\tFree Memory: " + Runtime.getRuntime().freeMemory());
+            writeLoggedFlushedResponse("\tTotal Memory: " + Runtime.getRuntime().totalMemory());
+            writeLoggedFlushedResponse("\tMax Memory: " + Runtime.getRuntime().maxMemory());
+        }
+
         return true;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


RE: svn commit: r440727 - /james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java

Posted by "Noel J. Bergman" <no...@devtech.com>.
Stefano Bagnara wrote:

> Noel J. Bergman wrote:
>>> URL: http://svn.apache.org/viewvc?view=rev&rev=440727
>>> Add MEMSTAT command to give some memory statistics,
>>> with optionally forced garbage collection.
>> Since we're going back through another RC, and since I received
>> OOM again this morning.
> Ok, but please apply it to trunk, also (if not already there).

:-)  About a week ago.  ;-)

	--- Noel



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r440727 - /james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java

Posted by Stefano Bagnara <ap...@bago.org>.
Noel J. Bergman wrote:
>> URL: http://svn.apache.org/viewvc?view=rev&rev=440727
>> Add MEMSTAT command to give some memory statistics,
>> with optionally forced garbage collection.
> 
> Since we're going back through another RC, and since I received OOM again this morning.
> 
> 	--- Noel

Ok, but please apply it to trunk, also (if not already there).

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: svn commit: r440727 - /james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java

Posted by Norman Maurer <nm...@byteaction.de>.
Its allready in there..

bye
Norman

Am Mittwoch, den 06.09.2006, 17:04 +0200 schrieb Stefano Bagnara:
> Noel J. Bergman wrote:
> >> URL: http://svn.apache.org/viewvc?view=rev&rev=440727
> >> Add MEMSTAT command to give some memory statistics,
> >> with optionally forced garbage collection.
> > 
> > Since we're going back through another RC, and since I received OOM again this morning.
> > 
> > 	--- Noel
> 
> Ok, but please apply it to trunk, also (if not already there).
> 
> Stefano
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
> For additional commands, e-mail: server-dev-help@james.apache.org
> 
> !EXCUBATOR:1,44fee3a445111898010934!

RE: svn commit: r440727 - /james/server/branches/v2.3/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java

Posted by "Noel J. Bergman" <no...@devtech.com>.
> URL: http://svn.apache.org/viewvc?view=rev&rev=440727
> Add MEMSTAT command to give some memory statistics,
> with optionally forced garbage collection.

Since we're going back through another RC, and since I received OOM again this morning.

	--- Noel



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org