summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Negrea <snegrea@redhat.com>2012-08-08 21:07:08 (GMT)
committerStefan Negrea <snegrea@redhat.com>2012-08-08 21:07:08 (GMT)
commit422438fa3b751562769cfe03be70e794376855dc (patch)
tree989670999d7de1d86e2284cf450c47065aaeb395
parent288295bd2dc0d244f98fb16dcb11c206e10bc8d8 (diff)
downloadrhq-422438fa3b751562769cfe03be70e794376855dc.zip
rhq-422438fa3b751562769cfe03be70e794376855dc.tar.gz
rhq-422438fa3b751562769cfe03be70e794376855dc.tar.xz
[BZ 837510] Prevent the edge case by retrieving the clustered property from AS5 only when the first metric collection occurs. Also marked the getter deprecated to prevent further use of the property outside of this component.
(cherry picked from commit 88c286048d73a963eb2e2debd1009d8ed0d595b0)
-rw-r--r--modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java46
1 files changed, 32 insertions, 14 deletions
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java
index 6eb7e7e..07708b7 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java
@@ -82,7 +82,7 @@ public class WebApplicationContextComponent extends ManagedComponentComponent {
private String servletComponentNamesRegex;
private ResponseTimeLogParser logParser;
- private boolean clustered;
+ private Boolean clustered;
@Override
public void start(ResourceContext<ProfileServiceComponent<?>> resourceContext) throws Exception {
@@ -97,17 +97,6 @@ public class WebApplicationContextComponent extends ManagedComponentComponent {
this.logParser.setExcludes(responseTimeConfig.getExcludes());
this.logParser.setTransforms(responseTimeConfig.getTransforms());
}
-
- try {
- ManagedProperty distributableProp = getManagedComponent().getProperty(DISTRIBUTABLE_MANAGED_PROPERTY);
- if (distributableProp != null) {
- Boolean distributable = (Boolean) getInnerValue(distributableProp.getValue());
- clustered = distributable != null && distributable.booleanValue();
- }
- } catch (Exception e) {
- log.warn("Failed to determine whether the web app context " + resourceContext.getResourceKey()
- + " is clustered or not.", e);
- }
}
@Override
@@ -144,8 +133,14 @@ public class WebApplicationContextComponent extends ManagedComponentComponent {
// TODO: Communicate this error back to the server for display in the GUI.
}
} else if (metricName.equals(CLUSTERED_TRAIT)) {
- MeasurementDataTrait trait = new MeasurementDataTrait(request, Boolean.toString(clustered));
- report.addData(trait);
+ if(clustered == null){
+ retrieveClusteredProperty();
+ }
+
+ if (clustered != null) {
+ MeasurementDataTrait trait = new MeasurementDataTrait(request, clustered.toString());
+ report.addData(trait);
+ }
} else {
String metricNameToUse = metricName;
if (clustered && !"runState".equals(metricName)) {
@@ -170,10 +165,33 @@ public class WebApplicationContextComponent extends ManagedComponentComponent {
}
}
+ /**
+ * @deprecated The clustered property should be retrieved by the individual component in the
+ * specific use case that requires it. Leaving this method for backwards compatibility
+ * with plugins that use the AS5 plugin and also use reflection.
+ */
+ @Deprecated
public boolean isClustered() {
+ if (clustered == null) {
+ return false;
+ }
+
return clustered;
}
+ private void retrieveClusteredProperty() {
+ try {
+ ManagedProperty distributableProp = getManagedComponent().getProperty(DISTRIBUTABLE_MANAGED_PROPERTY);
+ if (distributableProp != null) {
+ Boolean distributable = (Boolean) getInnerValue(distributableProp.getValue());
+ clustered = distributable != null && distributable.booleanValue();
+ }
+ } catch (Exception e) {
+ log.warn("Failed to determine whether the web app context " + this.getResourceContext().getResourceKey()
+ + " is clustered or not.", e);
+ }
+ }
+
private Double getServletMetric(ManagementView managementView, String metricName) throws Exception {
ComponentType servletComponentType = MoreKnownComponentTypes.MBean.Servlet.getType();
//Set<ManagedComponent> servletComponents = managementView.getMatchingComponents(this.servletComponentNamesRegex,