ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject [2/2] ambari git commit: AMBARI-8535. AMS Provider is not instantiated after install. (swagle)
Date Wed, 03 Dec 2014 21:04:09 GMT
AMBARI-8535. AMS Provider is not instantiated after install. (swagle)


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

Branch: refs/heads/trunk
Commit: 2160d544a648224f5320337bff5184fa0498b655
Parents: 2518a56
Author: Siddharth Wagle <swagle@hortonworks.com>
Authored: Wed Dec 3 12:29:37 2014 -0800
Committer: Siddharth Wagle <swagle@hortonworks.com>
Committed: Wed Dec 3 12:29:37 2014 -0800

----------------------------------------------------------------------
 .../internal/AbstractProviderModule.java        | 143 ++++++++++++----
 .../internal/ClusterResourceProvider.java       |   4 +-
 .../internal/StackDefinedPropertyProvider.java  |  22 +--
 .../controller/metrics/MetricHostProvider.java  |   3 +-
 .../metrics/MetricsPropertyProvider.java        | 118 +++++--------
 .../metrics/MetricsPropertyProviderProxy.java   | 169 +++++++++++++++++++
 .../metrics/MetricsReportPropertyProvider.java  |  31 +---
 .../MetricsReportPropertyProviderProxy.java     |  93 ++++++++++
 .../metrics/MetricsServiceProvider.java         |  35 ++++
 .../ganglia/GangliaHostPropertyProvider.java    |   1 -
 .../ganglia/GangliaPropertyProvider.java        |  32 ++--
 .../ganglia/GangliaReportPropertyProvider.java  |   4 +-
 .../metrics/timeline/AMSPropertyProvider.java   |  21 +--
 .../internal/MetricsServiceProviderTest.java    | 135 +++++++++++++++
 .../StackDefinedPropertyProviderTest.java       |  39 ++++-
 .../metrics/JMXPropertyProviderTest.java        |  17 +-
 .../RestMetricsPropertyProviderTest.java        |  17 +-
 .../ganglia/GangliaPropertyProviderTest.java    |  15 +-
 .../GangliaReportPropertyProviderTest.java      |   4 +-
 .../timeline/AMSPropertyProviderTest.java       |  26 ++-
 20 files changed, 718 insertions(+), 211 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
index 7b734cf..1616493 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
@@ -33,6 +33,7 @@ import org.apache.ambari.server.controller.jmx.JMXPropertyProvider;
 import org.apache.ambari.server.controller.metrics.MetricHostProvider;
 import org.apache.ambari.server.controller.metrics.MetricsPropertyProvider;
 import org.apache.ambari.server.controller.metrics.MetricsReportPropertyProvider;
+import org.apache.ambari.server.controller.metrics.MetricsServiceProvider;
 import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
 import org.apache.ambari.server.controller.spi.NoSuchResourceException;
 import org.apache.ambari.server.controller.spi.Predicate;
@@ -56,6 +57,7 @@ import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.State;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import java.net.InetAddress;
 import java.util.Collections;
 import java.util.EnumMap;
@@ -67,15 +69,16 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService;
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService.GANGLIA;
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService.TIMELINE_METRICS;
 
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.GANGLIA;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.TIMELINE_METRICS;
 
 /**
  * An abstract provider module implementation.
  */
-public abstract class AbstractProviderModule implements ProviderModule, ResourceProviderObserver, JMXHostProvider, MetricHostProvider, HostInfoProvider {
+public abstract class AbstractProviderModule implements ProviderModule,
+    ResourceProviderObserver, JMXHostProvider, MetricHostProvider,
+    MetricsServiceProvider, HostInfoProvider {
 
   private static final int PROPERTY_REQUEST_CONNECT_TIMEOUT = 5000;
   private static final int PROPERTY_REQUEST_READ_TIMEOUT    = 10000;
@@ -226,8 +229,93 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
     }
   }
 
+  // ----- MetricsServiceProvider ---------------------------------------------
+
+  /**
+   * Get type of Metrics system installed.
+   * @return @MetricsService, null if none found.
+   */
+  public MetricsService getMetricsServiceType() {
+    try {
+      checkInit();
+    } catch (SystemException e) {
+      LOG.error("Exception during checkInit.", e);
+    }
+    if (clusterGangliaCollectorMap.isEmpty() && clusterMetricCollectorMap.isEmpty()) {
+      resetMetricProviderMap();
+    }
+
+    if (!clusterMetricCollectorMap.isEmpty()) {
+      return TIMELINE_METRICS;
+    } else if (!clusterGangliaCollectorMap.isEmpty()) {
+      return GANGLIA;
+    }
+    return null;
+  }
+
+  private void resetMetricProviderMap() {
+    LOG.info("Resetting metric property provider.");
+    ResourceProvider provider = getResourceProvider(Resource.Type.Cluster);
+
+    Set<String> propertyIds = new HashSet<String>();
+    propertyIds.add(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID);
+
+    Map<String, String> requestInfoProperties = new HashMap<String, String>();
+    requestInfoProperties.put(ClusterResourceProvider.GET_IGNORE_PERMISSIONS_PROPERTY_ID, "true");
+
+    Request request = PropertyHelper.getReadRequest(propertyIds,
+      requestInfoProperties, null, null, null);
+
+    try {
+      Set<Resource> clusters = provider.getResources(request, null);
+
+      if (clusters != null && !clusters.isEmpty()) {
+        for (Resource cluster : clusters) {
+          String clusterName = (String) cluster.getPropertyValue(CLUSTER_NAME_PROPERTY_ID);
+
+          request = PropertyHelper.getReadRequest(HOST_COMPONENT_HOST_NAME_PROPERTY_ID,
+            HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID);
+
+          Predicate predicate =
+            new PredicateBuilder().property(HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID)
+              .equals(clusterName).and().property(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID)
+              .equals(GANGLIA_SERVER).toPredicate();
+
+          provider = getResourceProvider(Resource.Type.HostComponent);
+          Set<Resource> hostComponents = provider.getResources(request, predicate);
+
+          if (hostComponents != null && !hostComponents.isEmpty()) {
+            Resource hostComponent = hostComponents.iterator().next();
+            String hostName = (String) hostComponent.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID);
+            clusterGangliaCollectorMap.put(clusterName, hostName);
+          }
+
+          predicate = new PredicateBuilder().property(HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID)
+            .equals(clusterName).and().property(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID)
+            .equals(METRIC_SERVER).toPredicate();
+
+          hostComponents = provider.getResources(request, predicate);
+          if (hostComponents != null && !hostComponents.isEmpty()) {
+            Resource hostComponent = hostComponents.iterator().next();
+            String hostName = (String) hostComponent.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID);
+            clusterMetricCollectorMap.put(clusterName, hostName);
+          }
+        }
+      }
+
+    } catch (SystemException e) {
+      LOG.warn("Error finding metrics provider.", e);
+    } catch (UnsupportedPropertyException e) {
+      LOG.warn("Error finding metrics provider.", e);
+    } catch (NoSuchResourceException e) {
+      LOG.warn("Error finding metrics provider.", e);
+    } catch (NoSuchParentResourceException e) {
+      LOG.warn("Error finding metrics provider.", e);
+    }
 
-  // ----- MetricsHostProvider ---------------------------------------------------
+  }
+
+  // ----- MetricsHostProvider ------------------------------------------------
 
   @Override
   public String getCollectorHostName(String clusterName, MetricsService service) throws SystemException {
@@ -343,20 +431,6 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
       componentHostResponse.getLiveState().equals(State.STARTED.name());
   }
 
-  protected MetricsService getMetricsServiceType() {
-    try {
-      checkInit();
-    } catch (SystemException e) {
-      LOG.error("Exception during checkInit.", e);
-      return GANGLIA;
-    }
-    if (!clusterMetricCollectorMap.isEmpty()) {
-      return TIMELINE_METRICS;
-    } else {
-      return GANGLIA;
-    }
-  }
-
   protected boolean isHostLive(String clusterName, String hostName) {
     if (clusterName == null) {
       return false;
@@ -546,6 +620,7 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
             streamProvider,
             ComponentSSLConfiguration.instance(),
             this,
+            this,
             PropertyHelper.getPropertyId("Clusters", "cluster_name")));
           providers.add(new AlertSummaryPropertyProvider(type,
             "Clusters/cluster_name", null));
@@ -560,6 +635,7 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
             streamProvider,
             ComponentSSLConfiguration.instance(),
             this,
+            this,
             PropertyHelper.getPropertyId("Hosts", "cluster_name"),
             PropertyHelper.getPropertyId("Hosts", "host_name")
           ));
@@ -591,6 +667,7 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
               streamProvider,
               ComponentSSLConfiguration.instance(),
               this,
+              this,
               PropertyHelper.getPropertyId("ServiceComponentInfo", "cluster_name"),
               PropertyHelper.getPropertyId("ServiceComponentInfo", "component_name"));
           }
@@ -598,6 +675,7 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
               type,
               this,
               this,
+              this,
               streamProvider,
               PropertyHelper.getPropertyId("ServiceComponentInfo", "cluster_name"),
               null,
@@ -633,6 +711,7 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
               streamProvider,
               ComponentSSLConfiguration.instance(),
               this,
+              this,
               PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
               PropertyHelper.getPropertyId("HostRoles", "host_name"),
               PropertyHelper.getPropertyId("HostRoles", "component_name"));
@@ -641,6 +720,7 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
               type,
               this,
               this,
+              this,
               streamProvider,
               PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
               PropertyHelper.getPropertyId("HostRoles", "host_name"),
@@ -657,8 +737,6 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
     putPropertyProviders(type, providers);
   }
 
-
-
   private void checkInit() throws SystemException {
     if (!initialized) {
       synchronized (this) {
@@ -891,11 +969,12 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
   private PropertyProvider createMetricsReportPropertyProvider(Resource.Type type, StreamProvider streamProvider,
                                                                ComponentSSLConfiguration configuration,
                                                                MetricHostProvider hostProvider,
+                                                               MetricsServiceProvider serviceProvider,
                                                                String clusterNamePropertyId) {
 
     return MetricsReportPropertyProvider.createInstance(
-      getMetricsServiceType(), PropertyHelper.getMetricPropertyIds(type),
-      streamProvider, configuration, hostProvider, clusterNamePropertyId);
+      PropertyHelper.getMetricPropertyIds(type), streamProvider,
+      configuration, hostProvider, serviceProvider, clusterNamePropertyId);
   }
 
   /**
@@ -905,11 +984,13 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
                                                              StreamProvider streamProvider,
                                                              ComponentSSLConfiguration configuration,
                                                              MetricHostProvider hostProvider,
+                                                             MetricsServiceProvider serviceProvider,
                                                              String clusterNamePropertyId,
                                                              String hostNamePropertyId) {
-    return MetricsPropertyProvider.createInstance(getMetricsServiceType(), type,
+    return MetricsPropertyProvider.createInstance(type,
       PropertyHelper.getMetricPropertyIds(type), streamProvider, configuration,
-      hostProvider, clusterNamePropertyId, hostNamePropertyId, null);
+      hostProvider, serviceProvider, clusterNamePropertyId,
+      hostNamePropertyId, null);
   }
 
   /**
@@ -919,11 +1000,13 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
                                                                   StreamProvider streamProvider,
                                                                   ComponentSSLConfiguration configuration,
                                                                   MetricHostProvider hostProvider,
+                                                                  MetricsServiceProvider serviceProvider,
                                                                   String clusterNamePropertyId,
                                                                   String componentNamePropertyId) {
-    return MetricsPropertyProvider.createInstance(getMetricsServiceType(), type,
+    return MetricsPropertyProvider.createInstance(type,
       PropertyHelper.getMetricPropertyIds(type), streamProvider, configuration,
-      hostProvider, clusterNamePropertyId, null, componentNamePropertyId);
+      hostProvider, serviceProvider, clusterNamePropertyId, null,
+      componentNamePropertyId);
   }
 
 
@@ -934,13 +1017,15 @@ public abstract class AbstractProviderModule implements ProviderModule, Resource
                                                                       StreamProvider streamProvider,
                                                                       ComponentSSLConfiguration configuration,
                                                                       MetricHostProvider hostProvider,
+                                                                      MetricsServiceProvider serviceProvider,
                                                                       String clusterNamePropertyId,
                                                                       String hostNamePropertyId,
                                                                       String componentNamePropertyId) {
 
-    return MetricsPropertyProvider.createInstance(getMetricsServiceType(), type,
+    return MetricsPropertyProvider.createInstance(type,
       PropertyHelper.getMetricPropertyIds(type), streamProvider, configuration,
-      hostProvider, clusterNamePropertyId, hostNamePropertyId, componentNamePropertyId);
+      hostProvider, serviceProvider, clusterNamePropertyId, hostNamePropertyId,
+      componentNamePropertyId);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
index 15cd8de..7423c25 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
@@ -59,8 +59,8 @@ public class ClusterResourceProvider extends BaseBlueprintProcessor {
   // ----- Property ID constants ---------------------------------------------
 
   // Clusters
-  protected static final String CLUSTER_ID_PROPERTY_ID      = PropertyHelper.getPropertyId("Clusters", "cluster_id");
-  protected static final String CLUSTER_NAME_PROPERTY_ID    = PropertyHelper.getPropertyId("Clusters", "cluster_name");
+  public static final String CLUSTER_ID_PROPERTY_ID      = PropertyHelper.getPropertyId("Clusters", "cluster_id");
+  public static final String CLUSTER_NAME_PROPERTY_ID    = PropertyHelper.getPropertyId("Clusters", "cluster_name");
   protected static final String CLUSTER_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("Clusters", "version");
   protected static final String CLUSTER_PROVISIONING_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("Clusters", "provisioning_state");
   protected static final String CLUSTER_DESIRED_CONFIGS_PROPERTY_ID = PropertyHelper.getPropertyId("Clusters", "desired_configs");

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
index 5896a88..a18086b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
@@ -25,9 +25,7 @@ import org.apache.ambari.server.controller.jmx.JMXHostProvider;
 import org.apache.ambari.server.controller.jmx.JMXPropertyProvider;
 import org.apache.ambari.server.controller.metrics.MetricHostProvider;
 import org.apache.ambari.server.controller.metrics.MetricsPropertyProvider;
-import org.apache.ambari.server.controller.metrics.ganglia.GangliaComponentPropertyProvider;
-import org.apache.ambari.server.controller.metrics.ganglia.GangliaHostComponentPropertyProvider;
-import org.apache.ambari.server.controller.metrics.ganglia.GangliaPropertyProvider;
+import org.apache.ambari.server.controller.metrics.MetricsServiceProvider;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.PropertyProvider;
 import org.apache.ambari.server.controller.spi.Request;
@@ -41,7 +39,6 @@ import org.apache.ambari.server.state.stack.Metric;
 import org.apache.ambari.server.state.stack.MetricDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -52,7 +49,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService;
 
 /**
  * This class analyzes a service's metrics to determine if additional
@@ -82,6 +79,7 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
   private PropertyProvider defaultGanglia = null;
 
   private final MetricHostProvider metricHostProvider;
+  private final MetricsServiceProvider metricsServiceProvider;
   private MetricsService metricsService = MetricsService.GANGLIA;
 
   /**
@@ -100,6 +98,7 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
   public StackDefinedPropertyProvider(Resource.Type type,
                                       JMXHostProvider jmxHostProvider,
                                       MetricHostProvider metricHostProvider,
+                                      MetricsServiceProvider serviceProvider,
                                       StreamProvider streamProvider,
                                       String clusterPropertyId,
                                       String hostPropertyId,
@@ -109,6 +108,7 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
                                       PropertyProvider defaultGangliaPropertyProvider) {
 
     this.metricHostProvider = metricHostProvider;
+    this.metricsServiceProvider = serviceProvider;
 
     if (null == clusterPropertyId)
       throw new NullPointerException("Cluster name property id cannot be null");
@@ -133,6 +133,7 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
                                       MetricsService metricsService,
                                       JMXHostProvider jmxHostProvider,
                                       MetricHostProvider metricHostProvider,
+                                      MetricsServiceProvider serviceProvider,
                                       StreamProvider streamProvider,
                                       String clusterPropertyId,
                                       String hostPropertyId,
@@ -141,7 +142,7 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
                                       PropertyProvider defaultJmxPropertyProvider,
                                       PropertyProvider defaultGangliaPropertyProvider) {
 
-    this(type, jmxHostProvider, metricHostProvider,
+    this(type, jmxHostProvider, metricHostProvider, serviceProvider,
       streamProvider, clusterPropertyId, hostPropertyId, componentPropertyId,
       jmxStatePropertyId, defaultJmxPropertyProvider, defaultGangliaPropertyProvider);
 
@@ -198,10 +199,11 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
       }
 
       if (gangliaMap.size() > 0) {
-        MetricsPropertyProvider propertyProvider =
-          MetricsPropertyProvider.createInstance(metricsService,
-            type, gangliaMap, streamProvider, sslConfig, metricHostProvider,
-            clusterNamePropertyId, hostNamePropertyId, componentNamePropertyId);
+        PropertyProvider propertyProvider =
+          MetricsPropertyProvider.createInstance(type, gangliaMap,
+            streamProvider, sslConfig, metricHostProvider,
+            metricsServiceProvider, clusterNamePropertyId,
+            hostNamePropertyId, componentNamePropertyId);
 
         propertyProvider.populateResources(resources, request, predicate);
       } else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricHostProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricHostProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricHostProvider.java
index fec2b57..a5a7a71 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricHostProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricHostProvider.java
@@ -18,7 +18,8 @@
 package org.apache.ambari.server.controller.metrics;
 
 import org.apache.ambari.server.controller.spi.SystemException;
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService;
+
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService;
 
 public interface MetricHostProvider {
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsPropertyProvider.java
index 4f1964f..24e692c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsPropertyProvider.java
@@ -20,12 +20,6 @@ package org.apache.ambari.server.controller.metrics;
 import org.apache.ambari.server.configuration.ComponentSSLConfiguration;
 import org.apache.ambari.server.controller.internal.AbstractPropertyProvider;
 import org.apache.ambari.server.controller.internal.PropertyInfo;
-import org.apache.ambari.server.controller.metrics.ganglia.GangliaComponentPropertyProvider;
-import org.apache.ambari.server.controller.metrics.ganglia.GangliaHostComponentPropertyProvider;
-import org.apache.ambari.server.controller.metrics.ganglia.GangliaHostPropertyProvider;
-import org.apache.ambari.server.controller.metrics.timeline.AMSComponentPropertyProvider;
-import org.apache.ambari.server.controller.metrics.timeline.AMSHostComponentPropertyProvider;
-import org.apache.ambari.server.controller.metrics.timeline.AMSHostPropertyProvider;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.Resource;
@@ -33,13 +27,10 @@ import org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.controller.utilities.StreamProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
 
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService.TIMELINE_METRICS;
-
 public abstract class MetricsPropertyProvider extends AbstractPropertyProvider {
   protected final static Logger LOG =
     LoggerFactory.getLogger(MetricsPropertyProvider.class);
@@ -58,15 +49,8 @@ public abstract class MetricsPropertyProvider extends AbstractPropertyProvider {
 
   protected final ComponentSSLConfiguration configuration;
 
-  /**
-   * Enumeration to distinguish metrics service installed for a cluster
-   */
-  public enum MetricsService {
-    GANGLIA,
-    TIMELINE_METRICS
-  }
-
-  public MetricsPropertyProvider(Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap,
+  protected MetricsPropertyProvider(Map<String, Map<String,
+    PropertyInfo>> componentPropertyInfoMap,
                                  StreamProvider streamProvider,
                                  ComponentSSLConfiguration configuration,
                                  MetricHostProvider hostProvider,
@@ -84,77 +68,29 @@ public abstract class MetricsPropertyProvider extends AbstractPropertyProvider {
     this.componentNamePropertyId  = componentNamePropertyId;
   }
 
-  public static MetricsPropertyProvider createInstance(
-        MetricsService metricsService,
+  public static MetricsPropertyProviderProxy createInstance(
         Resource.Type type,
         Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap,
         StreamProvider streamProvider,
         ComponentSSLConfiguration configuration,
         MetricHostProvider hostProvider,
+        MetricsServiceProvider serviceProvider,
         String clusterNamePropertyId,
         String hostNamePropertyId,
         String componentNamePropertyId) {
 
     if (type.isInternalType()) {
-      switch (type.getInternalType()) {
-        case Host:
-          if (metricsService.equals(TIMELINE_METRICS)) {
-            return new AMSHostPropertyProvider(componentPropertyInfoMap,
-              streamProvider,
-              configuration,
-              hostProvider,
-              clusterNamePropertyId,
-              hostNamePropertyId);
-          } else {
-            return new GangliaHostPropertyProvider(
-              componentPropertyInfoMap,
-              streamProvider,
-              configuration,
-              hostProvider,
-              clusterNamePropertyId,
-              hostNamePropertyId);
-          }
-        case HostComponent:
-          if (metricsService.equals(TIMELINE_METRICS)) {
-            return new AMSHostComponentPropertyProvider(
-              componentPropertyInfoMap,
-              streamProvider,
-              configuration,
-              hostProvider,
-              clusterNamePropertyId,
-              hostNamePropertyId,
-              componentNamePropertyId);
-          } else {
-            return new GangliaHostComponentPropertyProvider(
-              componentPropertyInfoMap,
-              streamProvider,
-              configuration,
-              hostProvider,
-              clusterNamePropertyId,
-              hostNamePropertyId,
-              componentNamePropertyId);
-          }
-        case Component:
-          if (metricsService.equals(TIMELINE_METRICS)) {
-            return new AMSComponentPropertyProvider(
-              componentPropertyInfoMap,
-              streamProvider,
-              configuration,
-              hostProvider,
-              clusterNamePropertyId,
-              componentNamePropertyId);
-          } else {
-            return new GangliaComponentPropertyProvider(
-              componentPropertyInfoMap,
-              streamProvider,
-              configuration,
-              hostProvider,
-              clusterNamePropertyId,
-              componentNamePropertyId);
-          }
-        default:
-          break;
-      }
+      return new MetricsPropertyProviderProxy(
+        type.getInternalType(),
+        componentPropertyInfoMap,
+        streamProvider,
+        configuration,
+        hostProvider,
+        serviceProvider,
+        clusterNamePropertyId,
+        hostNamePropertyId,
+        componentNamePropertyId
+      );
     }
 
     return null;
@@ -178,6 +114,30 @@ public abstract class MetricsPropertyProvider extends AbstractPropertyProvider {
    */
   protected abstract String getComponentName(Resource resource);
 
+  @Override
+  public Set<Resource> populateResources(Set<Resource> resources,
+                Request request, Predicate predicate) throws SystemException {
+
+    Set<String> ids = getRequestPropertyIds(request, predicate);
+    if (ids.isEmpty()) {
+      return resources;
+    }
+
+    return populateResourcesWithProperties(resources, request, ids);
+  }
+
+  /**
+   * Delegate implementation of populating resources to concrete providers.
+   *
+   * @param resources @Resource
+   * @param request @Request
+   * @param propertyIds Set of ids
+   * @return @Set of resources
+   * @throws SystemException
+   */
+  protected abstract Set<Resource> populateResourcesWithProperties(Set<Resource> resources,
+      Request request, Set<String> propertyIds) throws SystemException;
+
   /**
    * Get a comma delimited string from the given set of strings or
    * an empty string if the size of the given set is greater than

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsPropertyProviderProxy.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsPropertyProviderProxy.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsPropertyProviderProxy.java
new file mode 100644
index 0000000..e1f607e
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsPropertyProviderProxy.java
@@ -0,0 +1,169 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.controller.metrics;
+
+import org.apache.ambari.server.configuration.ComponentSSLConfiguration;
+import org.apache.ambari.server.controller.internal.AbstractPropertyProvider;
+import org.apache.ambari.server.controller.internal.PropertyInfo;
+import org.apache.ambari.server.controller.metrics.ganglia.GangliaComponentPropertyProvider;
+import org.apache.ambari.server.controller.metrics.ganglia.GangliaHostComponentPropertyProvider;
+import org.apache.ambari.server.controller.metrics.ganglia.GangliaHostPropertyProvider;
+import org.apache.ambari.server.controller.metrics.ganglia.GangliaPropertyProvider;
+import org.apache.ambari.server.controller.metrics.ganglia.GangliaReportPropertyProvider;
+import org.apache.ambari.server.controller.metrics.timeline.AMSComponentPropertyProvider;
+import org.apache.ambari.server.controller.metrics.timeline.AMSHostComponentPropertyProvider;
+import org.apache.ambari.server.controller.metrics.timeline.AMSHostPropertyProvider;
+import org.apache.ambari.server.controller.metrics.timeline.AMSPropertyProvider;
+import org.apache.ambari.server.controller.metrics.timeline.AMSReportPropertyProvider;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.utilities.StreamProvider;
+import java.util.Map;
+import java.util.Set;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.GANGLIA;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.TIMELINE_METRICS;
+import static org.apache.ambari.server.controller.spi.Resource.InternalType;
+
+public class MetricsPropertyProviderProxy extends AbstractPropertyProvider {
+  private final MetricsServiceProvider metricsServiceProvider;
+  private AMSPropertyProvider amsPropertyProvider;
+  private GangliaPropertyProvider gangliaPropertyProvider;
+
+  public MetricsPropertyProviderProxy(
+    InternalType type,
+    Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap,
+    StreamProvider streamProvider,
+    ComponentSSLConfiguration configuration,
+    MetricHostProvider hostProvider,
+    MetricsServiceProvider serviceProvider,
+    String clusterNamePropertyId,
+    String hostNamePropertyId,
+    String componentNamePropertyId) {
+
+    super(componentPropertyInfoMap);
+    this.metricsServiceProvider = serviceProvider;
+
+    switch (type) {
+      case Host:
+        createHostPropertyProviders(componentPropertyInfoMap, streamProvider,
+          configuration, hostProvider, clusterNamePropertyId, hostNamePropertyId);
+        break;
+
+      case HostComponent:
+        createHostComponentPropertyProviders(componentPropertyInfoMap, streamProvider,
+          configuration, hostProvider, clusterNamePropertyId,
+          hostNamePropertyId, componentNamePropertyId);
+        break;
+
+      case Component:
+        createComponentPropertyProviders(componentPropertyInfoMap, streamProvider,
+          configuration, hostProvider, clusterNamePropertyId, componentNamePropertyId);
+        break;
+
+      default:
+        break;
+    }
+  }
+
+  private void createHostPropertyProviders(Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap,
+                                           StreamProvider streamProvider,
+                                           ComponentSSLConfiguration configuration,
+                                           MetricHostProvider hostProvider,
+                                           String clusterNamePropertyId,
+                                           String hostNamePropertyId) {
+
+    this.amsPropertyProvider = new AMSHostPropertyProvider(componentPropertyInfoMap,
+                                            streamProvider,
+                                            configuration,
+                                            hostProvider,
+                                            clusterNamePropertyId,
+                                            hostNamePropertyId);
+
+    this.gangliaPropertyProvider = new GangliaHostPropertyProvider(componentPropertyInfoMap,
+                                            streamProvider,
+                                            configuration,
+                                            hostProvider,
+                                            clusterNamePropertyId,
+                                            hostNamePropertyId);
+}
+
+  private void createHostComponentPropertyProviders(Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap,
+                                            StreamProvider streamProvider,
+                                            ComponentSSLConfiguration configuration,
+                                            MetricHostProvider hostProvider,
+                                            String clusterNamePropertyId,
+                                            String hostNamePropertyId,
+                                            String componentNamePropertyId) {
+
+    this.amsPropertyProvider = new AMSHostComponentPropertyProvider(
+                                            componentPropertyInfoMap,
+                                            streamProvider,
+                                            configuration,
+                                            hostProvider,
+                                            clusterNamePropertyId,
+                                            hostNamePropertyId,
+                                            componentNamePropertyId);
+
+    this.gangliaPropertyProvider = new GangliaHostComponentPropertyProvider(
+                                            componentPropertyInfoMap,
+                                            streamProvider,
+                                            configuration,
+                                            hostProvider,
+                                            clusterNamePropertyId,
+                                            hostNamePropertyId,
+                                            componentNamePropertyId);
+  }
+
+  private void createComponentPropertyProviders(Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap,
+                                                StreamProvider streamProvider,
+                                                ComponentSSLConfiguration configuration,
+                                                MetricHostProvider hostProvider,
+                                                String clusterNamePropertyId,
+                                                String componentNamePropertyId) {
+
+    this.amsPropertyProvider = new AMSComponentPropertyProvider(
+                                            componentPropertyInfoMap,
+                                            streamProvider,
+                                            configuration,
+                                            hostProvider,
+                                            clusterNamePropertyId,
+                                            componentNamePropertyId);
+
+    this.gangliaPropertyProvider = new GangliaComponentPropertyProvider(
+                                            componentPropertyInfoMap,
+                                            streamProvider,
+                                            configuration,
+                                            hostProvider,
+                                            clusterNamePropertyId,
+                                            componentNamePropertyId);
+  }
+
+  @Override
+  public Set<Resource> populateResources(Set<Resource> resources, Request request,
+                                         Predicate predicate) throws SystemException {
+
+    if (metricsServiceProvider.getMetricsServiceType().equals(GANGLIA)) {
+      return gangliaPropertyProvider.populateResources(resources, request, predicate);
+    } else if (metricsServiceProvider.getMetricsServiceType().equals(TIMELINE_METRICS)) {
+      return amsPropertyProvider.populateResources(resources, request, predicate);
+    }
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsReportPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsReportPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsReportPropertyProvider.java
index 39af1d9..20e11ad 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsReportPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsReportPropertyProvider.java
@@ -20,16 +20,11 @@ package org.apache.ambari.server.controller.metrics;
 import org.apache.ambari.server.configuration.ComponentSSLConfiguration;
 import org.apache.ambari.server.controller.internal.AbstractPropertyProvider;
 import org.apache.ambari.server.controller.internal.PropertyInfo;
-import org.apache.ambari.server.controller.metrics.ganglia.GangliaReportPropertyProvider;
-import org.apache.ambari.server.controller.metrics.timeline.AMSReportPropertyProvider;
 import org.apache.ambari.server.controller.utilities.StreamProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import java.util.Map;
 
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService;
-
 public abstract class MetricsReportPropertyProvider extends AbstractPropertyProvider {
 
   protected final StreamProvider streamProvider;
@@ -62,27 +57,19 @@ public abstract class MetricsReportPropertyProvider extends AbstractPropertyProv
     this.configuration = configuration;
   }
 
-  public static MetricsReportPropertyProvider createInstance(
-          MetricsService metricsService,
+  public static MetricsReportPropertyProviderProxy createInstance(
           Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap,
           StreamProvider streamProvider,
           ComponentSSLConfiguration configuration,
           MetricHostProvider hostProvider,
+          MetricsServiceProvider serviceProvider,
           String clusterNamePropertyId) {
-    if (metricsService.equals(MetricsService.GANGLIA)) {
-      return new GangliaReportPropertyProvider(
-        componentPropertyInfoMap,
-        streamProvider,
-        configuration,
-        hostProvider,
-        clusterNamePropertyId);
-    } else {
-      return new AMSReportPropertyProvider(
-        componentPropertyInfoMap,
-        streamProvider,
-        configuration,
-        hostProvider,
-        clusterNamePropertyId);
-    }
+
+    return new MetricsReportPropertyProviderProxy(componentPropertyInfoMap,
+                                                  streamProvider,
+                                                  configuration,
+                                                  hostProvider,
+                                                  serviceProvider,
+                                                  clusterNamePropertyId);
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsReportPropertyProviderProxy.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsReportPropertyProviderProxy.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsReportPropertyProviderProxy.java
new file mode 100644
index 0000000..154046f
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsReportPropertyProviderProxy.java
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.controller.metrics;
+
+import org.apache.ambari.server.configuration.ComponentSSLConfiguration;
+import org.apache.ambari.server.controller.internal.AbstractPropertyProvider;
+import org.apache.ambari.server.controller.internal.PropertyInfo;
+import org.apache.ambari.server.controller.metrics.ganglia.GangliaReportPropertyProvider;
+import org.apache.ambari.server.controller.metrics.timeline.AMSReportPropertyProvider;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.utilities.StreamProvider;
+
+import java.util.Map;
+import java.util.Set;
+
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.GANGLIA;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.TIMELINE_METRICS;
+
+public class MetricsReportPropertyProviderProxy extends AbstractPropertyProvider {
+  private MetricsReportPropertyProvider amsMetricsReportProvider;
+  private MetricsReportPropertyProvider gangliaMetricsReportProvider;
+  private final MetricsServiceProvider metricsServiceProvider;
+
+  public MetricsReportPropertyProviderProxy(
+    Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap,
+    StreamProvider streamProvider,
+    ComponentSSLConfiguration configuration,
+    MetricHostProvider hostProvider,
+    MetricsServiceProvider serviceProvider,
+    String clusterNamePropertyId) {
+
+
+    super(componentPropertyInfoMap);
+    this.metricsServiceProvider = serviceProvider;
+
+    createReportPropertyProviders(componentPropertyInfoMap,
+      streamProvider,
+      configuration,
+      hostProvider,
+      clusterNamePropertyId);
+  }
+
+  private void createReportPropertyProviders(Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap,
+                                             StreamProvider streamProvider,
+                                             ComponentSSLConfiguration configuration,
+                                             MetricHostProvider hostProvider,
+                                             String clusterNamePropertyId) {
+
+    this.amsMetricsReportProvider = new AMSReportPropertyProvider(
+      componentPropertyInfoMap,
+      streamProvider,
+      configuration,
+      hostProvider,
+      clusterNamePropertyId);
+
+    this.gangliaMetricsReportProvider = new GangliaReportPropertyProvider(
+      componentPropertyInfoMap,
+      streamProvider,
+      configuration,
+      hostProvider,
+      clusterNamePropertyId);
+  }
+
+  @Override
+  public Set<Resource> populateResources(Set<Resource> resources, Request request,
+                                         Predicate predicate) throws SystemException {
+
+    if (metricsServiceProvider.getMetricsServiceType().equals(GANGLIA)) {
+      return gangliaMetricsReportProvider.populateResources(resources, request, predicate);
+    } else if (metricsServiceProvider.getMetricsServiceType().equals(TIMELINE_METRICS)) {
+      return amsMetricsReportProvider.populateResources(resources, request, predicate);
+    }
+    return null;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsServiceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsServiceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsServiceProvider.java
new file mode 100644
index 0000000..f9f9dc6
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsServiceProvider.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.controller.metrics;
+
+public interface MetricsServiceProvider {
+
+  /**
+   * Enumeration to distinguish metrics service installed for a cluster
+   */
+  public enum MetricsService {
+    GANGLIA,
+    TIMELINE_METRICS
+  }
+
+  /**
+   * Provide type of metrics service installed.
+   * @return @MetricsService
+   */
+  public MetricsService getMetricsServiceType();
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaHostPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaHostPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaHostPropertyProvider.java
index df58ee5..41a500f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaHostPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaHostPropertyProvider.java
@@ -23,7 +23,6 @@ import org.apache.ambari.server.controller.internal.PropertyInfo;
 import org.apache.ambari.server.controller.metrics.MetricHostProvider;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.utilities.StreamProvider;
-
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProvider.java
index 63533c6..e23f461 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProvider.java
@@ -18,25 +18,34 @@
 
 package org.apache.ambari.server.controller.metrics.ganglia;
 
-import org.apache.ambari.server.controller.internal.AbstractPropertyProvider;
 import org.apache.ambari.server.configuration.ComponentSSLConfiguration;
 import org.apache.ambari.server.controller.internal.PropertyInfo;
 import org.apache.ambari.server.controller.metrics.MetricHostProvider;
 import org.apache.ambari.server.controller.metrics.MetricsPropertyProvider;
-import org.apache.ambari.server.controller.spi.*;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.TemporalInfo;
 import org.apache.ambari.server.controller.utilities.StreamProvider;
 import org.apache.http.client.utils.URIBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService.*;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.GANGLIA;
 
 /**
  * Abstract property provider implementation for a Ganglia source.
@@ -87,15 +96,10 @@ public abstract class GangliaPropertyProvider extends MetricsPropertyProvider {
   // ----- PropertyProvider --------------------------------------------------
 
   @Override
-  public Set<Resource> populateResources(Set<Resource> resources, Request request, Predicate predicate)
-      throws SystemException {
-
-    Set<String> ids = getRequestPropertyIds(request, predicate);
-    if (ids.isEmpty()) {
-      return resources;
-    }
+  public Set<Resource> populateResourcesWithProperties(Set<Resource> resources,
+            Request request, Set<String> propertyIds) throws SystemException {
 
-    Map<String, Map<TemporalInfo, RRDRequest>> requestMap = getRRDRequests(resources, request, ids);
+    Map<String, Map<TemporalInfo, RRDRequest>> requestMap = getRRDRequests(resources, request, propertyIds);
 
     // For each cluster...
     for (Map.Entry<String, Map<TemporalInfo, RRDRequest>> clusterEntry : requestMap.entrySet()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaReportPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaReportPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaReportPropertyProvider.java
index 09ea31c..e8dc7d1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaReportPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaReportPropertyProvider.java
@@ -32,15 +32,13 @@ import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.type.TypeReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService.GANGLIA;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.GANGLIA;
 
 /**
  * Property provider implementation for a Ganglia source. This provider is specialized

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
index d75c982..9e51a61 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
@@ -21,25 +21,18 @@ import org.apache.ambari.server.configuration.ComponentSSLConfiguration;
 import org.apache.ambari.server.controller.internal.PropertyInfo;
 import org.apache.ambari.server.controller.metrics.MetricHostProvider;
 import org.apache.ambari.server.controller.metrics.MetricsPropertyProvider;
-import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.controller.spi.TemporalInfo;
 import org.apache.ambari.server.controller.utilities.StreamProvider;
-import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.params.HttpMethodParams;
 import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric;
 import org.apache.hadoop.metrics2.sink.timeline.TimelineMetrics;
-import org.apache.http.HttpStatus;
 import org.apache.http.client.utils.URIBuilder;
 import org.codehaus.jackson.map.AnnotationIntrospector;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.ObjectReader;
 import org.codehaus.jackson.xc.JaxbAnnotationIntrospector;
-
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
@@ -54,8 +47,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService.TIMELINE_METRICS;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.TIMELINE_METRICS;
 import static org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
 
 public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
@@ -329,16 +321,11 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
   }
 
   @Override
-  public Set<Resource> populateResources(Set<Resource> resources,
-              Request request, Predicate predicate) throws SystemException {
-
-    Set<String> ids = getRequestPropertyIds(request, predicate);
-    if (ids.isEmpty()) {
-      return resources;
-    }
+  public Set<Resource> populateResourcesWithProperties(Set<Resource> resources,
+               Request request, Set<String> propertyIds) throws SystemException {
 
     Map<String, Map<TemporalInfo, MetricsRequest>> requestMap =
-      getMetricsRequests(resources, request, ids);
+      getMetricsRequests(resources, request, propertyIds);
 
     // For each cluster
     for (Map.Entry<String, Map<TemporalInfo, MetricsRequest>> clusterEntry : requestMap.entrySet()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MetricsServiceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MetricsServiceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MetricsServiceProviderTest.java
new file mode 100644
index 0000000..9e4131f
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/MetricsServiceProviderTest.java
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.controller.internal;
+
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.controller.utilities.PredicateBuilder;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.apache.ambari.server.controller.internal.ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID;
+import static org.apache.ambari.server.controller.internal.HostComponentResourceProvider.HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID;
+import static org.apache.ambari.server.controller.internal.HostComponentResourceProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID;
+import static org.apache.ambari.server.controller.internal.HostComponentResourceProvider.HOST_COMPONENT_HOST_NAME_PROPERTY_ID;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class MetricsServiceProviderTest {
+
+  @SuppressWarnings("unchecked")
+  @Test
+  public void testResetMetricProviderMap() throws Exception {
+    TestMetricProviderModule providerModule = new TestMetricProviderModule();
+
+    ResourceProvider clusterResourceProvider = providerModule.getResourceProvider(Resource.Type.Cluster);
+
+    final Resource cluster = mock(Resource.class);
+    final Set<Resource> resources = new HashSet<Resource>() {{ add(cluster); }};
+    when(clusterResourceProvider.getResources((Request) any(),
+      (Predicate) any())).thenReturn(resources);
+    when(cluster.getPropertyValue(CLUSTER_NAME_PROPERTY_ID)).thenReturn("c1");
+
+    // Assert requests and predicates used
+    ResourceProvider hostComponentResourceProvider = providerModule
+      .getResourceProvider(Resource.Type.HostComponent);
+
+    Set<String> propertyIds = new HashSet<String>();
+    propertyIds.add(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID);
+    propertyIds.add(HOST_COMPONENT_HOST_NAME_PROPERTY_ID);
+
+    Request expectedRequest = PropertyHelper.getReadRequest(propertyIds);
+
+    Predicate expectedPredicate1 =
+      new PredicateBuilder().property(HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID)
+        .equals("c1").and().property(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID)
+        .equals("GANGLIA_SERVER").toPredicate();
+
+    Predicate expectedPredicate2 =
+      new PredicateBuilder().property(HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID)
+        .equals("c1").and().property(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID)
+        .equals("METRIC_COLLECTOR").toPredicate();
+
+    ArgumentCaptor<Request> requestCapture = ArgumentCaptor.forClass(Request.class);
+    ArgumentCaptor<Predicate> predicateCapture = ArgumentCaptor.forClass(Predicate.class);
+
+    when(hostComponentResourceProvider.getResources(any(Request.class),
+      any(Predicate.class))).thenReturn(Collections.<Resource>emptySet());
+
+    // Assert default null
+    MetricsService service = providerModule.getMetricsServiceType();
+    verify(hostComponentResourceProvider, times(3)).getResources(requestCapture
+      .capture(), predicateCapture.capture());
+
+    List<Request> requests = requestCapture.getAllValues();
+    Request request1 = requests.get(requests.size() - 2); // GANGLIA check
+    Request request2 = requests.get(requests.size() - 1); // COLLECTOR check
+
+    List<Predicate> predicates = predicateCapture.getAllValues();
+    Predicate predicate1 = predicates.get(predicates.size() - 2);
+    Predicate predicate2 = predicates.get(predicates.size() - 1);
+
+    Assert.assertEquals(expectedRequest, request1);
+    Assert.assertEquals(expectedRequest, request2);
+    Assert.assertEquals(expectedPredicate1, predicate1);
+    Assert.assertEquals(expectedPredicate2, predicate2);
+
+    Assert.assertEquals(null, service);
+
+    // Assert change to actual service
+
+    final Resource hostComponent = mock(Resource.class);
+    Set<Resource> hostComponents = new HashSet<Resource>() {{ add(hostComponent); }};
+    when(hostComponentResourceProvider.getResources(any(Request.class),
+      any(Predicate.class))).thenReturn(hostComponents);
+    when(hostComponent.getPropertyValue
+      (HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID)).thenReturn("METRIC_COLLECTOR");
+    when(hostComponent.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID)).thenReturn("h1");
+
+    service = providerModule.getMetricsServiceType();
+    Assert.assertEquals(MetricsService.TIMELINE_METRICS, service);
+  }
+
+  private static class TestMetricProviderModule extends AbstractProviderModule {
+    ResourceProvider clusterResourceProvider = mock(ClusterResourceProvider.class);
+
+    ResourceProvider hostCompResourceProvider = mock(HostComponentResourceProvider.class);
+
+    @Override
+    protected ResourceProvider createResourceProvider(Resource.Type type) {
+      if (type == Resource.Type.Cluster)
+        return clusterResourceProvider;
+      else if (type == Resource.Type.HostComponent)
+        return hostCompResourceProvider;
+      return null;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java
index 8198e9c..c31cc37 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java
@@ -34,9 +34,9 @@ import org.apache.ambari.server.controller.utilities.StreamProvider;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.stack.Metric;
 import org.junit.After;
@@ -54,6 +54,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import static org.apache.ambari.server.controller.metrics.ganglia.GangliaPropertyProviderTest.TestGangliaServiceProvider;
+
 /**
  * Tests the stack defined property provider.
  */
@@ -103,10 +105,13 @@ public class StackDefinedPropertyProviderTest {
     JMXPropertyProviderTest.TestJMXHostProvider tj = new JMXPropertyProviderTest.TestJMXHostProvider(true);
     TestGangliaHostProvider tg = new TestGangliaHostProvider();
     JMXPropertyProviderTest.TestMetricHostProvider tm = new JMXPropertyProviderTest.TestMetricHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider sdpp = new StackDefinedPropertyProvider(
-        Resource.Type.HostComponent, tj, tm, new CombinedStreamProvider(),
-        "HostRoles/cluster_name", "HostRoles/host_name", "HostRoles/component_name", "HostRoles/state", null, null);
+        Resource.Type.HostComponent, tj, tm, serviceProvider,
+        new CombinedStreamProvider(), "HostRoles/cluster_name",
+        "HostRoles/host_name", "HostRoles/component_name", "HostRoles/state",
+        null, null);
 
     Resource resource = new ResourceImpl(Resource.Type.HostComponent);
 
@@ -290,11 +295,13 @@ public class StackDefinedPropertyProviderTest {
     JMXPropertyProviderTest.TestJMXHostProvider hostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(true);
     TestGangliaHostProvider gangliaHostProvider = new TestGangliaHostProvider();
     JMXPropertyProviderTest.TestMetricHostProvider metricsHostProvider = new JMXPropertyProviderTest.TestMetricHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         hostProvider,
         metricsHostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         PropertyHelper.getPropertyId("HostRoles", "host_name"),
@@ -351,11 +358,13 @@ public class StackDefinedPropertyProviderTest {
     JMXPropertyProviderTest.TestJMXHostProvider hostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(false);
     TestGangliaHostProvider gangliaHostProvider = new TestGangliaHostProvider();
     JMXPropertyProviderTest.TestMetricHostProvider metricsHostProvider = new JMXPropertyProviderTest.TestMetricHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         hostProvider,
         metricsHostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         PropertyHelper.getPropertyId("HostRoles", "host_name"),
@@ -403,11 +412,13 @@ public class StackDefinedPropertyProviderTest {
     JMXPropertyProviderTest.TestJMXHostProvider hostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(false);
     TestGangliaHostProvider gangliaHostProvider = new TestGangliaHostProvider();
     JMXPropertyProviderTest.TestMetricHostProvider metricsHostProvider = new JMXPropertyProviderTest.TestMetricHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         hostProvider,
         metricsHostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         PropertyHelper.getPropertyId("HostRoles", "host_name"),
@@ -440,12 +451,13 @@ public class StackDefinedPropertyProviderTest {
     JMXPropertyProviderTest.TestJMXHostProvider hostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(false);
     TestGangliaHostProvider gangliaHostProvider = new TestGangliaHostProvider();
     JMXPropertyProviderTest.TestMetricHostProvider metricsHostProvider = new JMXPropertyProviderTest.TestMetricHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         hostProvider,
-
         metricsHostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         PropertyHelper.getPropertyId("HostRoles", "host_name"),
@@ -493,12 +505,13 @@ public class StackDefinedPropertyProviderTest {
     JMXPropertyProviderTest.TestJMXHostProvider hostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(false);
     TestGangliaHostProvider gangliaHostProvider = new TestGangliaHostProvider();
     JMXPropertyProviderTest.TestMetricHostProvider metricsHostProvider = new JMXPropertyProviderTest.TestMetricHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         hostProvider,
-
         metricsHostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         PropertyHelper.getPropertyId("HostRoles", "host_name"),
@@ -552,12 +565,13 @@ public class StackDefinedPropertyProviderTest {
     JMXPropertyProviderTest.TestJMXHostProvider hostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(false);
     TestGangliaHostProvider gangliaHostProvider = new TestGangliaHostProvider();
     JMXPropertyProviderTest.TestMetricHostProvider metricsHostProvider = new JMXPropertyProviderTest.TestMetricHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         hostProvider,
-
         metricsHostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         PropertyHelper.getPropertyId("HostRoles", "host_name"),
@@ -678,11 +692,13 @@ public class StackDefinedPropertyProviderTest {
     JMXPropertyProviderTest.TestJMXHostProvider hostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(false);
     TestGangliaHostProvider gangliaHostProvider = new TestGangliaHostProvider();
     JMXPropertyProviderTest.TestMetricHostProvider metricsHostProvider = new JMXPropertyProviderTest.TestMetricHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         hostProvider,
         gangliaHostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         PropertyHelper.getPropertyId("HostRoles", "host_name"),
@@ -720,12 +736,13 @@ public class StackDefinedPropertyProviderTest {
     JMXPropertyProviderTest.TestJMXHostProvider hostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(false);
     TestGangliaHostProvider gangliaHostProvider = new TestGangliaHostProvider();
     JMXPropertyProviderTest.TestMetricHostProvider metricsHostProvider = new JMXPropertyProviderTest.TestMetricHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         hostProvider,
-
         metricsHostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         null,
@@ -757,11 +774,13 @@ public class StackDefinedPropertyProviderTest {
     JMXPropertyProviderTest.TestJMXHostProvider hostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(false);
     TestGangliaHostProvider gangliaHostProvider = new TestGangliaHostProvider();
     JMXPropertyProviderTest.TestMetricHostProvider metricsHostProvider = new JMXPropertyProviderTest.TestMetricHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         hostProvider,
         metricsHostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         PropertyHelper.getPropertyId("HostRoles", "host_name"),
@@ -799,11 +818,13 @@ public class StackDefinedPropertyProviderTest {
 
     JMXPropertyProviderTest.TestJMXHostProvider jmxHostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(true);
     TestGangliaHostProvider hostProvider = new TestGangliaHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         jmxHostProvider,
         hostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         PropertyHelper.getPropertyId("HostRoles", "host_name"),
@@ -845,11 +866,13 @@ public class StackDefinedPropertyProviderTest {
 
     JMXPropertyProviderTest.TestJMXHostProvider jmxHostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(true);
     TestGangliaHostProvider hostProvider = new TestGangliaHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         jmxHostProvider,
         hostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         PropertyHelper.getPropertyId("HostRoles", "host_name"),
@@ -968,11 +991,13 @@ public class StackDefinedPropertyProviderTest {
     JMXPropertyProviderTest.TestJMXHostProvider jmxHostProvider = new JMXPropertyProviderTest.TestJMXHostProvider(true);
     JMXPropertyProviderTest.TestMetricHostProvider metricsHostProvider = new JMXPropertyProviderTest.TestMetricHostProvider();
     TestGangliaHostProvider hostProvider = new TestGangliaHostProvider();
+    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();
 
     StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
         Resource.Type.HostComponent,
         jmxHostProvider,
         hostProvider,
+        serviceProvider,
         streamProvider,
         PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
         PropertyHelper.getPropertyId("HostRoles", "host_name"),

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/JMXPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/JMXPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/JMXPropertyProviderTest.java
index a640ec2..69fb5f5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/JMXPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/JMXPropertyProviderTest.java
@@ -29,9 +29,12 @@ import org.apache.ambari.server.controller.spi.TemporalInfo;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.junit.Assert;
 import org.junit.Test;
-
-import java.util.*;
-
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService;
 
 /**
  * JMX property provider tests.
@@ -515,7 +518,7 @@ public class JMXPropertyProviderTest {
   public static class TestMetricHostProvider implements MetricHostProvider {
 
     @Override
-    public String getCollectorHostName(String clusterName, MetricsPropertyProvider.MetricsService service) throws SystemException {
+    public String getCollectorHostName(String clusterName, MetricsService service) throws SystemException {
       return null;
     }
 
@@ -525,17 +528,17 @@ public class JMXPropertyProviderTest {
     }
 
     @Override
-    public String getCollectorPortName(String clusterName, MetricsPropertyProvider.MetricsService service) throws SystemException {
+    public String getCollectorPortName(String clusterName, MetricsService service) throws SystemException {
       return null;
     }
 
     @Override
-    public boolean isCollectorHostLive(String clusterName, MetricsPropertyProvider.MetricsService service) throws SystemException {
+    public boolean isCollectorHostLive(String clusterName, MetricsService service) throws SystemException {
       return false;
     }
 
     @Override
-    public boolean isCollectorComponentLive(String clusterName, MetricsPropertyProvider.MetricsService service) throws SystemException {
+    public boolean isCollectorComponentLive(String clusterName, MetricsService service) throws SystemException {
       return false;
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProviderTest.java
index 51e88ed..c50ccba 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/RestMetricsPropertyProviderTest.java
@@ -23,7 +23,6 @@ import com.google.inject.Injector;
 import org.apache.ambari.server.controller.internal.PropertyInfo;
 import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.internal.StackDefinedPropertyProvider;
-import org.apache.ambari.server.controller.jmx.JMXHostProvider;
 import org.apache.ambari.server.controller.jmx.TestStreamProvider;
 import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.Resource;
@@ -40,9 +39,13 @@ import org.apache.ambari.server.state.stack.MetricDefinition;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 
-import java.util.*;
-
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService;
 import static org.easymock.EasyMock.createNiceMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
@@ -383,7 +386,7 @@ public class RestMetricsPropertyProviderTest {
   public static class TestMetricsHostProvider implements MetricHostProvider {
 
     @Override
-    public String getCollectorHostName(String clusterName, MetricsPropertyProvider.MetricsService service) throws SystemException {
+    public String getCollectorHostName(String clusterName, MetricsService service) throws SystemException {
       return null;
     }
 
@@ -393,17 +396,17 @@ public class RestMetricsPropertyProviderTest {
     }
 
     @Override
-    public String getCollectorPortName(String clusterName, MetricsPropertyProvider.MetricsService service) throws SystemException {
+    public String getCollectorPortName(String clusterName, MetricsService service) throws SystemException {
       return null;
     }
 
     @Override
-    public boolean isCollectorHostLive(String clusterName, MetricsPropertyProvider.MetricsService service) throws SystemException {
+    public boolean isCollectorHostLive(String clusterName, MetricsService service) throws SystemException {
       return false;
     }
 
     @Override
-    public boolean isCollectorComponentLive(String clusterName, MetricsPropertyProvider.MetricsService service) throws SystemException {
+    public boolean isCollectorComponentLive(String clusterName, MetricsService service) throws SystemException {
       return false;
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/2160d544/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProviderTest.java
index 30a7598..befd062 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/ganglia/GangliaPropertyProviderTest.java
@@ -23,6 +23,7 @@ import org.apache.ambari.server.controller.internal.PropertyInfo;
 import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.internal.TemporalInfoImpl;
 import org.apache.ambari.server.controller.metrics.MetricHostProvider;
+import org.apache.ambari.server.controller.metrics.MetricsServiceProvider;
 import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.SystemException;
@@ -38,7 +39,6 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.powermock.api.easymock.PowerMock;
 import org.powermock.core.classloader.annotations.PrepareForTest;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -48,9 +48,8 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService;
-import static org.apache.ambari.server.controller.metrics.MetricsPropertyProvider.MetricsService.GANGLIA;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService;
+import static org.apache.ambari.server.controller.metrics.MetricsServiceProvider.MetricsService.GANGLIA;
 import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.eq;
 import static org.easymock.EasyMock.expect;
@@ -841,6 +840,14 @@ public class GangliaPropertyProviderTest {
     return metricsBuilder.toString();
   }
 
+  public static class TestGangliaServiceProvider implements MetricsServiceProvider {
+
+    @Override
+    public MetricsService getMetricsServiceType() {
+      return MetricsService.GANGLIA;
+    }
+  }
+
   public static class TestGangliaHostProvider implements MetricHostProvider {
 
     private boolean isHostLive;


Mime
View raw message