summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Negrea <snegrea@redhat.com>2012-08-08 21:04:19 (GMT)
committerStefan Negrea <snegrea@redhat.com>2012-08-08 21:04:40 (GMT)
commit88c286048d73a963eb2e2debd1009d8ed0d595b0 (patch)
tree5c50e630b181a331d314bc8b2ad01964feee7718
parent15552573391da403073ea1c27a8a9a5ffc969e65 (diff)
downloadrhq-88c286048d73a963eb2e2debd1009d8ed0d595b0.zip
rhq-88c286048d73a963eb2e2debd1009d8ed0d595b0.tar.gz
rhq-88c286048d73a963eb2e2debd1009d8ed0d595b0.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.
-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,