ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject git commit: AMBARI-5937. Provide ability to refresh capacity scheduler queues.
Date Fri, 25 Jul 2014 23:47:46 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9100e08a7 -> d7c0d8ae6


AMBARI-5937. Provide ability to refresh capacity scheduler queues.


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

Branch: refs/heads/trunk
Commit: d7c0d8ae60c595891e038e3aa2ec77b6d1f50ffa
Parents: 9100e08
Author: Mahadev Konar <mahadev@apache.org>
Authored: Fri Jul 25 16:47:21 2014 -0700
Committer: Mahadev Konar <mahadev@apache.org>
Committed: Fri Jul 25 16:47:21 2014 -0700

----------------------------------------------------------------------
 .../src/main/python/ambari_agent/ActionQueue.py |  12 +
 .../python/ambari_agent/ActualConfigHandler.py  |   8 +
 .../ambari/server/agent/ExecutionCommand.java   |  13 +
 .../server/api/util/StackExtensionHelper.java   |  30 ++-
 .../server/configuration/Configuration.java     |   2 +-
 .../AmbariCustomCommandExecutionHelper.java     |  26 +-
 .../ambari/server/state/ComponentInfo.java      |  16 ++
 .../ambari/server/state/ConfigHelper.java       |  15 +-
 .../apache/ambari/server/state/ServiceInfo.java |  33 ++-
 .../stacks/HDP/2.0.6/services/YARN/metainfo.xml |   4 +-
 .../services/YARN/package/scripts/service.py    |   2 +-
 .../stacks/HDP/2.1/services/YARN/metainfo.xml   |   9 +-
 .../server/api/services/AmbariMetaInfoTest.java |   3 +-
 .../api/util/StackExtensionHelperTest.java      |   5 +-
 .../AmbariCustomCommandExecutionHelperTest.java | 225 ++++++++++++++++++
 .../AmbariManagementControllerTest.java         |  14 +-
 ...hYarnCapacitySchedulerReleaseConfigTest.java | 237 +++++++++++++++++++
 .../stacks/HDP/2.0.5/services/YARN/metainfo.xml |   4 +-
 .../stacks/HDP/2.0.6/services/YARN/metainfo.xml |   5 +-
 .../stacks/HDP/2.0.7/services/YARN/metainfo.xml |   5 +-
 ambari-web/app/controllers/main/service/item.js |  44 ++++
 ambari-web/app/messages.js                      |   3 +
 ambari-web/app/utils/ajax/ajax.js               |  17 ++
 ambari-web/app/views/main/service/item.js       |   9 +
 24 files changed, 710 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
index d023cde..58d3e75 100644
--- a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
+++ b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
@@ -194,6 +194,18 @@ class ActionQueue(threading.Thread):
     # let ambari know that configuration tags were applied
     if status == self.COMPLETED_STATUS:
       configHandler = ActualConfigHandler(self.config, self.configTags)
+      #update 
+      if command.has_key('forceRefreshConfigTags') and len(command['forceRefreshConfigTags']) > 0  :
+        
+        forceRefreshConfigTags = command['forceRefreshConfigTags']
+        logger.info("Got refresh additional component tags command")
+        
+        for configTag in forceRefreshConfigTags :
+          configHandler.update_component_tag(command['role'], configTag, command['configurationTags'][configTag])
+        
+        roleResult['customCommand'] = self.CUSTOM_COMMAND_RESTART # force restart for component to evict stale_config on server side
+        command['configurationTags'] = configHandler.read_actual_component(command['role'])
+        
       if command.has_key('configurationTags'):
         configHandler.write_actual(command['configurationTags'])
         roleResult['configurationTags'] = command['configurationTags']

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-agent/src/main/python/ambari_agent/ActualConfigHandler.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/ActualConfigHandler.py b/ambari-agent/src/main/python/ambari_agent/ActualConfigHandler.py
index d8349ef..a038d8c 100644
--- a/ambari-agent/src/main/python/ambari_agent/ActualConfigHandler.py
+++ b/ambari-agent/src/main/python/ambari_agent/ActualConfigHandler.py
@@ -90,3 +90,11 @@ class ActualConfigHandler:
       self.configTags[componentName] = \
         self.read_file(componentName + "_" + self.CONFIG_NAME)
     return self.configTags[componentName]
+  
+  def update_component_tag(self, componentName, tag, version):
+    self.read_actual_component(componentName)
+    self.configTags[componentName][tag] = version
+    
+    filename = componentName + "_" + self.CONFIG_NAME
+    self.write_file(filename, self.configTags[componentName])
+    

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
index 07dd782..fdf96df 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java
@@ -18,6 +18,7 @@
 package org.apache.ambari.server.agent;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
@@ -55,6 +56,7 @@ public class ExecutionCommand extends AgentCommand {
   @SerializedName("configuration_attributes")
   private Map<String, Map<String, Map<String, String>>> configurationAttributes;
   private Map<String, Map<String, String>> configurationTags;
+  private Set<String> forceRefreshConfigTags = new HashSet<String>();
   private Map<String, String> commandParams;
   private String serviceName;
   private String componentName;
@@ -190,6 +192,16 @@ public class ExecutionCommand extends AgentCommand {
   public void setConfigurations(Map<String, Map<String, String>> configurations) {
     this.configurations = configurations;
   }
+  /**
+   * @return Returns the set of config-types that have to be propagated to actual-config of component of given custom command, if command is successfully finished. 
+   */
+  public Set<String> getForceRefreshConfigTags() {
+    return forceRefreshConfigTags;
+  }
+
+  public void setForceRefreshConfigTags(Set<String> forceRefreshConfigTags) {
+    this.forceRefreshConfigTags = forceRefreshConfigTags;
+  }
 
   @JsonProperty("configuration_attributes")
   public Map<String, Map<String, Map<String, String>>> getConfigurationAttributes() {
@@ -290,6 +302,7 @@ public class ExecutionCommand extends AgentCommand {
     String AMBARI_DB_RCA_USERNAME = "ambari_db_rca_username";
     String AMBARI_DB_RCA_PASSWORD = "ambari_db_rca_password";
     String COMPONENT_CATEGORY = "component_category";
+    String REFRESH_ADITIONAL_COMPONENT_TAGS = "forceRefreshConfigTags";
 
     String SERVICE_CHECK = "SERVICE_CHECK"; // TODO: is it standart command? maybe add it to RoleCommand enum?
     String CUSTOM_COMMAND = "custom_command";

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
index 8b41a1b..7a80938 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/util/StackExtensionHelper.java
@@ -43,8 +43,17 @@ import javax.xml.xpath.XPathFactory;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.metadata.ActionMetadata;
-import org.apache.ambari.server.state.*;
-import org.apache.ambari.server.state.stack.*;
+import org.apache.ambari.server.state.CommandScriptDefinition;
+import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.CustomCommandDefinition;
+import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.ServiceInfo;
+import org.apache.ambari.server.state.ServiceOsSpecific;
+import org.apache.ambari.server.state.StackInfo;
+import org.apache.ambari.server.state.stack.ConfigurationXml;
+import org.apache.ambari.server.state.stack.RepositoryXml;
+import org.apache.ambari.server.state.stack.ServiceMetainfoXml;
+import org.apache.ambari.server.state.stack.StackMetainfoXml;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -278,6 +287,10 @@ public class StackExtensionHelper {
     } else {
       result.setCommandScript(parent.getCommandScript());
     }
+    //keep the same semantic as for ServiceInfo
+    result.setConfigDependencies(
+        child.getConfigDependencies() != null ?
+            child.getConfigDependencies() : parent.getConfigDependencies());
 
     // Merge custom command definitions for service
     List<CustomCommandDefinition> mergedCustomCommands =
@@ -433,10 +446,9 @@ public class StackExtensionHelper {
             // process metrics.json
             if (metricsJson.exists())
               serviceInfo.setMetricsFile(metricsJson);
-            
             if (alertsJson.exists())
               serviceInfo.setAlertsFile(alertsJson);
-            
+
             // Get all properties from all "configs/*-site.xml" files
             setPropertiesFromConfigs(serviceFolder, serviceInfo);
 
@@ -642,7 +654,7 @@ public class StackExtensionHelper {
    * Populate ServiceInfo#configTypes with default entries based on ServiceInfo#configDependencies property
    */
   void populateConfigTypesFromDependencies(ServiceInfo serviceInfo) {
-    List<String> configDependencies = serviceInfo.getConfigDependencies();
+    List<String> configDependencies = serviceInfo.getConfigDependenciesWithComponents();
     if (configDependencies != null) {
       Map<String, Map<String, Map<String, String>>> configTypes = new HashMap<String, Map<String, Map<String, String>>>();
       for (String configDependency : configDependencies) {
@@ -664,9 +676,9 @@ public class StackExtensionHelper {
    * Put new property entry to ServiceInfo#configTypes collection for specified configType
    */
   void addConfigTypeProperty(ServiceInfo serviceInfo, String configType,
-                             String propertiesGroupName, String key, String value) {
-    Map<String, Map<String, Map<String, String>>> configTypes = serviceInfo.getConfigTypes();
-    if (configTypes != null && configTypes.containsKey(configType)) {
+      String propertiesGroupName, String key, String value) {
+   Map<String, Map<String, Map<String, String>>> configTypes = serviceInfo.getConfigTypes();
+   if (configTypes != null && configTypes.containsKey(configType)) {
       Map<String, Map<String, String>> configDependencyProperties = configTypes.get(configType);
       if (!configDependencyProperties.containsKey(propertiesGroupName)) {
         configDependencyProperties.put(propertiesGroupName, new HashMap<String, String>());
@@ -677,7 +689,7 @@ public class StackExtensionHelper {
   }
 
   /**
-   * Get all properties from all "configs/*-site.xml" files
+   * Get all properties from all "configs/*.xml" files. See {@see AmbariMetaInfo#SERVICE_CONFIG_FILE_NAME_POSTFIX}
    */
   void setPropertiesFromConfigs(File serviceFolder, ServiceInfo serviceInfo) {
     

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index d958443..c585402 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -908,7 +908,7 @@ public class Configuration {
   }
 
   /**
-   * @return cache expiration time in seconds
+   * @return whether staleConfig's flag is cached. 
    */
   public boolean isStaleConfigCacheEnabled() {
     String stringValue =

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
index a05b9d4..cf628d9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
@@ -43,6 +43,7 @@ import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.agent.ExecutionCommand;
+import org.apache.ambari.server.agent.ExecutionCommand.KeyNames;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.internal.RequestResourceFilter;
@@ -273,7 +274,10 @@ public class AmbariCustomCommandExecutionHelper {
       execCmd.setConfigurations(configurations);
       execCmd.setConfigurationAttributes(configurationAttributes);
       execCmd.setConfigurationTags(configTags);
-
+      
+      if(actionExecutionContext.getParameters() != null && actionExecutionContext.getParameters().containsKey(KeyNames.REFRESH_ADITIONAL_COMPONENT_TAGS)){
+        execCmd.setForceRefreshConfigTags(parseAndValidateComponentsMapping(actionExecutionContext.getParameters().get(KeyNames.REFRESH_ADITIONAL_COMPONENT_TAGS)));
+      }
 
       hostLevelParams.put(CUSTOM_COMMAND, commandName);
       // Set parameters required for re-installing clients on restart
@@ -339,6 +343,20 @@ public class AmbariCustomCommandExecutionHelper {
     }
   }
 
+  /**
+   * splits the passed commaseparated value and returns it as set
+   * @param comma separated list
+   * @return set of items or null
+   * @throws AmbariException
+   */
+  private Set<String> parseAndValidateComponentsMapping(String commaSeparatedTags) {
+    Set<String> retVal = null;
+    if(commaSeparatedTags != null && !commaSeparatedTags.trim().isEmpty()){
+      Collections.addAll(retVal = new HashSet<String>(), commaSeparatedTags.split(","));
+    }
+    return retVal;
+  }
+  
   private void findHostAndAddServiceCheckAction(
           final ActionExecutionContext actionExecutionContext,
           final RequestResourceFilter resourceFilter,
@@ -716,6 +734,7 @@ public class AmbariCustomCommandExecutionHelper {
     }
   }
 
+
   private StringBuilder getReadableDecommissionCommandDetail(
       ActionExecutionContext actionExecutionContext, Set<String> includedHosts,
       List<String> listOfExcludedHosts) {
@@ -802,7 +821,10 @@ public class AmbariCustomCommandExecutionHelper {
           extraParams = new HashMap<String, String>();
           extraParams.put(componentName, requestParams.get(componentName));
         }
-          
+        
+        if(requestParams.containsKey(KeyNames.REFRESH_ADITIONAL_COMPONENT_TAGS)){
+          actionExecutionContext.getParameters().put(KeyNames.REFRESH_ADITIONAL_COMPONENT_TAGS, requestParams.get(KeyNames.REFRESH_ADITIONAL_COMPONENT_TAGS));
+        }
         addCustomCommandAction(actionExecutionContext, resourceFilter, stage,
           hostLevelParams, extraParams, commandDetail);
       } else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
index 4012bd4..24d7aa9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ComponentInfo.java
@@ -78,6 +78,7 @@ public class ComponentInfo {
     customCommands = prototype.customCommands;
     dependencies = prototype.dependencies;
     autoDeploy = prototype.autoDeploy;
+    configDependencies = prototype.configDependencies;
   }
 
   public String getName() {
@@ -155,6 +156,21 @@ public class ComponentInfo {
   public List<DependencyInfo> getDependencies() {
     return dependencies;
   }
+  @XmlElementWrapper(name="configuration-dependencies")
+  @XmlElements(@XmlElement(name="config-type"))
+  private List<String> configDependencies;
+  
+
+  public List<String> getConfigDependencies() {
+    return configDependencies;
+  }
+  
+  public void setConfigDependencies(List<String> configDependencies) {
+    this.configDependencies = configDependencies;
+  }
+  public boolean hasConfigType(String type) {
+    return configDependencies != null && configDependencies.contains(type);
+  }
 
   public AutoDeployInfo getAutoDeploy() {
     return autoDeploy;

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
index 9575385..5a09b2c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
@@ -374,7 +374,7 @@ public class ConfigHelper {
     
     ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
         stackId.getStackVersion(), sch.getServiceName());
-
+    ComponentInfo componentInfo = getComponentInfo(serviceInfo,sch.getServiceComponentName());
     // Configs are considered stale when:
     // - desired type DOES NOT exist in actual
     // --- desired type DOES NOT exist in stack: not_stale
@@ -396,7 +396,7 @@ public class ConfigHelper {
       if (!actual.containsKey(type)) {
         // desired is set, but actual is not
         if (!serviceInfo.hasConfigType(type)) {
-          stale = false;
+          stale = componentInfo != null && componentInfo.hasConfigType(type);
         } else if (type.equals(Configuration.GLOBAL_CONFIG_TAG)) {
           // find out if the keys are stale by first checking the target service,
           // then all services
@@ -425,13 +425,22 @@ public class ConfigHelper {
             stale = true;
           }
         } else {
-          stale = serviceInfo.hasConfigType(type);
+          stale = serviceInfo.hasConfigType(type) || componentInfo.hasConfigType(type);
         }
       }
     }
     return stale;
   }
 
+  private ComponentInfo getComponentInfo(ServiceInfo serviceInfo, String componentName) {
+    for(ComponentInfo componentInfo : serviceInfo.getComponents()) {
+      if(componentInfo.getName().equals(componentName)){
+        return componentInfo;
+      }
+    }
+    return null;
+  }
+
   /**
    * @return <code>true</code> if any service on the stack defines a property
    * for the type.

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
index 2ac4a14..ee5ab44 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
@@ -19,7 +19,21 @@
 package org.apache.ambari.server.state;
 
 import java.io.File;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.StackServiceResponse;
@@ -27,8 +41,6 @@ import org.apache.ambari.server.state.stack.MetricDefinition;
 import org.codehaus.jackson.annotate.JsonIgnore;
 import org.codehaus.jackson.map.annotate.JsonFilter;
 
-import javax.xml.bind.annotation.*;
-
 @XmlAccessorType(XmlAccessType.FIELD)
 @JsonFilter("propertiesfilter")
 public class ServiceInfo {
@@ -221,7 +233,6 @@ public class ServiceInfo {
   public Map<String, Map<String, Map<String, String>>> getConfigTypes() {
     return configTypes;
   }
-
   public void setConfigTypes(Map<String, Map<String, Map<String, String>>> configTypes) {
     this.configTypes = configTypes;
   }
@@ -287,6 +298,20 @@ public class ServiceInfo {
   public List<String> getConfigDependencies() {
     return configDependencies;
   }
+  public List<String> getConfigDependenciesWithComponents(){
+    List<String> retVal = new ArrayList<String>();
+    if(configDependencies != null){
+      retVal.addAll(configDependencies);
+    }
+    if(components != null){
+      for (ComponentInfo c : components) {
+        if(c.getConfigDependencies() != null){
+          retVal.addAll(c.getConfigDependencies());
+        }
+      }
+    }
+    return retVal.size() == 0 ? (configDependencies == null ? null : configDependencies) : retVal;
+  }
 
   public void setConfigDependencies(List<String> configDependencies) {
     this.configDependencies = configDependencies;

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml
index f42e056..75c1bd9 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml
@@ -52,6 +52,9 @@
               </commandScript>
             </customCommand>
           </customCommands>
+          <configuration-dependencies>
+            <config-type>capacity-scheduler</config-type>
+          </configuration-dependencies>
         </component>
 
         <component>
@@ -100,7 +103,6 @@
       <configuration-dependencies>
         <config-type>yarn-site</config-type>
         <config-type>yarn-env</config-type>
-        <config-type>capacity-scheduler</config-type>
         <config-type>core-site</config-type>
         <config-type>mapred-site</config-type>
         <config-type>mapred-queue-acls</config-type>

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/service.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/service.py
index 0adc812..d696b67 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/service.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/YARN/package/scripts/service.py
@@ -62,7 +62,7 @@ def service(componentName, action='start', serviceName='yarn'):
     )
 
   elif action == 'refreshQueues':
-    refresh_cmd = format("yarn rmadmin -refreshQueues")
+    refresh_cmd = format("export HADOOP_LIBEXEC_DIR={hadoop_libexec_dir} && {yarn_container_bin}/yarn rmadmin -refreshQueues")
 
     Execute(refresh_cmd,
             user=usr,

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/main/resources/stacks/HDP/2.1/services/YARN/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.1/services/YARN/metainfo.xml b/ambari-server/src/main/resources/stacks/HDP/2.1/services/YARN/metainfo.xml
index 88a429b..7ebb32c 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.1/services/YARN/metainfo.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.1/services/YARN/metainfo.xml
@@ -35,6 +35,14 @@
             <timeout>600</timeout>
           </commandScript>
         </component>
+        
+       <component>
+         <name>RESOURCEMANAGER</name>
+         <category>MASTER</category>
+          <configuration-dependencies>
+            <config-type>capacity-scheduler</config-type>
+          </configuration-dependencies>
+        </component>
 
 
       </components>
@@ -56,7 +64,6 @@
       <configuration-dependencies>
         <config-type>yarn-site</config-type>
         <config-type>yarn-env</config-type>
-        <config-type>capacity-scheduler</config-type>
         <config-type>core-site</config-type>
         <config-type>yarn-log4j</config-type>
       </configuration-dependencies>

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
index 0c6f8f0..451e27b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
@@ -571,7 +571,8 @@ public class AmbariMetaInfoTest {
     Assert.assertEquals("mapreduce.shuffle", originalProperty.getValue());
     Assert.assertEquals("Auxilliary services of NodeManager",
       originalProperty.getDescription());
-    Assert.assertEquals(7, redefinedService.getConfigDependencies().size());
+    Assert.assertEquals(6, redefinedService.getConfigDependencies().size());
+    Assert.assertEquals(7, redefinedService.getConfigDependenciesWithComponents().size());
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java
index c82b11c..a59f0ba 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/util/StackExtensionHelperTest.java
@@ -46,7 +46,7 @@ import javax.xml.namespace.QName;
 public class StackExtensionHelperTest {
 
   private final String stackRootStr = "./src/test/resources/stacks/".
-          replaceAll("/", File.separator);
+      replaceAll("/", File.separator);
 
   private Injector injector = Guice.createInjector(new MockModule());
   
@@ -315,6 +315,7 @@ public class StackExtensionHelperTest {
     helper.populateConfigTypesFromDependencies(serviceInfo);
 
     Map<String, Map<String, Map<String, String>>> configTypes = serviceInfo.getConfigTypes();
+    assertNotNull(configTypes);
     assertEquals(0, configTypes.size());
   }
 
@@ -328,7 +329,7 @@ public class StackExtensionHelperTest {
     helper.populateConfigTypesFromDependencies(serviceInfo);
 
     Map<String, Map<String, Map<String, String>>> configTypes = serviceInfo.getConfigTypes();
-    assertTrue(configTypes == null);
+    assertNull(configTypes);
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
new file mode 100644
index 0000000..a14c86a
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
@@ -0,0 +1,225 @@
+/**
+ * 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;
+
+import static org.mockito.Matchers.any;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.Assert;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.actionmanager.ActionManager;
+import org.apache.ambari.server.actionmanager.ExecutionCommandWrapper;
+import org.apache.ambari.server.actionmanager.Stage;
+import org.apache.ambari.server.agent.ExecutionCommand;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.controller.internal.ComponentResourceProviderTest;
+import org.apache.ambari.server.controller.internal.RequestResourceFilter;
+import org.apache.ambari.server.controller.internal.ServiceResourceProviderTest;
+import org.apache.ambari.server.orm.GuiceJpaInitializer;
+import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.HostState;
+import org.apache.ambari.server.state.State;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.persist.PersistService;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AmbariCustomCommandExecutionHelperTest {
+  private Injector injector;
+  private AmbariManagementController controller;
+  private AmbariMetaInfo ambariMetaInfo;
+  private Clusters clusters;
+  
+  
+  private static final String REQUEST_CONTEXT_PROPERTY = "context";
+  
+  @Captor ArgumentCaptor<List<Stage>> stagesCaptor;
+  @Mock ActionManager am;
+  
+  @Before
+  public void setup() throws Exception {
+    InMemoryDefaultTestModule module = new InMemoryDefaultTestModule(){
+      @Override
+      protected void configure() {
+        super.configure();
+        bind(ActionManager.class).toInstance(am);
+      }
+    };
+    injector = Guice.createInjector(module);
+    
+    
+    injector.getInstance(GuiceJpaInitializer.class);
+    controller = injector.getInstance(AmbariManagementController.class);
+    clusters = injector.getInstance(Clusters.class);
+    ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
+    ambariMetaInfo.init();
+  }
+  @After
+  public void teardown() {
+    injector.getInstance(PersistService.class).stop();
+  }
+
+
+  
+
+
+  @SuppressWarnings("serial")
+  @Test
+  public void testRefreshQueueCustomCommand() {
+    try {
+      createClusterFixture();
+      
+      Map<String, String> requestProperties = new HashMap<String, String>() {
+        {
+          put(REQUEST_CONTEXT_PROPERTY, "Refresh YARN Capacity Scheduler");
+          put("command", "REFRESHQUEUES");
+        }
+      };
+
+      ExecuteActionRequest actionRequest = new ExecuteActionRequest("c1",
+          "REFRESHQUEUES", new HashMap<String, String>() {
+            {
+              put("forceRefreshConfigTags" , "capacity-scheduler");
+            }
+          });
+      actionRequest.getResourceFilters().add(new RequestResourceFilter("YARN", "RESOURCEMANAGER",Collections.singletonList("c6401")));
+      
+      controller.createAction(actionRequest, requestProperties);
+      
+      Mockito.verify(am, Mockito.times(1)).sendActions(stagesCaptor.capture(), any(ExecuteActionRequest.class));
+      
+      
+      List<Stage> stages = stagesCaptor.getValue();
+      Assert.assertEquals(1, stages.size());
+      Stage stage = stages.get(0);
+      
+      Assert.assertEquals(1, stage.getHosts().size());
+      
+      List<ExecutionCommandWrapper> commands = stage.getExecutionCommands("c6401");
+      Assert.assertEquals(1, commands.size());
+      
+      ExecutionCommand command = commands.get(0).getExecutionCommand();
+      
+      Assert.assertNotNull(command.getForceRefreshConfigTags());
+      Assert.assertEquals(1, command.getForceRefreshConfigTags().size());
+      Assert.assertEquals("capacity-scheduler", command.getForceRefreshConfigTags().iterator().next());
+      
+    } catch (AmbariException e) {
+      Assert.fail(e.getMessage());
+    }
+  }
+
+  
+  private void createClusterFixture() throws AmbariException {
+    createCluster("c1");
+    addHost("c6401","c1");
+    addHost("c6402","c1");
+    
+    clusters.getCluster("c1");
+    createService("c1", "YARN", null);
+    
+    createServiceComponent("c1","YARN","RESOURCEMANAGER", State.INIT);
+    createServiceComponent("c1","YARN","NODEMANAGER", State.INIT);
+    
+    createServiceComponentHost("c1","YARN","RESOURCEMANAGER","c6401", null);
+    createServiceComponentHost("c1","YARN","NODEMANAGER","c6401", null);
+    
+    createServiceComponentHost("c1","YARN","NODEMANAGER","c6402", null);
+  }
+  private void addHost(String hostname, String clusterName) throws AmbariException {
+    clusters.addHost(hostname);
+    setOsFamily(clusters.getHost(hostname), "redhat", "6.3");
+    clusters.getHost(hostname).setState(HostState.HEALTHY);
+    clusters.getHost(hostname).persist();
+    if (null != clusterName)
+      clusters.mapHostToCluster(hostname, clusterName);
+  }
+  private void setOsFamily(Host host, String osFamily, String osVersion) {
+    Map<String, String> hostAttributes = new HashMap<String, String>();
+    hostAttributes.put("os_family", osFamily);
+    hostAttributes.put("os_release_version", osVersion);
+    
+    host.setHostAttributes(hostAttributes);
+  }
+
+  private void createCluster(String clusterName) throws AmbariException {
+    ClusterRequest r = new ClusterRequest(null, clusterName, State.INSTALLED.name(), "HDP-2.0.6", null);
+    controller.createCluster(r);
+  }
+  
+  private void createService(String clusterName,
+      String serviceName, State desiredState) throws AmbariException {
+    String dStateStr = null;
+    if (desiredState != null) {
+      dStateStr = desiredState.toString();
+    }
+    ServiceRequest r1 = new ServiceRequest(clusterName, serviceName, dStateStr);
+    Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
+    requests.add(r1);
+
+    ServiceResourceProviderTest.createServices(controller, requests);
+  }
+
+  private void createServiceComponent(String clusterName,
+      String serviceName, String componentName, State desiredState)
+          throws AmbariException {
+    String dStateStr = null;
+    if (desiredState != null) {
+      dStateStr = desiredState.toString();
+    }
+    ServiceComponentRequest r = new ServiceComponentRequest(clusterName,
+        serviceName, componentName, dStateStr);
+    Set<ServiceComponentRequest> requests =
+        new HashSet<ServiceComponentRequest>();
+    requests.add(r);
+    ComponentResourceProviderTest.createComponents(controller, requests);
+  }
+
+  private void createServiceComponentHost(String clusterName, String serviceName, String componentName, String hostname, State desiredState) throws AmbariException {
+    String dStateStr = null;
+    if (desiredState != null) {
+      dStateStr = desiredState.toString();
+    }
+    ServiceComponentHostRequest r = new ServiceComponentHostRequest(clusterName,
+        serviceName, componentName, hostname, dStateStr);
+    Set<ServiceComponentHostRequest> requests =
+        new HashSet<ServiceComponentHostRequest>();
+    requests.add(r);
+    controller.createHostComponents(requests);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 36fc8a1..a332656 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -7125,7 +7125,19 @@ public class AmbariManagementControllerTest {
 
 
   }
-
+  @Test
+  public void testConfigInComponent() throws Exception {
+    StackServiceRequest requestWithParams = new StackServiceRequest(STACK_NAME, "2.0.6", "YARN");
+    Set<StackServiceResponse> responsesWithParams = controller.getStackServices(Collections.singleton(requestWithParams));
+    
+    Assert.assertEquals(1, responsesWithParams.size());
+    
+    for (StackServiceResponse responseWithParams: responsesWithParams) {
+      Assert.assertEquals(responseWithParams.getServiceName(), "YARN");
+      Assert.assertTrue(responseWithParams.getConfigTypes().containsKey("capacity-scheduler"));
+    }
+  }
+  
   @Test
   public void testGetStackConfigurations() throws Exception {
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java
new file mode 100644
index 0000000..e13c25e
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/RefreshYarnCapacitySchedulerReleaseConfigTest.java
@@ -0,0 +1,237 @@
+/**
+ * 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;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.Assert;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.controller.internal.ComponentResourceProviderTest;
+import org.apache.ambari.server.controller.internal.ServiceResourceProviderTest;
+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.Clusters;
+import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.HostState;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.State;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.persist.PersistService;
+@SuppressWarnings("serial")
+public class RefreshYarnCapacitySchedulerReleaseConfigTest {
+
+  private Injector injector;
+  private AmbariManagementController controller;
+  private AmbariMetaInfo ambariMetaInfo;
+  private Clusters clusters;
+  private ConfigHelper configHelper;
+  
+  @Before
+  public void setup() throws Exception {
+
+    injector = Guice.createInjector(new InMemoryDefaultTestModule());
+    
+    injector.getInstance(GuiceJpaInitializer.class);
+    controller = injector.getInstance(AmbariManagementController.class);
+    clusters = injector.getInstance(Clusters.class);
+    configHelper = injector.getInstance(ConfigHelper.class);
+    ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
+    ambariMetaInfo.init();
+  }
+  @After
+  public void teardown() {
+    injector.getInstance(PersistService.class).stop();
+  }
+
+
+  
+  @Test
+  public void testRMRequiresRestart() throws AmbariException{
+    createClusterFixture("HDP-2.0.7");
+    
+    
+    Cluster cluster = clusters.getCluster("c1");
+    
+    // Start
+    ClusterRequest cr = new ClusterRequest(cluster.getClusterId(), "c1", cluster.getDesiredStackVersion().getStackVersion(), null);
+
+    cr.setDesiredConfig(new ConfigurationRequest("c1","capacity-scheduler","version2",new HashMap<String, String>(), null));
+    
+    controller.updateClusters(Collections.singleton(cr) , null);
+    
+    
+    ServiceComponentHostRequest r = new ServiceComponentHostRequest("c1", null, null, null, null);
+    r.setStaleConfig("true");
+    Set<ServiceComponentHostResponse> resps = controller.getHostComponents(Collections.singleton(r));
+    Assert.assertEquals(1, resps.size());
+    
+    Assert.assertEquals(true, configHelper.isStaleConfigs(clusters.getCluster("c1").getService("YARN").getServiceComponent("RESOURCEMANAGER").getServiceComponentHost("c6401")));
+  }
+  @Test
+  public void testAllRequeiresRestart() throws AmbariException{
+    createClusterFixture("HDP-2.0.7");
+    Cluster cluster = clusters.getCluster("c1");
+    
+    // Start
+    ClusterRequest cr = new ClusterRequest(cluster.getClusterId(), "c1", cluster.getDesiredStackVersion().getStackVersion(), null);
+    
+    cr.setDesiredConfig(new ConfigurationRequest("c1","core-site","version2",new HashMap<String, String>(),null));
+    
+    controller.updateClusters(Collections.singleton(cr) , null);
+    
+    
+    ServiceComponentHostRequest r = new ServiceComponentHostRequest("c1", null, null, null, null);
+    r.setStaleConfig("true");
+    Set<ServiceComponentHostResponse> resps = controller.getHostComponents(Collections.singleton(r));
+    Assert.assertEquals(4, resps.size());
+    
+  }
+  @Test
+  public void testConfigInComponent() throws Exception {
+    StackServiceRequest requestWithParams = new StackServiceRequest("HDP", "2.0.6", "YARN");
+    Set<StackServiceResponse> responsesWithParams = controller.getStackServices(Collections.singleton(requestWithParams));
+    
+    Assert.assertEquals(1, responsesWithParams.size());
+    
+    for (StackServiceResponse responseWithParams: responsesWithParams) {
+      Assert.assertEquals(responseWithParams.getServiceName(), "YARN");
+      Assert.assertTrue(responseWithParams.getConfigTypes().containsKey("capacity-scheduler"));
+    }
+  }  
+  @Test
+  public void testConfigInComponentOverwrited() throws Exception {
+    StackServiceRequest requestWithParams = new StackServiceRequest("HDP", "2.0.7", "YARN");
+    Set<StackServiceResponse> responsesWithParams = controller.getStackServices(Collections.singleton(requestWithParams));
+    
+    Assert.assertEquals(1, responsesWithParams.size());
+    
+    for (StackServiceResponse responseWithParams: responsesWithParams) {
+      Assert.assertEquals(responseWithParams.getServiceName(), "YARN");
+      Assert.assertTrue(responseWithParams.getConfigTypes().containsKey("capacity-scheduler"));
+    }
+  }  
+  private void createClusterFixture(String stackName) throws AmbariException {
+    createCluster("c1", stackName);
+    addHost("c6401","c1");
+    addHost("c6402","c1");
+    
+    clusters.getCluster("c1");
+    createService("c1", "YARN", null);
+    
+    createServiceComponent("c1","YARN","RESOURCEMANAGER", State.INIT);
+    createServiceComponent("c1","YARN","NODEMANAGER", State.INIT);
+    createServiceComponent("c1","YARN","YARN_CLIENT", State.INIT);
+    
+    createServiceComponentHost("c1","YARN","RESOURCEMANAGER","c6401", null);
+    createServiceComponentHost("c1","YARN","NODEMANAGER","c6401", null);
+    
+    createServiceComponentHost("c1","YARN","NODEMANAGER","c6402", null);
+    createServiceComponentHost("c1","YARN","YARN_CLIENT","c6402", null);
+  }
+  private void addHost(String hostname, String clusterName) throws AmbariException {
+    clusters.addHost(hostname);
+    setOsFamily(clusters.getHost(hostname), "redhat", "6.3");
+    clusters.getHost(hostname).setState(HostState.HEALTHY);
+    clusters.getHost(hostname).persist();
+    if (null != clusterName)
+      clusters.mapHostToCluster(hostname, clusterName);
+  }
+  private void setOsFamily(Host host, String osFamily, String osVersion) {
+    Map<String, String> hostAttributes = new HashMap<String, String>();
+    hostAttributes.put("os_family", osFamily);
+    hostAttributes.put("os_release_version", osVersion);
+    
+    host.setHostAttributes(hostAttributes);
+  }
+
+  private void createCluster(String clusterName, String stackName) throws AmbariException {
+    ClusterRequest r = new ClusterRequest(null, clusterName, State.INSTALLED.name(), stackName, null);
+    controller.createCluster(r);
+  }
+  
+  private void createService(String clusterName,
+      String serviceName, State desiredState) throws AmbariException {
+    String dStateStr = null;
+    if (desiredState != null) {
+      dStateStr = desiredState.toString();
+    }
+    ServiceRequest r1 = new ServiceRequest(clusterName, serviceName, dStateStr);
+    Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
+    requests.add(r1);
+
+    ServiceResourceProviderTest.createServices(controller, requests);
+  }
+
+  private void createServiceComponent(String clusterName,
+      String serviceName, String componentName, State desiredState)
+          throws AmbariException {
+    String dStateStr = null;
+    if (desiredState != null) {
+      dStateStr = desiredState.toString();
+    }
+    ServiceComponentRequest r = new ServiceComponentRequest(clusterName,
+        serviceName, componentName, dStateStr);
+    Set<ServiceComponentRequest> requests =
+        new HashSet<ServiceComponentRequest>();
+    requests.add(r);
+    ComponentResourceProviderTest.createComponents(controller, requests);
+  }
+
+  private void createServiceComponentHost(String clusterName, String serviceName, String componentName, String hostname, State desiredState) throws AmbariException {
+    String dStateStr = null;
+    if (desiredState != null) {
+      dStateStr = desiredState.toString();
+    }
+    ServiceComponentHostRequest r = new ServiceComponentHostRequest(clusterName,
+        serviceName, componentName, hostname, dStateStr);
+    Set<ServiceComponentHostRequest> requests =
+        new HashSet<ServiceComponentHostRequest>();
+    requests.add(r);
+    controller.createHostComponents(requests);
+    
+    
+    //set actual config
+      Service service = clusters.getCluster(clusterName).getService(serviceName);
+      ServiceComponent rm = service.getServiceComponent(componentName);
+      ServiceComponentHost rmc1 = rm.getServiceComponentHost(hostname);
+      
+      rmc1.updateActualConfigs((new HashMap<String, Map<String,String>>() {{
+        put("capacity-scheduler", new HashMap<String,String>() {{ put("tag", "version1"); }});
+        put("hive-group", new HashMap<String,String>() {{ put("tag", "version1"); }});
+      }}));
+  }
+  
+  
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/YARN/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/YARN/metainfo.xml b/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/YARN/metainfo.xml
index d52e8c3..f14dd6e 100644
--- a/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/YARN/metainfo.xml
+++ b/ambari-server/src/test/resources/stacks/HDP/2.0.5/services/YARN/metainfo.xml
@@ -51,6 +51,9 @@
               </commandScript>
             </customCommand>
           </customCommands>
+          <configuration-dependencies>
+            <config-type>capacity-scheduler</config-type>
+          </configuration-dependencies>
         </component>
 
         <component>
@@ -98,7 +101,6 @@
 
       <configuration-dependencies>
         <config-type>yarn-site</config-type>
-        <config-type>capacity-scheduler</config-type>
         <config-type>core-site</config-type>
         <config-type>global</config-type>
         <config-type>mapred-site</config-type>

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml b/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml
index f4d35b9..78e31cc 100644
--- a/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml
+++ b/ambari-server/src/test/resources/stacks/HDP/2.0.6/services/YARN/metainfo.xml
@@ -52,6 +52,9 @@
               </commandScript>
             </customCommand>
           </customCommands>
+          <configuration-dependencies>
+            <config-type>capacity-scheduler</config-type>
+          </configuration-dependencies>
         </component>
 
         <component>
@@ -64,7 +67,6 @@
             <timeout>600</timeout>
           </commandScript>
         </component>
-
         <component>
           <name>YARN_CLIENT</name>
           <category>CLIENT</category>
@@ -104,7 +106,6 @@
 
       <configuration-dependencies>
         <config-type>yarn-site</config-type>
-        <config-type>capacity-scheduler</config-type>
         <config-type>core-site</config-type>
         <config-type>global</config-type>
         <config-type>mapred-site</config-type>

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-server/src/test/resources/stacks/HDP/2.0.7/services/YARN/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/stacks/HDP/2.0.7/services/YARN/metainfo.xml b/ambari-server/src/test/resources/stacks/HDP/2.0.7/services/YARN/metainfo.xml
index 426f275..08f9949 100644
--- a/ambari-server/src/test/resources/stacks/HDP/2.0.7/services/YARN/metainfo.xml
+++ b/ambari-server/src/test/resources/stacks/HDP/2.0.7/services/YARN/metainfo.xml
@@ -42,6 +42,9 @@
               </commandScript>
             </customCommand>
           </customCommands>
+          <configuration-dependencies>
+            <config-type>capacity-scheduler</config-type>
+          </configuration-dependencies>
         </component>
 
         <component>
@@ -96,7 +99,6 @@
 
       <configuration-dependencies>
         <config-type>yarn-site</config-type>
-        <config-type>capacity-scheduler</config-type>
         <config-type>core-site</config-type>
         <config-type>global</config-type>
         <config-type>mapred-site</config-type>
@@ -154,7 +156,6 @@
 
       <configuration-dependencies>
         <config-type>yarn-site</config-type>
-        <config-type>capacity-scheduler</config-type>
         <config-type>core-site</config-type>
         <config-type>global</config-type>
         <config-type>mapred-site</config-type>

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index ed09937..3fe9d27 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -182,6 +182,50 @@ App.MainServiceItemController = Em.Controller.extend({
       });
     });
   },
+   /**
+   * On click handler for Yarn Refresh Queues command from items menu
+   * @param event
+   */
+  refreshYarnQueues : function (event) {
+    var self = this;
+    return App.showConfirmationPopup(function() {
+      self.refreshYarnQueuesPrimary();
+    });
+  },
+  refreshYarnQueuesPrimary : function(){
+    App.ajax.send({
+      name : 'service.item.refreshQueueYarnRequest',
+      sender : this,
+      data : {
+        command : "REFRESHQUEUES",
+        context : Em.I18n.t('services.service.actions.run.yarnRefreshQueues.context') ,
+        hosts : App.Service.find('YARN').get('hostComponents').findProperty('componentName', 'RESOURCEMANAGER').get('hostName'),
+        serviceName : "YARN",
+        componentName : "RESOURCEMANAGER",
+        forceRefreshConfigTags : "capacity-scheduler"
+      },
+      success : 'refreshYarnQueuesSuccessCallback',
+      error : 'refreshYarnQueuesErrorCallback'
+    });
+  },
+  refreshYarnQueuesSuccessCallback  : function(data, ajaxOptions, params) {
+    if (data.Requests.id) {
+      App.router.get('backgroundOperationsController').showPopup();
+    } else {
+      console.warn('Error during refreshYarnQueues');
+    }
+  },
+  refreshYarnQueuesErrorCallback : function(data) {
+    var error = Em.I18n.t('services.service.actions.run.yarnRefreshQueues.error');
+    if(data && data.responseText){
+      try {
+        var json = $.parseJSON(data.responseText);
+        error += json.message;
+      } catch (err) {}
+    }
+    App.showAlertPopup(Em.I18n.t('services.service.actions.run.yarnRefreshQueues.error'), error);
+    console.warn('Error during refreshYarnQueues:'+error);
+  },
 
   /**
    * On click callback for <code>run compaction</code> button

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 44f9bad..48519ee 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1166,6 +1166,9 @@ Em.I18n.translations = {
   'services.service.summary.clientCount': '{0} Client Hosts',
   'services.service.summary.historyServer': 'History Server Web UI',
   'services.service.actions.run.rebalancer':'Run Rebalancer',
+  'services.service.actions.run.yarnRefreshQueues.menu':'Refresh YARN Capacity Scheduler',
+  'services.service.actions.run.yarnRefreshQueues.context':'Refresh YARN Capacity Scheduler',
+  'services.service.actions.run.yarnRefreshQueues.error':'Error during remote command: ',
   'services.service.actions.run.compaction':'Run Compaction',
   'services.service.actions.run.smoke':'Run Service Check',
   'services.service.actions.reassign.master':'Move {0}',

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index d5e0f97..8f41153 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -278,6 +278,23 @@ var urls = {
       };
     }
   },
+  'service.item.refreshQueueYarnRequest':{
+    'real': '/clusters/{clusterName}/requests',
+    'mock': '',
+    'format' : function(data) {
+        return {
+          type : 'POST',
+          data : JSON.stringify({
+            RequestInfo: {
+              'context': data.context,
+              'command': data.command,
+              'parameters/forceRefreshConfigTags' : data.forceRefreshConfigTags
+            },
+            "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName, 'hosts': data.hosts}]
+          })
+        }
+      }
+  },
   'service.load_config_groups': {
     'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*',
     'mock': '/data/configurations/config_group.json'

http://git-wip-us.apache.org/repos/asf/ambari/blob/d7c0d8ae/ambari-web/app/views/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/item.js b/ambari-web/app/views/main/service/item.js
index 318c90a..0b780a4 100644
--- a/ambari-web/app/views/main/service/item.js
+++ b/ambari-web/app/views/main/service/item.js
@@ -54,6 +54,12 @@ App.MainServiceItemView = Em.View.extend({
         cssClass: 'icon-refresh',
         disabled: !this.get('controller.content.isRestartRequired')
       },
+      REFRESH_YARN_QUEUE: {
+        action: 'refreshYarnQueues',
+        label: Em.I18n.t('services.service.actions.run.yarnRefreshQueues.menu'),
+        cssClass: 'icon-refresh',
+        disabled: false
+      },
       ROLLING_RESTART: {
         action: 'rollingRestart',
         context: this.get('rollingRestartComponent'),
@@ -118,6 +124,9 @@ App.MainServiceItemView = Em.View.extend({
       if (this.get('serviceName') === 'FLUME') {
         options.push(actionMap.REFRESH_CONFIGS);
       }
+      if (this.get('serviceName') === 'YARN') {
+        options.push(actionMap.REFRESH_YARN_QUEUE);
+      }
       options.push(actionMap.RESTART_ALL);
       allSlaves.forEach(function(slave) {
         options.push(self.createOption(actionMap.ROLLING_RESTART, {


Mime
View raw message