[rhq] modules/plugins

snegrea snegrea at fedoraproject.org
Wed Aug 8 21:04:47 UTC 2012


 modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextComponent.java |   46 ++++++----
 1 file changed, 32 insertions(+), 14 deletions(-)

New commits:
commit 88c286048d73a963eb2e2debd1009d8ed0d595b0
Author: Stefan Negrea <snegrea at redhat.com>
Date:   Wed Aug 8 16:04:19 2012 -0500

    [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.

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,




More information about the rhq-commits mailing list