Skip to content
Browse files

AS7-6620 ManagedDomainDeployableContainer kills the managed server in…

…stead of regular shutdown in stop() on Windows
  • Loading branch information...
1 parent 011cdd0 commit 7d5977ce1d927785424cca065395b1b724fc5c50 @rhusar rhusar committed with stuartwdouglas Feb 26, 2013
View
2 ...ain/java/org/jboss/as/arquillian/container/domain/CommonDomainContainerConfiguration.java
@@ -124,7 +124,7 @@ public void setContainerNameMap(String containerNameMap) {
* Change the container mode of the Servers or ServerGroups in the Domain.
* format: host:server-name=manual,host:.*=suite
*
- * @param containerModeMap
+ * @param containerModeString
*/
public void setContainerModeMap(String containerModeString) {
this.containerModeMap = convertToMap(containerModeString);
View
19 ...org/jboss/as/arquillian/container/domain/managed/ManagedDomainContainerConfiguration.java
@@ -39,6 +39,8 @@
private int startupTimeoutInSeconds = 60;
+ private int stopTimeoutInSeconds = 60;
+
private int autoServerStartupTimeoutInSeconds = 60;
private boolean outputToConsole = true;
@@ -127,6 +129,21 @@ public int getStartupTimeoutInSeconds() {
}
/**
+ * @param stopTimeoutInSeconds number of seconds to wait for the container process to shutdown
+ */
+ public void setStopTimeoutInSeconds(int stopTimeoutInSeconds) {
+ this.stopTimeoutInSeconds = stopTimeoutInSeconds;
+ }
+
+ /**
+ * @return stopTimeoutInSeconds number of seconds to wait for the container process to shutdown;
+ * defaults to 60
+ */
+ public int getStopTimeoutInSeconds() {
+ return stopTimeoutInSeconds;
+ }
+
+ /**
* The number of seconds to wait before failing when starting servers in Auto start mode
*
* @param autoServerStartupTimeoutInSeconds
@@ -185,7 +202,7 @@ public String getHostConfig() {
/**
* Set the server configuration file name. Equivalent to [-Djboss.host.default.config=...] on the command line.
*
- * @param domainConfig the host xml file name
+ * @param hostConfig the host xml file name
*/
public void setHostConfig(String hostConfig) {
this.hostConfig = hostConfig;
View
35 ...va/org/jboss/as/arquillian/container/domain/managed/ManagedDomainDeployableContainer.java
@@ -33,6 +33,7 @@
import org.jboss.as.arquillian.container.domain.Domain;
import org.jboss.as.arquillian.container.domain.ManagementClient;
import org.jboss.as.arquillian.container.domain.Domain.Server;
+import org.jboss.dmr.ModelNode;
/**
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
@@ -126,9 +127,41 @@ protected void stopInternal() throws LifecycleException {
}
try {
if (process != null) {
- process.destroy();
+ Thread shutdown = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(getContainerConfiguration().getStopTimeoutInSeconds() * 1000);
+ } catch (InterruptedException e) {
+ return;
+ }
+
+ // The process hasn't shutdown within 60 seconds. Terminate forcibly.
+ if (process != null) {
+ process.destroy();
+ }
+ }
+ });
+ shutdown.start();
+
+ // Fetch the local-host-name attribute (e.g. "master")
+ ModelNode op = new ModelNode();
+ op.get("operation").set("read-attribute");
+ op.get("name").set("local-host-name");
+ ModelNode result = getManagementClient().getControllerClient().execute(op, null);
+ String hostName = result.get("result").asString();
+
+ // AS7-6620: Create the shutdown operation and run it asynchronously and wait for process to terminate
+ op = new ModelNode();
+ op.get("operation").set("shutdown");
+ ModelNode address = op.get("address");
+ address.add("host", hostName);
+ getManagementClient().getControllerClient().executeAsync(op, null);
+
process.waitFor();
process = null;
+
+ shutdown.interrupt();
}
} catch (Exception e) {
throw new LifecycleException("Could not stop container", e);
View
4 ...est/java/org/jboss/as/arquillian/container/domain/managed/test/ManagedDomainTestCase.java
@@ -30,8 +30,8 @@
import org.junit.runner.RunWith;
/**
- * For Domain server DeployableContianer implementations, the DeployableContainer will register
- * all groups/individual servers it controls as Containers in Arquillians Registry during start.
+ * For Domain server DeployableContainer implementations, the DeployableContainer will register
+ * all groups/individual servers it controls as Containers in Arquillian's Registry during start.
*
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
* @version $Revision: $
View
4 .../java/org/jboss/as/arquillian/container/domain/managed/test/ManagedDomainTwoTestCase.java
@@ -30,8 +30,8 @@
import org.junit.runner.RunWith;
/**
- * For Domain server DeployableContianer implementations, the DeployableContainer will register
- * all groups/individual servers it controls as Containers in Arquillians Registry during start.
+ * For Domain server DeployableContainer implementations, the DeployableContainer will register
+ * all groups/individual servers it controls as Containers in Arquillian's Registry during start.
*
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a>
* @version $Revision: $

0 comments on commit 7d5977c

Please sign in to comment.
Something went wrong with that request. Please try again.