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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]