modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
| 13 +++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
| 35 ++++------
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
| 10 +-
3 files changed, 35 insertions(+), 23 deletions(-)
New commits:
commit 8737595774416a54383483fdd1678a436226af05
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Fri May 3 16:38:56 2013 +0200
Bug 911321 - [EAP 6.1] Reload operation fails in standalone mode
EAP can close the management http connection when receiving a reload operation
request. In this case, we will set a specific error message in ASConnection which
BaseServerComponent code will be able to detect.
diff --git
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 729201f..662d6ef 100644
---
a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++
b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
+import org.apache.http.NoHttpResponseException;
import org.apache.http.StatusLine;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
@@ -82,6 +83,8 @@ public class ASConnection {
@Deprecated
public static final String MANAGEMENT = MANAGEMENT_URI;
+ static final String FAILURE_NO_RESPONSE = "The server closed the connection
before sending the response";
+
private static final Log LOG = LogFactory.getLog(ASConnection.class);
private static final int MAX_POOLED_CONNECTIONS = 10;
@@ -367,6 +370,16 @@ public class ASConnection {
return operationResult;
+ } catch (NoHttpResponseException e) {
+ // For some operations like reload or shutdown, the server closes the
connection before sending the
+ // response. We use a specific description here so that callers can write
code to decide what to do
+ // in this situation.
+ Result failure = new Result();
+ failure.setFailureDescription(FAILURE_NO_RESPONSE);
+ failure.setOutcome("failure");
+ failure.setRhqThrowable(e);
+ JsonNode ret = mapper.valueToTree(failure);
+ return ret;
} catch (IOException e) {
Result failure = new Result();
failure.setFailureDescription(e.getMessage());
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 6d889c5..b80a39a 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
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,13 +13,12 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.modules.plugins.jbossas7;
import java.io.File;
-import java.net.ConnectException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
@@ -54,6 +53,7 @@ import org.rhq.core.system.ProcessExecutionResults;
import org.rhq.core.system.ProcessInfo;
import org.rhq.core.system.SystemInfo;
import org.rhq.core.util.PropertiesFileUpdate;
+import org.rhq.core.util.StringUtil;
import org.rhq.modules.plugins.jbossas7.helper.HostConfiguration;
import org.rhq.modules.plugins.jbossas7.helper.HostPort;
import org.rhq.modules.plugins.jbossas7.helper.ServerPluginConfiguration;
@@ -492,26 +492,23 @@ public abstract class BaseServerComponent<T extends
ResourceComponent<?>> extend
return operationResult;
}
- if (name.equals("shutdown") || name.equals("restart")) {
+ if (name.equals("shutdown") || name.equals("restart") ||
name.equals("reload")) {
/*
- * Shutdown needs a special treatment, because after sending the operation,
if shutdown succeeds,
- * the server connection is closed and we can't read from it. So if we
get connection refused for
- * reading, this is a good sign.
+ * Shutdown, restart and reload need a special treatment, because after
sending the operation, event if
+ * it succeeds, the server connection is sometimes closed and we can't
read from it.
*/
if (!res.isSuccess()) {
- if (res.getRhqThrowable() != null
- && (res.getRhqThrowable() instanceof ConnectException ||
res.getRhqThrowable().getMessage()
- .equals("Connection refused"))) {
+ if (StringUtil.isNotBlank(res.getFailureDescription())
+ &&
res.getFailureDescription().startsWith(ASConnection.FAILURE_NO_RESPONSE)) {
operationResult.setSimpleResult("Success");
- log.debug("Got a ConnectionRefused for operation "
- + name
- + " this is considered ok, as the remote server sometimes
closes the communications channel before sending a reply");
- }
- if (res.getFailureDescription().contains("Socket closed")) { //
See
https://issues.jboss.org/browse/AS7-4192
- operationResult.setSimpleResult("Success");
- log.debug("Got a 'Socket closed' result from AS for
operation " + name);
- } else
+ if (log.isDebugEnabled()) {
+ log.debug("Got no response for operation '" + name
+ "'. "
+ + "This is considered ok, as the remote server
sometimes closes the communications "
+ + "channel before sending a reply");
+ }
+ } else {
operationResult.setErrorMessage(res.getFailureDescription());
+ }
} else {
operationResult.setSimpleResult("Success");
}
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 778d127..d399d1b 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
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.modules.plugins.jbossas7;
@@ -213,7 +213,9 @@ public class StandaloneASComponent<T extends
ResourceComponent<?>> extends BaseS
count++;
}
- log.debug("waitUntilReloaded: Used " + count + " delay round(s) to
reload. Reload=" + reloaded);
+ if (log.isDebugEnabled()) {
+ log.debug("waitUntilReloaded: Used " + count + " delay
round(s) to reload. Reload=" + reloaded);
+ }
return reloaded;
}