You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/05/29 22:46:34 UTC

svn commit: r1487638 [4/8] - in /incubator/ambari/branches/branch-1.4.0: ./ ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/ ambari-agent/src/main/puppet/modules/hdp-hadoop/templates/ ambari-agent/src/main/puppet/modules/hdp-hbase/manifests/ ...

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/update-services.md
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/update-services.md?rev=1487638&r1=1487637&r2=1487638&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/update-services.md (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/update-services.md Wed May 29 20:46:31 2013
@@ -1,3 +1,4 @@
+
 <!---
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements. See the NOTICE file distributed with

Added: incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflow-resources.md
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflow-resources.md?rev=1487638&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflow-resources.md (added)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflow-resources.md Wed May 29 20:46:31 2013
@@ -0,0 +1,22 @@
+<!---
+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.
+-->
+
+# Workflow Resources
+ 
+
+- [List workflows](workflows.md)
+- [View workflow information](workflows-workflow.md)

Added: incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflows-workflow.md
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflows-workflow.md?rev=1487638&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflows-workflow.md (added)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflows-workflow.md Wed May 29 20:46:31 2013
@@ -0,0 +1,57 @@
+<!---
+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.
+-->
+
+View Workflow Information
+=====
+
+[Back to Resources](index.md#resources)
+
+Returns information about a single workflow in a given cluster.
+
+    GET /clusters/:name/workflows/:workflowid
+
+**Response**
+
+    200 OK
+    {
+        "href" : "http://your.ambari.server/api/v1/clusters/c1/workflows/mr_201305061943_0001",
+        "Workflow" : {
+            "cluster_name" : "c1",
+            "workflow_id" : "mr_201305061943_0001"
+            "last_update_time" : 1367883887044,
+            "input_bytes" : 2009,
+            "output_bytes" : 1968,
+            "user_name" : "ambari-qa",
+            "elapsed_time" : 25734,
+            "num_jobs_total" : 1,
+            "num_jobs_completed" : 1,
+            "name" : "word count",
+            "context" : "{\"workflowId\":null,\"workflowName\":null,\"workflowDag\":{\"entries\":[{\"source\":\"X\",\"targets\":[]}]},\"parentWorkflowContext\":null,\"workflowEntityName\":null}",
+            "start_time" : 1367883861310,
+            "parent_id" : null
+        },
+        "jobs" : [
+            {
+                "href" : "http://your.ambari.server/api/v1/clusters/c1/workflows/mr_201305061943_0001/jobs/job_201305061943_0001",
+                "Job" : {
+                    "cluster_name" : "c1",
+                    "workflow_id" : "mr_201305061943_0001",
+                    "job_id" : "job_201305061943_0001"
+                }
+            }
+        ]
+    }

Added: incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflows.md
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflows.md?rev=1487638&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflows.md (added)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/docs/api/v1/workflows.md Wed May 29 20:46:31 2013
@@ -0,0 +1,48 @@
+<!---
+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.
+-->
+
+List Workflows
+=====
+
+[Back to Resources](index.md#resources)
+
+Returns a collection of all workflows in a given cluster.
+
+    GET /clusters/:name/workflows
+
+**Response**
+
+    200 OK
+    {
+        "href" : "http://your.ambari.server/api/v1/clusters/c1/workflows",
+        "items" : [
+            {
+                "href" : "http://your.ambari.server/api/v1/clusters/c1/workflows/mr_201305061943_0001",
+                "Workflow" : {
+                    "cluster_name" : "c1",
+                    "workflow_id" : "mr_201305061943_0001"
+                }
+            },
+            {
+                "href" : "http://your.ambari.server/api/v1/clusters/c1/workflows/mr_201305061943_0002",
+                "Workflow" : {
+                    "cluster_name" : "c1",
+                    "workflow_id" : "mr_201305061943_0002"
+                }
+            }
+        ]
+    }

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/Role.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/Role.java?rev=1487638&r1=1487637&r2=1487638&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/Role.java (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/Role.java Wed May 29 20:46:31 2013
@@ -40,6 +40,7 @@ public enum Role {
   HADOOP_CLIENT,
   JOBTRACKER_SERVICE_CHECK,
   MAPREDUCE_SERVICE_CHECK,
+  MAPREDUCE2_SERVICE_CHECK,
   ZOOKEEPER_SERVICE_CHECK,
   ZOOKEEPER_QUORUM_SERVICE_CHECK,
   HBASE_SERVICE_CHECK,

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java?rev=1487638&r1=1487637&r2=1487638&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java Wed May 29 20:46:31 2013
@@ -119,11 +119,11 @@ public class HeartbeatMonitor implements
       } catch (AmbariException e) {
         LOG.warn("Exception in getting host object; Is it fatal?", e);
       }
-      if (lastHeartbeat + 2*threadWakeupInterval < now) {
-        LOG.warn("Hearbeat lost from host "+host);
+      if (lastHeartbeat + 2 * threadWakeupInterval < now) {
+        LOG.warn("Heartbeat lost from host " + host);
         //Heartbeat is expired
         hostObj.handleEvent(new HostHeartbeatLostEvent(host));
-        
+
         // mark all components that are not clients with unknown status
         for (Cluster cluster : fsm.getClustersForHost(hostObj.getHostName())) {
           for (ServiceComponentHost sch : cluster.getServiceComponentHosts(hostObj.getHostName())) {
@@ -134,14 +134,17 @@ public class HeartbeatMonitor implements
                 !sch.getState().equals(State.INSTALLING) &&
                 !sch.getState().equals(State.INSTALL_FAILED) &&
                 !sch.getState().equals(State.UNINSTALLED)) {
+              LOG.warn("Setting component state to UNKNOWN for component " + sc.getName() + " on " + host);
               sch.setState(State.UNKNOWN);
             }
           }
         }
-        
+
         // hbase
-        if(hostState != hostObj.getState() && scanner != null) scanner.updateHBaseMaster(hostObj);
-        
+        if (hostState != hostObj.getState() && scanner != null) {
+          scanner.updateHBaseMaster(hostObj);
+        }
+
         //Purge action queue
         actionQueue.dequeueAll(host);
         //notify action manager
@@ -149,7 +152,7 @@ public class HeartbeatMonitor implements
       }
       if (hostState == HostState.WAITING_FOR_HOST_STATUS_UPDATES) {
         long timeSpentInState = hostObj.getTimeInState();
-        if (timeSpentInState + 5*threadWakeupInterval < now) {
+        if (timeSpentInState + 5 * threadWakeupInterval < now) {
           //Go back to init, the agent will be asked to register again in the next heartbeat
           LOG.warn("timeSpentInState + 5*threadWakeupInterval < now, Go back to init");
           hostObj.setState(HostState.INIT);
@@ -159,7 +162,7 @@ public class HeartbeatMonitor implements
       // Get status of service components
       List<StatusCommand> cmds = generateStatusCommands(hostname);
       LOG.trace("Generated " + cmds.size() + " status commands for host: " +
-        hostname);
+          hostname);
       if (cmds.isEmpty()) {
         // Nothing to do
       } else {

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java?rev=1487638&r1=1487637&r2=1487638&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java Wed May 29 20:46:31 2013
@@ -25,12 +25,14 @@ import org.apache.ambari.server.controll
 import org.apache.ambari.server.controller.ganglia.GangliaReportPropertyProvider;
 import org.apache.ambari.server.controller.ganglia.GangliaHostProvider;
 import org.apache.ambari.server.controller.jmx.JMXHostProvider;
+import org.apache.ambari.server.controller.jmx.JMXVersioningPropertyProvider;
 import org.apache.ambari.server.controller.jmx.JMXPropertyProvider;
 import org.apache.ambari.server.controller.spi.*;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import com.google.inject.Inject;
+import org.apache.ambari.server.controller.utilities.StreamProvider;
 import org.apache.ambari.server.state.Service;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,6 +48,7 @@ public abstract class AbstractProviderMo
   private static final int PROPERTY_REQUEST_READ_TIMEOUT    = 10000;
 
   private static final String CLUSTER_NAME_PROPERTY_ID                  = PropertyHelper.getPropertyId("Clusters", "cluster_name");
+  private static final String CLUSTER_VERSION_PROPERTY_ID               = PropertyHelper.getPropertyId("Clusters", "version");
   private static final String HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID   = PropertyHelper.getPropertyId("HostRoles", "cluster_name");
   private static final String HOST_COMPONENT_HOST_NAME_PROPERTY_ID      = PropertyHelper.getPropertyId("HostRoles", "host_name");
   private static final String HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("HostRoles", "component_name");
@@ -97,6 +100,12 @@ public abstract class AbstractProviderMo
   private AmbariManagementController managementController;
 
   /**
+   * Cluster versions.
+   */
+  private final Map<String, PropertyHelper.JMXMetricsVersion> clusterVersionsMap =
+      new HashMap<String, PropertyHelper.JMXMetricsVersion>();
+
+  /**
    * The map of host components.
    */
   private Map<String, Map<String, String>> clusterHostComponentMap;
@@ -156,8 +165,11 @@ public abstract class AbstractProviderMo
   public void update(ResourceProviderEvent event) {
     Resource.Type type = event.getResourceType();
 
-    if (type == Resource.Type.Cluster ||
-        type == Resource.Type.Host ||
+    if (type == Resource.Type.Cluster) {
+      resetInit();
+      updateClusterVersion();
+    }
+    if (type == Resource.Type.Host ||
         type == Resource.Type.HostComponent) {
       resetInit();
     }
@@ -235,7 +247,7 @@ public abstract class AbstractProviderMo
   }
 
   protected void putResourceProvider(Resource.Type type, ResourceProvider resourceProvider) {
-    resourceProviders.put( type , resourceProvider);
+    resourceProviders.put(type, resourceProvider);
   }
 
   protected void putPropertyProviders(Resource.Type type, List<PropertyProvider> providers) {
@@ -267,8 +279,8 @@ public abstract class AbstractProviderMo
         ));
         break;
       case Component :
-        providers.add(new JMXPropertyProvider(
-            PropertyHelper.getJMXPropertyIds(type),
+        providers.add(createJMXPropertyProvider(
+            type,
             streamProvider,
             this,
             PropertyHelper.getPropertyId("ServiceComponentInfo", "cluster_name"),
@@ -285,8 +297,8 @@ public abstract class AbstractProviderMo
             PropertyHelper.getPropertyId("ServiceComponentInfo", "component_name")));
         break;
       case HostComponent:
-        providers.add(new JMXPropertyProvider(
-            PropertyHelper.getJMXPropertyIds(type),
+        providers.add(createJMXPropertyProvider(
+            type,
             streamProvider,
             this,
             PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
@@ -329,7 +341,39 @@ public abstract class AbstractProviderMo
     }
   }
 
-  private void initProviderMaps() throws SystemException{
+  /**
+   * Update a map of known cluster names to version of JMX metrics.  The JMX metrics version is based on the
+   * HDP version of the cluster.
+   */
+  private void updateClusterVersion() {
+    synchronized (clusterVersionsMap) {
+      clusterVersionsMap.clear();
+
+      ResourceProvider provider = getResourceProvider(Resource.Type.Cluster);
+      Request request = PropertyHelper.getReadRequest(CLUSTER_NAME_PROPERTY_ID, CLUSTER_VERSION_PROPERTY_ID);
+
+      try {
+        Set<Resource> clusters = provider.getResources(request, null);
+
+        for (Resource cluster : clusters) {
+          String clusterVersion = (String) cluster.getPropertyValue(CLUSTER_VERSION_PROPERTY_ID);
+
+          PropertyHelper.JMXMetricsVersion version =  clusterVersion.startsWith("HDP-2") ?
+              PropertyHelper.JMXMetricsVersion.Two : PropertyHelper.JMXMetricsVersion.One;
+
+          clusterVersionsMap.put(
+              (String) cluster.getPropertyValue(CLUSTER_NAME_PROPERTY_ID),
+              version);
+        }
+      } catch (Exception e) {
+        if (LOG.isErrorEnabled()) {
+          LOG.error("Caught exception while trying to get the cluster versions.", e);
+        }
+      }
+    }
+  }
+
+  private void initProviderMaps() throws SystemException {
     ResourceProvider provider = getResourceProvider(Resource.Type.Cluster);
     Request          request  = PropertyHelper.getReadRequest(CLUSTER_NAME_PROPERTY_ID);
 
@@ -465,4 +509,28 @@ public abstract class AbstractProviderMo
     }
     return mConfigs;
   }
+
+  /**
+   * Create the JMX property provider for the given type.
+   */
+  private PropertyProvider createJMXPropertyProvider( Resource.Type type, StreamProvider streamProvider,
+                                                      JMXHostProvider jmxHostProvider,
+                                                      String clusterNamePropertyId,
+                                                      String hostNamePropertyId,
+                                                      String componentNamePropertyId,
+                                                      String statePropertyId,
+                                                      Set<String> healthyStates) {
+    updateClusterVersion();
+
+    Map<PropertyHelper.JMXMetricsVersion, JMXPropertyProvider> providers =
+        new HashMap<PropertyHelper.JMXMetricsVersion, JMXPropertyProvider>();
+
+    for (PropertyHelper.JMXMetricsVersion version : PropertyHelper.JMXMetricsVersion.values()) {
+
+      providers.put(version, new JMXPropertyProvider(PropertyHelper.getJMXPropertyIds(type, version), streamProvider,
+          jmxHostProvider, clusterNamePropertyId, hostNamePropertyId, componentNamePropertyId, statePropertyId, healthyStates));
+    }
+
+    return new JMXVersioningPropertyProvider(clusterVersionsMap, providers, clusterNamePropertyId);
+  }
 }

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java?rev=1487638&r1=1487637&r2=1487638&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java Wed May 29 20:46:31 2013
@@ -260,28 +260,28 @@ public class ClusterControllerImpl imple
     Iterable<Resource> resources = getResources(type, readRequest, predicate);
 
     PredicateBuilder pb = new PredicateBuilder();
-    PredicateBuilder.PredicateBuilderPredicate pbPredicate = null;
+    PredicateBuilder.PredicateBuilderWithPredicate pbWithPredicate = null;
 
     for (Resource resource : resources) {
-      if (pbPredicate != null) {
-        pb = pbPredicate.or();
+      if (pbWithPredicate != null) {
+        pb = pbWithPredicate.or();
       }
 
-      pb          = pb.begin();
-      pbPredicate = null;
+      pb              = pb.begin();
+      pbWithPredicate = null;
 
       for (String keyPropertyId : keyPropertyIds) {
-        if (pbPredicate != null) {
-          pb = pbPredicate.and();
+        if (pbWithPredicate != null) {
+          pb = pbWithPredicate.and();
         }
-        pbPredicate =
+        pbWithPredicate =
             pb.property(keyPropertyId).equals((Comparable) resource.getPropertyValue(keyPropertyId));
       }
-      if (pbPredicate != null) {
-        pbPredicate = pbPredicate.end();
+      if (pbWithPredicate != null) {
+        pbWithPredicate = pbWithPredicate.end();
       }
     }
-    return pbPredicate == null ? null : pbPredicate.toPredicate();
+    return pbWithPredicate == null ? null : pbWithPredicate.toPredicate();
   }
 
   /**

Added: incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXVersioningPropertyProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXVersioningPropertyProvider.java?rev=1487638&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXVersioningPropertyProvider.java (added)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXVersioningPropertyProvider.java Wed May 29 20:46:31 2013
@@ -0,0 +1,108 @@
+/**
+ * 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.jmx;
+
+import org.apache.ambari.server.controller.internal.BaseProvider;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.PropertyProvider;
+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.PropertyHelper;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A JMX property manager that delegates to other JMX Property managers based on the
+ * JMX metrics version of the cluster associated with the resources being populated.
+ */
+public class JMXVersioningPropertyProvider extends BaseProvider implements PropertyProvider {
+
+  private final Map<String, PropertyHelper.JMXMetricsVersion> clusterVersions;
+  private final Map<PropertyHelper.JMXMetricsVersion, JMXPropertyProvider> providers;
+  private final String clusterNamePropertyId;
+
+  /**
+   * Create a version aware JMX property provider.
+   */
+  public JMXVersioningPropertyProvider(Map<String, PropertyHelper.JMXMetricsVersion> clusterVersions,
+                                       Map<PropertyHelper.JMXMetricsVersion, JMXPropertyProvider> providers,
+                                       String clusterNamePropertyId) {
+    super(getComponentMetrics(providers));
+
+    this.clusterVersions       = clusterVersions;
+    this.providers             = providers;
+    this.clusterNamePropertyId = clusterNamePropertyId;
+  }
+
+  @Override
+  public Set<Resource> populateResources(Set<Resource> resources, Request request, Predicate predicate)
+      throws SystemException {
+
+    Set<Resource> keepers = new HashSet<Resource>();
+
+    // divide up the given resources according to their associated clusters
+    Map<String, Set<Resource>> resourcesByCluster = new HashMap<String, Set<Resource>>();
+
+    for (Resource resource : resources) {
+      String clusterName = (String) resource.getPropertyValue(clusterNamePropertyId);
+
+      Set<Resource> resourceSet = resourcesByCluster.get(clusterName);
+
+      if (resourceSet == null) {
+        resourceSet = new HashSet<Resource>();
+        resourcesByCluster.put(clusterName, resourceSet);
+      }
+      resourceSet.add(resource);
+    }
+
+    // give each set of resources to the underlying JMX provider that matches the
+    // JMX metrics version of the associated cluster
+    for (Map.Entry<String, Set<Resource>> entry : resourcesByCluster.entrySet()) {
+      String clusterName = entry.getKey();
+      Set<Resource> resourceSet = entry.getValue();
+
+      PropertyHelper.JMXMetricsVersion version = clusterVersions.get(clusterName);
+
+      if (version != null) {
+
+        JMXPropertyProvider provider = providers.get(version);
+        if (provider != null) {
+          keepers.addAll(provider.populateResources(resourceSet, request, predicate));
+        }
+      }
+    }
+    return keepers;
+  }
+
+  // ----- helper methods ----------------------------------------------------
+
+  private static Set<String> getComponentMetrics(Map<PropertyHelper.JMXMetricsVersion, JMXPropertyProvider> providers) {
+
+    Set<String> propertyIds = new HashSet<String>();
+
+    for (JMXPropertyProvider provider : providers.values()) {
+      propertyIds.addAll(provider.getPropertyIds());
+    }
+    return propertyIds;
+  }
+}

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PredicateBuilder.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PredicateBuilder.java?rev=1487638&r1=1487637&r2=1487638&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PredicateBuilder.java (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PredicateBuilder.java Wed May 29 20:46:31 2013
@@ -32,65 +32,6 @@ import java.util.List;
 
 /**
  * Builder for predicates.
- * <p/>
- * The builder enforces a domain specific language according to the following
- * grammar :
- * <p/>
- * <predicate> ::= <property_name> <relational_operator> <value>
- * <predicate> ::= NOT <predicate>
- * <predicate> ::= ( <predicate> )
- * <predicate> ::= <predicate> AND <predicate>
- * <predicate> ::= <predicate> OR <predicate>
- *
- * <relational_operator> ::= =|>|<|>=|<=
- * <p/>
- * The predicate builder uses the normal method chaining of the builder pattern
- * along with intermediate objects.  The use of intermediate objects allows
- * for compiler checked constraints.
- * <p/>
- * For example, the predicate builder can be used to build a predicate where
- * property1=="foo" && property2=="bar".
- *
- * <pre>
- * {@code
- * PredicateBuilder builder = new PredicateBuilder();
- *
- * Predicate predicate = builder.property(property1).equals("foo").
- *     and().property(property2).equals("bar").toPredicate();
- * }
- * </pre>
- *
- * In this example, we are starting with an instance of {@link PredicateBuilder}.
- * Calling the method {@link PredicateBuilder#property(String)} returns an
- * instance of {@link PredicateBuilderProperty} which exposes methods for attaching
- * a relational operator to the property to form a simple predicate.
- * <p/>
- * Notice that the method {@link PredicateBuilderProperty#equals(Comparable)}
- * returns an instance of {@link PredicateBuilderPredicate} which exposes methods
- * for using predicates with logical operators to create complex predicates.
- * <p/>
- * Calling the method {@link PredicateBuilderPredicate#and()} returns an instance
- * of {@link PredicateBuilder} which allows us to start over building the predicate
- * for property2.
- * <p/>
- * The reason for having these intermediate return objects is that they only
- * expose the methods that make sense for that point in the building process.
- * In other words, we can use the compiler to check the syntax of our DSL
- * grammar at compile time rather than having a single builder class with a
- * bunch of runtime checks.
- * <p/>
- * For example, if the user tries to make an inappropriate call to the and()
- * method ...
- *
- * <pre>
- * {@code
- *
- * Predicate predicate = builder.property(property1).and().
- *     property(property2).equals("bar").toPredicate();
- * }
- * </pre>
- *
- * ... the compiler will flag it as an error and the code will simply not compile.
  */
 public class PredicateBuilder {
 
@@ -101,122 +42,47 @@ public class PredicateBuilder {
   private boolean done = false;
   private boolean not = false;
 
-
-  // ----- Constructors ------------------------------------------------------
-
-  /**
-   * Construct a predicate builder.
-   */
   public PredicateBuilder() {
     this.outer = null;
   }
 
-  /**
-   * Construct a predicate builder within another predicate builder.
-   *
-   * @param outer  the outer predicate builder
-   */
   private PredicateBuilder(PredicateBuilder outer) {
     this.outer = outer;
   }
 
-
-  // ----- enums ------------------------------------------------------
-
-  /**
-   * Logical operators
-   */
   private enum Operator {
     And,
     Or
   }
 
-
-  // ----- PredicateBuilder --------------------------------------------------
-
-  /**
-   * Create a property from the given property id.  This supports method
-   * chaining by returning an instance of {@link PredicateBuilderProperty}
-   * which is an intermediate object that represents the property in the DSL.
-   *
-   * @param id  the property id
-   *
-   * @return a property that can be used in the building of the predicate.
-   *
-   * @throws IllegalStateException if an attempt is made to reuse a predicate builder
-   */
-  public PredicateBuilderProperty property(String id) {
+  public PredicateBuilderWithProperty property(String id) {
     checkDone();
     propertyId = id;
-    return new PredicateBuilderProperty();
+    return new PredicateBuilderWithProperty();
   }
 
-  /**
-   * Set the builder to negate the predicate being built.  This supports method
-   * chaining by returning an instance of {@link PredicateBuilder} which can be
-   * used to continue building the predicate.
-   *
-   * For example, the following shows a usage of the not() method to
-   * produce a predicate where property "p1" does not equal "foo".
-   *
-   * <pre>
-   * {@code
-   * Predicate predicate = builder.not().property("p1").equals("foo").toPredicate();
-   * }
-   * </pre>
-   *
-   * @return a builder to be used to continue building the predicate
-   */
   public PredicateBuilder not() {
     not = true;
     return this;
   }
 
-  /**
-   * Set the builder to begin a block around the predicate being built.  Calling this
-   * method is the equivalent of using a left parenthesis.  This supports method
-   * chaining by returning an instance of {@link PredicateBuilder} which can be
-   * used to continue building the predicate.
-   *
-   * For example, the following shows a usage of the begin() method to
-   * produce a predicate where p1==foo && (p2==bar || p3 == cat).
-   *
-   * <pre>
-   * {@code
-   * Predicate predicate = builder.property("p1").equals("foo").and().
-   *     begin().property("p2").equals("bar").or().property("p3").equals("cat").end().
-   *     toPredicate();
-   * }
-   * </pre>
-   *
-   * @return a builder to be used to continue building the predicate
-   *
-   * @throws IllegalStateException if an attempt is made to reuse a predicate builder
-   */
   public PredicateBuilder begin() {
     checkDone();
     return new PredicateBuilder(this);
   }
 
-  /**
-   * Produce a {@link Predicate} object from the builder.
-   *
-   * @return the predicate object
-   */
   public Predicate toPredicate() {
     return getPredicate();
   }
 
-  // ----- helper methods ----------------------------------------------------
-
   private void checkDone() {
     if (done) {
       throw new IllegalStateException("Can't reuse a predicate builder.");
     }
   }
 
-  private PredicateBuilderPredicate getPredicateBuilderWithPredicate() {
-    return new PredicateBuilderPredicate();
+  private PredicateBuilderWithPredicate getPredicateBuilderWithPredicate() {
+    return new PredicateBuilderWithPredicate();
   }
 
   private void addPredicate(Predicate predicate) {
@@ -261,212 +127,60 @@ public class PredicateBuilder {
     throw new IllegalStateException("Can't return a predicate.");
   }
 
-  // ----- inner classes -----------------------------------------------------
-
-  // ----- PredicateBuilderProperty ------------------------------------------
+  public class PredicateBuilderWithProperty {
 
-  /**
-   * A builder object that represents the property portion of the predicate being built.
-   * The PredicateBuilderProperty is itself a builder object that may be returned for
-   * method chaining of the predicate builder methods.
-   */
-  public class PredicateBuilderProperty {
-
-    /**
-     * Create a {@link PredicateBuilderPredicate} representing an equals 
-     * predicate for the property represented by this builder for the given
-     * value.  This supports method chaining by returning an instance of 
-     * {@link PredicateBuilderPredicate} which can be used to continue building 
-     * the predicate.
-     *
-     * For example, the following shows a usage of the equals() method to
-     * produce a predicate where p1==foo.
-     *
-     * <pre>
-     * {@code
-     * Predicate predicate = builder.property("p1").equals("foo").
-     *     toPredicate();
-     * }
-     * </pre>
-     * 
-     * @param value  the right operand (value) of the = operator
-     * @param <T>    the type of the property
-     *           
-     * @return a new builder representing an equals predicate
-     *
-     * @throws IllegalStateException if no property name was specified on this builder
-     */
-    public <T>PredicateBuilderPredicate equals(Comparable<T> value) {
+    // ----- Equals -----
+    public <T>PredicateBuilderWithPredicate equals(Comparable<T> value) {
       if (propertyId == null) {
         throw new IllegalStateException("No property.");
       }
       addPredicate(new EqualsPredicate<T>(propertyId, value));
 
-      return new PredicateBuilderPredicate();
+      return new PredicateBuilderWithPredicate();
     }
 
-    /**
-     * Create a {@link PredicateBuilderPredicate} representing an greater than 
-     * predicate for the property represented by this builder for the given
-     * value.  This supports method chaining by returning an instance of 
-     * {@link PredicateBuilderPredicate} which can be used to continue building 
-     * the predicate.
-     *
-     * For example, the following shows a usage of the greaterThan() method to
-     * produce a predicate where p1 > 5.
-     *
-     * <pre>
-     * {@code
-     * Predicate predicate = builder.property("p1").greaterThan(5).
-     *     toPredicate();
-     * }
-     * </pre>
-     *
-     * @param value  the right operand (value) of the > operator
-     * @param <T>    the type of the property
-     *
-     * @return a new builder representing a greater than predicate
-     *
-     * @throws IllegalStateException if no property name was specified on this builder
-     */
-    public <T>PredicateBuilderPredicate greaterThan(Comparable<T> value) {
+    // ----- Greater than -----
+    public <T>PredicateBuilderWithPredicate greaterThan(Comparable<T> value) {
       if (propertyId == null) {
         throw new IllegalStateException("No property.");
       }
       addPredicate(new GreaterPredicate<T>(propertyId, value));
 
-      return new PredicateBuilderPredicate();
+      return new PredicateBuilderWithPredicate();
     }
 
-    /**
-     * Create a {@link PredicateBuilderPredicate} representing a 
-     * greater than or equals predicate for the property represented by this 
-     * builder for the given value.  This supports method chaining by returning 
-     * an instance of {@link PredicateBuilderPredicate} which can be used to 
-     * continue building the predicate.
-     *
-     * For example, the following shows a usage of the greaterThanEqualTo()
-     * method to produce a predicate where p1 >= 5.
-     *
-     * <pre>
-     * {@code
-     * Predicate predicate = builder.property("p1").greaterThanEqualTo(5).
-     *     toPredicate();
-     * }
-     * </pre>
-     *
-     * @param value  the right operand (value) of the >= operator
-     * @param <T>    the type of the property
-     *
-     * @return a new builder representing a greater than or equals predicate
-     *
-     * @throws IllegalStateException if no property name was specified on this builder
-     */
-    public <T>PredicateBuilderPredicate greaterThanEqualTo(Comparable<T> value) {
+    // ----- Greater than equal to -----
+    public <T>PredicateBuilderWithPredicate greaterThanEqualTo(Comparable<T> value) {
       if (propertyId == null) {
         throw new IllegalStateException("No property.");
       }
       addPredicate(new GreaterEqualsPredicate<T>(propertyId, value));
 
-      return new PredicateBuilderPredicate();
+      return new PredicateBuilderWithPredicate();
     }
 
-    /**
-     * Create a {@link PredicateBuilderPredicate} representing a 
-     * less than predicate for the property represented by this builder 
-     * for the given value.  This supports method chaining by returning 
-     * an instance of {@link PredicateBuilderPredicate} which can be used to 
-     * continue building the predicate.
-     *
-     * For example, the following shows a usage of the lessThan()
-     * method to produce a predicate where p1 < 5.
-     *
-     * <pre>
-     * {@code
-     * Predicate predicate = builder.property("p1").lessThan(5).
-     *     toPredicate();
-     * }
-     * </pre>
-     *
-     * @param value  the right operand (value) of the < operator
-     * @param <T>    the type of the property
-     *
-     * @return a new builder representing a less than predicate
-     *
-     * @throws IllegalStateException if no property name was specified on this builder
-     */
-    public <T>PredicateBuilderPredicate lessThan(Comparable<T> value) {
+    // ----- Less than -----
+    public <T>PredicateBuilderWithPredicate lessThan(Comparable<T> value) {
       if (propertyId == null) {
         throw new IllegalStateException("No property.");
       }
       addPredicate(new LessPredicate<T>(propertyId, value));
 
-      return new PredicateBuilderPredicate();
+      return new PredicateBuilderWithPredicate();
     }
 
-    /**
-     * Create a {@link PredicateBuilderPredicate} representing a 
-     * less than or equals predicate for the property represented by this 
-     * builder for the given value.  This supports method chaining by returning 
-     * an instance of {@link PredicateBuilderPredicate} which can be used to 
-     * continue building the predicate.
-     *
-     * For example, the following shows a usage of the lessThanEqualTo()
-     * method to produce a predicate where p1 <= 5.
-     *
-     * <pre>
-     * {@code
-     * Predicate predicate = builder.property("p1").lessThanEqualTo(5).
-     *     toPredicate();
-     * }
-     * </pre>
-     *
-     * @param value  the right operand (value) of the <= operator
-     * @param <T>    the type of the property
-     *
-     * @return a new builder representing a less than or equals predicate
-     *
-     * @throws IllegalStateException if no property name was specified on this builder
-     */
-    public <T>PredicateBuilderPredicate lessThanEqualTo(Comparable<T> value) {
+    // ----- Less than equal to -----
+    public <T>PredicateBuilderWithPredicate lessThanEqualTo(Comparable<T> value) {
       if (propertyId == null) {
         throw new IllegalStateException("No property.");
       }
       addPredicate(new LessEqualsPredicate<T>(propertyId, value));
 
-      return new PredicateBuilderPredicate();
+      return new PredicateBuilderWithPredicate();
     }
   }
 
-  // ----- PredicateBuilderPredicate -----------------------------------------
-  
-  /**
-   * A builder object that represents an inner predicate portion of the predicate being built.
-   * Note that the predicate represented by an instance of PredicateBuilderPredicate may be
-   * part of a larger complex predicate being built by the predicate builder.  The
-   * PredicateBuilderPredicate is itself a builder object that may be returned for method
-   * chaining of the predicate builder methods.
-   */
-  public class PredicateBuilderPredicate {
-
-    /**
-     * Get a {@link PredicateBuilder} object that can be used to build a 
-     * predicate that will be ANDed with the predicate represented by this 
-     * PredicateBuilderPredicate.
-     *
-     * For example, the following shows a usage of the and() method to
-     * produce a predicate where p1==foo && p2==bar.
-     *
-     * <pre>
-     * {@code
-     * Predicate predicate = builder.property(p1).equals("foo").
-     *     and().property(p2).equals("bar").toPredicate();
-     * }
-     * </pre>
-     * 
-     * @return a new predicate builder that should be used to build the predicate
-     *         being ANDed with the predicate from this builder
-     */
+  public class PredicateBuilderWithPredicate {
     public PredicateBuilder and() {
 
       if (operator != Operator.And) {
@@ -476,24 +190,6 @@ public class PredicateBuilder {
       return PredicateBuilder.this;
     }
 
-    /**
-     * Get a {@link PredicateBuilder} object that can be used to build a 
-     * predicate that will be ORed with the predicate represented by this 
-     * PredicateBuilderPredicate.
-     *
-     * For example, the following shows a usage of the and() method to
-     * produce a predicate where p1==foo || p2==bar.
-     *
-     * <pre>
-     * {@code
-     * Predicate predicate = builder.property(p1).equals("foo").
-     *     or().property(p2).equals("bar").toPredicate();
-     * }
-     * </pre>
-     *
-     * @return a new predicate builder that should be used to build the predicate
-     *         being ORed with the predicate from this builder
-     */
     public PredicateBuilder or() {
 
       if (operator != Operator.Or) {
@@ -503,13 +199,6 @@ public class PredicateBuilder {
       return PredicateBuilder.this;
     }
 
-    /**
-     * Produce a {@link Predicate} object from the builder.
-     *
-     * @return the predicate object
-     *
-     * @throws IllegalStateException if the block is unbalanced (missing end call)
-     */
     public Predicate toPredicate() {
       if (outer != null) {
         throw new IllegalStateException("Unbalanced block - missing end.");
@@ -518,28 +207,7 @@ public class PredicateBuilder {
       return getPredicate();
     }
 
-    /**
-     * Set the builder to end a block around the predicate being built.  Calling this
-     * method is the equivalent of using a right parenthesis.  This supports method
-     * chaining by returning an instance of {@link PredicateBuilderPredicate} which can 
-     * be used to continue building the predicate.
-     *
-     * For example, the following shows a usage of the end() method to
-     * produce a predicate where p1==foo && (p2==bar || p3 == cat).
-     *
-     * <pre>
-     * {@code
-     * Predicate predicate = builder.property("p1").equals("foo").and().
-     *     begin().property("p2").equals("bar").or().property("p3").equals("cat").end().
-     *     toPredicate();
-     * }
-     * </pre>
-     *
-     * @return a builder to be used to continue building the predicate
-     *
-     * @throws IllegalStateException if the block is unbalanced (missing end call)
-     */
-    public PredicateBuilderPredicate end() {
+    public PredicateBuilderWithPredicate end() {
       if (outer == null) {
         throw new IllegalStateException("Unbalanced block - missing begin.");
       }

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java?rev=1487638&r1=1487637&r2=1487638&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java Wed May 29 20:46:31 2013
@@ -41,14 +41,24 @@ public class PropertyHelper {
   private static final String PROPERTIES_FILE = "properties.json";
   private static final String GANGLIA_PROPERTIES_FILE = "ganglia_properties.json";
   private static final String JMX_PROPERTIES_FILE = "jmx_properties.json";
+  private static final String JMX_PROPERTIES_FILE_2 = "jmx_properties_2.json";
   private static final String KEY_PROPERTIES_FILE = "key_properties.json";
   private static final char EXTERNAL_PATH_SEP = '/';
 
   private static final Map<Resource.Type, Set<String>> PROPERTY_IDS = readPropertyIds(PROPERTIES_FILE);
   private static final Map<Resource.Type, Map<String, Map<String, PropertyInfo>>> JMX_PROPERTY_IDS = readPropertyProviderIds(JMX_PROPERTIES_FILE);
+  private static final Map<Resource.Type, Map<String, Map<String, PropertyInfo>>> JMX_PROPERTY_IDS_2 = readPropertyProviderIds(JMX_PROPERTIES_FILE_2);
   private static final Map<Resource.Type, Map<String, Map<String, PropertyInfo>>> GANGLIA_PROPERTY_IDS = readPropertyProviderIds(GANGLIA_PROPERTIES_FILE);
   private static final Map<Resource.Type, Map<Resource.Type, String>> KEY_PROPERTY_IDS = readKeyPropertyIds(KEY_PROPERTIES_FILE);
 
+  /**
+   * JMX metrics versions.
+   */
+  public enum JMXMetricsVersion {
+    One, // HDP-1.x
+    Two  // HDP-2.x
+  }
+
   public static String getPropertyId(String category, String name) {
     String propertyId =  (category == null || category.isEmpty())? name :
            (name == null || name.isEmpty()) ? category : category + EXTERNAL_PATH_SEP + name;
@@ -85,8 +95,14 @@ public class PropertyHelper {
     return GANGLIA_PROPERTY_IDS.get(resourceType);
   }
 
-  public static Map<String, Map<String, PropertyInfo>> getJMXPropertyIds(Resource.Type resourceType) {
-    return JMX_PROPERTY_IDS.get(resourceType);
+  public static Map<String, Map<String, PropertyInfo>> getJMXPropertyIds(Resource.Type resourceType, JMXMetricsVersion version) {
+
+    switch (version) {
+      case Two:
+        return JMX_PROPERTY_IDS_2.get(resourceType);
+      default:
+        return JMX_PROPERTY_IDS.get(resourceType);
+    }
   }
 
   public static Map<Resource.Type, String> getKeyPropertyIds(Resource.Type resourceType) {

Modified: incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/metadata/RoleCommandOrder.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/metadata/RoleCommandOrder.java?rev=1487638&r1=1487637&r2=1487638&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/metadata/RoleCommandOrder.java (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-server/src/main/java/org/apache/ambari/server/metadata/RoleCommandOrder.java Wed May 29 20:46:31 2013
@@ -155,6 +155,8 @@ public class RoleCommandOrder {
         RoleCommand.START);
     addDependency(Role.HDFS_SERVICE_CHECK, RoleCommand.EXECUTE, Role.DATANODE,
         RoleCommand.START);
+    addDependency(Role.HDFS_SERVICE_CHECK, RoleCommand.EXECUTE, Role.SECONDARY_NAMENODE,
+        RoleCommand.START);
     addDependency(Role.MAPREDUCE_SERVICE_CHECK, RoleCommand.EXECUTE,
         Role.JOBTRACKER, RoleCommand.START);
     addDependency(Role.MAPREDUCE_SERVICE_CHECK, RoleCommand.EXECUTE,
@@ -179,6 +181,10 @@ public class RoleCommandOrder {
         Role.JOBTRACKER, RoleCommand.START);
     addDependency(Role.PIG_SERVICE_CHECK, RoleCommand.EXECUTE,
         Role.TASKTRACKER, RoleCommand.START);
+    addDependency(Role.PIG_SERVICE_CHECK, RoleCommand.EXECUTE,
+        Role.RESOURCEMANAGER, RoleCommand.START);
+    addDependency(Role.PIG_SERVICE_CHECK, RoleCommand.EXECUTE,
+        Role.NODEMANAGER, RoleCommand.START);
     addDependency(Role.SQOOP_SERVICE_CHECK, RoleCommand.EXECUTE,
         Role.JOBTRACKER, RoleCommand.START);
     addDependency(Role.SQOOP_SERVICE_CHECK, RoleCommand.EXECUTE,