modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
| 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
| 4 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/StandaloneASComponent.java
| 25 +++-------
3 files changed, 14 insertions(+), 17 deletions(-)
New commits:
commit 6ad3c87c08631a00cb960a4ffa4c4929329aa6d8
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Tue Jul 16 13:42:50 2013 +0200
Bug 982804 - AS7 reload behavior includes hardcoded timeout of 20 seconds
diff --git
a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
index 8c708db..41a1c41 100644
---
a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
+++
b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
@@ -173,6 +173,8 @@ public class ResourceContext<T extends
ResourceComponent<?>> {
* @param availabilityContext a {@link AvailabilityContext} the plugin can use
to interoperate with the
* plugin container inventory manager
* @param pluginContainerDeployment indicates where the plugin container is running
+ * @param componentInvocationContext a {@link ComponentInvocationContext} the plugin
can use to determine if the
+ * current component invocation has been canceled
or timed out.
*/
public ResourceContext(Resource resource, T parentResourceComponent,
ResourceContext<?> parentResourceContext,
ResourceDiscoveryComponent<T> resourceDiscoveryComponent, SystemInfo
systemInfo, File temporaryDirectory,
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
index 4cb2cff..a9fe1c2 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/ResourceContainer.java
@@ -609,6 +609,8 @@ public class ResourceContainer implements Serializable {
}
private static class ComponentInvocation implements Callable {
+ private static final Log LOG = LogFactory.getLog(ComponentInvocation.class);
+
private final ResourceContainer resourceContainer;
private final Method method;
private final Object[] args;
@@ -669,6 +671,8 @@ public class ResourceContainer implements Serializable {
public void markContextInterrupted() {
localContext.markInterrupted();
+ LOG.warn("Invocation has been marked interrupted for method [" +
method + "] on resource ["
+ + resourceContainer.getResource() + "]");
}
}
}
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 d399d1b..ccb8ce0 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
@@ -18,6 +18,8 @@
*/
package org.rhq.modules.plugins.jbossas7;
+import static java.util.concurrent.TimeUnit.SECONDS;
+
import java.io.File;
import java.util.HashSet;
import java.util.Map;
@@ -184,39 +186,28 @@ public class StandaloneASComponent<T extends
ResourceComponent<?>> extends BaseS
return operationResult;
}
- private boolean waitUntilReloaded() {
+ private boolean waitUntilReloaded() throws InterruptedException {
boolean reloaded = false;
- int count = 0;
-
while (!reloaded) {
Operation op = new ReadAttribute(new Address(),
"release-version");
- try{
+ 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
}
-
if (!reloaded) {
- try {
- Thread.sleep(1000); // Wait 1s
- } catch (InterruptedException e) {
- // ignore
+ if (context.getComponentInvocationContext().isInterrupted()) {
+ // Operation canceled or timed out
+ throw new InterruptedException();
}
+ Thread.sleep(SECONDS.toMillis(1));
}
- count++;
}
-
- if (log.isDebugEnabled()) {
- log.debug("waitUntilReloaded: Used " + count + " delay
round(s) to reload. Reload=" + reloaded);
- }
-
return reloaded;
}
Show replies by date