AMBARI-10750. Initial merge of advanced api provisioning work.

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

Branch: refs/heads/trunk
Commit: c9f0dd0b8206956a7a71fa0adca64160710d2910
Parents: 6f67c4f
Author: John Speidel <jspei...@hortonworks.com>
Authored: Mon Apr 27 01:48:16 2015 -0400
Committer: John Speidel <jspei...@hortonworks.com>
Committed: Mon Apr 27 01:51:01 2015 -0400

----------------------------------------------------------------------
 .../server/actionmanager/ActionManager.java     |   30 +-
 .../server/actionmanager/HostRoleCommand.java   |   27 +-
 .../query/render/ClusterBlueprintRenderer.java  |  601 +-
 .../controller/AmbariActionExecutionHelper.java |    2 +-
 .../AmbariCustomCommandExecutionHelper.java     |    6 +-
 .../AmbariManagementControllerImpl.java         |   18 +-
 .../ambari/server/controller/AmbariServer.java  |   25 +-
 .../server/controller/ControllerModule.java     |    4 +
 .../server/controller/KerberosHelper.java       |    6 +-
 .../server/controller/ShortTaskStatus.java      |    9 +
 .../internal/AbstractResourceProvider.java      |    8 +-
 .../internal/BaseBlueprintProcessor.java        |  771 ---
 .../BlueprintConfigurationProcessor.java        |  670 ++-
 .../internal/BlueprintResourceProvider.java     |  279 +-
 .../server/controller/internal/Cardinality.java |   86 -
 .../internal/ClientConfigResourceProvider.java  |    2 +-
 .../internal/ClusterResourceProvider.java       |  907 +--
 .../internal/ComponentResourceProvider.java     |    5 +-
 .../ConfigurationTopologyException.java         |   39 +
 .../internal/ExportBlueprintRequest.java        |  531 ++
 .../internal/HostComponentResourceProvider.java |   75 +-
 .../server/controller/internal/HostGroup.java   |   56 -
 .../internal/HostResourceProvider.java          |  237 +-
 .../internal/ProvisionClusterRequest.java       |  180 +
 .../internal/RequestResourceProvider.java       |   25 +
 .../internal/ScaleClusterRequest.java           |  156 +
 .../internal/ServiceResourceProvider.java       |   63 +-
 .../server/controller/internal/Stack.java       |  374 +-
 .../internal/StageResourceProvider.java         |   70 +-
 .../ambari/server/orm/dao/BlueprintDAO.java     |   15 +
 .../server/orm/entities/BlueprintEntity.java    |  123 +-
 .../server/stack/NoSuchStackException.java      |   28 +
 .../org/apache/ambari/server/state/Cluster.java |    6 +
 .../server/state/cluster/ClusterImpl.java       |   19 +
 .../ambari/server/state/host/HostImpl.java      |   18 +
 .../ambari/server/topology/Blueprint.java       |  126 +
 .../server/topology/BlueprintFactory.java       |  199 +
 .../ambari/server/topology/BlueprintImpl.java   |  397 ++
 .../server/topology/BlueprintValidator.java     |   41 +
 .../server/topology/BlueprintValidatorImpl.java |  318 ++
 .../ambari/server/topology/Cardinality.java     |   90 +
 .../topology/ClusterConfigurationRequest.java   |  271 +
 .../ambari/server/topology/ClusterTopology.java |  116 +
 .../server/topology/ClusterTopologyImpl.java    |  245 +
 .../ambari/server/topology/Configuration.java   |  187 +
 .../server/topology/ConfigurationFactory.java   |  121 +
 .../ambari/server/topology/HostGroup.java       |  119 +
 .../ambari/server/topology/HostGroupImpl.java   |  239 +
 .../ambari/server/topology/HostGroupInfo.java   |   91 +
 .../server/topology/HostOfferResponse.java      |   62 +
 .../ambari/server/topology/HostRequest.java     |  814 +++
 .../topology/InvalidTopologyException.java      |   32 +
 .../InvalidTopologyTemplateException.java       |   34 +
 .../ambari/server/topology/LogicalRequest.java  |  307 +
 .../topology/NoSuchBlueprintException.java      |   29 +
 .../topology/NoSuchHostGroupException.java      |   37 +
 .../topology/RequiredPasswordValidator.java     |  155 +
 .../ambari/server/topology/TopologyManager.java |  610 ++
 .../ambari/server/topology/TopologyRequest.java |   40 +
 .../server/topology/TopologyRequestFactory.java |   30 +
 .../topology/TopologyRequestFactoryImpl.java    |   34 +
 .../ambari/server/topology/TopologyTask.java    |   42 +
 .../server/topology/TopologyValidator.java      |   26 +
 .../apache/ambari/server/utils/StageUtils.java  |   69 +-
 .../render/ClusterBlueprintRendererTest.java    |  127 +-
 .../AmbariCustomCommandExecutionHelperTest.java |    3 +
 .../AmbariManagementControllerTest.java         |   30 +-
 .../BackgroundCustomCommandExecutionTest.java   |    3 +
 .../server/controller/KerberosHelperTest.java   |   19 +
 .../internal/BaseBlueprintProcessorTest.java    |  494 +-
 .../BlueprintConfigurationProcessorTest.java    | 5255 +++++++++---------
 .../internal/BlueprintResourceProviderTest.java | 1051 +---
 .../ClientConfigResourceProviderTest.java       |   11 +-
 .../internal/ClusterResourceProviderTest.java   | 4045 +++-----------
 .../HostComponentResourceProviderTest.java      |  124 +-
 .../internal/ProvisionClusterRequestTest.java   |  282 +
 .../internal/RequestResourceProviderTest.java   |   24 +-
 .../internal/UpgradeResourceProviderTest.java   |    6 +
 .../orm/entities/BlueprintEntityTest.java       |  231 +-
 .../server/topology/BlueprintFactoryTest.java   |  235 +
 .../server/topology/BlueprintImplTest.java      |  870 +++
 .../topology/ClusterTopologyImplTest.java       |  213 +
 .../topology/ConfigurationFactoryTest.java      |  150 +
 .../topology/RequiredPasswordValidatorTest.java |  305 +
 .../ambari/server/utils/TestStageUtils.java     |    2 +-
 85 files changed, 13223 insertions(+), 10609 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c9f0dd0b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
index 097a0f1..9cd569b 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
@@ -19,6 +19,7 @@ package org.apache.ambari.server.actionmanager;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -32,6 +33,7 @@ import 
org.apache.ambari.server.controller.ExecuteActionRequest;
 import org.apache.ambari.server.controller.HostsMap;
 import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.topology.TopologyManager;
 import org.apache.ambari.server.utils.StageUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -53,6 +55,7 @@ public class ActionManager {
   private final ActionQueue actionQueue;
   private final AtomicLong requestCounter;
   private final RequestFactory requestFactory;
+  private static TopologyManager topologyManager;
 
 
   @Inject
@@ -98,7 +101,10 @@ public class ActionManager {
   }
 
   public List<Request> getRequests(Collection<Long> requestIds) {
-    return db.getRequests(requestIds);
+    List<Request> requests =  db.getRequests(requestIds);
+    requests.addAll(topologyManager.getRequests(requestIds));
+
+    return requests;
   }
 
   public List<Stage> getRequestStatus(long requestId) {
@@ -197,7 +203,11 @@ public class ActionManager {
   }
 
   public List<HostRoleCommand> getTasksByRequestAndTaskIds(Collection<Long> 
requestIds, Collection<Long> taskIds) {
-    return db.getTasksByRequestAndTaskIds(requestIds, taskIds);
+    // wrapping in new list as returned list may be Collections.emptyList() 
which doesn't support add()
+    List<HostRoleCommand> tasks = new 
ArrayList<HostRoleCommand>(db.getTasksByRequestAndTaskIds(requestIds, taskIds));
+    tasks.addAll(topologyManager.getTasks(requestIds));
+
+    return tasks;
   }
 
   public Collection<HostRoleCommand> getTasks(Collection<Long> taskIds) {
@@ -217,7 +227,16 @@ public class ActionManager {
    *         respectively
    */
   public List<Long> getRequestsByStatus(RequestStatus status, int maxResults, 
boolean ascOrder) {
-    return db.getRequestsByStatus(status, maxResults, ascOrder);
+    List<Long> requests = db.getRequestsByStatus(status, maxResults, ascOrder);
+
+    for (Request logicalRequest : 
topologyManager.getRequests(Collections.<Long>emptySet())) {
+      //todo: Request.getStatus() returns HostRoleStatus and we are comparing 
to RequestStatus
+      //todo: for now just compare the names as RequestStatus names are a 
subset of HostRoleStatus names
+      if (status == null || 
logicalRequest.getStatus().name().equals(status.name())) {
+        requests.add(logicalRequest.getRequestId());
+      }
+    }
+    return requests;
   }
 
   public Map<Long, String> getRequestContext(List<Long> requestIds) {
@@ -232,4 +251,9 @@ public class ActionManager {
     scheduler.scheduleCancellingRequest(requestId, reason);
     scheduler.awake();
   }
+
+  //todo: proper static injection
+  public static void setTopologyManager(TopologyManager topologyManager) {
+    ActionManager.topologyManager = topologyManager;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9f0dd0b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java
index 662a545..871ce30 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java
@@ -131,7 +131,9 @@ public class HostRoleCommand {
     customCommandName = hostRoleCommandEntity.getCustomCommandName();
   }
 
-  HostRoleCommandEntity constructNewPersistenceEntity() {
+  //todo: why is this not symmetrical with the constructor which takes an 
entity
+  //todo: why are we only setting some fields in this constructor, 8 fields 
missing?????
+  public HostRoleCommandEntity constructNewPersistenceEntity() {
     HostRoleCommandEntity hostRoleCommandEntity = new HostRoleCommandEntity();
     hostRoleCommandEntity.setHostEntity(hostEntity);
     hostRoleCommandEntity.setRole(role);
@@ -164,20 +166,37 @@ public class HostRoleCommand {
     return taskId;
   }
 
+  public void setRequestId(long requestId) {
+    this.requestId = requestId;
+  }
+
+  public void setStageId(long stageId) {
+    this.stageId = stageId;
+  }
+
   public void setTaskId(long taskId) {
     if (this.taskId != -1) {
       throw new RuntimeException("Attempt to set taskId again, not allowed");
     }
     this.taskId = taskId;
-    executionCommandWrapper.getExecutionCommand().setTaskId(taskId);
-    //Need to invalidate json because taskId is updated.
-    executionCommandWrapper.invalidateJson();
+    //todo: do we need to have a wrapper?  This invariant isn't enforced in 
constructor.
+    //todo: for now, I am just going to wrap this in a null check
+    if (executionCommandWrapper != null) {
+      executionCommandWrapper.getExecutionCommand().setTaskId(taskId);
+      //Need to invalidate json because taskId is updated.
+      executionCommandWrapper.invalidateJson();
+    }
   }
 
   public String getHostName() {
     return hostEntity != null ? hostEntity.getHostName() : null;
   }
 
+  public void setHostEntity(HostEntity entity) {
+    //todo: initial entity id and name may be null in case of 'logical' tasks
+    hostEntity = entity;
+  }
+
   public Role getRole() {
     return role;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9f0dd0b/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
index a5cdfe0..5c84d4c 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
@@ -18,9 +18,7 @@
 
 package org.apache.ambari.server.api.query.render;
 
-import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.query.QueryInfo;
-import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.api.services.Request;
 import org.apache.ambari.server.api.services.Result;
 import org.apache.ambari.server.api.services.ResultImpl;
@@ -31,25 +29,26 @@ import org.apache.ambari.server.api.util.TreeNodeImpl;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.AmbariServer;
 import 
org.apache.ambari.server.controller.internal.BlueprintConfigurationProcessor;
-import org.apache.ambari.server.controller.internal.HostGroup;
+import org.apache.ambari.server.controller.internal.ExportBlueprintRequest;
 import org.apache.ambari.server.controller.internal.ResourceImpl;
+import org.apache.ambari.server.controller.internal.Stack;
 import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.apache.ambari.server.state.DesiredConfig;
-import org.apache.ambari.server.state.HostConfig;
-import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.ClusterTopologyImpl;
+import org.apache.ambari.server.topology.Configuration;
+import org.apache.ambari.server.topology.HostGroup;
+import org.apache.ambari.server.topology.HostGroupInfo;
+import org.apache.ambari.server.topology.InvalidTopologyException;
+import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
+import org.apache.ambari.server.topology.NoSuchHostGroupException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.ambari.server.state.ServiceInfo;
-import org.apache.ambari.server.state.StackInfo;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -64,11 +63,11 @@ public class ClusterBlueprintRenderer extends BaseRenderer 
implements Renderer {
    */
   private AmbariManagementController controller = AmbariServer.getController();
 
-  /**
-   * Map of configuration type to configuration properties which are required 
that a user
-   * input.  These properties will be stripped from the exported blueprint.
-   */
-  private Map<String, Collection<String>> propertiesToStrip = new 
HashMap<String, Collection<String>>();
+//  /**
+//   * Map of configuration type to configuration properties which are 
required that a user
+//   * input.  These properties will be stripped from the exported blueprint.
+//   */
+//  private Map<String, Collection<String>> propertiesToStrip = new 
HashMap<String, Collection<String>>();
 
   private final static Logger LOG = 
LoggerFactory.getLogger(ClusterBlueprintRenderer.class);
 
@@ -145,190 +144,95 @@ public class ClusterBlueprintRenderer extends 
BaseRenderer implements Renderer {
    * @return a new blueprint resource
    */
   private Resource createBlueprintResource(TreeNode<Resource> clusterNode) {
-    Resource clusterResource = clusterNode.getObject();
     Resource blueprintResource = new ResourceImpl(Resource.Type.Cluster);
 
-    String[] stackTokens = ((String) clusterResource.getPropertyValue(
-            PropertyHelper.getPropertyId("Clusters", "version"))).split("-");
+    ClusterTopology topology;
+    try {
+      topology = createClusterTopology(clusterNode);
+    } catch (InvalidTopologyTemplateException e) {
+      //todo
+      throw new RuntimeException("Unable to process blueprint export request: 
" + e, e);
+    } catch (InvalidTopologyException e) {
+      //todo:
+      throw new RuntimeException("Unable to process blueprint export request: 
" + e, e);
+    }
 
-    blueprintResource.setProperty("Blueprints/stack_name", stackTokens[0]);
-    blueprintResource.setProperty("Blueprints/stack_version", stackTokens[1]);
+    BlueprintConfigurationProcessor configProcessor = new 
BlueprintConfigurationProcessor(topology);
+    configProcessor.doUpdateForBlueprintExport();
 
-    Collection<HostGroupImpl> hostGroups =  
processHostGroups(clusterNode.getChild("hosts"));
+    Stack stack = topology.getBlueprint().getStack();
+    blueprintResource.setProperty("Blueprints/stack_name", stack.getName());
+    blueprintResource.setProperty("Blueprints/stack_version", 
stack.getVersion());
 
-    List<Map<String, Object>> groupList = formatGroupsAsList(hostGroups);
+    List<Map<String, Object>> groupList = formatGroupsAsList(topology);
     blueprintResource.setProperty("host_groups", groupList);
 
-    determinePropertiesToStrip(clusterNode.getChild("services"), 
stackTokens[0], stackTokens[1]);
+    //todo: ensure that this is properly handled in config processor
+    //determinePropertiesToStrip(topology);
 
-    blueprintResource.setProperty("configurations", 
processConfigurations(clusterNode, hostGroups));
+    blueprintResource.setProperty("configurations", 
processConfigurations(topology));
 
     return blueprintResource;
   }
 
   /**
-   * Determine which configuration properties need to be stripped from the 
configuration prior to exporting.
-   * Stripped properties are any property which are marked as required in the 
stack definition.  For example,
-   * all passwords are required properties and are therefore not exported.
-   *
-   * @param servicesNode  services node
-   * @param stackName     stack name
-   * @param stackVersion  stack version
-   */
-  private void determinePropertiesToStrip(TreeNode<Resource> servicesNode, 
String stackName, String stackVersion) {
-    AmbariMetaInfo ambariMetaInfo = getController().getAmbariMetaInfo();
-    StackInfo stack;
-    try {
-      stack = ambariMetaInfo.getStack(stackName, stackVersion);
-    } catch (AmbariException e) {
-      // shouldn't ever happen.
-      // Exception indicates that stack is not defined
-      // but we are getting the stack name from a running cluster.
-      throw new RuntimeException("Unexpected exception occurred while 
generating a blueprint. "  +
-          "The stack '" + stackName + ":" + stackVersion + "' does not exist");
-    }
-    Map<String, PropertyInfo> requiredStackProperties = 
stack.getRequiredProperties();
-    updatePropertiesToStrip(requiredStackProperties);
-
-    for (TreeNode<Resource> serviceNode : servicesNode.getChildren()) {
-      String name = (String) 
serviceNode.getObject().getPropertyValue("ServiceInfo/service_name");
-      ServiceInfo service;
-      try {
-        service = ambariMetaInfo.getService(stackName, stackVersion, name);
-      } catch (AmbariException e) {
-        // shouldn't ever happen.
-        // Exception indicates that service is not in the stack
-        // but we are getting the name from a running cluster.
-        throw new RuntimeException("Unexpected exception occurred while 
generating a blueprint.  The service '" +
-            name + "' was not found in the stack: '" + stackName + ":" + 
stackVersion);
-      }
-
-      Map<String, PropertyInfo> requiredProperties = 
service.getRequiredProperties();
-      updatePropertiesToStrip(requiredProperties);
-    }
-  }
-
-  /**
-   * Helper method to update propertiesToStrip with properties that are marked 
as required
-   *
-   * @param requiredProperties  Properties marked as required
-   */
-  private void updatePropertiesToStrip(Map<String, PropertyInfo> 
requiredProperties) {
-
-    for (Map.Entry<String, PropertyInfo> entry : 
requiredProperties.entrySet()) {
-      String propertyName = entry.getKey();
-      PropertyInfo propertyInfo = entry.getValue();
-      String configCategory = propertyInfo.getFilename();
-      if (configCategory.endsWith(".xml")) {
-        configCategory = configCategory.substring(0, 
configCategory.indexOf(".xml"));
-      }
-      Collection<String> categoryProperties = 
propertiesToStrip.get(configCategory);
-      if (categoryProperties == null) {
-        categoryProperties = new ArrayList<String>();
-        propertiesToStrip.put(configCategory, categoryProperties);
-      }
-      categoryProperties.add(propertyName);
-    }
-  }
-
-  /**
    * Process cluster scoped configurations.
    *
-   * @param clusterNode  cluster node
-   * @param hostGroups   all host groups
    *
    * @return cluster configuration
    */
-  private List<Map<String, Map<String, Map<String, ?>>>>  
processConfigurations(TreeNode<Resource> clusterNode,
-                                                                        
Collection<HostGroupImpl> hostGroups) {
+  private List<Map<String, Map<String, Map<String, ?>>>>  
processConfigurations(ClusterTopology topology) {
 
     List<Map<String, Map<String, Map<String, ?>>>> configList = new 
ArrayList<Map<String, Map<String, Map<String, ?>>>>();
 
-    Map<String, Object> desiredConfigMap = 
clusterNode.getObject().getPropertiesMap().get("Clusters/desired_configs");
-    TreeNode<Resource> configNode = clusterNode.getChild("configurations");
-    for (TreeNode<Resource> config : configNode.getChildren()) {
-      Configuration configuration = new Configuration(config);
-      DesiredConfig desiredConfig = (DesiredConfig) 
desiredConfigMap.get(configuration.getType());
-      if (desiredConfig != null && 
desiredConfig.getTag().equals(configuration.getTag())) {
-        Map<String, Map<String, String>> properties = Collections.singletonMap(
-            configuration.getType(), configuration.getProperties());
-
-        BlueprintConfigurationProcessor updater = new 
BlueprintConfigurationProcessor(properties);
-        properties = updater.doUpdateForBlueprintExport(hostGroups);
-
-        // build up maps for properties and property attributes
-        Map<String, Map<String, ?>> typeMap =
-          new HashMap<String, Map<String, ?>>();
-        typeMap.put("properties", properties.get(configuration.getType()));
-        if ((configuration.getPropertyAttributes() != null) && 
!configuration.getPropertyAttributes().isEmpty()) {
-          typeMap.put("properties_attributes", 
configuration.getPropertyAttributes());
-        }
-
-        configList.add(Collections.singletonMap(configuration.getType(), 
typeMap));
+    Configuration configuration = topology.getConfiguration();
+    Collection<String> allTypes = new HashSet<String>();
+    allTypes.addAll(configuration.getFullProperties().keySet());
+    allTypes.addAll(configuration.getFullAttributes().keySet());
+    for (String type : allTypes) {
+      Map<String, Map<String, ?>> typeMap = new HashMap<String, Map<String, 
?>>();
+      typeMap.put("properties", configuration.getFullProperties().get(type));
+      if (! configuration.getFullAttributes().isEmpty()) {
+        typeMap.put("properties_attributes", 
configuration.getFullAttributes().get(type));
       }
-    }
-    return configList;
-  }
 
-  /**
-   * Process cluster host groups.
-   *
-   * @param hostNode  host node
-   *
-   * @return collection of host groups
-   */
-  private Collection<HostGroupImpl> processHostGroups(TreeNode<Resource> 
hostNode) {
-    Map<HostGroupImpl, HostGroupImpl> mapHostGroups = new 
HashMap<HostGroupImpl, HostGroupImpl>();
-    int count = 1;
-    for (TreeNode<Resource> host : hostNode.getChildren()) {
-      HostGroupImpl group = new HostGroupImpl(host);
-      String hostName = (String) host.getObject().getPropertyValue(
-          PropertyHelper.getPropertyId("Hosts", "host_name"));
-
-      if (mapHostGroups.containsKey(group)) {
-        HostGroupImpl hostGroup = mapHostGroups.get(group);
-        hostGroup.incrementCardinality();
-        hostGroup.addHost(hostName);
-      } else {
-        mapHostGroups.put(group, group);
-        group.setName("host_group_" + count++);
-        group.addHost(hostName);
-      }
+      configList.add(Collections.singletonMap(type, typeMap));
     }
-    return mapHostGroups.values();
-  }
 
+    return configList;
+  }
 
   /**
    * Process host group information for all hosts.
    *
-   * @param hostGroups all host groups
    *
    * @return list of host group property maps, one element for each host group
    */
-  private List<Map<String, Object>> 
formatGroupsAsList(Collection<HostGroupImpl> hostGroups) {
+  private List<Map<String, Object>> formatGroupsAsList(ClusterTopology 
topology) {
     List<Map<String, Object>> listHostGroups = new ArrayList<Map<String, 
Object>>();
-    for (HostGroupImpl group : hostGroups) {
+    for (HostGroupInfo group : topology.getHostGroupInfo().values()) {
       Map<String, Object> mapGroupProperties = new HashMap<String, Object>();
       listHostGroups.add(mapGroupProperties);
 
-      mapGroupProperties.put("name", group.getName());
-      mapGroupProperties.put("cardinality", 
String.valueOf(group.getCardinality()));
-      mapGroupProperties.put("components", processHostGroupComponents(group));
-      List<Map<String, Map<String, String>>> hostConfigurations = new 
ArrayList<Map<String, Map<String, String>>>();
-      for (Configuration configuration : group.getConfigurations()) {
+      String name = group.getHostGroupName();
+      mapGroupProperties.put("name", name);
+      mapGroupProperties.put("cardinality", 
String.valueOf(group.getHostNames().size()));
+      mapGroupProperties.put("components", 
processHostGroupComponents(topology.getBlueprint().getHostGroup(name)));
+
+      Configuration configuration = 
topology.getHostGroupInfo().get(name).getConfiguration();
+      List<Map<String, Map<String, String>>> configList = new 
ArrayList<Map<String, Map<String, String>>>();
+      for (Map.Entry<String, Map<String, String>> typeEntry : 
configuration.getProperties().entrySet()) {
         Map<String, Map<String, String>> propertyMap = 
Collections.singletonMap(
-            configuration.getType(), configuration.properties);
-        BlueprintConfigurationProcessor configurationProcessor = new 
BlueprintConfigurationProcessor(propertyMap);
-        Map<String, Map<String, String>> updatedProps = 
configurationProcessor.doUpdateForBlueprintExport(hostGroups);
-        hostConfigurations.add(updatedProps);
+            typeEntry.getKey(), typeEntry.getValue());
 
+        configList.add(propertyMap);
       }
-      mapGroupProperties.put("configurations", hostConfigurations);
+      mapGroupProperties.put("configurations", configList);
     }
     return listHostGroups;
   }
 
+
   /**
    * Process host group component information for a specific host.
    *
@@ -336,7 +240,7 @@ public class ClusterBlueprintRenderer extends BaseRenderer 
implements Renderer {
    *
    * @return list of component names for the host
    */
-  private List<Map<String, String>> processHostGroupComponents(HostGroupImpl 
group) {
+  private List<Map<String, String>> processHostGroupComponents(HostGroup 
group) {
     List<Map<String, String>> listHostGroupComponents = new 
ArrayList<Map<String, String>>();
     for (String component : group.getComponents()) {
       Map<String, String> mapComponentProperties = new HashMap<String, 
String>();
@@ -346,6 +250,12 @@ public class ClusterBlueprintRenderer extends BaseRenderer 
implements Renderer {
     return listHostGroupComponents;
   }
 
+  protected ClusterTopology createClusterTopology(TreeNode<Resource> 
clusterNode)
+      throws InvalidTopologyTemplateException, InvalidTopologyException {
+
+    return new ClusterTopologyImpl(new ExportBlueprintRequest(clusterNode));
+  }
+
   /**
    * Determine whether a node represents a collection.
    *
@@ -367,320 +277,75 @@ public class ClusterBlueprintRenderer extends 
BaseRenderer implements Renderer {
     return controller;
   }
 
-  // ----- Host Group inner class --------------------------------------------
-
-  /**
-   * Host Group representation.
-   */
-  private class HostGroupImpl implements HostGroup {
-
-    /**
-     * Host Group name.
-     *
-     */
-    private String name;
-
-    /**
-     * Associated components.
-     */
-    private Set<String> components = new HashSet<String>();
-
-    /**
-     * Host group scoped configurations.
-     */
-    private Collection<Configuration> configurations = new 
HashSet<Configuration>();
-
-    /**
-     * Number of instances.
-     */
-    private int m_cardinality = 1;
-
-    /**
-     * Collection of associated hosts.
-     */
-    private Collection<String> hosts = new HashSet<String>();
-
-    /**
-     * Constructor.
-     *
-     * @param host  host node
-     */
-    public HostGroupImpl(TreeNode<Resource> host) {
-      TreeNode<Resource> components = host.getChild("host_components");
-      for (TreeNode<Resource> component : components.getChildren()) {
-        getComponents().add((String) component.getObject().getPropertyValue(
-            "HostRoles/component_name"));
-      }
-      addAmbariComponentIfLocalhost((String) host.getObject().getPropertyValue(
-          PropertyHelper.getPropertyId("Hosts", "host_name")));
-
-      processGroupConfiguration(host);
-    }
-
-    /**
-     * Preocess host group configuration.
-     *
-     * @param host  host node
-     */
-    private void processGroupConfiguration(TreeNode<Resource> host) {
-      Map<String, Object> desiredConfigMap = 
host.getObject().getPropertiesMap().get("Hosts/desired_configs");
-      if (desiredConfigMap != null) {
-        for (Map.Entry<String, Object> entry : desiredConfigMap.entrySet()) {
-          String type = entry.getKey();
-          HostConfig hostConfig = (HostConfig) entry.getValue();
-          Map<Long, String> overrides = hostConfig.getConfigGroupOverrides();
-
-          if (overrides != null && ! overrides.isEmpty()) {
-            Long version = Collections.max(overrides.keySet());
-            String tag = overrides.get(version);
-            TreeNode<Resource> clusterNode = host.getParent().getParent();
-            TreeNode<Resource> configNode = 
clusterNode.getChild("configurations");
-            for (TreeNode<Resource> config : configNode.getChildren()) {
-              Configuration configuration = new Configuration(config);
-              if (type.equals(configuration.getType()) && 
tag.equals(configuration.getTag())) {
-                getConfigurations().add(configuration);
-                break;
-              }
-            }
-          }
-        }
-      }
-    }
-
-    @Override
-    public String getName() {
-      return name;
-    }
-
-    @Override
-    public Set<String> getComponents() {
-      return components;
-    }
-
-    @Override
-    public Collection<String> getHostInfo() {
-      return hosts;
-    }
-
-    @Override
-    public Map<String, Map<String, String>> getConfigurationProperties() {
-      Map<String, Map<String, String>> properties = new HashMap<String, 
Map<String, String>>();
-      for (Configuration configuration : configurations) {
-        properties.put(configuration.getType(), configuration.getProperties());
-      }
-
-      return properties;
-    }
-
-    /**
-     * Set the name.
-     *
-     * @param  name name of host group
-     */
-    public void setName(String name) {
-      this.name = name;
-    }
-
-    /**
-     * Add a host.
-     *
-     * @param host  host to add
-     */
-    public void addHost(String host) {
-      hosts.add(host);
-    }
-
-    /**
-     * Obtain associated host group scoped configurations.
-     *
-     * @return collection of host group scoped configurations
-     */
-    public Collection<Configuration> getConfigurations() {
-      return configurations;
-    }
-
-    /**
-     * Obtain the number of instances associated with this host group.
-     *
-     * @return number of hosts associated with this host group
-     */
-    public int getCardinality() {
-      return m_cardinality;
-    }
-
-    /**
-     * Increment the cardinality count by one.
-     */
-    public void incrementCardinality() {
-      m_cardinality += 1;
-    }
-
-    /**
-     * Add the AMBARI_SERVER component if the host is the local host.
-     *
-     * @param hostname  host to check
-     */
-    private void addAmbariComponentIfLocalhost(String hostname) {
-      try {
-        InetAddress hostAddress = InetAddress.getByName(hostname);
-        try {
-          if (hostAddress.equals(InetAddress.getLocalHost())) {
-            getComponents().add("AMBARI_SERVER");
-          }
-        } catch (UnknownHostException e) {
-          //todo: SystemException?
-          throw new RuntimeException("Unable to obtain local host name", e);
-        }
-      } catch (UnknownHostException e) {
-        // ignore
-      }
-    }
-
-    @Override
-    public boolean equals(Object o) {
-      if (this == o) return true;
-      if (o == null || getClass() != o.getClass()) return false;
-
-      HostGroupImpl hostGroup = (HostGroupImpl) o;
-
-      return components.equals(hostGroup.components) &&
-          configurations.equals(hostGroup.configurations);
-    }
-
-    @Override
-    public int hashCode() {
-      int result = components.hashCode();
-      result = 31 * result + configurations.hashCode();
-      return result;
-    }
-  }
-
-  /**
-   * Encapsulates a configuration.
-   */
-  private class Configuration {
-    /**
-     * Configuration type such as hdfs-site.
-     */
-    private String type;
-
-    /**
-     * Configuration tag.
-     */
-    private String tag;
-
-    /**
-     * Properties of the configuration.
-     */
-    private Map<String, String> properties = new HashMap<String, String>();
-
-    /**
-     * Attributes for the properties in the cluster configuration.
-     */
-    private Map<String, ?> propertyAttributes =
-      new HashMap<String, Object>();
-
-    /**
-     * Constructor.
-     *
-     * @param configNode  configuration node
-     */
-    @SuppressWarnings("unchecked")
-    public Configuration(TreeNode<Resource> configNode) {
-      Resource configResource = configNode.getObject();
-      type = (String) configResource.getPropertyValue("type");
-      tag  = (String) configResource.getPropertyValue("tag");
-
-      // property map type is currently <String, Object>
-      properties = (Map) 
configNode.getObject().getPropertiesMap().get("properties");
-
-      // get the property attributes set in this configuration
-      propertyAttributes = (Map) 
configNode.getObject().getPropertiesMap().get("properties_attributes");
-
-      if (properties != null) {
-        stripRequiredProperties(properties);
-      } else {
-        LOG.warn("Empty configuration found for configuration type = " + type +
-          " during Blueprint export.  This may occur after an upgrade of 
Ambari, when" +
-          "attempting to export a Blueprint from a cluster started by an older 
version of " +
-          "Ambari.");
-      }
-
-    }
-
-    /**
-     * Get configuration type.
-     *
-     * @return configuration type
-     */
-    public String getType() {
-      return type;
-    }
 
-    /**
-     * Get configuration tag.
-     *
-     * @return configuration tag
-     */
-    public String getTag() {
-      return tag;
-    }
+  //  /**
+//   * Determine which configuration properties need to be stripped from the 
configuration prior to exporting.
+//   * Stripped properties are any property which are marked as required in 
the stack definition.  For example,
+//   * all passwords are required properties and are therefore not exported.
+//   *
+//   * @param servicesNode  services node
+//   * @param stackName     stack name
+//   * @param stackVersion  stack version
+//   */
+//  private void determinePropertiesToStrip(TreeNode<Resource> servicesNode, 
String stackName, String stackVersion) {
+//    AmbariMetaInfo ambariMetaInfo = getController().getAmbariMetaInfo();
+//    StackInfo stack;
+//    try {
+//      stack = ambariMetaInfo.getStack(stackName, stackVersion);
+//    } catch (AmbariException e) {
+//      // shouldn't ever happen.
+//      // Exception indicates that stack is not defined
+//      // but we are getting the stack name from a running cluster.
+//      throw new RuntimeException("Unexpected exception occurred while 
generating a blueprint. "  +
+//          "The stack '" + stackName + ":" + stackVersion + "' does not 
exist");
+//    }
+//    Map<String, PropertyInfo> requiredStackProperties = 
stack.getRequiredProperties();
+//    updatePropertiesToStrip(requiredStackProperties);
+//
+//    for (TreeNode<Resource> serviceNode : servicesNode.getChildren()) {
+//      String name = (String) 
serviceNode.getObject().getPropertyValue("ServiceInfo/service_name");
+//      ServiceInfo service;
+//      try {
+//        service = ambariMetaInfo.getService(stackName, stackVersion, name);
+//      } catch (AmbariException e) {
+//        // shouldn't ever happen.
+//        // Exception indicates that service is not in the stack
+//        // but we are getting the name from a running cluster.
+//        throw new RuntimeException("Unexpected exception occurred while 
generating a blueprint.  The service '" +
+//            name + "' was not found in the stack: '" + stackName + ":" + 
stackVersion);
+//      }
+//
+//      Map<String, PropertyInfo> requiredProperties = 
service.getRequiredProperties();
+//      updatePropertiesToStrip(requiredProperties);
+//    }
+//  }
+
+//  /**
+//   * Helper method to update propertiesToStrip with properties that are 
marked as required
+//   *
+//   * @param requiredProperties  Properties marked as required
+//   */
+//  private void updatePropertiesToStrip(Map<String, PropertyInfo> 
requiredProperties) {
+//
+//    for (Map.Entry<String, PropertyInfo> entry : 
requiredProperties.entrySet()) {
+//      String propertyName = entry.getKey();
+//      PropertyInfo propertyInfo = entry.getValue();
+//      String configCategory = propertyInfo.getFilename();
+//      if (configCategory.endsWith(".xml")) {
+//        configCategory = configCategory.substring(0, 
configCategory.indexOf(".xml"));
+//      }
+//      Collection<String> categoryProperties = 
propertiesToStrip.get(configCategory);
+//      if (categoryProperties == null) {
+//        categoryProperties = new ArrayList<String>();
+//        propertiesToStrip.put(configCategory, categoryProperties);
+//      }
+//      categoryProperties.add(propertyName);
+//    }
+//  }
 
-    /**
-     * Get configuration properties.
-     *
-     * @return map of properties and values
-     */
-    public Map<String, String> getProperties() {
-      return properties;
-    }
 
-    /**
-     * Get property attributes.
-     *
-     * @return map of property attributes
-     */
-    public Map<String, ?> getPropertyAttributes() {
-      return propertyAttributes;
-    }
 
-    @Override
-    public boolean equals(Object o) {
-      if (this == o) return true;
-      if (o == null || getClass() != o.getClass()) return false;
-
-      Configuration that = (Configuration) o;
-      return tag.equals(that.tag) && type.equals(that.type) && 
properties.equals(that.properties)
-        && propertyAttributes.equals(that.propertyAttributes);
-    }
 
-    @Override
-    public int hashCode() {
-      int result = type.hashCode();
-      result = 31 * result + tag.hashCode();
-      result = 31 * result + properties.hashCode();
-      result = 31 * result + propertyAttributes.hashCode();
-      return result;
-    }
-
-    /**
-     * Strip required properties from configuration.
-     *
-     * @param properties  property map
-     */
-    private void stripRequiredProperties(Map<String, String> properties) {
-      Iterator<Map.Entry<String, String>> iter = 
properties.entrySet().iterator();
-      while (iter.hasNext()) {
-        Map.Entry<String, String> entry = iter.next();
-        String property = entry.getKey();
-        String category = getType();
-        Collection<String> categoryProperties = 
propertiesToStrip.get(category);
-        if (categoryProperties != null && 
categoryProperties.contains(property)) {
-          iter.remove();
-        }
-      }
-    }
-  }
 
   // ----- Blueprint Post Processor inner class ------------------------------
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9f0dd0b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
index 11a51c4..1e1001c 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
@@ -384,7 +384,7 @@ public class AmbariActionExecutionHelper {
       // Generate cluster host info
       if (null != cluster) {
         execCmd.setClusterHostInfo(
-          
StageUtils.getClusterHostInfo(clusters.getHostsForCluster(clusterName), 
cluster));
+          StageUtils.getClusterHostInfo(cluster));
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9f0dd0b/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 d54a14d..52e4d19 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
@@ -556,7 +556,7 @@ public class AmbariCustomCommandExecutionHelper {
 
     // Generate cluster host info
     execCmd.setClusterHostInfo(
-        
StageUtils.getClusterHostInfo(clusters.getHostsForCluster(clusterName), 
cluster));
+        StageUtils.getClusterHostInfo(cluster));
 
     Map<String, String> commandParams = new TreeMap<String, String>();
 
@@ -809,7 +809,7 @@ public class AmbariCustomCommandExecutionHelper {
       );
 
       String clusterHostInfoJson = StageUtils.getGson().toJson(
-          
StageUtils.getClusterHostInfo(clusters.getHostsForCluster(cluster.getClusterName()),
 cluster));
+          StageUtils.getClusterHostInfo(cluster));
 
       // Reset cluster host info as it has changed
       stage.setClusterHostInfo(clusterHostInfoJson);
@@ -1051,7 +1051,7 @@ public class AmbariCustomCommandExecutionHelper {
 
     if (null != cluster) {
       clusterHostInfo = StageUtils.getClusterHostInfo(
-        clusters.getHostsForCluster(cluster.getClusterName()), cluster);
+          cluster);
       hostParamsStage = createDefaultHostParams(cluster);
       StackId stackId = cluster.getDesiredStackVersion();
       String componentName = null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9f0dd0b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 0743629..7b77bfa 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -1981,8 +1981,7 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
 
       // FIXME cannot work with a single stage
       // multiple stages may be needed for reconfigure
-      Map<String, Set<String>> clusterHostInfo = StageUtils.getClusterHostInfo(
-          clusters.getHostsForCluster(cluster.getClusterName()), cluster);
+      Map<String, Set<String>> clusterHostInfo = 
StageUtils.getClusterHostInfo(cluster);
 
       String clusterHostInfoJson = 
StageUtils.getGson().toJson(clusterHostInfo);
       String hostParamsJson = StageUtils.getGson().toJson(
@@ -2089,11 +2088,15 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
                     stackId.getStackName(), stackId.getStackVersion(), 
scHost.getServiceName(),
                     scHost.getServiceComponentName());
 
-
                 if (oldSchState == State.INSTALLED ||
                     oldSchState == State.STARTING ||
-                    requestStages.getProjectedState(scHost.getHostName(),
-                        scHost.getServiceComponentName()) == State.INSTALLED) {
+                    //todo: after separating install and start, the install 
stage is no longer in request stage container
+                    //todo: so projected state will not equal INSTALLED which 
causes an exception for invalid state transition
+                    //todo: so for now disabling this check
+                    //todo: this change breaks test 
AmbariManagementControllerTest.testServiceComponentHostUpdateRecursive()
+                    true) {
+//                    requestStages.getProjectedState(scHost.getHostName(),
+//                        scHost.getServiceComponentName()) == 
State.INSTALLED) {
                   roleCommand = RoleCommand.START;
                   event = new ServiceComponentHostStartEvent(
                       scHost.getServiceComponentName(), scHost.getHostName(),
@@ -2280,8 +2283,7 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
   public ExecutionCommand getExecutionCommand(Cluster cluster,
                                               ServiceComponentHost scHost,
                                               RoleCommand roleCommand) throws 
AmbariException {
-    Map<String, Set<String>> clusterHostInfo = StageUtils.getClusterHostInfo(
-        clusters.getHostsForCluster(cluster.getClusterName()), cluster);
+    Map<String, Set<String>> clusterHostInfo = 
StageUtils.getClusterHostInfo(cluster);
     String clusterHostInfoJson = StageUtils.getGson().toJson(clusterHostInfo);
     Map<String, String> hostParamsCmd = 
customCommandExecutionHelper.createDefaultHostParams(cluster);
     Stage stage = createNewStage(0, cluster,
@@ -2305,7 +2307,7 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
     ec.getHostLevelParams().putAll(hostParamsCmd);
 
     ec.setClusterHostInfo(
-        
StageUtils.getClusterHostInfo(clusters.getHostsForCluster(cluster.getClusterName()),
 cluster));
+        StageUtils.getClusterHostInfo(cluster));
 
     // Hack - Remove passwords from configs
     if (ec.getRole().equals(Role.HIVE_CLIENT.toString()) &&

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9f0dd0b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index 8b767d7..e9bc385 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -31,6 +31,7 @@ import 
org.apache.ambari.eventdb.webservice.WorkflowJsonService;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.StaticallyInject;
 import org.apache.ambari.server.actionmanager.ActionManager;
+import org.apache.ambari.server.actionmanager.HostRoleCommandFactory;
 import org.apache.ambari.server.agent.HeartBeatHandler;
 import org.apache.ambari.server.agent.rest.AgentResource;
 import org.apache.ambari.server.api.AmbariErrorHandler;
@@ -50,8 +51,11 @@ import 
org.apache.ambari.server.controller.internal.AmbariPrivilegeResourceProvi
 import org.apache.ambari.server.controller.internal.BlueprintResourceProvider;
 import 
org.apache.ambari.server.controller.internal.ClusterPrivilegeResourceProvider;
 import org.apache.ambari.server.controller.internal.ClusterResourceProvider;
+import org.apache.ambari.server.controller.internal.HostResourceProvider;
 import org.apache.ambari.server.controller.internal.PermissionResourceProvider;
 import org.apache.ambari.server.controller.internal.PrivilegeResourceProvider;
+import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
+import org.apache.ambari.server.controller.internal.ScaleClusterRequest;
 import 
org.apache.ambari.server.controller.internal.StackAdvisorResourceProvider;
 import 
org.apache.ambari.server.controller.internal.StackDefinedPropertyProvider;
 import 
org.apache.ambari.server.controller.internal.StackDependencyResourceProvider;
@@ -68,7 +72,6 @@ import org.apache.ambari.server.orm.dao.PermissionDAO;
 import org.apache.ambari.server.orm.dao.PrincipalDAO;
 import org.apache.ambari.server.orm.dao.PrivilegeDAO;
 import org.apache.ambari.server.orm.dao.ResourceDAO;
-import org.apache.ambari.server.orm.dao.StackDAO;
 import org.apache.ambari.server.orm.dao.UserDAO;
 import org.apache.ambari.server.orm.dao.ViewInstanceDAO;
 import org.apache.ambari.server.orm.entities.MetainfoEntity;
@@ -87,7 +90,10 @@ import 
org.apache.ambari.server.security.unsecured.rest.CertificateDownload;
 import org.apache.ambari.server.security.unsecured.rest.CertificateSign;
 import org.apache.ambari.server.security.unsecured.rest.ConnectionInfo;
 import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.topology.BlueprintFactory;
+import org.apache.ambari.server.topology.HostRequest;
+import org.apache.ambari.server.topology.TopologyManager;
+import org.apache.ambari.server.topology.TopologyRequestFactoryImpl;
 import org.apache.ambari.server.utils.StageUtils;
 import org.apache.ambari.server.view.ViewRegistry;
 import org.apache.velocity.app.Velocity;
@@ -598,16 +604,22 @@ public class AmbariServer {
     BootStrapResource.init(injector.getInstance(BootStrapImpl.class));
     
StackAdvisorResourceProvider.init(injector.getInstance(StackAdvisorHelper.class));
     StageUtils.setGson(injector.getInstance(Gson.class));
+    StageUtils.setTopologyManager(injector.getInstance(TopologyManager.class));
     WorkflowJsonService.setDBProperties(
         injector.getInstance(Configuration.class));
     SecurityFilter.init(injector.getInstance(Configuration.class));
     StackDefinedPropertyProvider.init(injector);
     
AbstractControllerResourceProvider.init(injector.getInstance(ResourceProviderFactory.class));
-    BlueprintResourceProvider.init(injector.getInstance(BlueprintDAO.class),
-        injector.getInstance(StackDAO.class),
-        injector.getInstance(Gson.class), ambariMetaInfo);
+    
BlueprintResourceProvider.init(injector.getInstance(BlueprintFactory.class),
+        injector.getInstance(BlueprintDAO.class), 
injector.getInstance(Gson.class));
     StackDependencyResourceProvider.init(ambariMetaInfo);
-    ClusterResourceProvider.init(injector.getInstance(BlueprintDAO.class), 
ambariMetaInfo, injector.getInstance(ConfigHelper.class));
+    ClusterResourceProvider.init(injector.getInstance(TopologyManager.class),
+        injector.getInstance(TopologyRequestFactoryImpl.class));
+    
HostResourceProvider.setTopologyManager(injector.getInstance(TopologyManager.class));
+    BlueprintFactory.init(injector.getInstance(BlueprintDAO.class));
+    ProvisionClusterRequest.init(injector.getInstance(BlueprintFactory.class));
+    ScaleClusterRequest.init(injector.getInstance(BlueprintFactory.class));
+    HostRequest.init(injector.getInstance(HostRoleCommandFactory.class));
 
     PermissionResourceProvider.init(injector.getInstance(PermissionDAO.class));
     
ViewPermissionResourceProvider.init(injector.getInstance(PermissionDAO.class));
@@ -618,6 +630,7 @@ public class AmbariServer {
         injector.getInstance(GroupDAO.class), 
injector.getInstance(ViewInstanceDAO.class));
     
ClusterPrivilegeResourceProvider.init(injector.getInstance(ClusterDAO.class));
     
AmbariPrivilegeResourceProvider.init(injector.getInstance(ClusterDAO.class));
+    
ActionManager.setTopologyManager(injector.getInstance(TopologyManager.class));
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9f0dd0b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
index 184c8db..e79e745 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
@@ -109,6 +109,8 @@ import 
org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
 import org.apache.ambari.server.state.scheduler.RequestExecutionImpl;
 import org.apache.ambari.server.state.stack.OsFamily;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostImpl;
+import org.apache.ambari.server.topology.BlueprintFactory;
+import org.apache.ambari.server.topology.TopologyManager;
 import org.apache.ambari.server.view.ViewInstanceHandlerList;
 import org.eclipse.jetty.server.SessionIdManager;
 import org.eclipse.jetty.server.SessionManager;
@@ -321,6 +323,7 @@ public class ControllerModule extends AbstractModule {
     bind(ExecutionScheduler.class).to(ExecutionSchedulerImpl.class);
     bind(DBAccessor.class).to(DBAccessorImpl.class);
     bind(ViewInstanceHandlerList.class).to(AmbariHandlerList.class);
+    bind(TopologyManager.class);
 
     requestStaticInjection(ExecutionCommandWrapper.class);
     requestStaticInjection(DatabaseChecker.class);
@@ -408,6 +411,7 @@ public class ControllerModule extends AbstractModule {
     
     bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class);
     bind(SecurityHelper.class).toInstance(SecurityHelperImpl.getInstance());
+    bind(BlueprintFactory.class);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9f0dd0b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
index f198523..bdf94a5 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelper.java
@@ -19,7 +19,6 @@
 package org.apache.ambari.server.controller;
 
 import com.google.inject.Inject;
-import com.google.inject.Injector;
 import com.google.inject.persist.Transactional;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.Role;
@@ -887,7 +886,7 @@ public class KerberosHelper {
         // Always set up the necessary stages to perform the tasks needed to 
complete the operation.
         // Some stages may be no-ops, this is expected.
         // Gather data needed to create stages and tasks...
-        Map<String, Set<String>> clusterHostInfo = 
StageUtils.getClusterHostInfo(hosts, cluster);
+        Map<String, Set<String>> clusterHostInfo = 
StageUtils.getClusterHostInfo(cluster);
         String clusterHostInfoJson = 
StageUtils.getGson().toJson(clusterHostInfo);
         Map<String, String> hostParams = 
customCommandExecutionHelper.createDefaultHostParams(cluster);
         String hostParamsJson = StageUtils.getGson().toJson(hostParams);
@@ -1131,7 +1130,7 @@ public class KerberosHelper {
           // Always set up the necessary stages to perform the tasks needed to 
complete the operation.
           // Some stages may be no-ops, this is expected.
           // Gather data needed to create stages and tasks...
-          Map<String, Set<String>> clusterHostInfo = 
StageUtils.getClusterHostInfo(hosts, cluster);
+          Map<String, Set<String>> clusterHostInfo = 
StageUtils.getClusterHostInfo(cluster);
           String clusterHostInfoJson = 
StageUtils.getGson().toJson(clusterHostInfo);
           Map<String, String> hostParams = 
customCommandExecutionHelper.createDefaultHostParams(cluster);
           String hostParamsJson = StageUtils.getGson().toJson(hostParams);
@@ -1156,6 +1155,7 @@ public class KerberosHelper {
               clusterHostInfoJson, hostParamsJson, event, roleCommandOrder, 
kerberosDetails,
               dataDirectory, requestStageContainer, 
serviceComponentHostsToProcess, hostsWithValidKerberosClient);
 
+
           handler.addFinalizeOperationStage(cluster, clusterHostInfoJson, 
hostParamsJson, event,
               dataDirectory, roleCommandOrder, requestStageContainer);
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9f0dd0b/ambari-server/src/main/java/org/apache/ambari/server/controller/ShortTaskStatus.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/ShortTaskStatus.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ShortTaskStatus.java
index 3155746..6fe4db2 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/ShortTaskStatus.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ShortTaskStatus.java
@@ -21,6 +21,7 @@ package org.apache.ambari.server.controller;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 
 public class ShortTaskStatus {
+  protected long requestId;
   protected long taskId;
   protected long stageId;
   protected String hostName;
@@ -59,6 +60,14 @@ public class ShortTaskStatus {
     this.errorLog = hostRoleCommand.getErrorLog();
   }
 
+  public void setRequestId(long requestId) {
+    this.requestId = requestId;
+  }
+
+  public long getRequestId() {
+    return requestId;
+  }
+
   public String getCustomCommandName() {
     return customCommandName;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c9f0dd0b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java
index 652cae3..753f9f9 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java
@@ -58,7 +58,7 @@ public abstract class AbstractResourceProvider extends 
BaseProvider implements R
 
   protected final static Logger LOG = 
LoggerFactory.getLogger(AbstractResourceProvider.class);
   protected final static String PROPERTIES_ATTRIBUTES_REGEX = 
"properties_attributes/[a-zA-Z][a-zA-Z._-]*$";
-  private static Pattern propertiesAttributesPattern = Pattern.compile(".*/" + 
PROPERTIES_ATTRIBUTES_REGEX);
+  public static Pattern propertiesAttributesPattern = Pattern.compile(".*/" + 
PROPERTIES_ATTRIBUTES_REGEX);
 
 
   // ----- Constructors ------------------------------------------------------
@@ -210,7 +210,7 @@ public abstract class AbstractResourceProvider extends 
BaseProvider implements R
         requestResource.setProperty(PropertyHelper.getPropertyId("Requests", 
"message"), response.getMessage());
       }
       requestResource.setProperty(PropertyHelper.getPropertyId("Requests", 
"id"), response.getRequestId());
-      requestResource.setProperty(PropertyHelper.getPropertyId("Requests", 
"status"), "InProgress");
+      requestResource.setProperty(PropertyHelper.getPropertyId("Requests", 
"status"), "Accepted");
       return new RequestStatusImpl(requestResource, associatedResources);
     }
     return new RequestStatusImpl(null, associatedResources);
@@ -347,7 +347,7 @@ public abstract class AbstractResourceProvider extends 
BaseProvider implements R
    *    whose category is the parent and marked as a desired config.
    * @param properties  the properties on the request.
    */
-  protected List<ConfigurationRequest> getConfigurationRequests(String 
parentCategory, Map<String, Object> properties) {
+  public static List<ConfigurationRequest> getConfigurationRequests(String 
parentCategory, Map<String, Object> properties) {
 
     List<ConfigurationRequest> configs = new 
LinkedList<ConfigurationRequest>();
 
@@ -392,7 +392,7 @@ public abstract class AbstractResourceProvider extends 
BaseProvider implements R
     return configs;
   }
 
-  private void parseProperties(ConfigurationRequest config, String 
absCategory, String propName, String propValue) {
+  public static void parseProperties(ConfigurationRequest config, String 
absCategory, String propName, String propValue) {
     if (propName.equals("type"))
       config.setType(propValue);
     else if (propName.equals("tag"))

Reply via email to