ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject git commit: AMBARI-6299. JMXPropertyProvider makes call to endpoint without checking support for properties. (swagle via yusaku)
Date Fri, 27 Jun 2014 02:44:46 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.1 cc02e8c3f -> d118c97d8


AMBARI-6299. JMXPropertyProvider makes call to endpoint without checking support for properties.
(swagle via yusaku)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d118c97d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d118c97d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d118c97d

Branch: refs/heads/branch-1.6.1
Commit: d118c97d81ff74fb218cdf771ceca09c4a591c68
Parents: cc02e8c
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Thu Jun 26 19:44:12 2014 -0700
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Thu Jun 26 19:44:12 2014 -0700

----------------------------------------------------------------------
 .../internal/AbstractPropertyProvider.java      | 13 ++++++++++++
 .../controller/internal/BaseProvider.java       |  4 ++--
 .../controller/jmx/JMXPropertyProvider.java     | 22 +++++++++++---------
 3 files changed, 27 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d118c97d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java
index 297b2ab..00db711 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractPropertyProvider.java
@@ -297,4 +297,17 @@ public abstract class AbstractPropertyProvider extends BaseProvider implements
P
 
     }
   }
+
+  /**
+   * Verify that the component metrics contains the property id.
+   * @param componentName Name of the component
+   * @param propertyId Property Id
+   * @return true/false
+   */
+  protected boolean isSupportedPropertyId(String componentName, String propertyId) {
+    Map<String, PropertyInfo> componentMetricMap = componentMetrics.get(componentName);
+
+    return componentMetricMap != null
+      && (componentMetricMap.containsKey(propertyId) || checkCategory(propertyId));
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d118c97d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseProvider.java
index d92959d..d18bbfc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseProvider.java
@@ -170,10 +170,10 @@ public abstract class BaseProvider {
    * Check the categories to account for map properties where the entries will not be
    * in the provider property list ids but the map (category) might be.
    */
-  private boolean checkCategory(String unsupportedPropertyId) {
+  protected boolean checkCategory(String unsupportedPropertyId) {
     String category = PropertyHelper.getPropertyCategory(unsupportedPropertyId);
     while (category != null) {
-      if( this.propertyIds.contains(category)) {
+      if(this.categoryIds.contains(category)) {
         return true;
       }
       category = PropertyHelper.getPropertyCategory(category);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d118c97d/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
index a4dc2b2..734da90 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
@@ -295,14 +295,23 @@ public class JMXPropertyProvider extends AbstractPropertyProvider {
       throws SystemException {
 
     Set<String> ids = getRequestPropertyIds(request, predicate);
-    Set<String> temporalIds = new HashSet<String>();
+    Set<String> unsupportedIds = new HashSet<String>();
+    String componentName = (String) resource.getPropertyValue(componentNamePropertyId);
+
+    if (getComponentMetrics().get(componentName) == null) {
+      // If there are no metrics defined for the given component then there is nothing to
do.
+      return resource;
+    }
 
     for (String id : ids) {
       if (request.getTemporalInfo(id) != null) {
-        temporalIds.add(id);
+        unsupportedIds.add(id);
+      }
+      if (!isSupportedPropertyId(componentName, id)) {
+        unsupportedIds.add(id);
       }
     }
-    ids.removeAll(temporalIds);
+    ids.removeAll(unsupportedIds);
 
     if (ids.isEmpty()) {
       // no properties requested
@@ -317,13 +326,6 @@ public class JMXPropertyProvider extends AbstractPropertyProvider {
       }
     }
 
-    String componentName = (String) resource.getPropertyValue(componentNamePropertyId);
-
-    if (getComponentMetrics().get(componentName) == null) {
-      // If there are no metrics defined for the given component then there is nothing to
do.
-      return resource;
-    }
-
     String clusterName = (String) resource.getPropertyValue(clusterNamePropertyId);
 
     String port = getPort(clusterName, componentName);


Mime
View raw message