Author: azeez
Date: Thu Dec 6 03:55:54 2007
New Revision: 10633
Log:
Handle graceful shutdown and restart in a different thread. Interoduced a
default timeout.
Modified:
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServerAdmin.java
trunk/wsas/java/modules/core/conf/axis2.xml
trunk/wsas/java/modules/core/src/org/wso2/wsas/ServerManagement.java
Modified:
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServerAdmin.java
==============================================================================
---
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServerAdmin.java
(original)
+++
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServerAdmin.java
Thu Dec 6 03:55:54 2007
@@ -33,6 +33,7 @@
*/
public class ServerAdmin extends AbstractAdmin {
private static final Log log = LogFactory.getLog(ServerAdmin.class);
+ private Controllable controllable;
public ServerData getServerData() throws AxisFault {
return new ServerData(ServerConstants.SERVER_NAME,
@@ -46,62 +47,82 @@
}
public void restart() throws AxisFault {
- try {
- ConfigurationContext configurationContext =
-
MessageContext.getCurrentMessageContext().getConfigurationContext();
- Controllable controllable =
- (Controllable) configurationContext.
- getProperty(ServerConstants.WSO2WSAS_INSTANCE);
- controllable.restart();
- } catch (ServerException e) {
- String msg = "Cannot restart server";
- log.error(msg, e);
- throw new AxisFault(msg, e);
- }
+ ConfigurationContext configurationContext =
+
MessageContext.getCurrentMessageContext().getConfigurationContext();
+ controllable =
+ (Controllable) configurationContext.
+ getProperty(ServerConstants.WSO2WSAS_INSTANCE);
+ Thread th = new Thread() {
+ public void run() {
+ try {
+ controllable.restart();
+ } catch (ServerException e) {
+ String msg = "Cannot restart server";
+ log.error(msg, e);
+ throw new RuntimeException(msg, e);
+ }
+ }
+ };
+ th.start();
}
public void restartGracefully() throws AxisFault {
- try {
- ConfigurationContext configurationContext =
-
MessageContext.getCurrentMessageContext().getConfigurationContext();
- Controllable controllable =
- (Controllable) configurationContext.
- getProperty(ServerConstants.WSO2WSAS_INSTANCE);
- controllable.restartGracefully();
- } catch (ServerException e) {
- String msg = "Cannot restart server";
- log.error(msg, e);
- throw new AxisFault(msg, e);
- }
+ ConfigurationContext configurationContext =
+
MessageContext.getCurrentMessageContext().getConfigurationContext();
+ controllable =
+ (Controllable) configurationContext.
+ getProperty(ServerConstants.WSO2WSAS_INSTANCE);
+ Thread th = new Thread() {
+ public void run() {
+ try {
+ controllable.restartGracefully();
+ } catch (ServerException e) {
+ String msg = "Cannot restart server";
+ log.error(msg, e);
+ throw new RuntimeException(msg, e);
+ }
+ }
+ };
+ th.start();
}
public void shutdown() throws AxisFault {
- try {
- ConfigurationContext configurationContext =
-
MessageContext.getCurrentMessageContext().getConfigurationContext();
- Controllable controllable =
- (Controllable) configurationContext.
- getProperty(ServerConstants.WSO2WSAS_INSTANCE);
- controllable.shutdown();
- } catch (Exception e) {
- String msg = "Cannot shutdown server";
- log.error(msg, e);
- throw new AxisFault(msg, e);
- }
+ ConfigurationContext configurationContext =
+
MessageContext.getCurrentMessageContext().getConfigurationContext();
+ controllable =
+ (Controllable) configurationContext.
+ getProperty(ServerConstants.WSO2WSAS_INSTANCE);
+ Thread th = new Thread() {
+ public void run() {
+ try {
+ controllable.shutdown();
+ } catch (Exception e) {
+ String msg = "Cannot shutdown server";
+ log.error(msg, e);
+ throw new RuntimeException(msg, e);
+ }
+ }
+ };
+ th.start();
}
public void shutdownGracefully() throws AxisFault {
- try {
- ConfigurationContext configurationContext =
-
MessageContext.getCurrentMessageContext().getConfigurationContext();
- Controllable controllable =
- (Controllable) configurationContext.
- getProperty(ServerConstants.WSO2WSAS_INSTANCE);
- controllable.shutdownGracefully();
- } catch (Exception e) {
- String msg = "Cannot gracefully shutdown server";
- log.error(msg, e);
- throw new AxisFault(msg, e);
- }
+ ConfigurationContext configurationContext =
+
MessageContext.getCurrentMessageContext().getConfigurationContext();
+ controllable =
+ (Controllable) configurationContext.
+ getProperty(ServerConstants.WSO2WSAS_INSTANCE);
+ Thread th = new Thread() {
+ public void run() {
+ try {
+ controllable.shutdownGracefully();
+ } catch (Exception e) {
+ String msg = "Cannot gracefully shutdown server";
+ log.error(msg, e);
+ throw new RuntimeException(msg, e);
+ }
+ }
+ };
+ th.start();
}
}
Modified: trunk/wsas/java/modules/core/conf/axis2.xml
==============================================================================
--- trunk/wsas/java/modules/core/conf/axis2.xml (original)
+++ trunk/wsas/java/modules/core/conf/axis2.xml Thu Dec 6 03:55:54 2007
@@ -154,7 +154,7 @@
<parameter name="enableLookups">false</parameter>
<parameter name="disableUploadTimeout">false</parameter>
<parameter name="clientAuth">false</parameter>
- <parameter name="maxKeepAliveRequests">0</parameter>
+ <parameter name="maxKeepAliveRequests">100</parameter>
<parameter name="acceptCount">100</parameter>
<parameter name="compression">force</parameter>
@@ -182,7 +182,7 @@
<parameter name="enableLookups">false</parameter>
<parameter name="disableUploadTimeout">false</parameter>
<parameter name="clientAuth">false</parameter>
- <parameter name="maxKeepAliveRequests">0</parameter>
+ <parameter name="maxKeepAliveRequests">100</parameter>
<parameter name="acceptCount">100</parameter>
<parameter name="compression">force</parameter>
Modified: trunk/wsas/java/modules/core/src/org/wso2/wsas/ServerManagement.java
==============================================================================
--- trunk/wsas/java/modules/core/src/org/wso2/wsas/ServerManagement.java
(original)
+++ trunk/wsas/java/modules/core/src/org/wso2/wsas/ServerManagement.java
Thu Dec 6 03:55:54 2007
@@ -21,8 +21,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.Query;
@@ -39,6 +37,7 @@
public class ServerManagement implements ServerManagementMBean {
private static final Log log = LogFactory.getLog(ServerManagement.class);
+ private static final long TIMEOUT = 60 * 1000;
private Map inTransports;
public ServerManagement(Map inTransports) {
@@ -97,6 +96,7 @@
* @return An appropriate message
*/
public String startMaintenance() throws Exception {
+ long start = System.currentTimeMillis();
log.info("Starting to switch to maintenance mode...");
for (Iterator iter = inTransports.values().iterator();
iter.hasNext();) {
TransportInDescription tinDesc = (TransportInDescription)
iter.next();
@@ -118,6 +118,10 @@
Set set = mbs.queryNames(new
ObjectName("Catalina:type=RequestProcessor,*"), q);
if (set.size() > 0) {
areRequestsInService = true;
+ if (System.currentTimeMillis() - start > TIMEOUT) {
+ log.warn("Timeout occurred even though there are active
connections.");
+ break;
+ }
Thread.sleep(2000);
} else {
areRequestsInService = false;
_______________________________________________
Wsas-java-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/wsas-java-dev