summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Negrea <snegrea@redhat.com>2012-08-29 07:20:24 (GMT)
committerStefan Negrea <snegrea@redhat.com>2012-08-29 07:20:24 (GMT)
commite6e91058f3ac76c6458847bd66a8ee5c9c24493e (patch)
tree566abe3b77d7c79a6f73c83defd691731b432fda
parent96602db100b087e36016b1aa6a2e39780b583898 (diff)
downloadrhq-e6e91058f3ac76c6458847bd66a8ee5c9c24493e.zip
rhq-e6e91058f3ac76c6458847bd66a8ee5c9c24493e.tar.gz
rhq-e6e91058f3ac76c6458847bd66a8ee5c9c24493e.tar.xz
[BZ 847674] Updated all the wait methods for reload, shutdown, and restart to have the same design. All the methods now take into account possible exceptions for the test operation sent to the application server.
-rw-r--r--modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java31
-rw-r--r--modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java7
-rw-r--r--modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java56
3 files changed, 64 insertions, 30 deletions
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
index 27b1133..98a46d2 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -241,25 +241,36 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
return startServer();
}
- protected boolean waitUntilDown(OperationResult tmp) throws InterruptedException {
+ protected boolean waitUntilDown() throws InterruptedException {
boolean down=false;
int count=0;
+
while (!down) {
Operation op = new ReadAttribute(new Address(),"release-version");
- Result res = getASConnection().execute(op);
- if (!res.isSuccess()) { // If op succeeds, server is not down
- down=true;
- } else if (count > 20) {
- tmp.setErrorMessage("Was not able to shut down the server");
- return true;
+
+ try{
+ Result res = getASConnection().execute(op);
+ if (!res.isSuccess()) { // If op succeeds, server is not down
+ down = true;
+ } else if (count > 20) {
+ break;
+ }
+ } catch (Exception e) {
+ down = true;
}
+
if (!down) {
- Thread.sleep(1000); // Wait 1s
+ try {
+ Thread.sleep(1000); // Wait 1s
+ } catch (InterruptedException e) {
+ // ignore
+ }
}
count++;
}
- log.debug("waitUntilDown: Used " + count + " delay round(s) to shut down");
- return false;
+
+ log.debug("waitUntilDown: Used " + count + " delay round(s) to shut down. Server down=" + down);
+ return down;
}
/**
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
index 565add2..7ea12b9 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/HostControllerComponent.java
@@ -92,8 +92,11 @@ public class HostControllerComponent<T extends ResourceComponent<?>> extends Bas
Result res = getASConnection().execute(op);
operationResult = postProcessResult(name, res);
- waitUntilDown(operationResult);
-
+ if (waitUntilDown()) {
+ operationResult.setSimpleResult("Success");
+ } else {
+ operationResult.setErrorMessage("Was not able to shut down the server.");
+ }
} else if (name.equals("installRhqUser")) {
operationResult = installManagementUser(parameters, pluginConfiguration);
} else {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
index 573742e..778d127 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
@@ -163,39 +163,59 @@ public class StandaloneASComponent<T extends ResourceComponent<?>> extends BaseS
OperationResult operationResult = postProcessResult(name, res);
- if (name.equals("shutdown"))
- waitUntilDown(operationResult);
+ if (name.equals("shutdown")) {
+ if (waitUntilDown()) {
+ operationResult.setSimpleResult("Success");
+ } else {
+ operationResult.setErrorMessage("Was not able to shut down the server.");
+ }
+ }
- if (name.equals("reload"))
- waitUntilReloaded(operationResult);
+ if (name.equals("reload")) {
+ if (waitUntilReloaded()) {
+ operationResult.setSimpleResult("Success");
+ } else {
+ operationResult.setErrorMessage("Was not able to reload the server.");
+ }
+ }
context.getAvailabilityContext().requestAvailabilityCheck();
return operationResult;
}
- private void waitUntilReloaded(OperationResult operationResult) {
+ private boolean waitUntilReloaded() {
boolean reloaded = false;
int count = 0;
+
while (!reloaded) {
- try {
- Thread.sleep(2000); // Wait 2s
- } catch (InterruptedException e) {
- // Ignore
+ Operation op = new ReadAttribute(new Address(), "release-version");
+ try{
+ Result res = getASConnection().execute(op);
+ if (res.isSuccess() && !res.isReloadRequired()) {
+ reloaded = true;
+ } else if (count > 20) {
+ break;
+ }
+ } catch (Exception e) {
+ //do absolutely nothing
+ //if an exception is thrown that means the server is still reloading, so consider this
+ //a single failed attempt, equivalent to res.isSuccess == false
}
- Operation op = new ReadAttribute(new Address(), "release-version");
- Result res = getASConnection().execute(op);
- if (res.isSuccess() && !res.isReloadRequired()) {
- reloaded = true;
- } else if (count > 20) {
- operationResult.setErrorMessage("Was not able to reload the server");
- return;
+ if (!reloaded) {
+ try {
+ Thread.sleep(1000); // Wait 1s
+ } catch (InterruptedException e) {
+ // ignore
+ }
}
count++;
}
- log.debug("waitUntilReloaded: Used " + count + " delay round(s) to reload");
- return;
+
+ log.debug("waitUntilReloaded: Used " + count + " delay round(s) to reload. Reload=" + reloaded);
+
+ return reloaded;
}
@Override