You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mr...@apache.org on 2017/10/30 19:04:37 UTC

[01/30] ambari git commit: AMBARI-22196. Refactor non-stack cluster-env configs to cluster settings.

Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-14714-ui 96959e9bb -> 272e5006c


http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
index 31fcb9d..afd4b46 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
@@ -35,7 +35,7 @@ import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlList;
 
-import org.apache.ambari.server.controller.StackConfigurationResponse;
+import org.apache.ambari.server.controller.ReadOnlyConfigurationResponse;
 import org.w3c.dom.Element;
 
 @XmlAccessorType(XmlAccessType.FIELD)
@@ -167,8 +167,8 @@ public class PropertyInfo {
     this.propertyAmbariUpgradeBehavior = propertyAmbariUpgradeBehavior;
   }
 
-  public StackConfigurationResponse convertToResponse() {
-    return new StackConfigurationResponse(getName(), getValue(),
+  public ReadOnlyConfigurationResponse convertToResponse() {
+    return new ReadOnlyConfigurationResponse(getName(), getValue(),
       getDescription(), getDisplayName() , getFilename(), isRequireInput(),
       getPropertyTypes(), getAttributesMap(), getPropertyValueAttributes(),
       getDependsOnProperties());

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/resources/cluster-settings.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/cluster-settings.xml b/ambari-server/src/main/resources/cluster-settings.xml
new file mode 100644
index 0000000..70b100a
--- /dev/null
+++ b/ambari-server/src/main/resources/cluster-settings.xml
@@ -0,0 +1,322 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
+<!--
+/**
+ * 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.
+ */
+-->
+<configuration>
+    <property>
+        <name>recovery_enabled</name>
+        <value>true</value>
+        <description>Auto start enabled or not for this cluster.</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>recovery_type</name>
+        <value>AUTO_START</value>
+        <description>Auto start type.</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>recovery_lifetime_max_count</name>
+        <value>1024</value>
+        <description>Auto start lifetime maximum count of recovery attempt allowed per host component. This is reset
+            when agent is restarted.
+        </description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>recovery_max_count</name>
+        <value>6</value>
+        <description>Auto start maximum count of recovery attempt allowed per host component in a window. This is reset
+            when agent is restarted.
+        </description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>recovery_window_in_minutes</name>
+        <value>60</value>
+        <description>Auto start recovery window size in minutes.</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>recovery_retry_interval</name>
+        <value>5</value>
+        <description>Auto start recovery retry gap between tries per host component.</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>security_enabled</name>
+        <value>false</value>
+        <description>Hadoop Security</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>kerberos_domain</name>
+        <value>EXAMPLE.COM</value>
+        <description>Kerberos realm.</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>ignore_groupsusers_create</name>
+        <display-name>Skip group modifications during install</display-name>
+        <value>false</value>
+        <property-type>ADDITIONAL_USER_PROPERTY</property-type>
+        <description>Whether to ignore failures on users and group creation</description>
+        <value-attributes>
+            <overridable>false</overridable>
+            <type>boolean</type>
+        </value-attributes>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>sysprep_skip_create_users_and_groups</name>
+        <display-name>Whether to skip creating users and groups in a sysprepped cluster</display-name>
+        <value>false</value>
+        <property-type>ADDITIONAL_USER_PROPERTY</property-type>
+        <description>Whether to skip creating users and groups in a sysprepped cluster</description>
+        <value-attributes>
+            <overridable>true</overridable>
+            <type>boolean</type>
+        </value-attributes>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>sysprep_skip_copy_fast_jar_hdfs</name>
+        <display-name>Whether to skip copying the tarballs to HDFS on a sysprepped cluster</display-name>
+        <value>false</value>
+        <description>Whether to skip copying the tarballs to HDFS on a sysprepped cluster, during both fresh install and
+            stack upgrade
+        </description>
+        <value-attributes>
+            <overridable>true</overridable>
+            <type>boolean</type>
+        </value-attributes>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>sysprep_skip_copy_tarballs_hdfs</name>
+        <display-name>Whether to skip copying the tarballs to HDFS on a sysprepped cluster</display-name>
+        <value>false</value>
+        <description>Whether to skip copying the tarballs to HDFS on a sysprepped cluster, during both fresh install and
+            stack upgrade
+        </description>
+        <value-attributes>
+            <overridable>true</overridable>
+            <type>boolean</type>
+        </value-attributes>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>sysprep_skip_copy_oozie_share_lib_to_hdfs</name>
+        <display-name>Whether to skip copying the Oozie share lib to HDFS on sysprepped cluster</display-name>
+        <value>false</value>
+        <description>Whether to skip copying the Oozie share lib to HDFS on sysprepped cluster, during both fresh
+            install and stack upgrade
+        </description>
+        <value-attributes>
+            <overridable>true</overridable>
+            <type>boolean</type>
+        </value-attributes>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>sysprep_skip_setup_jce</name>
+        <display-name>Whether to skip setting up the unlimited key JCE policy on sysprepped cluster</display-name>
+        <value>false</value>
+        <description>Whether to skip setting up the unlimited key JCE policy on sysprepped cluster, during both fresh
+            install and upgrades
+        </description>
+        <value-attributes>
+            <overridable>true</overridable>
+            <type>boolean</type>
+        </value-attributes>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>smokeuser</name>
+        <display-name>Smoke User</display-name>
+        <value>ambari-qa</value>
+        <property-type>USER</property-type>
+        <description>User executing service checks</description>
+        <value-attributes>
+            <type>user</type>
+            <overridable>false</overridable>
+        </value-attributes>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>smokeuser_keytab</name>
+        <value>/etc/security/keytabs/smokeuser.headless.keytab</value>
+        <description>Path to smoke test user keytab file</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>user_group</name>
+        <display-name>Hadoop Group</display-name>
+        <value>hadoop</value>
+        <property-type>GROUP</property-type>
+        <description>Hadoop user group.</description>
+        <value-attributes>
+            <type>user</type>
+            <overridable>false</overridable>
+        </value-attributes>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>repo_suse_rhel_template</name>
+        <value>[{{repo_id}}]
+            name={{repo_id}}
+            {% if mirror_list %}mirrorlist={{mirror_list}}{% else %}baseurl={{base_url}}{% endif %}
+
+            path=/
+            enabled=1
+            gpgcheck=0
+        </value>
+        <description>Template of repositories for rhel and suse.</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>repo_ubuntu_template</name>
+        <value>{{package_type}} {{base_url}} {{components}}</value>
+        <description>Template of repositories for ubuntu.</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>override_uid</name>
+        <value>true</value>
+        <property-type>ADDITIONAL_USER_PROPERTY</property-type>
+        <display-name>Have Ambari manage UIDs</display-name>
+        <description>Have Ambari manage UIDs</description>
+        <value-attributes>
+            <overridable>false</overridable>
+            <type>boolean</type>
+        </value-attributes>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>fetch_nonlocal_groups</name>
+        <value>true</value>
+        <display-name>Ambari fetch nonlocal groups</display-name>
+        <description>Ambari requires fetching all the groups. This can be slow
+            on envs with enabled ldap. Setting this option to false will enable Ambari,
+            to skip user/group management connected with ldap groups.
+        </description>
+        <value-attributes>
+            <overridable>false</overridable>
+            <type>boolean</type>
+        </value-attributes>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>managed_hdfs_resource_property_names</name>
+        <value/>
+        <description>Comma separated list of property names with HDFS resource paths.
+            Resource from this list will be managed even if it is marked as not managed in the stack
+        </description>
+        <value-attributes>
+            <overridable>false</overridable>
+            <empty-value-valid>true</empty-value-valid>
+        </value-attributes>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>alerts_repeat_tolerance</name>
+        <value>1</value>
+        <description>The number of consecutive alerts required to transition an alert from the SOFT to the HARD state.
+        </description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>ignore_bad_mounts</name>
+        <value>false</value>
+        <description>For properties handled by handle_mounted_dirs this will make Ambari not to create any
+            directories.
+        </description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>manage_dirs_on_root</name>
+        <value>true</value>
+        <description>For properties handled by handle_mounted_dirs this will make Ambari to manage (create and set
+            permissions) unknown directories on / partition
+        </description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>one_dir_per_partition</name>
+        <value>false</value>
+        <description>For properties handled by handle_mounted_dirs this will make Ambari</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>hide_yarn_memory_widget</name>
+        <value>false</value>
+        <description>YARN Memory widget should be hidden by default on the dashboard.</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>agent_mounts_ignore_list</name>
+        <value/>
+        <description>Comma separated list of the mounts which would be ignored by Ambari during property values
+            suggestion by Stack Advisor
+        </description>
+        <on-ambari-upgrade add="false"/>
+        <value-attributes>
+            <visible>true</visible>
+            <empty-value-valid>true</empty-value-valid>
+        </value-attributes>
+    </property>
+    <property>
+        <name>enable_external_ranger</name>
+        <value>false</value>
+        <description>Flag to turn on when external setup of External Ranger is done.</description>
+        <on-ambari-upgrade add="false"/>
+    </property>
+    <property>
+        <name>service_check_type</name>
+        <display-name>Service Check Type</display-name>
+        <value>full</value>
+        <description>Indicates the complexity of the service check. Valid values are 'minimal' or 'full'.</description>
+        <on-ambari-upgrade add="true"/>
+        <value-attributes>
+            <visible>true</visible>
+            <empty-value-valid>true</empty-value-valid>
+        </value-attributes>
+    </property>
+    <property>
+        <name>namenode_rolling_restart_timeout</name>
+        <value>4200</value>
+        <description>Timeout for namenode rolling restart command.</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>namenode_rolling_restart_safemode_exit_timeout</name>
+        <value>3600</value>
+        <description>Timeout for safemode exit, during namenode rolling restart</description>
+        <on-ambari-upgrade add="true"/>
+    </property>
+    <property>
+        <name>manage_hive_fsroot</name>
+        <value>true</value>
+        <description>If flag is set to true, ambari will manage fsroot for Hive, by setting it to fs.defautlFS of local
+            HDFS
+        </description>
+        <on-ambari-upgrade add="false"/>
+    </property>
+</configuration>


[18/30] ambari git commit: AMBARI-22253. Modify TopologyManager to create service groups (mradhakrishnan) - ADDENDUM (fix rat issues)

Posted by mr...@apache.org.
AMBARI-22253. Modify TopologyManager to create service groups (mradhakrishnan) - ADDENDUM (fix rat issues)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 3d8c9b744a557f7b55abd9ec910c9757b5a5c661
Parents: 36eff0f
Author: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Authored: Fri Oct 20 14:44:48 2017 -0700
Committer: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Committed: Fri Oct 20 14:44:48 2017 -0700

----------------------------------------------------------------------
 .../ambari/server/topology/HostGroupV2Impl.java    | 17 +++++++++++++++++
 .../apache/ambari/server/topology/ServiceId.java   | 17 +++++++++++++++++
 .../topology/validators/BlueprintImplV2Test.java   | 17 +++++++++++++++++
 3 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3d8c9b74/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
index e9f4f4b..ca19df3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
@@ -1,3 +1,20 @@
+/*
+ * 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.topology;
 
 import java.util.Collection;

http://git-wip-us.apache.org/repos/asf/ambari/blob/3d8c9b74/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java
index 2aae1d3..669e031 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java
@@ -1,3 +1,20 @@
+/*
+ * 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.topology;
 
 import com.fasterxml.jackson.annotation.JsonProperty;

http://git-wip-us.apache.org/repos/asf/ambari/blob/3d8c9b74/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
index 5a676bc..6b98b77 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
@@ -1,3 +1,20 @@
+/*
+ * 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.topology.validators;
 
 import java.util.HashMap;


[02/30] ambari git commit: AMBARI-22196. Refactor non-stack cluster-env configs to cluster settings.

Posted by mr...@apache.org.
AMBARI-22196. Refactor non-stack cluster-env configs to cluster settings.


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 8d8c1a551579b696d1730afcde9c49594a1dc77b
Parents: 5ddb07c
Author: Swapan Shridhar <ss...@hortonworks.com>
Authored: Fri Oct 6 01:19:13 2017 -0700
Committer: Swapan Shridhar <ss...@hortonworks.com>
Committed: Thu Oct 12 00:43:25 2017 -0700

----------------------------------------------------------------------
 .../server/PropertyNotFoundException.java       |  27 ++
 .../server/ResourcesPathNotFoundException.java  |  25 ++
 .../resources/ResourceInstanceFactoryImpl.java  |   4 +
 .../RootClusterSettingsResourceDefinition.java  |  52 +++
 .../server/api/services/AmbariMetaInfo.java     |  49 +++
 .../api/services/RootClusterSettingService.java | 135 ++++++++
 .../server/api/services/StacksService.java      |  10 +-
 .../controller/AmbariManagementController.java  |  12 +-
 .../AmbariManagementControllerImpl.java         |  54 +++-
 .../server/controller/ControllerModule.java     |   2 +
 .../ReadOnlyConfigurationResponse.java          | 272 ++++++++++++++++
 .../controller/RootClusterSettingRequest.java   |  39 +++
 .../controller/StackConfigurationResponse.java  | 266 ---------------
 .../StackLevelConfigurationRequest.java         |   2 +-
 .../StackLevelConfigurationResponse.java        |  20 +-
 .../ambari/server/controller/StackV2.java       |  12 +-
 .../AbstractControllerResourceProvider.java     |   2 +
 .../RootClusterSettingsResourceProvider.java    | 167 ++++++++++
 .../server/controller/internal/Stack.java       |  14 +-
 .../StackConfigurationResourceProvider.java     |   8 +-
 ...StackLevelConfigurationResourceProvider.java |   8 +-
 .../ambari/server/controller/spi/Resource.java  |   2 +
 .../ResourceLevelClusterSettingManager.java     | 168 ++++++++++
 ...sourceLevelClusterSettingManagerFactory.java |  34 ++
 .../ambari/server/state/ConfigHelper.java       |   1 +
 .../ambari/server/state/PropertyInfo.java       |   6 +-
 .../src/main/resources/cluster-settings.xml     | 322 +++++++++++++++++++
 27 files changed, 1393 insertions(+), 320 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/PropertyNotFoundException.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/PropertyNotFoundException.java b/ambari-server/src/main/java/org/apache/ambari/server/PropertyNotFoundException.java
new file mode 100644
index 0000000..b036c20
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/PropertyNotFoundException.java
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+@SuppressWarnings("serial")
+public class PropertyNotFoundException extends ObjectNotFoundException {
+
+  public PropertyNotFoundException(String message) {
+    super(message);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/ResourcesPathNotFoundException.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ResourcesPathNotFoundException.java b/ambari-server/src/main/java/org/apache/ambari/server/ResourcesPathNotFoundException.java
new file mode 100644
index 0000000..fdc1971
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ResourcesPathNotFoundException.java
@@ -0,0 +1,25 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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;
+
+public class ResourcesPathNotFoundException extends ObjectNotFoundException {
+  public ResourcesPathNotFoundException(String resourceDirPath) {
+    super("Resources folder not found. Path passed-in is : "
+            + resourceDirPath);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
index 7431f9d..737b9b4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
@@ -104,6 +104,10 @@ public class ResourceInstanceFactoryImpl implements ResourceInstanceFactory {
         resourceDefinition = new ClusterResourceDefinition();
         break;
 
+      case RootClusterSetting:
+        resourceDefinition = new RootClusterSettingsResourceDefinition();
+        break;
+
       case ServiceGroup:
         resourceDefinition = new ServiceGroupResourceDefinition();
         break;

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RootClusterSettingsResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RootClusterSettingsResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RootClusterSettingsResourceDefinition.java
new file mode 100644
index 0000000..e83c191
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/RootClusterSettingsResourceDefinition.java
@@ -0,0 +1,52 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.api.resources;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.ambari.server.controller.spi.Resource;
+
+public class RootClusterSettingsResourceDefinition extends BaseResourceDefinition {
+  /**
+   * Constructor.
+   */
+  public RootClusterSettingsResourceDefinition() {
+    super(Resource.Type.RootClusterSetting);
+  }
+
+  @Override
+  public String getPluralName() {
+    return "rootClusterSettings";
+  }
+
+  @Override
+  public String getSingularName() {
+    return "rootClusterSetting";
+  }
+
+  @Override
+  public Set<SubResourceDefinition> getSubResourceDefinitions() {
+    Set<SubResourceDefinition> subs = new HashSet<SubResourceDefinition>();
+    return subs;
+  }
+}
+
+
+
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
index c07df43..2bb450b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
@@ -41,6 +41,8 @@ import javax.xml.bind.JAXBException;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ParentObjectNotFoundException;
+import org.apache.ambari.server.PropertyNotFoundException;
+import org.apache.ambari.server.ResourcesPathNotFoundException;
 import org.apache.ambari.server.StackAccessException;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.MpackRequest;
@@ -61,6 +63,8 @@ import org.apache.ambari.server.orm.dao.MetainfoDAO;
 import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
 import org.apache.ambari.server.orm.entities.MpackEntity;
 import org.apache.ambari.server.orm.entities.StackEntity;
+import org.apache.ambari.server.resources.ResourceLevelClusterSettingManager;
+import org.apache.ambari.server.resources.ResourceLevelClusterSettingManagerFactory;
 import org.apache.ambari.server.stack.StackManager;
 import org.apache.ambari.server.stack.StackManagerFactory;
 import org.apache.ambari.server.state.Cluster;
@@ -139,6 +143,7 @@ public class AmbariMetaInfo {
 
   private final ActionDefinitionManager adManager = new ActionDefinitionManager();
   private String serverVersion = "undefined";
+  private String clusterSettingFileName = "cluster-settings.xml";
 
   private File resourcesRoot;
   private File stackRoot;
@@ -220,6 +225,17 @@ public class AmbariMetaInfo {
   */
   private MpackManager mpackManager;
 
+  /**
+   * Factory for injecting {@link ResourceLevelClusterSettingManager} instances.
+   */
+  @Inject
+  private ResourceLevelClusterSettingManagerFactory resourceLevelClusterSettingManagerFactory;
+
+  /**
+   * Singleton instance of Resource Level 'Cluster Setting' Manager
+   */
+  private ResourceLevelClusterSettingManager resourceLevelClusterSettingManager;
+
 
   private Configuration conf;
 
@@ -236,6 +252,8 @@ public class AmbariMetaInfo {
     String resourcesPath = conf.getResourceDirPath();
     if(resourcesPath != null && !resourcesPath.isEmpty()) {
       resourcesRoot = new File(resourcesPath);
+    } else {
+      throw new ResourcesPathNotFoundException(resourcesPath);
     }
 
     String stackPath = conf.getMetadataPath();
@@ -280,6 +298,8 @@ public class AmbariMetaInfo {
 
     mpackManager = mpackManagerFactory.create(mpacksV2Staging, stackRoot);
 
+    resourceLevelClusterSettingManager = resourceLevelClusterSettingManagerFactory.create(conf.getResourceDirPath());
+
     getCustomActionDefinitions(customActionRoot);
   }
 
@@ -789,6 +809,35 @@ public class AmbariMetaInfo {
     return propertyResult;
   }
 
+  /*
+ Returns Resource Level read only 'Cluster Properties'.
+ */
+  public Set<PropertyInfo> getClusterProperties() {
+    return new HashSet<>(resourceLevelClusterSettingManager.getClusterSettingsMap());
+  }
+
+  /*
+   Returns specific Resource Level read only 'Cluster Property'.
+   */
+  public Set<PropertyInfo> getClusterPropertiesByName(String propertyName) throws AmbariException {
+    HashSet<PropertyInfo> properties = new HashSet<>(resourceLevelClusterSettingManager.getClusterSettingsMap());
+    if (properties.size() == 0) {
+      throw new PropertyNotFoundException("'" + propertyName + "', in " + clusterSettingFileName);
+    }
+    Set<PropertyInfo> propertyResult = new HashSet<>();
+
+    for (PropertyInfo property : properties) {
+      if (property.getName().equals(propertyName)) {
+        propertyResult.add(property);
+      }
+    }
+
+    if (propertyResult.isEmpty()) {
+      throw new PropertyNotFoundException("'" + propertyName + "', in " + clusterSettingFileName);
+    }
+    return propertyResult;
+  }
+
   public Set<PropertyInfo> getStackPropertiesByName(String stackName, String version, String propertyName)
       throws AmbariException {
     Set<PropertyInfo> properties = getStackProperties(stackName, version);

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/api/services/RootClusterSettingService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/RootClusterSettingService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RootClusterSettingService.java
new file mode 100644
index 0000000..d77b347
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/RootClusterSettingService.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.api.services;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.controller.ReadOnlyConfigurationResponse;
+import org.apache.ambari.server.controller.internal.MpackResourceProvider;
+import org.apache.ambari.server.controller.internal.RootClusterSettingsResourceProvider;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.http.HttpStatus;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+/**
+ * Service responsible for services resource requests.
+ */
+@Path("/cluster_settings/")
+@Api(value = "ClusterSettings", description = "Endpoint for fetching read only 'cluster settings'")
+public class RootClusterSettingService extends BaseService {
+
+  public RootClusterSettingService() {
+    super();
+  }
+
+  /**
+   * Handles: GET /cluster_settings
+   * Get all default settings for a cluster.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   * @return service collection resource representation
+   */
+  @GET
+  @Produces(MediaType.TEXT_PLAIN)
+  @ApiOperation(value = "Returns information for all the read only 'cluster settings'",
+          response = ReadOnlyConfigurationResponse.ReadOnlyConfigurationResponseSwagger.class, responseContainer = RESPONSE_CONTAINER_LIST)
+  @ApiImplicitParams({
+          @ApiImplicitParam(name = QUERY_FIELDS, value = QUERY_FILTER_DESCRIPTION, dataType = DATA_TYPE_STRING,
+                  paramType = PARAM_TYPE_QUERY, defaultValue = MpackResourceProvider.MPACK_ID),
+          @ApiImplicitParam(name = QUERY_SORT, value = QUERY_SORT_DESCRIPTION, dataType = DATA_TYPE_STRING,
+                  paramType = PARAM_TYPE_QUERY),
+          @ApiImplicitParam(name = QUERY_PAGE_SIZE, value = QUERY_PAGE_SIZE_DESCRIPTION, defaultValue = DEFAULT_PAGE_SIZE,
+                  dataType = DATA_TYPE_INT, paramType = PARAM_TYPE_QUERY),
+          @ApiImplicitParam(name = QUERY_FROM, value = QUERY_FROM_DESCRIPTION, allowableValues = QUERY_FROM_VALUES,
+                  defaultValue = DEFAULT_FROM, dataType = DATA_TYPE_INT, paramType = PARAM_TYPE_QUERY),
+          @ApiImplicitParam(name = QUERY_TO, value = QUERY_TO_DESCRIPTION, allowableValues = QUERY_TO_VALUES,
+                  dataType = DATA_TYPE_INT, paramType = PARAM_TYPE_QUERY),
+  })
+  @ApiResponses({
+          @ApiResponse(code = HttpStatus.SC_OK, message = MSG_SUCCESSFUL_OPERATION),
+          @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = MSG_RESOURCE_NOT_FOUND),
+          @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = MSG_NOT_AUTHENTICATED),
+          @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = MSG_PERMISSION_DENIED),
+          @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR),
+  })
+
+  public Response getClusterSettings(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
+    return handleRequest(headers, body, ui, Request.Type.GET, createClusterSettingsResource(null));
+  }
+
+  /**
+   * Handles GET /cluster_settings/{settingName}
+   * Get specific default setting for a cluster.
+   *
+   * @param headers http headers
+   * @param ui      uri info
+   * @return service collection resource representation
+   */
+  @GET
+  @Path("{settingName}")
+  @Produces("text/plain")
+  @ApiOperation(value = "Returns information about specific read only 'cluster settings'",
+          response = ReadOnlyConfigurationResponse.ReadOnlyConfigurationResponseSwagger.class)
+  @ApiImplicitParams({
+          @ApiImplicitParam(name = QUERY_FIELDS, value = QUERY_FILTER_DESCRIPTION, dataType = DATA_TYPE_STRING,
+                  paramType = PARAM_TYPE_QUERY, defaultValue = RootClusterSettingsResourceProvider.ALL_PROPERTIES),
+  })
+  @ApiResponses({
+          @ApiResponse(code = HttpStatus.SC_OK, message = MSG_SUCCESSFUL_OPERATION),
+          @ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = MSG_RESOURCE_NOT_FOUND),
+          @ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = MSG_NOT_AUTHENTICATED),
+          @ApiResponse(code = HttpStatus.SC_FORBIDDEN, message = MSG_PERMISSION_DENIED),
+          @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = MSG_SERVER_ERROR),
+  })
+  public Response getClusterSetting(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+                                    @PathParam("settingName") String settingName) {
+    return handleRequest(headers, body, ui, Request.Type.GET, createClusterSettingsResource(settingName));
+  }
+
+  /**
+   * Create a 'cluster setting' resource instance.
+   *
+   * @return 'cluster setting' resource instance
+   */
+  ResourceInstance createClusterSettingsResource(String settingName) {
+    Map<Resource.Type, String> mapIds = new HashMap<>();
+    mapIds.put(Resource.Type.RootClusterSetting, settingName);
+
+    return createResource(Resource.Type.RootClusterSetting, mapIds);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
index 67d3a15..aef7fc1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
@@ -37,9 +37,9 @@ import org.apache.ambari.server.api.resources.ResourceInstance;
 import org.apache.ambari.server.controller.ComponentDependencyResponse;
 import org.apache.ambari.server.controller.ExtensionLinkResponse;
 import org.apache.ambari.server.controller.QuickLinksResponse;
+import org.apache.ambari.server.controller.ReadOnlyConfigurationResponse;
 import org.apache.ambari.server.controller.StackArtifactResponse;
 import org.apache.ambari.server.controller.StackConfigurationDependencyResponse;
-import org.apache.ambari.server.controller.StackConfigurationResponse;
 import org.apache.ambari.server.controller.StackResponse;
 import org.apache.ambari.server.controller.StackServiceArtifactResponse;
 import org.apache.ambari.server.controller.StackServiceComponentResponse;
@@ -223,7 +223,7 @@ public class StacksService extends BaseService {
   @ApiOperation(value = "Get all configurations for a stack version",
       nickname = "StacksService#getStackLevelConfigurations",
       notes = "Returns all configurations for a stack version.",
-      response = StackConfigurationResponse.StackConfigurationResponseSwagger.class,
+      response = ReadOnlyConfigurationResponse.ReadOnlyConfigurationResponseSwagger.class,
       responseContainer = RESPONSE_CONTAINER_LIST)
   @ApiImplicitParams({
       @ApiImplicitParam(name = QUERY_FIELDS, value = "Filter returned attributes",
@@ -261,7 +261,7 @@ public class StacksService extends BaseService {
   @ApiOperation(value = "Get configuration details for a given property",
       nickname = "StacksService#getStackLevelConfiguration",
       notes = "Returns the configuration details for a given property.",
-      response = StackConfigurationResponse.StackConfigurationResponseSwagger.class)
+      response = ReadOnlyConfigurationResponse.ReadOnlyConfigurationResponseSwagger.class)
   @ApiImplicitParams({
       @ApiImplicitParam(name = QUERY_FIELDS, value = "Filter returned attributes",
           defaultValue = "StackLevelConfigurations/*",
@@ -611,7 +611,7 @@ public class StacksService extends BaseService {
   @ApiOperation(value = "Get all configurations for a stack service",
       nickname = "StacksService#getStackConfigurations",
       notes = "Returns all configurations for a stack service.",
-      response = StackConfigurationResponse.StackConfigurationResponseSwagger.class,
+      response = ReadOnlyConfigurationResponse.ReadOnlyConfigurationResponseSwagger.class,
       responseContainer = RESPONSE_CONTAINER_LIST)
   @ApiImplicitParams({
       @ApiImplicitParam(name = QUERY_FIELDS, value = "Filter returned attributes",
@@ -653,7 +653,7 @@ public class StacksService extends BaseService {
   @ApiOperation(value = "Get stack service configuration details",
       nickname = "StacksService#getStackConfiguration",
       notes = "Returns the details of a stack service configuration.",
-      response = StackConfigurationResponse.StackConfigurationResponseSwagger.class)
+      response = ReadOnlyConfigurationResponse.ReadOnlyConfigurationResponseSwagger.class)
   @ApiImplicitParams({
       @ApiImplicitParam(name = QUERY_FIELDS, value = "Filter returned attributes",
           defaultValue = "StackConfigurations/*",

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
index f2c4c52..ce61497 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
@@ -484,7 +484,7 @@ public interface AmbariManagementController {
    *
    * @throws  AmbariException if the resources cannot be read
    */
-  Set<StackConfigurationResponse> getStackConfigurations(Set<StackConfigurationRequest> requests) throws AmbariException;
+  Set<ReadOnlyConfigurationResponse> getStackConfigurations(Set<StackConfigurationRequest> requests) throws AmbariException;
 
 
   /**
@@ -843,7 +843,15 @@ public interface AmbariManagementController {
    * @return
    * @throws AmbariException
    */
-  Set<StackConfigurationResponse> getStackLevelConfigurations(Set<StackLevelConfigurationRequest> requests) throws AmbariException;
+  Set<ReadOnlyConfigurationResponse> getStackLevelConfigurations(Set<StackLevelConfigurationRequest> requests) throws AmbariException;
+
+  /**
+   * Get initial settings for a cluster (!not a service).
+   * @param requests
+   * @return
+   * @throws AmbariException
+   */
+  Set<ReadOnlyConfigurationResponse> getResourceLevelClusterSettings(Set<RootClusterSettingRequest> requests) throws AmbariException;
 
   /**
    * @param serviceInfo service info for a given service

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/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 188d4d3..28b5c28 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
@@ -4812,17 +4812,17 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
   }
 
   @Override
-  public Set<StackConfigurationResponse> getStackLevelConfigurations(
+  public Set<ReadOnlyConfigurationResponse> getStackLevelConfigurations(
       Set<StackLevelConfigurationRequest> requests) throws AmbariException {
-    Set<StackConfigurationResponse> response = new HashSet<>();
+    Set<ReadOnlyConfigurationResponse> response = new HashSet<>();
     for (StackLevelConfigurationRequest request : requests) {
 
       String stackName    = request.getStackName();
       String stackVersion = request.getStackVersion();
 
-      Set<StackConfigurationResponse> stackConfigurations = getStackLevelConfigurations(request);
+      Set<ReadOnlyConfigurationResponse> stackConfigurations = getStackLevelConfigurations(request);
 
-      for (StackConfigurationResponse stackConfigurationResponse : stackConfigurations) {
+      for (ReadOnlyConfigurationResponse stackConfigurationResponse : stackConfigurations) {
         stackConfigurationResponse.setStackName(stackName);
         stackConfigurationResponse.setStackVersion(stackVersion);
       }
@@ -4833,10 +4833,10 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     return response;
   }
 
-  private Set<StackConfigurationResponse> getStackLevelConfigurations(
+  private Set<ReadOnlyConfigurationResponse> getStackLevelConfigurations(
       StackLevelConfigurationRequest request) throws AmbariException {
 
-    Set<StackConfigurationResponse> response = new HashSet<>();
+    Set<ReadOnlyConfigurationResponse> response = new HashSet<>();
 
     String stackName = request.getStackName();
     String stackVersion = request.getStackVersion();
@@ -4856,18 +4856,48 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
   }
 
   @Override
-  public Set<StackConfigurationResponse> getStackConfigurations(
+  public Set<ReadOnlyConfigurationResponse> getResourceLevelClusterSettings(
+          Set<RootClusterSettingRequest> requests) throws AmbariException {
+    Set<ReadOnlyConfigurationResponse> response = new HashSet<>();
+    for (RootClusterSettingRequest request : requests) {
+      Set<ReadOnlyConfigurationResponse> stackConfigurations = getResourceLevelClusterSettings(request);
+      response.addAll(stackConfigurations);
+    }
+
+    return response;
+  }
+
+  private Set<ReadOnlyConfigurationResponse> getResourceLevelClusterSettings(
+          RootClusterSettingRequest request) throws AmbariException {
+    Set<ReadOnlyConfigurationResponse> response = new HashSet<>();
+    String propertyName = request.getPropertyName();
+
+    Set<PropertyInfo> properties;
+    if (propertyName != null) {
+      properties = ambariMetaInfo.getClusterPropertiesByName(propertyName);
+    } else {
+      properties = ambariMetaInfo.getClusterProperties();
+    }
+    for (PropertyInfo property : properties) {
+      response.add(property.convertToResponse());
+    }
+    return response;
+  }
+
+
+  @Override
+  public Set<ReadOnlyConfigurationResponse> getStackConfigurations(
       Set<StackConfigurationRequest> requests) throws AmbariException {
-    Set<StackConfigurationResponse> response = new HashSet<>();
+    Set<ReadOnlyConfigurationResponse> response = new HashSet<>();
     for (StackConfigurationRequest request : requests) {
 
       String stackName    = request.getStackName();
       String stackVersion = request.getStackVersion();
       String serviceName  = request.getServiceName();
 
-      Set<StackConfigurationResponse> stackConfigurations = getStackConfigurations(request);
+      Set<ReadOnlyConfigurationResponse> stackConfigurations = getStackConfigurations(request);
 
-      for (StackConfigurationResponse stackConfigurationResponse : stackConfigurations) {
+      for (ReadOnlyConfigurationResponse stackConfigurationResponse : stackConfigurations) {
         stackConfigurationResponse.setStackName(stackName);
         stackConfigurationResponse.setStackVersion(stackVersion);
         stackConfigurationResponse.setServiceName(serviceName);
@@ -4879,10 +4909,10 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     return response;
   }
 
-  private Set<StackConfigurationResponse> getStackConfigurations(
+  private Set<ReadOnlyConfigurationResponse> getStackConfigurations(
       StackConfigurationRequest request) throws AmbariException {
 
-    Set<StackConfigurationResponse> response = new HashSet<>();
+    Set<ReadOnlyConfigurationResponse> response = new HashSet<>();
 
     String stackName = request.getStackName();
     String stackVersion = request.getStackVersion();

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/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 a4339ab..3117186 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,7 @@ import org.apache.ambari.server.registry.RegistryFactory;
 import org.apache.ambari.server.registry.RegistryFactoryImpl;
 import org.apache.ambari.server.registry.RegistryManager;
 import org.apache.ambari.server.registry.RegistryManagerImpl;
+import org.apache.ambari.server.resources.ResourceLevelClusterSettingManagerFactory;
 import org.apache.ambari.server.scheduler.ExecutionScheduler;
 import org.apache.ambari.server.scheduler.ExecutionSchedulerImpl;
 import org.apache.ambari.server.security.SecurityHelper;
@@ -511,6 +512,7 @@ public class ControllerModule extends AbstractModule {
     install(new FactoryModuleBuilder().build(MetricPropertyProviderFactory.class));
     install(new FactoryModuleBuilder().build(UpgradeContextFactory.class));
     install(new FactoryModuleBuilder().build(MpackManagerFactory.class));
+    install(new FactoryModuleBuilder().build(ResourceLevelClusterSettingManagerFactory.class));
 
     bind(RegistryFactory.class).to(RegistryFactoryImpl.class);
     bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/ReadOnlyConfigurationResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ReadOnlyConfigurationResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ReadOnlyConfigurationResponse.java
new file mode 100644
index 0000000..0033ea3
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ReadOnlyConfigurationResponse.java
@@ -0,0 +1,272 @@
+/*
+ * 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.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.state.PropertyDependencyInfo;
+import org.apache.ambari.server.state.PropertyInfo.PropertyType;
+import org.apache.ambari.server.state.ValueAttributesInfo;
+
+import io.swagger.annotations.ApiModelProperty;
+
+
+public class ReadOnlyConfigurationResponse {
+
+  /**
+   * Configuration response.
+   *
+   * @param propertyName        Property Key
+   * @param propertyValue       Property Value
+   * @param propertyDescription Property Description
+   * @param type                Configuration type
+   * @param propertyAttributes  Attributes map
+   */
+  public ReadOnlyConfigurationResponse(String propertyName, String propertyValue, String propertyDescription,
+                                       String type, Map<String, String> propertyAttributes) {
+    setPropertyName(propertyName);
+    setPropertyValue(propertyValue);
+    setPropertyDescription(propertyDescription);
+    setType(type);
+    setPropertyAttributes(propertyAttributes);
+  }
+
+  /**
+   * Configuration response with all properties.
+   *
+   * @param propertyName            Property Key
+   * @param propertyValue           Property Value
+   * @param propertyDescription     Property Description
+   * @param type                    Configuration type
+   * @param isRequired              Is required to be set
+   * @param propertyTypes           Property Types
+   * @param propertyAttributes      Attributes map
+   * @param propertyValueAttributes Value Attributes
+   * @param dependsOnProperties     depends on properties set
+   */
+  public ReadOnlyConfigurationResponse(String propertyName, String propertyValue,
+                                       String propertyDescription, String propertyDisplayName, String type,
+                                       Boolean isRequired,
+                                       Set<PropertyType> propertyTypes,
+                                       Map<String, String> propertyAttributes,
+                                       ValueAttributesInfo propertyValueAttributes,
+                                       Set<PropertyDependencyInfo> dependsOnProperties) {
+    setPropertyName(propertyName);
+    setPropertyValue(propertyValue);
+    setPropertyDescription(propertyDescription);
+    setPropertyDisplayName(propertyDisplayName);
+    setType(type);
+    setRequired(isRequired);
+    setPropertyType(propertyTypes);
+    setPropertyAttributes(propertyAttributes);
+    setPropertyValueAttributes(propertyValueAttributes);
+    setDependsOnProperties(dependsOnProperties);
+  }
+
+  private String stackName;
+  private String stackVersion;
+  private String serviceName;
+  private String propertyName;
+  private String propertyValue;
+  private String propertyDescription;
+  private String propertyDisplayName;
+  private String type;
+  private Map<String, String> propertyAttributes;
+  private ValueAttributesInfo propertyValueAttributes;
+  private Set<PropertyDependencyInfo> dependsOnProperties;
+  private Boolean isRequired;
+  private Set<PropertyType> propertyTypes;
+
+  @ApiModelProperty(name = "stack_name")
+  public String getStackName() {
+    return stackName;
+  }
+
+  public void setStackName(String stackName) {
+    this.stackName = stackName;
+  }
+
+  @ApiModelProperty(name = "stack_version")
+  public String getStackVersion() {
+    return stackVersion;
+  }
+
+  public void setStackVersion(String stackVersion) {
+    this.stackVersion = stackVersion;
+  }
+
+  @ApiModelProperty(name = "service_name")
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+
+  @ApiModelProperty(name = "property_name")
+  public String getPropertyName() {
+    return propertyName;
+  }
+
+  public void setPropertyName(String propertyName) {
+    this.propertyName = propertyName;
+  }
+
+  @ApiModelProperty(name = "property_value")
+  public String getPropertyValue() {
+    return propertyValue;
+  }
+
+  public void setPropertyValue(String propertyValue) {
+    this.propertyValue = propertyValue;
+  }
+
+  @ApiModelProperty(name = "property_description")
+  public String getPropertyDescription() {
+    return propertyDescription;
+  }
+
+  public void setPropertyDescription(String propertyDescription) {
+    this.propertyDescription = propertyDescription;
+  }
+
+  @ApiModelProperty(name = "property_display_name")
+  public String getPropertyDisplayName() {
+    return propertyDisplayName;
+  }
+
+  public void setPropertyDisplayName(String propertyDisplayName) {
+    this.propertyDisplayName = propertyDisplayName;
+  }
+
+  /**
+   * Configuration type
+   *
+   * @return Configuration type (*-site.xml)
+   */
+  public String getType() {
+    return type;
+  }
+
+  @ApiModelProperty(name = "type")
+  public void setType(String type) {
+    this.type = type;
+  }
+
+  /**
+   * Provides attributes of this configuration.
+   *
+   * @return Map of attribute name to attribute value
+   */
+  @ApiModelProperty(hidden = true)
+  public Map<String, String> getPropertyAttributes() {
+    return propertyAttributes;
+  }
+
+  /**
+   * Sets attributes for this configuration.
+   *
+   * @param propertyAttributes Map of attribute name to attribute value
+   */
+  public void setPropertyAttributes(Map<String, String> propertyAttributes) {
+    this.propertyAttributes = propertyAttributes;
+  }
+
+  /**
+   * Provides value attributes of this configuration.
+   *
+   * @return value attributes
+   */
+  @ApiModelProperty(name = "property_value_attributes")
+  public ValueAttributesInfo getPropertyValueAttributes() {
+    return propertyValueAttributes;
+  }
+
+  /**
+   * Sets value attributes for this configuration.
+   *
+   * @param propertyValueAttributes
+   */
+  public void setPropertyValueAttributes(ValueAttributesInfo propertyValueAttributes) {
+    this.propertyValueAttributes = propertyValueAttributes;
+  }
+
+  /**
+   * Provides depends on properties of this configuration.
+   *
+   * @return depends on properties set
+   */
+  @ApiModelProperty(name = "dependencies")
+  public Set<PropertyDependencyInfo> getDependsOnProperties() {
+    return dependsOnProperties;
+  }
+
+  /**
+   * Sets depends on properties set for this configuration.
+   *
+   * @param dependsOnProperties
+   */
+  public void setDependsOnProperties(Set<PropertyDependencyInfo> dependsOnProperties) {
+    this.dependsOnProperties = dependsOnProperties;
+  }
+
+  /**
+   * Is property a isRequired property
+   *
+   * @return True/False
+   */
+  @ApiModelProperty(hidden = true)
+  public Boolean isRequired() {
+    return isRequired;
+  }
+
+  /**
+   * Set required attribute on this property.
+   *
+   * @param required True/False.
+   */
+  public void setRequired(Boolean required) {
+    this.isRequired = required;
+  }
+
+  /**
+   * Get type of property as set in the stack definition.
+   *
+   * @return Property type.
+   */
+  @ApiModelProperty(name = "property_type")
+  public Set<PropertyType> getPropertyType() {
+    return propertyTypes;
+  }
+
+  public void setPropertyType(Set<PropertyType> propertyTypes) {
+    this.propertyTypes = propertyTypes;
+  }
+
+  /**
+   * Interface to help correct Swagger documentation generation
+   */
+  public interface ReadOnlyConfigurationResponseSwagger extends ApiModel {
+    @ApiModelProperty(name = "ReadOnlyConfigurations")
+    public ReadOnlyConfigurationResponse getStackConfigurationResponse();
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/RootClusterSettingRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RootClusterSettingRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RootClusterSettingRequest.java
new file mode 100644
index 0000000..e86c94d
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RootClusterSettingRequest.java
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+public class RootClusterSettingRequest {
+
+  private String propertyName;
+
+  public RootClusterSettingRequest(String propertyName) {
+    super();
+    setPropertyName(propertyName);
+  }
+
+  public String getPropertyName() {
+    return propertyName;
+  }
+
+  public void setPropertyName(String propertyName) {
+    this.propertyName = propertyName;
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationResponse.java
deleted file mode 100644
index fb31c19..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationResponse.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * 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.Map;
-import java.util.Set;
-
-import org.apache.ambari.server.state.PropertyDependencyInfo;
-import org.apache.ambari.server.state.PropertyInfo.PropertyType;
-import org.apache.ambari.server.state.ValueAttributesInfo;
-
-import io.swagger.annotations.ApiModelProperty;
-
-
-public class StackConfigurationResponse {
-
-  /**
-   * Stack configuration response.
-   * @param propertyName Property Key
-   * @param propertyValue Property Value
-   * @param propertyDescription Property Description
-   * @param type Configuration type
-   * @param propertyAttributes Attributes map
-   */
-  public StackConfigurationResponse(String propertyName, String propertyValue, String propertyDescription,
-                                    String type, Map<String, String> propertyAttributes) {
-    setPropertyName(propertyName);
-    setPropertyValue(propertyValue);
-    setPropertyDescription(propertyDescription);
-    setType(type);
-    setPropertyAttributes(propertyAttributes);
-  }
-
-  /**
-   * Stack configuration response with all properties.
-   * @param propertyName Property Key
-   * @param propertyValue Property Value
-   * @param propertyDescription Property Description
-   * @param type Configuration type
-   * @param isRequired Is required to be set
-   * @param propertyTypes Property Types
-   * @param propertyAttributes Attributes map
-   * @param propertyValueAttributes Value Attributes
-   * @param dependsOnProperties depends on properties set
-   */
-  public StackConfigurationResponse(String propertyName, String propertyValue,
-                                    String propertyDescription, String propertyDisplayName, String type,
-                                    Boolean isRequired,
-                                    Set<PropertyType> propertyTypes,
-                                    Map<String, String> propertyAttributes,
-                                    ValueAttributesInfo propertyValueAttributes,
-                                    Set<PropertyDependencyInfo> dependsOnProperties) {
-    setPropertyName(propertyName);
-    setPropertyValue(propertyValue);
-    setPropertyDescription(propertyDescription);
-    setPropertyDisplayName(propertyDisplayName);
-    setType(type);
-    setRequired(isRequired);
-    setPropertyType(propertyTypes);
-    setPropertyAttributes(propertyAttributes);
-    setPropertyValueAttributes(propertyValueAttributes);
-    setDependsOnProperties(dependsOnProperties);
-  }
-
-  private String stackName;
-  private String stackVersion;
-  private String serviceName;
-  private String propertyName;
-  private String propertyValue;
-  private String propertyDescription;
-  private String propertyDisplayName;
-  private String type;
-  private Map<String, String> propertyAttributes;
-  private ValueAttributesInfo propertyValueAttributes;
-  private Set<PropertyDependencyInfo> dependsOnProperties;
-  private Boolean isRequired;
-  private Set<PropertyType> propertyTypes;
-
-  @ApiModelProperty(name = "stack_name")
-  public String getStackName() {
-    return stackName;
-  }
-
-  public void setStackName(String stackName) {
-    this.stackName = stackName;
-  }
-
-  @ApiModelProperty(name = "stack_version")
-  public String getStackVersion() {
-    return stackVersion;
-  }
-
-  public void setStackVersion(String stackVersion) {
-    this.stackVersion = stackVersion;
-  }
-
-  @ApiModelProperty(name = "service_name")
-  public String getServiceName() {
-    return serviceName;
-  }
-
-  public void setServiceName(String serviceName) {
-    this.serviceName = serviceName;
-  }
-
-  @ApiModelProperty(name = "property_name")
-  public String getPropertyName() {
-    return propertyName;
-  }
-
-  public void setPropertyName(String propertyName) {
-    this.propertyName = propertyName;
-  }
-
-  @ApiModelProperty(name = "property_value")
-  public String getPropertyValue() {
-    return propertyValue;
-  }
-
-  public void setPropertyValue(String propertyValue) {
-    this.propertyValue = propertyValue;
-  }
-
-  @ApiModelProperty(name = "property_description")
-  public String getPropertyDescription() {
-    return propertyDescription;
-  }
-
-  public void setPropertyDescription(String propertyDescription) {
-    this.propertyDescription = propertyDescription;
-  }
-
-  @ApiModelProperty(name = "property_display_name")
-  public String getPropertyDisplayName() {
-    return propertyDisplayName;
-  }
-
-  public void setPropertyDisplayName(String propertyDisplayName) {
-    this.propertyDisplayName = propertyDisplayName;
-  }
-
-  /**
-   * Configuration type
-   * @return Configuration type (*-site.xml)
-   */
-  public String getType() {
-    return type;
-  }
-
-  @ApiModelProperty(name = "type")
-  public void setType(String type) {
-    this.type = type;
-  }
-
-  /**
-   * Provides attributes of this configuration.
-   *
-   * @return Map of attribute name to attribute value
-   */
-  @ApiModelProperty(hidden = true)
-  public Map<String, String> getPropertyAttributes() {
-    return propertyAttributes;
-  }
-
-  /**
-   * Sets attributes for this configuration.
-   *
-   * @param propertyAttributes Map of attribute name to attribute value
-   */
-  public void setPropertyAttributes(Map<String, String> propertyAttributes) {
-    this.propertyAttributes = propertyAttributes;
-  }
-
-  /**
-   * Provides value attributes of this configuration.
-   *
-   * @return value attributes
-   */
-  @ApiModelProperty(name = "property_value_attributes")
-  public ValueAttributesInfo getPropertyValueAttributes() {
-    return propertyValueAttributes;
-  }
-
-  /**
-   * Sets value attributes for this configuration.
-   *
-   * @param propertyValueAttributes
-   */
-  public void setPropertyValueAttributes(ValueAttributesInfo propertyValueAttributes) {
-    this.propertyValueAttributes = propertyValueAttributes;
-  }
-
-  /**
-   * Provides depends on properties of this configuration.
-   *
-   * @return depends on properties set
-   */
-  @ApiModelProperty(name = "dependencies")
-  public Set<PropertyDependencyInfo> getDependsOnProperties() {
-    return dependsOnProperties;
-  }
-
-  /**
-   * Sets depends on properties set for this configuration.
-   *
-   * @param dependsOnProperties
-   */
-  public void setDependsOnProperties(Set<PropertyDependencyInfo> dependsOnProperties) {
-    this.dependsOnProperties = dependsOnProperties;
-  }
-
-  /**
-   * Is property a isRequired property
-   * @return True/False
-   */
-  @ApiModelProperty(hidden = true)
-  public Boolean isRequired() {
-    return isRequired;
-  }
-
-  /**
-   * Set required attribute on this property.
-   * @param required True/False.
-   */
-  public void setRequired(Boolean required) {
-    this.isRequired = required;
-  }
-
-  /**
-   * Get type of property as set in the stack definition.
-   * @return Property type.
-   */
-  @ApiModelProperty(name = "property_type")
-  public Set<PropertyType> getPropertyType() {
-    return propertyTypes;
-  }
-
-  public void setPropertyType(Set<PropertyType> propertyTypes) {
-    this.propertyTypes = propertyTypes;
-  }
-
-  /**
-   * Interface to help correct Swagger documentation generation
-   */
-  public interface StackConfigurationResponseSwagger extends ApiModel {
-    @ApiModelProperty(name = "StackConfigurations")
-    public StackConfigurationResponse getStackConfigurationResponse();
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationRequest.java
index ea67207..70678ad 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationRequest.java
@@ -39,4 +39,4 @@ public class StackLevelConfigurationRequest extends StackVersionRequest {
     this.propertyName = propertyName;
   }
 
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationResponse.java
index d33b5cb..a962466 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationResponse.java
@@ -26,20 +26,20 @@ import org.apache.ambari.server.state.PropertyDependencyInfo;
 import org.apache.ambari.server.state.PropertyInfo.PropertyType;
 import org.apache.ambari.server.state.ValueAttributesInfo;
 
-public class StackLevelConfigurationResponse extends StackConfigurationResponse {
+public class StackLevelConfigurationResponse extends ReadOnlyConfigurationResponse {
   public StackLevelConfigurationResponse(String propertyName,
-      String propertyValue, String propertyDescription, String propertyDisplayName, String type,
-      Boolean isRequired, Set<PropertyType> propertyTypes,
-      Map<String, String> propertyAttributes,
-      ValueAttributesInfo propertyValueAttributes,
-      Set<PropertyDependencyInfo> dependsOnProperties) {
+                                         String propertyValue, String propertyDescription, String propertyDisplayName, String type,
+                                         Boolean isRequired, Set<PropertyType> propertyTypes,
+                                         Map<String, String> propertyAttributes,
+                                         ValueAttributesInfo propertyValueAttributes,
+                                         Set<PropertyDependencyInfo> dependsOnProperties) {
     super(propertyName, propertyValue, propertyDescription, propertyDisplayName, type, isRequired,
-        propertyTypes, propertyAttributes, propertyValueAttributes,
-        dependsOnProperties);
+            propertyTypes, propertyAttributes, propertyValueAttributes,
+            dependsOnProperties);
   }
-  
+
   public StackLevelConfigurationResponse(String propertyName, String propertyValue, String propertyDescription,
-      String type, Map<String, String> propertyAttributes) {
+                                         String type, Map<String, String> propertyAttributes) {
     super(propertyName, propertyValue, propertyDescription, type, propertyAttributes);
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
index 8a2208d..a6d8979 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
@@ -670,14 +670,14 @@ public class StackV2 {
     serviceConfigurations.put(service, mapServiceConfig);
     requiredServiceConfigurations.put(service, mapRequiredServiceConfig);
 
-    Set<StackConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
+    Set<ReadOnlyConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
         Collections.singleton(new StackConfigurationRequest(name, version, service, null)));
-    Set<StackConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
         Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
     serviceConfigs.addAll(stackLevelConfigs);
 
     // shouldn't have any required properties in stack level configuration
-    for (StackConfigurationResponse config : serviceConfigs) {
+    for (ReadOnlyConfigurationResponse config : serviceConfigs) {
       ConfigProperty configProperty = new ConfigProperty(config);
       String type = configProperty.getType();
 
@@ -711,10 +711,10 @@ public class StackV2 {
 
   private void parseStackConfigurations () throws AmbariException {
 
-    Set<StackConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
         Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
 
-    for (StackConfigurationResponse config : stackLevelConfigs) {
+    for (ReadOnlyConfigurationResponse config : stackLevelConfigs) {
       ConfigProperty configProperty = new ConfigProperty(config);
       String type = configProperty.getType();
 
@@ -759,7 +759,7 @@ public class StackV2 {
     private Set<PropertyDependencyInfo> dependsOnProperties =
       Collections.emptySet();
 
-    public ConfigProperty(StackConfigurationResponse config) {
+    public ConfigProperty(ReadOnlyConfigurationResponse config) {
       this.name = config.getPropertyName();
       this.value = config.getPropertyValue();
       this.attributes = config.getPropertyAttributes();

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
index 84df08a..b8c1674 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
@@ -196,6 +196,8 @@ public abstract class AbstractControllerResourceProvider extends AbstractAuthori
         return new RegistryMpackVersionResourceProvider(managementController);
       case Mpack:
         return new MpackResourceProvider(managementController);
+      case RootClusterSetting:
+        return new RootClusterSettingsResourceProvider(managementController);
       case StackVersion:
         return new StackVersionResourceProvider(propertyIds, keyPropertyIds, managementController);
       case ClusterStackVersion:

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootClusterSettingsResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootClusterSettingsResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootClusterSettingsResourceProvider.java
new file mode 100644
index 0000000..1488672
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootClusterSettingsResourceProvider.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.ambari.server.controller.internal;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.ReadOnlyConfigurationResponse;
+import org.apache.ambari.server.controller.RootClusterSettingRequest;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Resource.Type;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.commons.lang.StringUtils;
+
+import com.google.inject.assistedinject.Assisted;
+
+public class RootClusterSettingsResourceProvider extends ReadOnlyResourceProvider {
+
+  public static final String RESPONSE_KEY = "ClusterSettingsInfo";
+  public static final String ALL_PROPERTIES = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "*";
+
+  public static final String PROPERTY_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "property_name";
+  public static final String PROPERTY_DISPLAY_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "property_display_name";
+  public static final String PROPERTY_VALUE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "property_value";
+  public static final String PROPERTY_VALUE_ATTRIBUTES_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "property_value_attributes";
+  public static final String DEPENDS_ON_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "property_depends_on";
+  public static final String PROPERTY_DESCRIPTION_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "property_description";
+  public static final String PROPERTY_PROPERTY_TYPE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "property_type";
+  public static final String PROPERTY_TYPE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "type";
+  public static final String PROPERTY_FINAL_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "final";
+
+  private static Set<String> pkPropertyIds = new HashSet<>(Arrays.asList(new String[]{PROPERTY_NAME_PROPERTY_ID}));
+
+  /**
+   * The key property ids for 'cluster_setting' resource.
+   */
+  private static final Map<Resource.Type, String> KEY_PROPERTY_IDS = new HashMap<>();
+
+  /**
+   * The property ids for an 'cluster_setting' resource.
+   */
+  private static final Set<String> PROPERTY_IDS = new HashSet<>();
+
+  static {
+    // properties
+    PROPERTY_IDS.add(PROPERTY_NAME_PROPERTY_ID);
+    PROPERTY_IDS.add(PROPERTY_DISPLAY_NAME_PROPERTY_ID);
+    PROPERTY_IDS.add(PROPERTY_VALUE_PROPERTY_ID);
+    PROPERTY_IDS.add(PROPERTY_VALUE_ATTRIBUTES_PROPERTY_ID);
+    PROPERTY_IDS.add(DEPENDS_ON_PROPERTY_ID);
+    PROPERTY_IDS.add(PROPERTY_DESCRIPTION_PROPERTY_ID);
+    PROPERTY_IDS.add(PROPERTY_PROPERTY_TYPE_PROPERTY_ID);
+    PROPERTY_IDS.add(PROPERTY_TYPE_PROPERTY_ID);
+    PROPERTY_IDS.add(PROPERTY_FINAL_PROPERTY_ID);
+
+    // keys
+    KEY_PROPERTY_IDS.put(Type.RootClusterSetting, PROPERTY_NAME_PROPERTY_ID);
+  }
+
+  protected RootClusterSettingsResourceProvider(@Assisted AmbariManagementController managementController) {
+    super(PROPERTY_IDS, KEY_PROPERTY_IDS, managementController);
+  }
+
+
+  @Override
+  public Set<Resource> getResources(Request request, Predicate predicate)
+          throws SystemException, UnsupportedPropertyException,
+          NoSuchResourceException, NoSuchParentResourceException {
+
+    final Set<RootClusterSettingRequest> requests = new HashSet<>();
+
+    if (predicate == null) {
+      requests.add(getRequest(Collections.emptyMap()));
+    } else {
+      for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
+        requests.add(getRequest(propertyMap));
+      }
+    }
+
+    Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+
+    Set<ReadOnlyConfigurationResponse> responses = getResources(new Command<Set<ReadOnlyConfigurationResponse>>() {
+      @Override
+      public Set<ReadOnlyConfigurationResponse> invoke() throws AmbariException {
+        return getManagementController().getResourceLevelClusterSettings(requests);
+      }
+    });
+
+    Set<Resource> resources = new HashSet<>();
+
+    for (ReadOnlyConfigurationResponse response : responses) {
+      Resource resource = new ResourceImpl(Type.RootClusterSetting);
+
+      setResourceProperty(resource, PROPERTY_NAME_PROPERTY_ID, response.getPropertyName(), requestedIds);
+      setResourceProperty(resource, PROPERTY_VALUE_PROPERTY_ID, response.getPropertyValue(), requestedIds);
+      setResourceProperty(resource, PROPERTY_VALUE_ATTRIBUTES_PROPERTY_ID, response.getPropertyValueAttributes(), requestedIds);
+      setResourceProperty(resource, DEPENDS_ON_PROPERTY_ID, response.getDependsOnProperties(), requestedIds);
+      setResourceProperty(resource, PROPERTY_DESCRIPTION_PROPERTY_ID, response.getPropertyDescription(), requestedIds);
+
+      //should not be returned if empty
+      if (StringUtils.isNotEmpty(response.getPropertyDisplayName())) {
+        setResourceProperty(resource, PROPERTY_DISPLAY_NAME_PROPERTY_ID, response.getPropertyDisplayName(), requestedIds);
+      }
+
+      setResourceProperty(resource, PROPERTY_PROPERTY_TYPE_PROPERTY_ID, response.getPropertyType(), requestedIds);
+
+      setResourceProperty(resource, PROPERTY_TYPE_PROPERTY_ID, response.getType(), requestedIds);
+
+      setDefaultPropertiesAttributes(resource, requestedIds);
+
+      for (Map.Entry<String, String> attribute : response.getPropertyAttributes().entrySet()) {
+        setResourceProperty(resource, PropertyHelper.getPropertyId(RESPONSE_KEY, attribute.getKey()),
+                attribute.getValue(), requestedIds);
+      }
+      resources.add(resource);
+    }
+    return resources;
+  }
+
+  /**
+   * Set default values for properties attributes before applying original ones
+   * to prevent absence in case of empty attributes map
+   */
+  private void setDefaultPropertiesAttributes(Resource resource, Set<String> requestedIds) {
+    setResourceProperty(resource, PROPERTY_FINAL_PROPERTY_ID,
+            "false", requestedIds);
+  }
+
+  private RootClusterSettingRequest getRequest(Map<String, Object> properties) {
+    return new RootClusterSettingRequest((String) properties.get(PROPERTY_NAME_PROPERTY_ID));
+  }
+
+  @Override
+  protected Set<String> getPKPropertyIds() {
+    return pkPropertyIds;
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
index f8feef2..16907a1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/Stack.java
@@ -27,8 +27,8 @@ import java.util.Set;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.ReadOnlyConfigurationResponse;
 import org.apache.ambari.server.controller.StackConfigurationRequest;
-import org.apache.ambari.server.controller.StackConfigurationResponse;
 import org.apache.ambari.server.controller.StackLevelConfigurationRequest;
 import org.apache.ambari.server.controller.StackServiceComponentRequest;
 import org.apache.ambari.server.controller.StackServiceComponentResponse;
@@ -668,14 +668,14 @@ public class Stack {
     serviceConfigurations.put(service, mapServiceConfig);
     requiredServiceConfigurations.put(service, mapRequiredServiceConfig);
 
-    Set<StackConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
+    Set<ReadOnlyConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
         Collections.singleton(new StackConfigurationRequest(name, version, service, null)));
-    Set<StackConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
         Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
     serviceConfigs.addAll(stackLevelConfigs);
 
     // shouldn't have any required properties in stack level configuration
-    for (StackConfigurationResponse config : serviceConfigs) {
+    for (ReadOnlyConfigurationResponse config : serviceConfigs) {
       ConfigProperty configProperty = new ConfigProperty(config);
       String type = configProperty.getType();
 
@@ -709,10 +709,10 @@ public class Stack {
 
   private void parseStackConfigurations () throws AmbariException {
 
-    Set<StackConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
         Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
 
-    for (StackConfigurationResponse config : stackLevelConfigs) {
+    for (ReadOnlyConfigurationResponse config : stackLevelConfigs) {
       ConfigProperty configProperty = new ConfigProperty(config);
       String type = configProperty.getType();
 
@@ -757,7 +757,7 @@ public class Stack {
     private Set<PropertyDependencyInfo> dependsOnProperties =
       Collections.emptySet();
 
-    public ConfigProperty(StackConfigurationResponse config) {
+    public ConfigProperty(ReadOnlyConfigurationResponse config) {
       this.name = config.getPropertyName();
       this.value = config.getPropertyValue();
       this.attributes = config.getPropertyAttributes();

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
index 6f5b0f8..b0b1db0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
@@ -27,8 +27,8 @@ import java.util.Set;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.ReadOnlyConfigurationResponse;
 import org.apache.ambari.server.controller.StackConfigurationRequest;
-import org.apache.ambari.server.controller.StackConfigurationResponse;
 import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
 import org.apache.ambari.server.controller.spi.NoSuchResourceException;
 import org.apache.ambari.server.controller.spi.Predicate;
@@ -108,16 +108,16 @@ public class StackConfigurationResourceProvider extends
 
     Set<String> requestedIds = getRequestPropertyIds(request, predicate);
 
-    Set<StackConfigurationResponse> responses = getResources(new Command<Set<StackConfigurationResponse>>() {
+    Set<ReadOnlyConfigurationResponse> responses = getResources(new Command<Set<ReadOnlyConfigurationResponse>>() {
       @Override
-      public Set<StackConfigurationResponse> invoke() throws AmbariException {
+      public Set<ReadOnlyConfigurationResponse> invoke() throws AmbariException {
         return getManagementController().getStackConfigurations(requests);
       }
     });
 
     Set<Resource> resources = new HashSet<>();
     
-    for (StackConfigurationResponse response : responses) {
+    for (ReadOnlyConfigurationResponse response : responses) {
       Resource resource = new ResourceImpl(Resource.Type.StackConfiguration);
 
       setResourceProperty(resource, STACK_NAME_PROPERTY_ID,

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java
index 819507b..361f80a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java
@@ -27,7 +27,7 @@ import java.util.Set;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.StackConfigurationResponse;
+import org.apache.ambari.server.controller.ReadOnlyConfigurationResponse;
 import org.apache.ambari.server.controller.StackLevelConfigurationRequest;
 import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
 import org.apache.ambari.server.controller.spi.NoSuchResourceException;
@@ -105,16 +105,16 @@ public class StackLevelConfigurationResourceProvider extends
 
     Set<String> requestedIds = getRequestPropertyIds(request, predicate);
 
-    Set<StackConfigurationResponse> responses = getResources(new Command<Set<StackConfigurationResponse>>() {
+    Set<ReadOnlyConfigurationResponse> responses = getResources(new Command<Set<ReadOnlyConfigurationResponse>>() {
       @Override
-      public Set<StackConfigurationResponse> invoke() throws AmbariException {
+      public Set<ReadOnlyConfigurationResponse> invoke() throws AmbariException {
         return getManagementController().getStackLevelConfigurations(requests);
       }
     });
 
     Set<Resource> resources = new HashSet<>();
     
-    for (StackConfigurationResponse response : responses) {
+    for (ReadOnlyConfigurationResponse response : responses) {
       Resource resource = new ResourceImpl(Resource.Type.StackLevelConfiguration);
 
       setResourceProperty(resource, STACK_NAME_PROPERTY_ID,

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
index a364c4c..6a76fff 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
@@ -75,6 +75,7 @@ public interface Resource {
    */
   enum InternalType {
     Cluster,
+    RootClusterSetting,
     Service,
     ServiceGroup,
     Setting,
@@ -204,6 +205,7 @@ public interface Resource {
      * Internal types.  See {@link InternalType}.
      */
     public static final Type Cluster = InternalType.Cluster.getType();
+    public static final Type RootClusterSetting = InternalType.RootClusterSetting.getType();
     public static final Type ServiceGroup = InternalType.ServiceGroup.getType();
     public static final Type Service = InternalType.Service.getType();
     public static final Type Setting = InternalType.Setting.getType();

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceLevelClusterSettingManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceLevelClusterSettingManager.java b/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceLevelClusterSettingManager.java
new file mode 100644
index 0000000..4cb6cd9
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceLevelClusterSettingManager.java
@@ -0,0 +1,168 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.resources;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.xml.namespace.QName;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.stack.ConfigurationInfo;
+import org.apache.ambari.server.stack.ConfigurationModule;
+import org.apache.ambari.server.stack.ModuleFileUnmarshaller;
+import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.stack.ConfigurationXml;
+import org.apache.ambari.server.utils.XmlUtils;
+import org.apache.commons.io.FileUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+
+public class ResourceLevelClusterSettingManager {
+  /**
+   * Used to unmarshal a configuration file to an object representation
+   */
+  private static ModuleFileUnmarshaller unmarshaller = new ModuleFileUnmarshaller();
+
+  private String clusterSettingsPath;
+  private static final String CLUSTER_SETTINGS_FILE_NAME = "cluster-settings.xml";
+  private static final String clusterSettingsConfigType = "cluster-settings";
+  private static File clusterSettingsFile;
+  private final static Logger LOG = LoggerFactory.getLogger(ResourceLevelClusterSettingManager.class);
+  private Map<String, Map<String, PropertyInfo>> clusterSettingsMap = new ConcurrentHashMap<>();
+  private Map<String, ConfigurationModule> configurationModules = new HashMap<>();
+
+  @AssistedInject
+  public ResourceLevelClusterSettingManager(@Assisted("resourcesDirPath") String resourcesDirPath) {
+    clusterSettingsPath = resourcesDirPath;
+    clusterSettingsFile = new File(clusterSettingsPath + File.separator + CLUSTER_SETTINGS_FILE_NAME);
+    populateClusterSettingsXml();
+  }
+
+  public Collection<PropertyInfo> getClusterSettingsMap() {
+    return configurationModules.get("cluster-settings").getModuleInfo().getProperties();
+  }
+
+  /**
+   * Obtain a collection of of configuration modules representing each configuration
+   * file contained in this configuration directory.
+   *
+   * @return collection of configuration modules
+   */
+  public Collection<ConfigurationModule> getConfigurationModules() {
+    return configurationModules.values();
+  }
+
+  /**
+   * Parses 'cluster-settings.xml' during ambari-server boostrap and (re)start
+   * Reads from /var/lib/ambari-server/resources
+   *
+   * @throws java.io.IOException
+   */
+  private void populateClusterSettingsXml() {
+    ConfigurationXml config = null;
+    try {
+      config = unmarshaller.unmarshal(ConfigurationXml.class, clusterSettingsFile);
+      ConfigurationInfo configInfo = new ConfigurationInfo(parseProperties(config, clusterSettingsFile.getName()),
+              parseAttributes(config));
+      ConfigurationModule module = new ConfigurationModule(clusterSettingsConfigType, configInfo);
+      configurationModules.put(clusterSettingsConfigType, module);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+
+  }
+
+  /**
+   * Parse a configurations type attributes.
+   *
+   * @param configuration object representation of a configuration file
+   * @return collection of attributes for the configuration type
+   */
+  private Map<String, String> parseAttributes(ConfigurationXml configuration) {
+    Map<String, String> attributes = new HashMap<>();
+    for (Map.Entry<QName, String> attribute : configuration.getAttributes().entrySet()) {
+      attributes.put(attribute.getKey().getLocalPart(), attribute.getValue());
+    }
+    return attributes;
+  }
+
+  /**
+   * Parse a configurations properties.
+   *
+   * @param configuration object representation of a configuration file
+   * @param fileName      configuration file name
+   * @return collection of properties
+   */
+  private Collection<PropertyInfo> parseProperties(ConfigurationXml configuration, String fileName)
+          throws FileNotFoundException, RuntimeException {
+    List<PropertyInfo> props = new ArrayList<>();
+    for (PropertyInfo pi : configuration.getProperties()) {
+      pi.setFilename(fileName);
+      if (pi.getPropertyTypes().contains(PropertyInfo.PropertyType.VALUE_FROM_PROPERTY_FILE)) {
+        if (clusterSettingsPath != null || clusterSettingsPath.isEmpty()) {
+          String propertyFileType = pi.getPropertyValueAttributes().getPropertyFileType();
+          if (clusterSettingsFile.exists() && clusterSettingsFile.isFile()) {
+            try {
+              String propertyValue = FileUtils.readFileToString(clusterSettingsFile);
+              boolean valid = true;
+              switch (propertyFileType.toLowerCase()) {
+                case "xml":
+                  if (!XmlUtils.isValidXml(propertyValue)) {
+                    valid = false;
+                    LOG.error("Failed to load value from property file. Property file {} is not a valid XML file",
+                            clusterSettingsFile);
+                  }
+                  break;
+                case "json": // Not supporting JSON as of now.
+                case "text": // fallthrough
+                default:
+                  throw new AmbariException("'" + propertyFileType + "' type file not supported for '"
+                          + clusterSettingsConfigType + "'. File Path : " + clusterSettingsFile.getAbsolutePath());
+              }
+              if (valid) {
+                pi.setValue(propertyValue);
+              }
+            } catch (IOException e) {
+              LOG.error("Failed to load value from property file {}. Error Message {}",
+                      clusterSettingsFile.getAbsolutePath(), e.getMessage());
+            }
+          } else {
+            throw new FileNotFoundException("Failed to find '" + CLUSTER_SETTINGS_FILE_NAME + "' file with path : "
+                    + clusterSettingsFile);
+          }
+        } else {
+          throw new RuntimeException("Failed to load value from property file. Properties directory {} does not exist"
+                  + clusterSettingsFile.getAbsolutePath());
+        }
+      }
+      props.add(pi);
+    }
+    return props;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceLevelClusterSettingManagerFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceLevelClusterSettingManagerFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceLevelClusterSettingManagerFactory.java
new file mode 100644
index 0000000..fcda654
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/resources/ResourceLevelClusterSettingManagerFactory.java
@@ -0,0 +1,34 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.resources;
+
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+
+/**
+ * The {@link ResourceLevelClusterSettingManagerFactory} is used along with {@link AssistedInject} to
+ * build instances of {@link ResourceLevelClusterSettingManager}.
+ */
+public interface ResourceLevelClusterSettingManagerFactory {
+
+  /**
+   * @return a ResourceLevelClusterSetting manager instance.
+   */
+  ResourceLevelClusterSettingManager create(@Assisted("resourcesDirPath") String resourcesDirPath);
+}
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/8d8c1a55/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 eade914..58b0300 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
@@ -89,6 +89,7 @@ public class ConfigHelper {
   public static final String HIVE_SITE = "hive-site";
   public static final String YARN_SITE = "yarn-site";
   public static final String CLUSTER_ENV = "cluster-env";
+  public static final String CLUSTER_SETTINGS = "cluster-settings";
   public static final String CLUSTER_ENV_ALERT_REPEAT_TOLERANCE = "alerts_repeat_tolerance";
   public static final String CLUSTER_ENV_RETRY_ENABLED = "command_retry_enabled";
   public static final String SERVICE_CHECK_TYPE = "service_check_type";


[23/30] ambari git commit: AMBARI-22283 : Add stack name and version to mpack API (mradhakrishnan)

Posted by mr...@apache.org.
AMBARI-22283 : Add stack name and version to mpack API (mradhakrishnan)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: e1fb736bde1056cbb88d01632bad50906972d648
Parents: 4b96339
Author: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Authored: Tue Oct 24 14:44:07 2017 -0700
Committer: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Committed: Tue Oct 24 14:44:07 2017 -0700

----------------------------------------------------------------------
 .../api/resources/MpackResourceDefinition.java  |   9 ++
 .../StackVersionResourceDefinition.java         |  50 ++++++++
 .../AbstractControllerResourceProvider.java     |   2 +-
 .../internal/MpackResourceProvider.java         |  10 --
 .../internal/StackVersionResourceProvider.java  | 115 ++++++++++++++-----
 5 files changed, 146 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e1fb736b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/MpackResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/MpackResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/MpackResourceDefinition.java
index aaf7fd9..bd9938c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/MpackResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/MpackResourceDefinition.java
@@ -18,8 +18,10 @@
 package org.apache.ambari.server.api.resources;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.ambari.server.api.services.Request;
 import org.apache.ambari.server.api.util.TreeNode;
@@ -56,6 +58,13 @@ public class MpackResourceDefinition extends BaseResourceDefinition {
   }
 
   @Override
+  public Set<SubResourceDefinition> getSubResourceDefinitions() {
+    Set<SubResourceDefinition> setChildren = new HashSet<>();
+    setChildren.add(new SubResourceDefinition(Resource.Type.StackVersion, null, false));
+    return setChildren;
+  }
+
+  @Override
   public List<PostProcessor> getPostProcessors() {
     List<PostProcessor> listProcessors = new ArrayList<>();
     listProcessors.add(new MpackHrefProcessor());

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1fb736b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
index dc05924..d621210 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackVersionResourceDefinition.java
@@ -18,9 +18,15 @@
 
 package org.apache.ambari.server.api.resources;
 
+import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
+import org.apache.ambari.server.api.services.Request;
+import org.apache.ambari.server.api.util.TreeNode;
+import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.spi.Resource;
 
 public class StackVersionResourceDefinition extends BaseResourceDefinition {
@@ -54,4 +60,48 @@ public class StackVersionResourceDefinition extends BaseResourceDefinition {
     return children;
   }
 
+  @Override
+  public List<PostProcessor> getPostProcessors() {
+    List<PostProcessor> listProcessors = new ArrayList<>();
+    listProcessors.add(new StackVersionHrefProcessor());
+    listProcessors.add(new StackVersionPostProcessor());
+    return listProcessors;
+  }
+
+  /**
+   * Post Processing the mpack href when the call comes from stack endpoint to ensure that the
+   * href is a backreference to the mpacks end point
+   */
+  private class StackVersionHrefProcessor extends BaseHrefPostProcessor {
+    @Override
+    public void process(Request request, TreeNode<Resource> resultNode, String href) {
+      if (href.contains("/mpacks/")) {
+        ResourceImpl mpack = (ResourceImpl) resultNode.getObject();
+        Map<String, Map<String, Object>> mapInfo = mpack.getPropertiesMap();
+        Map<String, Object> versionInfo = mapInfo.get("Versions");
+
+        int idx = href.indexOf("mpacks/");
+        String stackName = (String)versionInfo.get("stack_name");
+        String stackVersion = (String)versionInfo.get("stack_version");
+        href = href.substring(0, idx) + "stacks/" + stackName + "/versions/" + stackVersion;
+        resultNode.setProperty("href", href);
+      } else {
+        super.process(request, resultNode, href);
+      }
+    }
+  }
+
+  /***
+   * Post processing to change the name of the result node to current_mpack
+   */
+  private class StackVersionPostProcessor implements PostProcessor {
+    @Override
+    public void process(Request request, TreeNode<Resource> resultNode, String href) {
+      if (href.contains("/mpacks/")) {
+        resultNode.setName("stack");
+
+      }
+    }
+  }
+
  }

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1fb736b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
index b8c1674..afca803 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
@@ -199,7 +199,7 @@ public abstract class AbstractControllerResourceProvider extends AbstractAuthori
       case RootClusterSetting:
         return new RootClusterSettingsResourceProvider(managementController);
       case StackVersion:
-        return new StackVersionResourceProvider(propertyIds, keyPropertyIds, managementController);
+        return new StackVersionResourceProvider(managementController);
       case ClusterStackVersion:
         return resourceProviderFactory.getClusterStackVersionResourceProvider(managementController);
       case HostStackVersion:

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1fb736b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
index c72ae1b..84babef 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
@@ -144,16 +144,12 @@ public class MpackResourceProvider extends AbstractControllerResourceProvider {
       MpackResponse response = getManagementController().registerMpack(mpackRequest);
       if (response != null) {
         notifyCreate(Resource.Type.Mpack, request);
-        String[] stackNameVersion = response.getStackId().split("-");
         Resource resource = new ResourceImpl(Resource.Type.Mpack);
         resource.setProperty(MPACK_ID, response.getMpackId());
         resource.setProperty(REGISTRY_ID, response.getRegistryId());
         resource.setProperty(MPACK_NAME, response.getMpackName());
         resource.setProperty(MPACK_VERSION, response.getMpackVersion());
         resource.setProperty(MPACK_URI, response.getMpackUri());
-        resource.setProperty(STACK_NAME_PROPERTY_ID, stackNameVersion[0]);
-        resource.setProperty(STACK_VERSION_PROPERTY_ID, stackNameVersion[1]);
-
         associatedResources.add(resource);
         return getRequestStatus(null, associatedResources);
       }
@@ -255,9 +251,6 @@ public class MpackResourceProvider extends AbstractControllerResourceProvider {
         resource.setProperty(MPACK_VERSION, entity.getMpackVersion());
         resource.setProperty(MPACK_URI, entity.getMpackUri());
         resource.setProperty(REGISTRY_ID, entity.getRegistryId());
-        StackEntity stackEntity = stackDAO.findByMpack(entity.getMpackId());
-        resource.setProperty(STACK_NAME_PROPERTY_ID, stackEntity.getStackName());
-        resource.setProperty(STACK_VERSION_PROPERTY_ID, stackEntity.getStackVersion());
         results.add(resource);
       }
     } else {
@@ -296,9 +289,6 @@ public class MpackResourceProvider extends AbstractControllerResourceProvider {
           resource.setProperty(MPACK_VERSION, entity.getMpackVersion());
           resource.setProperty(MPACK_URI, entity.getMpackUri());
           resource.setProperty(REGISTRY_ID, entity.getRegistryId());
-          StackEntity stackEntity = stackDAO.findByMpack(entity.getMpackId());
-          resource.setProperty(STACK_NAME_PROPERTY_ID, stackEntity.getStackName());
-          resource.setProperty(STACK_VERSION_PROPERTY_ID, stackEntity.getStackVersion());
           List<Packlet> packlets = getManagementController().getPacklets(entity.getMpackId());
           resource.setProperty(PACKLETS, packlets);
           results.add(resource);

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1fb736b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
index 094c75b..0633628 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
@@ -21,6 +21,7 @@ package org.apache.ambari.server.controller.internal;
 
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -35,49 +36,104 @@ import org.apache.ambari.server.controller.spi.NoSuchResourceException;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.Resource.Type;
 import org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PredicateHelper;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.orm.dao.StackDAO;
+import org.apache.ambari.server.orm.entities.StackEntity;
+
+import com.google.inject.Inject;
 
 @StaticallyInject
 public class StackVersionResourceProvider extends ReadOnlyResourceProvider {
-
-  public static final String STACK_VERSION_PROPERTY_ID     = PropertyHelper.getPropertyId("Versions", "stack_version");
-  public static final String STACK_NAME_PROPERTY_ID        = PropertyHelper.getPropertyId("Versions", "stack_name");
-  public static final String STACK_MIN_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("Versions", "min_upgrade_version");
-  public static final String STACK_ACTIVE_PROPERTY_ID      = PropertyHelper.getPropertyId("Versions", "active");
-  public static final String STACK_VALID_PROPERTY_ID      = PropertyHelper.getPropertyId("Versions", "valid");
-  public static final String STACK_ERROR_SET      = PropertyHelper.getPropertyId("Versions", "stack-errors");
-  public static final String STACK_CONFIG_TYPES            = PropertyHelper.getPropertyId("Versions", "config_types");
-  public static final String STACK_PARENT_PROPERTY_ID      = PropertyHelper.getPropertyId("Versions", "parent_stack_version");
-  public static final String UPGRADE_PACKS_PROPERTY_ID = PropertyHelper.getPropertyId("Versions", "upgrade_packs");
-  public static final String STACK_MIN_JDK     = PropertyHelper.getPropertyId("Versions", "min_jdk");
-  public static final String STACK_MAX_JDK     = PropertyHelper.getPropertyId("Versions", "max_jdk");
+  public static final String RESPONSE_KEY = "Versions";
+  public static final String ALL_PROPERTIES = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "*";
+  public static final String STACK_VERSION_PROPERTY_ID     = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "stack_version";
+  public static final String STACK_NAME_PROPERTY_ID        = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "stack_name";
+  public static final String STACK_MIN_VERSION_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "min_upgrade_version";
+  public static final String STACK_ACTIVE_PROPERTY_ID      = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "active";
+  public static final String STACK_VALID_PROPERTY_ID      = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "valid";
+  public static final String STACK_ERROR_SET      = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP +"stack-errors";
+  public static final String STACK_CONFIG_TYPES            = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "config_types";
+  public static final String STACK_PARENT_PROPERTY_ID      = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "parent_stack_version";
+  public static final String UPGRADE_PACKS_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "upgrade_packs";
+  public static final String STACK_MIN_JDK     = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "min_jdk";
+  public static final String STACK_MAX_JDK     = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "max_jdk";
+  public static final String MPACK_ID     = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "mpack_id";
+
+  public static final Set<String> PROPERTY_IDS = new HashSet<>();
+
+  @Inject
+  protected static StackDAO stackDAO;
 
   private static Set<String> pkPropertyIds = new HashSet<>(
-    Arrays.asList(new String[]{STACK_NAME_PROPERTY_ID, STACK_VERSION_PROPERTY_ID}));
+    Arrays.asList(new String[]{STACK_NAME_PROPERTY_ID, STACK_VERSION_PROPERTY_ID, MPACK_ID}));
+
+  /**
+   * The key property ids for a mpack resource.
+   */
+  public static final Map<Resource.Type, String> KEY_PROPERTY_IDS = new HashMap<>();
+
+  static {
+    // properties
+    PROPERTY_IDS.add(MPACK_ID);
+    PROPERTY_IDS.add(STACK_VERSION_PROPERTY_ID);
+    PROPERTY_IDS.add(STACK_NAME_PROPERTY_ID);
+    PROPERTY_IDS.add(STACK_MIN_VERSION_PROPERTY_ID);
+    PROPERTY_IDS.add(STACK_ACTIVE_PROPERTY_ID);
+    PROPERTY_IDS.add(STACK_VALID_PROPERTY_ID);
+    PROPERTY_IDS.add(STACK_ERROR_SET);
+    PROPERTY_IDS.add(STACK_CONFIG_TYPES);
+    PROPERTY_IDS.add(STACK_PARENT_PROPERTY_ID);
+    PROPERTY_IDS.add(UPGRADE_PACKS_PROPERTY_ID);
+    PROPERTY_IDS.add(STACK_MIN_JDK);
+    PROPERTY_IDS.add(STACK_MAX_JDK);
+
+    // keys
+    KEY_PROPERTY_IDS.put(Resource.Type.Mpack, MPACK_ID);
+    KEY_PROPERTY_IDS.put(Resource.Type.Stack, STACK_NAME_PROPERTY_ID);
+    KEY_PROPERTY_IDS.put(Resource.Type.StackVersion, STACK_VERSION_PROPERTY_ID);
 
-  protected StackVersionResourceProvider(Set<String> propertyIds,
-      Map<Type, String> keyPropertyIds,
-      AmbariManagementController managementController) {
-    super(propertyIds, keyPropertyIds, managementController);
   }
 
+  StackVersionResourceProvider(AmbariManagementController controller) {
+    super(PROPERTY_IDS, KEY_PROPERTY_IDS, controller);
+  }
+
+
   @Override
   public Set<Resource> getResources(Request request, Predicate predicate)
       throws SystemException, UnsupportedPropertyException,
       NoSuchResourceException, NoSuchParentResourceException {
 
     final Set<StackVersionRequest> requests = new HashSet<>();
+    Set<Resource> resources = new HashSet<>();
 
     if (predicate == null) {
       requests.add(getRequest(Collections.emptyMap()));
     } else {
-      for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
-        requests.add(getRequest(propertyMap));
-      }
-    }
+      Map<String, Object> propertyMap = new HashMap<>(PredicateHelper.getProperties(predicate));
+      if (propertyMap.containsKey(MPACK_ID)) {
+        Resource resource = new ResourceImpl(Resource.Type.StackVersion);
+        Long mpackId = Long.valueOf((String) propertyMap.get(MPACK_ID));
+        StackEntity stackEntity = stackDAO.findByMpack(mpackId);
+        requests.add(new StackVersionRequest(stackEntity.getStackName(), stackEntity.getStackVersion()));
+        resource.setProperty(STACK_NAME_PROPERTY_ID,
+                (String)stackEntity.getStackName());
+
+        resource.setProperty(STACK_VERSION_PROPERTY_ID,
+                (String)stackEntity.getStackVersion());
+
+        resource.setProperty(MPACK_ID, mpackId);
+
+        resources.add(resource);
+
+      } else {
+        for (Map<String, Object> propertyMap1:
+             getPropertyMaps(predicate)) {
+          requests.add(getRequest(propertyMap1));
+        }
 
     Set<String> requestedIds = getRequestPropertyIds(request, predicate);
 
@@ -88,7 +144,6 @@ public class StackVersionResourceProvider extends ReadOnlyResourceProvider {
       }
     });
 
-    Set<Resource> resources = new HashSet<>();
 
     for (StackVersionResponse response : responses) {
       Resource resource = new ResourceImpl(Resource.Type.StackVersion);
@@ -107,16 +162,16 @@ public class StackVersionResourceProvider extends ReadOnlyResourceProvider {
 
       setResourceProperty(resource, STACK_VALID_PROPERTY_ID,
           response.isValid(), requestedIds);
-      
+
       setResourceProperty(resource, STACK_ERROR_SET,
           response.getErrors(), requestedIds);
-      
+
       setResourceProperty(resource, STACK_PARENT_PROPERTY_ID,
         response.getParentVersion(), requestedIds);
 
       setResourceProperty(resource, STACK_CONFIG_TYPES,
           response.getConfigTypes(), requestedIds);
-      
+
       setResourceProperty(resource, UPGRADE_PACKS_PROPERTY_ID,
           response.getUpgradePacks(), requestedIds);
 
@@ -126,11 +181,13 @@ public class StackVersionResourceProvider extends ReadOnlyResourceProvider {
       setResourceProperty(resource, STACK_MAX_JDK,
               response.getMaxJdk(), requestedIds);
 
-      resources.add(resource);
+        resources.add(resource);
+      }
+      }
     }
 
-    return resources;
-  }
+      return resources;
+    }
 
   private StackVersionRequest getRequest(Map<String, Object> properties) {
     return new StackVersionRequest(


[19/30] ambari git commit: AMBARI-22283 : Add stack name and version to mpack API (mradhakrishnan)

Posted by mr...@apache.org.
AMBARI-22283 : Add stack name and version to mpack API (mradhakrishnan)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 1c6de7914d6c7417584cd93e506f4e9c2f0d43e5
Parents: 3d8c9b7
Author: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Authored: Sun Oct 22 14:34:34 2017 -0700
Committer: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Committed: Sun Oct 22 14:34:34 2017 -0700

----------------------------------------------------------------------
 .../server/controller/internal/MpackResourceProvider.java | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1c6de791/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
index 2642d10..c72ae1b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/MpackResourceProvider.java
@@ -144,12 +144,15 @@ public class MpackResourceProvider extends AbstractControllerResourceProvider {
       MpackResponse response = getManagementController().registerMpack(mpackRequest);
       if (response != null) {
         notifyCreate(Resource.Type.Mpack, request);
+        String[] stackNameVersion = response.getStackId().split("-");
         Resource resource = new ResourceImpl(Resource.Type.Mpack);
         resource.setProperty(MPACK_ID, response.getMpackId());
         resource.setProperty(REGISTRY_ID, response.getRegistryId());
         resource.setProperty(MPACK_NAME, response.getMpackName());
         resource.setProperty(MPACK_VERSION, response.getMpackVersion());
         resource.setProperty(MPACK_URI, response.getMpackUri());
+        resource.setProperty(STACK_NAME_PROPERTY_ID, stackNameVersion[0]);
+        resource.setProperty(STACK_VERSION_PROPERTY_ID, stackNameVersion[1]);
 
         associatedResources.add(resource);
         return getRequestStatus(null, associatedResources);
@@ -252,6 +255,9 @@ public class MpackResourceProvider extends AbstractControllerResourceProvider {
         resource.setProperty(MPACK_VERSION, entity.getMpackVersion());
         resource.setProperty(MPACK_URI, entity.getMpackUri());
         resource.setProperty(REGISTRY_ID, entity.getRegistryId());
+        StackEntity stackEntity = stackDAO.findByMpack(entity.getMpackId());
+        resource.setProperty(STACK_NAME_PROPERTY_ID, stackEntity.getStackName());
+        resource.setProperty(STACK_VERSION_PROPERTY_ID, stackEntity.getStackVersion());
         results.add(resource);
       }
     } else {
@@ -290,7 +296,9 @@ public class MpackResourceProvider extends AbstractControllerResourceProvider {
           resource.setProperty(MPACK_VERSION, entity.getMpackVersion());
           resource.setProperty(MPACK_URI, entity.getMpackUri());
           resource.setProperty(REGISTRY_ID, entity.getRegistryId());
-
+          StackEntity stackEntity = stackDAO.findByMpack(entity.getMpackId());
+          resource.setProperty(STACK_NAME_PROPERTY_ID, stackEntity.getStackName());
+          resource.setProperty(STACK_VERSION_PROPERTY_ID, stackEntity.getStackVersion());
           List<Packlet> packlets = getManagementController().getPacklets(entity.getMpackId());
           resource.setProperty(PACKLETS, packlets);
           results.add(resource);


[16/30] ambari git commit: AMBARI-22247 : Return display name when requesting mpack info (mradhakrishnan)

Posted by mr...@apache.org.
AMBARI-22247 : Return display name when requesting mpack info (mradhakrishnan)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 5451ba53c69aa115719ef83ff6171787c0fbacdc
Parents: 841cc7e
Author: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Authored: Thu Oct 19 14:13:00 2017 -0700
Committer: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Committed: Thu Oct 19 14:15:23 2017 -0700

----------------------------------------------------------------------
 .../ambari/server/controller/RegistryMpackResponse.java  | 11 ++++++++++-
 .../internal/RegistryMpackResourceProvider.java          |  5 +++++
 .../org/apache/ambari/server/registry/RegistryMpack.java |  6 ++++++
 .../ambari/server/registry/json/JsonRegistryMpack.java   |  6 ++++++
 4 files changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5451ba53/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryMpackResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryMpackResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryMpackResponse.java
index b12a866..1bc9659 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryMpackResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RegistryMpackResponse.java
@@ -27,6 +27,7 @@ import io.swagger.annotations.ApiModelProperty;
 public class RegistryMpackResponse {
   private Long registryId;
   private String mpackName;
+  private String mpackDisplayName;
   private String mpackDescription;
   private String mpackLogoUrl;
 
@@ -34,12 +35,14 @@ public class RegistryMpackResponse {
    * Constructor
    * @param registryId        registry id
    * @param mpackName         mpack name
+   * @param mpackDisplayName      mpack Display Name
    * @param mpackDescription  mpack description
    * @param mpackLogoUrl      mpack logo url
    */
-  public RegistryMpackResponse(Long registryId, String mpackName, String mpackDescription, String mpackLogoUrl) {
+  public RegistryMpackResponse(Long registryId, String mpackName, String mpackDisplayName, String mpackDescription, String mpackLogoUrl) {
     this.registryId = registryId;
     this.mpackName = mpackName;
+    this.mpackDisplayName = mpackDisplayName;
     this.mpackDescription = mpackDescription;
     this.mpackLogoUrl = mpackLogoUrl;
   }
@@ -61,6 +64,12 @@ public class RegistryMpackResponse {
   }
 
   /**
+   * Get mpack summary
+   * @return
+   */
+  public String getMpackDisplayName() {return mpackDisplayName;}
+
+  /**
    * Get mpack description
    * @return mpack description
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/5451ba53/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackResourceProvider.java
index 69d3d63..3e5d896 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackResourceProvider.java
@@ -50,6 +50,7 @@ public class RegistryMpackResourceProvider extends AbstractControllerResourcePro
   public static final String ALL_PROPERTIES = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "*";
   public static final String REGISTRY_ID =  RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP +  "registry_id";
   public static final String REGISTRY_MPACK_NAME = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "mpack_name";
+  public static final String REGISTRY_MPACK_DISPLAY_NAME = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "mpack_display_name";
   public static final String REGISTRY_MPACK_DESC = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "mpack_description";
   public static final String REGISTRY_MPACK_LOGO_URL = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "mpack_logo_url";
 
@@ -70,6 +71,7 @@ public class RegistryMpackResourceProvider extends AbstractControllerResourcePro
     // properties
     PROPERTY_IDS.add(REGISTRY_ID);
     PROPERTY_IDS.add(REGISTRY_MPACK_NAME);
+    PROPERTY_IDS.add(REGISTRY_MPACK_DISPLAY_NAME);
     PROPERTY_IDS.add(REGISTRY_MPACK_DESC);
     PROPERTY_IDS.add(REGISTRY_MPACK_LOGO_URL);
 
@@ -129,6 +131,7 @@ public class RegistryMpackResourceProvider extends AbstractControllerResourcePro
       Resource resource = new ResourceImpl(Resource.Type.RegistryMpack);
       setResourceProperty(resource, REGISTRY_ID, response.getRegistryId(), requestedIds);
       setResourceProperty(resource, REGISTRY_MPACK_NAME, response.getMpackName(), requestedIds);
+      setResourceProperty(resource, REGISTRY_MPACK_DISPLAY_NAME, response.getMpackDisplayName(), requestedIds);
       setResourceProperty(resource, REGISTRY_MPACK_DESC, response.getMpackDescription(), requestedIds);
       setResourceProperty(resource, REGISTRY_MPACK_LOGO_URL, response.getMpackLogoUrl(), requestedIds);
       resources.add(resource);
@@ -182,6 +185,7 @@ public class RegistryMpackResourceProvider extends AbstractControllerResourcePro
         RegistryMpackResponse response = new RegistryMpackResponse(
           registry.getRegistryId(),
           registryMpack.getMpackName(),
+          registryMpack.getSummary(),
           registryMpack.getMpackDescription(),
           registryMpack.getMpackLogoUrl());
         responses.add(response);
@@ -192,6 +196,7 @@ public class RegistryMpackResourceProvider extends AbstractControllerResourcePro
         RegistryMpackResponse response = new RegistryMpackResponse(
           registry.getRegistryId(),
           registryMpack.getMpackName(),
+          registryMpack.getSummary(),
           registryMpack.getMpackDescription(),
           registryMpack.getMpackLogoUrl());
         responses.add(response);

http://git-wip-us.apache.org/repos/asf/ambari/blob/5451ba53/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryMpack.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryMpack.java b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryMpack.java
index dd8004f..d15a146 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryMpack.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/registry/RegistryMpack.java
@@ -32,6 +32,12 @@ public interface RegistryMpack {
   public String getMpackName();
 
   /**
+   * Get mpack display name
+   * @return
+   */
+  public String getMpackDisplayName();
+
+  /**
    * Get mpack description
    * @return
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/5451ba53/ambari-server/src/main/java/org/apache/ambari/server/registry/json/JsonRegistryMpack.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/registry/json/JsonRegistryMpack.java b/ambari-server/src/main/java/org/apache/ambari/server/registry/json/JsonRegistryMpack.java
index 2aac1f0..d58a29d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/registry/json/JsonRegistryMpack.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/registry/json/JsonRegistryMpack.java
@@ -35,6 +35,9 @@ public class JsonRegistryMpack implements RegistryMpack {
   @SerializedName("name")
   private String name;
 
+  @SerializedName("displayName")
+  private String displayName;
+
   @SerializedName("description")
   private String description;
 
@@ -50,6 +53,9 @@ public class JsonRegistryMpack implements RegistryMpack {
   }
 
   @Override
+  public String getMpackDisplayName() {return displayName;}
+
+  @Override
   public String getMpackDescription() {
     return description;
   }


[24/30] ambari git commit: AMBARI-22297 Fix getComponentInfo (benyoka)

Posted by mr...@apache.org.
AMBARI-22297 Fix getComponentInfo  (benyoka)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: c118e515ab1973603362d149d253269c8b7c17a4
Parents: e1fb736
Author: Balazs Bence Sari <be...@apache.org>
Authored: Wed Oct 25 12:00:08 2017 +0200
Committer: Balazs Bence Sari <be...@apache.org>
Committed: Wed Oct 25 12:18:28 2017 +0200

----------------------------------------------------------------------
 .../ambari/server/controller/StackV2.java       | 18 ++++-------
 .../server/controller/StackV2Factory.java       | 34 +++++++++++++++++++-
 2 files changed, 39 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c118e515/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
index 040e604..0b0329c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
@@ -91,6 +91,8 @@ public class StackV2 {
   /** Map of service to set of excluded config types */
   private final Map<String, Set<String>> excludedConfigurationTypes;
 
+  private final Map<String, ComponentInfo> componentInfos;
+
   public StackV2(String name,
            String version,
            String repoVersion,
@@ -101,7 +103,8 @@ public class StackV2 {
            Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations,
            Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations,
            Map<String, Map<String, ConfigProperty>> stackConfigurations,
-           Map<String, Set<String>> excludedConfigurationTypes) {
+           Map<String, Set<String>> excludedConfigurationTypes,
+           Map<String, ComponentInfo> componentInfos) {
     this.name = name;
     this.version = version;
     this.repoVersion = repoVersion;
@@ -128,6 +131,7 @@ public class StackV2 {
     this.requiredServiceConfigurations = requiredServiceConfigurations;
     this.stackConfigurations = stackConfigurations;
     this.excludedConfigurationTypes = excludedConfigurationTypes;
+    this.componentInfos = componentInfos;
   }
 
   /** @return stack name */
@@ -181,17 +185,7 @@ public class StackV2 {
      */
     @Deprecated
     public ComponentInfo getComponentInfo(String component) {
-    ComponentInfo componentInfo = null;
-//    String service = getServiceForComponent(component);
-//    if (service != null) {
-//      try {
-//      componentInfo = controller.getAmbariMetaInfo().getComponent(
-//        getName(), getVersion(), service, component);
-//      } catch (AmbariException e) {
-//      // just return null if component doesn't exist
-//      }
-//    }
-    return componentInfo;
+      return componentInfos.get(component);
     }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/c118e515/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
index ed1bbf8..784b368 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
@@ -18,20 +18,29 @@
 
 package org.apache.ambari.server.controller;
 
+import static java.util.AbstractMap.SimpleImmutableEntry;
+
 import java.util.Collection;
 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 java.util.stream.Collectors;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.orm.entities.StackEntity;
 import org.apache.ambari.server.state.AutoDeployInfo;
+import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.DependencyInfo;
 import org.apache.ambari.server.state.StackId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class StackV2Factory {
+  private final static Logger LOG = LoggerFactory.getLogger(StackV2Factory.class);
+
 
   private AmbariManagementController controller;
 
@@ -64,9 +73,30 @@ public class StackV2Factory {
     //todo: already done for each service
     parseStackConfigurations(stackData);
 
+    getComponentInfos(stackData);
+
     return new StackV2(name, version, stackData.repoVersion /* TODO */, stackData.serviceComponents, stackData.dependencies,
       stackData.dbDependencyInfo, stackData.componentAutoDeployInfo, stackData.serviceConfigurations,
-      stackData.requiredServiceConfigurations, stackData.stackConfigurations, stackData.excludedConfigurationTypes);
+      stackData.requiredServiceConfigurations, stackData.stackConfigurations, stackData.excludedConfigurationTypes,
+      stackData.componentInfos);
+  }
+
+  private void getComponentInfos(StackData stackData) {
+    List<Map.Entry<String, String>> componentServices = stackData.serviceComponents.entrySet().stream().
+      flatMap(e -> e.getValue().stream().map( v -> new SimpleImmutableEntry<>(e.getKey(), v))).
+      collect(Collectors.toList());
+    componentServices.stream().forEach( componentService -> {
+      try {
+        ComponentInfo componentInfo = controller.getAmbariMetaInfo().getComponent(stackData.stackName,
+          stackData.stackVersion, componentService.getKey(), componentService.getValue());
+        if (null != componentInfo) {
+          stackData.componentInfos.put(componentService.getKey(), componentInfo);
+        }
+      } catch (AmbariException e) {
+        LOG.debug("No component info for service: {}, component: {}, stack name: {}, stack version: {}, Exception: {}",
+          componentService.getKey(), componentService.getValue(), stackData.stackName, stackData.stackVersion, e);
+      }
+    });
   }
 
   /**
@@ -172,6 +202,7 @@ public class StackV2Factory {
         stackData.masterComponents.add(componentName);
       }
     }
+
     stackData.serviceComponents.put(service, componentSet);
   }
 
@@ -215,5 +246,6 @@ public class StackV2Factory {
     final Map<String, String> dbDependencyInfo = new HashMap<>();
     final Map<String, Set<String>> excludedConfigurationTypes = new HashMap<>();
     final Map<String, Map<String, StackV2.ConfigProperty>> stackConfigurations = new HashMap<>();
+    final Map<String, ComponentInfo> componentInfos = new HashMap<>();
   }
 }


[17/30] ambari git commit: AMBARI-22247 : Return display name when requesting mpack info (mradhakrishnan) - Addendum

Posted by mr...@apache.org.
AMBARI-22247 : Return display name when requesting mpack info (mradhakrishnan) - Addendum


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 36eff0f3550bc91733124107c1ced5df07eece8b
Parents: 5451ba5
Author: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Authored: Thu Oct 19 15:55:19 2017 -0700
Committer: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Committed: Thu Oct 19 15:55:19 2017 -0700

----------------------------------------------------------------------
 .../controller/internal/RegistryMpackResourceProvider.java       | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/36eff0f3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackResourceProvider.java
index 3e5d896..c0212ea 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackResourceProvider.java
@@ -185,7 +185,7 @@ public class RegistryMpackResourceProvider extends AbstractControllerResourcePro
         RegistryMpackResponse response = new RegistryMpackResponse(
           registry.getRegistryId(),
           registryMpack.getMpackName(),
-          registryMpack.getSummary(),
+          registryMpack.getMpackDisplayName(),
           registryMpack.getMpackDescription(),
           registryMpack.getMpackLogoUrl());
         responses.add(response);
@@ -196,7 +196,7 @@ public class RegistryMpackResourceProvider extends AbstractControllerResourcePro
         RegistryMpackResponse response = new RegistryMpackResponse(
           registry.getRegistryId(),
           registryMpack.getMpackName(),
-          registryMpack.getSummary(),
+          registryMpack.getMpackDisplayName(),
           registryMpack.getMpackDescription(),
           registryMpack.getMpackLogoUrl());
         responses.add(response);


[27/30] ambari git commit: AMBARI-22297 BlueprintV2ResourceProvider, fixes in object model, startup logging fix (benyoka)

Posted by mr...@apache.org.
AMBARI-22297 BlueprintV2ResourceProvider,fixes in object model, startup logging fix (benyoka)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 36013fe43c297b4e170b9eac23f7f0c8c7131f33
Parents: d8406d0
Author: Balazs Bence Sari <be...@apache.org>
Authored: Fri Oct 27 11:05:14 2017 +0200
Committer: Balazs Bence Sari <be...@apache.org>
Committed: Fri Oct 27 14:45:44 2017 +0200

----------------------------------------------------------------------
 .../ambari/server/controller/AmbariServer.java  |   2 +-
 .../internal/BlueprintV2ResourceProvider.java   | 391 +++++++++++++++++++
 .../server/orm/entities/BlueprintV2Entity.java  |  29 --
 .../ambari/server/topology/BlueprintImplV2.java |  10 +
 .../ambari/server/topology/BlueprintV2.java     |   3 +
 .../server/topology/BlueprintV2Factory.java     |  51 ++-
 .../internal/BlueprintResourceProviderTest.java |   5 +-
 .../validators/BlueprintImplV2Test.java         |   7 +-
 8 files changed, 447 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/36013fe4/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 f900452..afe5647 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
@@ -1065,10 +1065,10 @@ public class AmbariServer {
 
   public static void main(String[] args) throws Exception {
     logStartup();
-    Injector injector = Guice.createInjector(new ControllerModule(), new AuditLoggerModule());
 
     AmbariServer server = null;
     try {
+      Injector injector = Guice.createInjector(new ControllerModule(), new AuditLoggerModule());
       LOG.info("Getting the controller");
 
       // check if this instance is the active instance

http://git-wip-us.apache.org/repos/asf/ambari/blob/36013fe4/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintV2ResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintV2ResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintV2ResourceProvider.java
new file mode 100644
index 0000000..ccc9836
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintV2ResourceProvider.java
@@ -0,0 +1,391 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+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 org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.DuplicateResourceException;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.orm.dao.BlueprintV2DAO;
+import org.apache.ambari.server.orm.entities.BlueprintV2Entity;
+import org.apache.ambari.server.topology.BlueprintV2;
+import org.apache.ambari.server.topology.BlueprintV2Factory;
+import org.apache.ambari.server.topology.InvalidTopologyException;
+import org.apache.ambari.server.topology.SecurityConfigurationFactory;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
+import com.google.common.base.Strings;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.SetMultimap;
+
+
+/**
+ * Resource Provider for Blueprint resources.
+ */
+public class BlueprintV2ResourceProvider extends AbstractControllerResourceProvider {
+
+  // ----- Property ID constants ---------------------------------------------
+
+  // Blueprints
+  public static final String BLUEPRINT_NAME_PROPERTY_ID =
+    PropertyHelper.getPropertyId("Blueprints", "blueprint_name");
+
+  public static final String BLUEPRINT_SECURITY_PROPERTY_ID =
+    PropertyHelper.getPropertyId("Blueprints", "security");
+
+  public static final String BLUEPRINTS_PROPERTY_ID = "Blueprints";
+
+  // Host Groups
+  public static final String HOST_GROUP_PROPERTY_ID = "host_groups";
+  public static final String HOST_GROUP_NAME_PROPERTY_ID = "name";
+  public static final String HOST_GROUP_CARDINALITY_PROPERTY_ID = "cardinality";
+
+  // Host Group Components
+  public static final String COMPONENT_PROPERTY_ID ="components";
+  public static final String COMPONENT_NAME_PROPERTY_ID ="name";
+  public static final String COMPONENT_PROVISION_ACTION_PROPERTY_ID = "provision_action";
+
+  // Configurations
+  public static final String CONFIGURATION_PROPERTY_ID = "configurations";
+
+
+  // Setting
+  public static final String SETTING_PROPERTY_ID = "settings";
+  public static final String CLUSTER_SETTING_PROPERTY_ID = "cluster_settings";
+
+  public static final String PROPERTIES_PROPERTY_ID = "properties";
+  public static final String PROPERTIES_ATTRIBUTES_PROPERTY_ID = "properties_attributes";
+  public static final String SCHEMA_IS_NOT_SUPPORTED_MESSAGE =
+    "Configuration format provided in Blueprint is not supported";
+  public static final String REQUEST_BODY_EMPTY_ERROR_MESSAGE =
+    "Request body for Blueprint create request is empty";
+  public static final String CONFIGURATION_LIST_CHECK_ERROR_MESSAGE =
+    "Configurations property must be a List of Maps";
+  public static final String CONFIGURATION_MAP_CHECK_ERROR_MESSAGE =
+    "Configuration elements must be Maps";
+  public static final String CONFIGURATION_MAP_SIZE_CHECK_ERROR_MESSAGE =
+    "Configuration Maps must hold a single configuration type each";
+
+  // Primary Key Fields
+  private static Set<String> pkPropertyIds =
+    new HashSet<>(Arrays.asList(new String[]{
+      BLUEPRINT_NAME_PROPERTY_ID}));
+
+  /**
+   * Used to create Blueprint instances
+   */
+  private static BlueprintV2Factory blueprintFactory;
+
+  /**
+   * Used to create SecurityConfiguration instances
+   */
+  private static SecurityConfigurationFactory securityConfigurationFactory;
+
+  /**
+   * Blueprint Data Access Object
+   */
+  private static BlueprintV2DAO blueprintDAO;
+
+  // ----- Constructors ----------------------------------------------------
+
+  /**
+   * Create a  new resource provider for the given management controller.
+   *
+   * @param propertyIds     the property ids
+   * @param keyPropertyIds  the key property ids
+   * @param controller      management controller
+   */
+  BlueprintV2ResourceProvider(Set<String> propertyIds,
+                            Map<Resource.Type, String> keyPropertyIds,
+                            AmbariManagementController controller) {
+
+    super(propertyIds, keyPropertyIds, controller);
+  }
+
+  /**
+   * Static initialization.
+   *
+   * @param factory   blueprint factory
+   * @param dao       blueprint data access object
+   * @param securityFactory
+   * @param metaInfo
+   */
+  public static void init(BlueprintV2Factory factory, BlueprintV2DAO dao, SecurityConfigurationFactory
+    securityFactory, AmbariMetaInfo metaInfo) {
+    blueprintFactory = factory;
+    blueprintDAO = dao;
+    securityConfigurationFactory = securityFactory;
+    ambariMetaInfo = metaInfo;
+  }
+
+  // ----- ResourceProvider ------------------------------------------------
+
+  @Override
+  protected Set<String> getPKPropertyIds() {
+    return pkPropertyIds;
+  }
+
+  @Override
+  public RequestStatus createResources(Request request)
+    throws SystemException, UnsupportedPropertyException,
+    ResourceAlreadyExistsException, NoSuchParentResourceException {
+
+    for (Map<String, Object> properties : request.getProperties()) {
+      try {
+        createResources(getCreateCommand(properties, request.getRequestInfoProperties()));
+      }catch(IllegalArgumentException e) {
+        LOG.error("Exception while creating blueprint", e);
+        throw e;
+      }
+    }
+    notifyCreate(Resource.Type.Blueprint, request);
+
+    return getRequestStatus(null);
+  }
+
+  @Override
+  //todo: continue to use dao/entity directly or use blueprint factory?
+  public Set<Resource> getResources(Request request, Predicate predicate)
+    throws SystemException, UnsupportedPropertyException,
+    NoSuchResourceException, NoSuchParentResourceException {
+
+    List<BlueprintV2Entity> results = null;
+    boolean applyPredicate = false;
+
+    if (predicate != null) {
+      Set<Map<String, Object>> requestProps = getPropertyMaps(predicate);
+      if (requestProps.size() == 1 ) {
+        String name = (String) requestProps.iterator().next().get(
+          BLUEPRINT_NAME_PROPERTY_ID);
+
+        if (name != null) {
+          BlueprintV2Entity entity = blueprintDAO.findByName(name);
+          results = entity == null ? Collections.emptyList() : Collections.singletonList(entity);
+        }
+      }
+    }
+
+    if (results == null) {
+      applyPredicate = true;
+      results = blueprintDAO.findAll();
+    }
+
+    Set<Resource> resources  = new HashSet<>();
+    for (BlueprintV2Entity entity : results) {
+      Resource resource = toResource(entity, getRequestPropertyIds(request, predicate));
+      if (predicate == null || ! applyPredicate || predicate.evaluate(resource)) {
+        resources.add(resource);
+      }
+    }
+
+    if (predicate != null && resources.isEmpty()) {
+      throw new NoSuchResourceException(
+        "The requested resource doesn't exist: Blueprint not found, " + predicate);
+    }
+
+    return resources;
+  }
+
+  @Override
+  public RequestStatus updateResources(Request request, Predicate predicate)
+    throws SystemException, UnsupportedPropertyException,
+    NoSuchResourceException, NoSuchParentResourceException {
+
+    // no-op, blueprints are immutable.  Service doesn't support PUT so should never get here.
+    return null;
+  }
+
+  @Override
+  public RequestStatus deleteResources(Request request, Predicate predicate)
+    throws SystemException, UnsupportedPropertyException,
+    NoSuchResourceException, NoSuchParentResourceException {
+
+    //TODO (jspeidel): Revisit concurrency control
+    Set<Resource> setResources = getResources(
+      new RequestImpl(null, null, null, null), predicate);
+
+    for (final Resource resource : setResources) {
+      final String blueprintName =
+        (String) resource.getPropertyValue(BLUEPRINT_NAME_PROPERTY_ID);
+
+      LOG.info("Deleting Blueprint, name = " + blueprintName);
+
+      modifyResources(new Command<Void>() {
+        @Override
+        public Void invoke() throws AmbariException {
+          blueprintDAO.removeByName(blueprintName);
+          return null;
+        }
+      });
+    }
+
+    notifyDelete(Resource.Type.Blueprint, predicate);
+    return getRequestStatus(null);
+  }
+
+  /**
+   * Used to get stack metainfo.
+   */
+  private static AmbariMetaInfo ambariMetaInfo;
+
+  // ----- Instance Methods ------------------------------------------------
+
+  /**
+   * Create a resource instance from a blueprint entity.
+   *
+   * @param entity        blueprint entity
+   * @param requestedIds  requested id's
+   *
+   * @return a new resource instance for the given blueprint entity
+   */
+  protected Resource toResource(BlueprintV2Entity entity, Set<String> requestedIds) throws NoSuchResourceException {
+    try {
+      Resource resource = new ResourceImpl(Resource.Type.Blueprint);
+      Map<String, Object> blueprintAsMap = blueprintFactory.convertToMap(entity);
+      if (!requestedIds.isEmpty()) {
+        Map<String, Object> filteredMap = new HashMap<>();
+        applySelectFilters(requestedIds, blueprintAsMap, filteredMap);
+        blueprintAsMap = filteredMap;
+      }
+      blueprintAsMap.entrySet().forEach( entry -> resource.setProperty(entry.getKey(), entry.getValue()) );
+      return resource;
+    }
+    catch (IOException e) {
+      throw new NoSuchResourceException("Cannot convert blueprint entity to resource. name=" + entity.getBlueprintName(), e);
+    }
+  }
+
+  /**
+   * Recursively applies select filters on an input map. Only properties matchig the filters will be preserved.
+   * @param filters list of filters. Each filter is a string that can contain subfilters sepatated by '/'
+   * @param startingMap The map to filter
+   * @param collectingMap The map to put the results to
+   */
+  private void applySelectFilters(Set<String> filters, Map<String, Object> startingMap, Map<String, Object> collectingMap) {
+    // Identify filters that apply to this level and those that will be applied on lower levels of the recursion
+    Splitter splitter = Splitter.on('/').omitEmptyStrings().trimResults();
+    Joiner joiner = Joiner.on('/');
+    SetMultimap<String, String> lowerLevelFilters = HashMultimap.create();
+    List<String> currentLevelFilters = new ArrayList<>();
+    filters.forEach( filter -> {
+      List<String> filterParts = ImmutableList.copyOf(splitter.split(filter));
+      if (filterParts.size() == 1) {
+        currentLevelFilters.add(filter);
+      }
+      else {
+        lowerLevelFilters.put(filterParts.get(0), joiner.join(filterParts.subList(1, filterParts.size())));
+      }
+    });
+    startingMap.entrySet().forEach( entry -> {
+      if (currentLevelFilters.contains(entry.getKey())) {
+        collectingMap.put(entry.getKey(), entry.getValue());
+      }
+      else if (lowerLevelFilters.containsKey(entry.getKey()) && entry.getValue() instanceof Map) {
+        Map<String, Object> lowerLevelCollector = (Map<String, Object>)collectingMap.get(entry.getKey());
+        if (null == lowerLevelCollector) {
+          lowerLevelCollector = new HashMap<>();
+          collectingMap.put(entry.getKey(), lowerLevelCollector);
+        }
+        applySelectFilters(lowerLevelFilters.get(entry.getKey()), (Map<String, Object>)entry.getValue(), lowerLevelCollector);
+      }
+    });
+  }
+
+
+  /**
+   * Create a create command with all properties set.
+   *
+   * @param properties        properties to be applied to blueprint
+   * @param requestInfoProps  request info properties
+   *
+   * @return a new create command
+   */
+  private Command<Void> getCreateCommand(final Map<String, Object> properties, final Map<String, String> requestInfoProps) {
+    return new Command<Void>() {
+      @SuppressWarnings("rawtypes")
+      @Override
+      public Void invoke() throws AmbariException {
+        String rawRequestBody = requestInfoProps.get(Request.REQUEST_INFO_BODY_PROPERTY);
+        Preconditions.checkArgument(!Strings.isNullOrEmpty(rawRequestBody), REQUEST_BODY_EMPTY_ERROR_MESSAGE);
+
+        BlueprintV2 blueprint = null;
+        try {
+          blueprint = blueprintFactory.convertFromJson(rawRequestBody);
+        }
+        catch (IOException e) {
+            throw new AmbariException("Unable to parse blueprint", e);
+        }
+
+        if (blueprintDAO.findByName(blueprint.getName()) != null) {
+          throw new DuplicateResourceException(
+            "Attempted to create a Blueprint which already exists, blueprint_name=" +
+              blueprint.getName());
+        }
+
+        try {
+          blueprint.validateRequiredProperties();
+        } catch (InvalidTopologyException e) {
+          throw new IllegalArgumentException("Blueprint configuration validation failed: " + e.getMessage(), e);
+        }
+
+        String validateTopology =  requestInfoProps.get("validate_topology");
+        if (validateTopology == null || ! validateTopology.equalsIgnoreCase("false")) {
+          try {
+            blueprint.validateTopology();
+          } catch (InvalidTopologyException e) {
+            throw new IllegalArgumentException("Invalid blueprint topology", e);
+          }
+        }
+
+        // TODO: handle security descriptor
+
+        try {
+          BlueprintV2Entity entity = blueprintFactory.convertToEntity(blueprint);
+          blueprintDAO.create(entity);
+        } catch (Exception e) {
+          throw new RuntimeException(e);
+        }
+        return null;
+      }
+    };
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/36013fe4/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintV2Entity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintV2Entity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintV2Entity.java
index 046c2e5..de9bde4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintV2Entity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintV2Entity.java
@@ -24,9 +24,7 @@ import javax.persistence.Entity;
 import javax.persistence.EnumType;
 import javax.persistence.Enumerated;
 import javax.persistence.Id;
-import javax.persistence.JoinColumn;
 import javax.persistence.NamedQuery;
-import javax.persistence.OneToOne;
 import javax.persistence.Table;
 
 import org.apache.ambari.server.state.SecurityType;
@@ -58,33 +56,6 @@ public class BlueprintV2Entity {
   @Column(name = "content", nullable = false, insertable = true, updatable = true)
   private String content;
 
-  /**
-   * Unidirectional one-to-one association to {@link StackEntity}
-   */
-  @OneToOne
-  @JoinColumn(name = "stack_id", unique = false, nullable = false, insertable = true, updatable = false)
-  private StackEntity stack;
-
-  /**
-   * Gets the blueprint's stack.
-   *
-   * @return the stack.
-   */
-  public StackEntity getStack() {
-    return stack;
-  }
-
-  /**
-   * Sets the blueprint's stack.
-   *
-   * @param stack
-   *          the stack to set for the blueprint (not {@code null}).
-   */
-  public void setStack(StackEntity stack) {
-    this.stack = stack;
-  }
-
-
   public String getBlueprintName() {
     return blueprintName;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/36013fe4/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
index 356a72e..f7ee730 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
@@ -308,6 +308,16 @@ public class BlueprintImplV2 implements BlueprintV2 {
     return this.securityConfiguration;
   }
 
+  @Override
+  public void validateRequiredProperties() throws InvalidTopologyException {
+    // TODO implement
+  }
+
+  @Override
+  public void validateTopology() throws InvalidTopologyException {
+    // TODO implement
+  }
+
 
   @Override
   public boolean isValidConfigType(String configType) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/36013fe4/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
index 3925c4f..9ca0248 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
@@ -228,6 +228,9 @@ public interface BlueprintV2 {
 
   SecurityConfiguration getSecurity();
 
+  void validateRequiredProperties() throws InvalidTopologyException;
+
+  void validateTopology() throws InvalidTopologyException;
 
   /**
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/36013fe4/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
index ddb7cf8..4f6e8e6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
@@ -23,10 +23,10 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
+import java.util.stream.Collectors;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ObjectNotFoundException;
-import org.apache.ambari.server.StackAccessException;
 import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.controller.StackV2Factory;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
@@ -37,6 +37,7 @@ import org.apache.ambari.server.orm.entities.StackEntity;
 import org.apache.ambari.server.stack.NoSuchStackException;
 import org.apache.ambari.server.state.StackId;
 
+import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.core.Version;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
@@ -88,30 +89,50 @@ public class BlueprintV2Factory {
     return convertFromEntity(entity);
   }
 
-  public BlueprintV2 convertFromEntity(BlueprintV2Entity blueprintEntity) throws NoSuchStackException, IOException {
-    BlueprintImplV2 blueprintV2 = createObjectMapper().readValue(blueprintEntity.getContent(), BlueprintImplV2.class);
+  public BlueprintV2 convertFromJson(String json) throws IOException {
+    BlueprintImplV2 blueprintV2 = createObjectMapper().readValue(json, BlueprintImplV2.class);
     blueprintV2.postDeserialization();
-    Map<StackId, StackV2> stacks = new HashMap<>();
-    for (String stackIdString: blueprintV2.getStackIds()) {
-      StackId stackId = new StackId(stackIdString);
-      stacks.put(stackId, parseStack(stackDao.find(stackId)));
-    }
-    blueprintV2.setStacks(stacks);
+    blueprintV2.setStacks(
+      blueprintV2.getStackIds().stream().collect(Collectors.toMap(
+        stackId -> new StackId(stackId),
+        stackId -> parseStack(new StackId(stackId))
+      ))
+    );
     return blueprintV2;
   }
 
+  public BlueprintV2 convertFromEntity(BlueprintV2Entity blueprintEntity) throws IOException {
+    return convertFromJson(blueprintEntity.getContent());
+  }
 
-  private StackV2 parseStack(StackEntity stackEntity) throws NoSuchStackException {
+  public Map<String, Object> convertToMap(BlueprintV2Entity entity) throws IOException {
+    return createObjectMapper().readValue(entity.getContent(), HashMap.class);
+  }
+
+  private StackV2 parseStack(StackId stackId) {
     try {
-      return stackFactory.create(stackEntity.getStackName(), stackEntity.getStackVersion());
-    } catch (StackAccessException e) {
-      throw new NoSuchStackException(stackEntity.getStackName(), stackEntity.getStackVersion());
+      return stackFactory.create(stackId.getStackName(), stackId.getStackVersion());
     } catch (AmbariException e) {
-      //todo:
-      throw new RuntimeException("An error occurred parsing the stack information.", e);
+      throw new IllegalArgumentException(
+        String.format("Unable to parse stack. name=%s, version=%s", stackId.getStackName(), stackId.getStackVersion()),
+        e);
     }
   }
 
+  private StackV2 parseStack(StackEntity stackEntity) {
+    return parseStack(new StackId(stackEntity.getStackName(), stackEntity.getStackVersion()));
+  }
+
+  public BlueprintV2Entity convertToEntity(BlueprintV2 blueprint) throws JsonProcessingException {
+    BlueprintV2Entity entity = new BlueprintV2Entity();
+    String content = createObjectMapper().writeValueAsString(blueprint);
+    entity.setContent(content);
+    entity.setBlueprintName(blueprint.getName());
+    entity.setSecurityType(blueprint.getSecurity().getType());
+    entity.setSecurityDescriptorReference(blueprint.getSecurity().getDescriptorReference());
+    return entity;
+  }
+
   /**
    * Convert a map of properties to a blueprint entity.
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/36013fe4/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java
index f534411..48d6f20 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java
@@ -56,6 +56,7 @@ import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
 import org.apache.ambari.server.controller.spi.NoSuchResourceException;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
@@ -341,8 +342,8 @@ public class BlueprintResourceProviderTest {
     AbstractResourceProviderTest.TestObserver observer = new AbstractResourceProviderTest.TestObserver();
     ((ObservableResourceProvider)provider).addObserver(observer);
 
-    provider.createResources(request);
-
+    RequestStatus resources = provider.createResources(request);
+    System.out.println(resources);
     ResourceProviderEvent lastEvent = observer.getLastEvent();
     assertNotNull(lastEvent);
     assertEquals(Resource.Type.Blueprint, lastEvent.getResourceType());

http://git-wip-us.apache.org/repos/asf/ambari/blob/36013fe4/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
index 3bcf31b..ad2cdbd 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
@@ -59,9 +59,9 @@ public class BlueprintImplV2Test {
     bp.postDeserialization();
     // -- add stack --
     StackV2 hdpCore = new StackV2("HDPCORE", "3.0.0", "3.0.0.0-1", new HashMap<>(), new HashMap<>(), new HashMap<>(),
-      new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>());
+      new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>());
     StackV2 analytics = new StackV2("ANALYTICS", "1.0.0", "1.0.0.0-1", new HashMap<>(), new HashMap<>(), new HashMap<>(),
-      new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>());
+      new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>());
     bp.setStacks(ImmutableMap.of(new StackId("HDPCORE", "3.0.0"), hdpCore, new StackId("ANALYTICS", "1.0.0"), analytics));
     // ---------------
     String bpJson = mapper.writeValueAsString(bp);
@@ -76,5 +76,4 @@ public class BlueprintImplV2Test {
     BlueprintImplV2 bp2 = mapper.readValue(bpJson2, BlueprintImplV2.class);
     System.out.println(bp2);
   }
-
-}
+}
\ No newline at end of file


[13/30] ambari git commit: Blueprint V2 data model (benyoka)

Posted by mr...@apache.org.
Blueprint V2 data model (benyoka)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: f82497d4d5c8d96dbf5629578a0205de0807e422
Parents: 17e4330
Author: Balazs Bence Sari <be...@apache.org>
Authored: Wed Oct 18 17:39:59 2017 +0200
Committer: Sandor Magyari <sm...@hortonworks.com>
Committed: Thu Oct 19 14:30:14 2017 +0200

----------------------------------------------------------------------
 .../ambari/server/controller/StackV2.java       | 605 +++++++++++++++++++
 .../server/controller/StackV2Factory.java       | 219 +++++++
 .../ambari/server/orm/dao/BlueprintV2DAO.java   | 136 +++++
 .../server/orm/entities/BlueprintEntity.java    |   1 -
 .../server/orm/entities/BlueprintV2Entity.java  | 119 ++++
 .../orm/entities/HostGroupComponentEntity.java  |  17 +-
 .../ambari/server/orm/entities/StackEntity.java |  11 +-
 .../ambari/server/topology/BlueprintImplV2.java | 256 +++++++-
 .../ambari/server/topology/BlueprintV2.java     |  55 +-
 .../server/topology/BlueprintV2Factory.java     | 170 ++++++
 .../server/topology/BlueprintValidatorV2.java   |  43 ++
 .../ambari/server/topology/ComponentV2.java     |  88 ++-
 .../ambari/server/topology/Configurable.java    |  40 ++
 .../ambari/server/topology/Configuration.java   |   7 +
 .../ambari/server/topology/HostGroupImpl.java   |   2 -
 .../ambari/server/topology/HostGroupV2.java     |  15 +-
 .../ambari/server/topology/HostGroupV2Impl.java | 124 ++++
 .../server/topology/RepositoryVersion.java      |  71 +++
 .../server/topology/SecurityConfiguration.java  |   7 +-
 .../apache/ambari/server/topology/Service.java  |  85 +--
 .../ambari/server/topology/ServiceGroup.java    |  42 +-
 .../ambari/server/topology/ServiceId.java       |  52 ++
 .../validators/BlueprintImplV2Test.java         |   9 +
 23 files changed, 2034 insertions(+), 140 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
new file mode 100644
index 0000000..8d7de5d
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
@@ -0,0 +1,605 @@
+/*
+ * 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.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.state.AutoDeployInfo;
+import org.apache.ambari.server.state.DependencyInfo;
+import org.apache.ambari.server.state.PropertyDependencyInfo;
+import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.ValueAttributesInfo;
+import org.apache.ambari.server.topology.Cardinality;
+import org.apache.ambari.server.topology.Configuration;
+
+/**
+ * Encapsulates stack information.
+ */
+public class StackV2 {
+
+    /** Stack name */
+    private final String name;
+
+    /** Stack version */
+    private final String version;
+
+    /** Repo version */
+    private final String repoVersion;
+
+    /** Map of service name to components */
+    private final Map<String, Collection<String>> serviceComponents;
+
+    /** Map of component to service */
+    private final Map<String, String> componentService;
+
+    /** Map of component to dependencies */
+    private final Map<String, Collection<DependencyInfo>> dependencies;
+
+    /** Map of dependency to conditional service */
+    private final Map<DependencyInfo, String> dependencyConditionalServiceMap;
+
+    /**
+     * Map of database component name to configuration property which indicates whether
+     * the database in to be managed or if it is an external non-managed instance.
+     * If the value of the config property starts with 'New', the database is determined
+     * to be managed, otherwise it is non-managed.
+     */
+    private final Map<String, String> dbDependencyInfo;
+
+    /** Map of component to required cardinality */
+    private final Map<String, String> cardinalityRequirements = new HashMap<>();
+
+    //todo: instead of all these maps from component -> * ,
+    //todo: we should use a Component object with all of these attributes
+    private Set<String> masterComponents = new HashSet<>();
+
+    /** Map of component to auto-deploy information */
+    private final Map<String, AutoDeployInfo> componentAutoDeployInfo;
+
+    /** Map of service to config type properties */
+    private final Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations;
+
+    /** Map of service to required type properties */
+    private final Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations;
+
+    /** Map of service to config type properties */
+    private final Map<String, Map<String, ConfigProperty>> stackConfigurations;
+
+    /** Map of service to set of excluded config types */
+    private final Map<String, Set<String>> excludedConfigurationTypes;
+
+    public StackV2(String name,
+                   String version,
+                   String repoVersion,
+                   Map<String, Collection<String>> serviceComponents,
+                   Map<String, Collection<DependencyInfo>> dependencies,
+                   Map<String, String> dbDependencyInfo,
+                   Map<String, AutoDeployInfo> componentAutoDeployInfo,
+                   Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations,
+                   Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations,
+                   Map<String, Map<String, ConfigProperty>> stackConfigurations,
+                   Map<String, Set<String>> excludedConfigurationTypes) {
+        this.name = name;
+        this.version = version;
+        this.repoVersion = repoVersion;
+
+        this.serviceComponents = serviceComponents;
+        this.componentService = new HashMap<>();
+        for (Map.Entry<String, Collection<String>> entry: serviceComponents.entrySet()) {
+            for (String comp: entry.getValue()) {
+                componentService.put(comp, entry.getKey());
+            }
+        }
+
+        this.dependencies = dependencies;
+        this.dependencyConditionalServiceMap = new HashMap<>();
+        for (Map.Entry<String, Collection<DependencyInfo>> entry: dependencies.entrySet()) {
+            for (DependencyInfo di: entry.getValue()) {
+                dependencyConditionalServiceMap.put(di, entry.getKey());
+            }
+        }
+
+        this.dbDependencyInfo = dbDependencyInfo;
+        this.componentAutoDeployInfo = componentAutoDeployInfo;
+        this.serviceConfigurations = serviceConfigurations;
+        this.requiredServiceConfigurations = requiredServiceConfigurations;
+        this.stackConfigurations = stackConfigurations;
+        this.excludedConfigurationTypes = excludedConfigurationTypes;
+    }
+
+    /** @return stack name */
+    public String getName() {
+        return name;
+    }
+
+    /** @return stack version */
+    public String getVersion() {
+        return version;
+    }
+
+    /** @return repo version */
+    public String getRepoVersion() { return repoVersion; }
+
+    Map<DependencyInfo, String> getDependencyConditionalServiceMap() {
+        return dependencyConditionalServiceMap;
+    }
+
+    /** @return collection of all services for the stack */
+    public Collection<String> getServices() {
+        return serviceComponents.keySet();
+    }
+
+    /**
+     * Get components contained in the stack for the specified service.
+     *
+     * @param service  service name
+     * @return collection of component names for the specified service
+     */
+    public Collection<String> getComponents(String service) {
+        return serviceComponents.get(service);
+    }
+
+    /** @return map of service to associated components */
+    public Map<String, Collection<String>> getComponents() {
+        return serviceComponents;
+    }
+
+//  /**
+//   * Get info for the specified component.
+//   *
+//   * @param component  component name
+//   *
+//   * @return component information for the requested component
+//   *         or null if the component doesn't exist in the stack
+//   */
+//  @Deprecated
+//  public ComponentInfo getComponentInfo(String component) {
+//    ComponentInfo componentInfo = null;
+//    String service = getServiceForComponent(component);
+//    if (service != null) {
+//      try {
+//        componentInfo = controller.getAmbariMetaInfo().getComponent(
+//            getName(), getVersion(), service, component);
+//      } catch (AmbariException e) {
+//        // just return null if component doesn't exist
+//      }
+//    }
+//    return componentInfo;
+//  }
+
+    /**
+     * Get all configuration types, including excluded types for the specified service.
+     *
+     * @param service  service name
+     *
+     * @return collection of all configuration types for the specified service
+     */
+    public Collection<String> getAllConfigurationTypes(String service) {
+        return serviceConfigurations.get(service).keySet();
+    }
+
+    /**
+     * Get configuration types for the specified service.
+     * This doesn't include any service excluded types.
+     *
+     * @param service  service name
+     *
+     * @return collection of all configuration types for the specified service
+     */
+    public Collection<String> getConfigurationTypes(String service) {
+        Set<String> serviceTypes = new HashSet<>(serviceConfigurations.get(service).keySet());
+        serviceTypes.removeAll(getExcludedConfigurationTypes(service));
+        return serviceTypes;
+    }
+
+    /**
+     * Get the set of excluded configuration types for this service.
+     *
+     * @param service service name
+     *
+     * @return Set of names of excluded config types. Will not return null.
+     */
+    public Set<String> getExcludedConfigurationTypes(String service) {
+        return excludedConfigurationTypes.containsKey(service) ?
+                excludedConfigurationTypes.get(service) :
+                Collections.emptySet();
+    }
+
+    /**
+     * Get config properties for the specified service and configuration type.
+     *
+     * @param service  service name
+     * @param type     configuration type
+     *
+     * @return map of property names to values for the specified service and configuration type
+     */
+    public Map<String, String> getConfigurationProperties(String service, String type) {
+        Map<String, String> configMap = new HashMap<>();
+        Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
+        if (configProperties != null) {
+            for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+                configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
+            }
+        }
+        return configMap;
+    }
+
+    public Map<String, ConfigProperty> getConfigurationPropertiesWithMetadata(String service, String type) {
+        return serviceConfigurations.get(service).get(type);
+    }
+
+    /**
+     * Get all required config properties for the specified service.
+     *
+     * @param service  service name
+     *
+     * @return collection of all required properties for the given service
+     */
+    public Collection<ConfigProperty> getRequiredConfigurationProperties(String service) {
+        Collection<ConfigProperty> requiredConfigProperties = new HashSet<>();
+        Map<String, Map<String, ConfigProperty>> serviceProperties = requiredServiceConfigurations.get(service);
+        if (serviceProperties != null) {
+            for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : serviceProperties.entrySet()) {
+                requiredConfigProperties.addAll(typePropertiesEntry.getValue().values());
+            }
+        }
+        return requiredConfigProperties;
+    }
+
+    /**
+     * Get required config properties for the specified service which belong to the specified property type.
+     *
+     * @param service       service name
+     * @param propertyType  property type
+     *
+     * @return collection of required properties for the given service and property type
+     */
+    public Collection<ConfigProperty> getRequiredConfigurationProperties(String service, PropertyInfo.PropertyType propertyType) {
+        Collection<ConfigProperty> matchingProperties = new HashSet<>();
+        Map<String, Map<String, ConfigProperty>> requiredProperties = requiredServiceConfigurations.get(service);
+        if (requiredProperties != null) {
+            for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : requiredProperties.entrySet()) {
+                for (ConfigProperty configProperty : typePropertiesEntry.getValue().values()) {
+                    if (configProperty.getPropertyTypes().contains(propertyType)) {
+                        matchingProperties.add(configProperty);
+                    }
+                }
+            }
+        }
+        return matchingProperties;
+    }
+
+    public boolean isPasswordProperty(String service, String type, String propertyName) {
+        return (serviceConfigurations.containsKey(service) &&
+                serviceConfigurations.get(service).containsKey(type) &&
+                serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
+                serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
+                        contains(PropertyInfo.PropertyType.PASSWORD));
+    }
+
+    //todo
+    public Map<String, String> getStackConfigurationProperties(String type) {
+        Map<String, String> configMap = new HashMap<>();
+        Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
+        if (configProperties != null) {
+            for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+                configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
+            }
+        }
+        return configMap;
+    }
+
+    public boolean isKerberosPrincipalNameProperty(String service, String type, String propertyName) {
+        return (serviceConfigurations.containsKey(service) &&
+                serviceConfigurations.get(service).containsKey(type) &&
+                serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
+                serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
+                        contains(PropertyInfo.PropertyType.KERBEROS_PRINCIPAL));
+    }
+    /**
+     * Get config attributes for the specified service and configuration type.
+     *
+     * @param service  service name
+     * @param type     configuration type
+     *
+     * @return  map of attribute names to map of property names to attribute values
+     *          for the specified service and configuration type
+     */
+    public Map<String, Map<String, String>> getConfigurationAttributes(String service, String type) {
+        Map<String, Map<String, String>> attributesMap = new HashMap<>();
+        Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
+        if (configProperties != null) {
+            for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+                String propertyName = configProperty.getKey();
+                Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
+                if (propertyAttributes != null) {
+                    for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
+                        String attributeName = propertyAttribute.getKey();
+                        String attributeValue = propertyAttribute.getValue();
+                        if (attributeValue != null) {
+                            Map<String, String> attributes = getWithEmptyDefault(attributesMap, attributeName);
+                            attributes.put(propertyName, attributeValue);
+                        }
+                    }
+                }
+            }
+        }
+        return attributesMap;
+    }
+
+    //todo:
+    public Map<String, Map<String, String>> getStackConfigurationAttributes(String type) {
+        Map<String, Map<String, String>> attributesMap = new HashMap<>();
+        Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
+        if (configProperties != null) {
+            for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+                String propertyName = configProperty.getKey();
+                Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
+                if (propertyAttributes != null) {
+                    for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
+                        String attributeName = propertyAttribute.getKey();
+                        String attributeValue = propertyAttribute.getValue();
+                        Map<String, String> attributes = getWithEmptyDefault(attributesMap, attributeName);
+                        attributes.put(propertyName, attributeValue);
+                    }
+                }
+            }
+        }
+        return attributesMap;
+    }
+
+    /**
+     * Get the service for the specified component.
+     *
+     * @param component  component name
+     *
+     * @return service name that contains tha specified component
+     */
+    public String getServiceForComponent(String component) {
+        return componentService.get(component);
+    }
+
+    /**
+     * Get the names of the services which contains the specified components.
+     *
+     * @param components collection of components
+     *
+     * @return collection of services which contain the specified components
+     */
+    public Collection<String> getServicesForComponents(Collection<String> components) {
+        Set<String> services = new HashSet<>();
+        for (String component : components) {
+            services.add(getServiceForComponent(component));
+        }
+
+        return services;
+    }
+
+    /**
+     * Obtain the service name which corresponds to the specified configuration.
+     *
+     * @param config  configuration type
+     *
+     * @return name of service which corresponds to the specified configuration type
+     */
+    public String getServiceForConfigType(String config) {
+        for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) {
+            Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue();
+            String serviceName = entry.getKey();
+            if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) {
+                return serviceName;
+            }
+        }
+        throw new IllegalArgumentException(
+                "Specified configuration type is not associated with any service: " + config);
+    }
+
+    /**
+     * Return the dependencies specified for the given component.
+     *
+     * @param component  component to get dependency information for
+     *
+     * @return collection of dependency information for the specified component
+     */
+    //todo: full dependency graph
+    public Collection<DependencyInfo> getDependenciesForComponent(String component) {
+        return dependencies.containsKey(component) ? dependencies.get(component) :
+                Collections.emptySet();
+    }
+
+    /**
+     * Get the service, if any, that a component dependency is conditional on.
+     *
+     * @param dependency  dependency to get conditional service for
+     *
+     * @return conditional service for provided component or null if dependency
+     *         is not conditional on a service
+     */
+    public String getConditionalServiceForDependency(DependencyInfo dependency) {
+        return dependencyConditionalServiceMap.get(dependency);
+    }
+
+    public String getExternalComponentConfig(String component) {
+        return dbDependencyInfo.get(component);
+    }
+
+    /**
+     * Obtain the required cardinality for the specified component.
+     */
+    public Cardinality getCardinality(String component) {
+        return new Cardinality(cardinalityRequirements.get(component));
+    }
+
+    /**
+     * Obtain auto-deploy information for the specified component.
+     */
+    public AutoDeployInfo getAutoDeployInfo(String component) {
+        return componentAutoDeployInfo.get(component);
+    }
+
+    public boolean isMasterComponent(String component) {
+        return masterComponents.contains(component);
+    }
+
+    public Configuration getConfiguration(Collection<String> services) {
+        Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>();
+        Map<String, Map<String, String>> properties = new HashMap<>();
+
+        for (String service : services) {
+            Collection<String> serviceConfigTypes = getConfigurationTypes(service);
+            for (String type : serviceConfigTypes) {
+                Map<String, String> typeProps = getWithEmptyDefault(properties, type);
+                typeProps.putAll(getConfigurationProperties(service, type));
+
+                Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
+                if (!stackTypeAttributes.isEmpty()) {
+                    if (! attributes.containsKey(type)) {
+                        attributes.put(type, new HashMap<>());
+                    }
+                    Map<String, Map<String, String>> typeAttributes = attributes.get(type);
+                    for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
+                        String attributeName = attribute.getKey();
+                        Map<String, String> attributeProps = getWithEmptyDefault(typeAttributes, attributeName);
+                        attributeProps.putAll(attribute.getValue());
+                    }
+                }
+            }
+        }
+        return new Configuration(properties, attributes);
+    }
+
+    public Configuration getConfiguration() {
+        Map<String, Map<String, Map<String, String>>> stackAttributes = new HashMap<>();
+        Map<String, Map<String, String>> stackConfigs = new HashMap<>();
+
+        for (String service : getServices()) {
+            for (String type : getAllConfigurationTypes(service)) {
+                Map<String, String> typeProps = getWithEmptyDefault(stackConfigs, type);
+                typeProps.putAll(getConfigurationProperties(service, type));
+
+                Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
+                if (!stackTypeAttributes.isEmpty()) {
+                    if (! stackAttributes.containsKey(type)) {
+                        stackAttributes.put(type, new HashMap<>());
+                    }
+                    Map<String, Map<String, String>> typeAttrs = stackAttributes.get(type);
+                    for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
+                        String attributeName = attribute.getKey();
+                        Map<String, String> attributes = getWithEmptyDefault(typeAttrs, attributeName);
+                        attributes.putAll(attribute.getValue());
+                    }
+                }
+            }
+        }
+        return new Configuration(stackConfigs, stackAttributes);
+    }
+
+    static <OK, IK, IV> Map<IK, IV> getWithEmptyDefault(Map<OK, Map<IK, IV>> outerMap, OK outerKey) {
+        Map<IK, IV> innerMap = outerMap.get(outerKey);
+        if (null == innerMap) {
+            innerMap = new HashMap<>();
+            outerMap.put(outerKey, innerMap);
+        }
+        return innerMap;
+    }
+
+
+    /**
+     * Contains a configuration property's value and attributes.
+     */
+    public static class ConfigProperty {
+        private ValueAttributesInfo propertyValueAttributes = null;
+        private String name;
+        private String value;
+        private Map<String, String> attributes;
+        private Set<PropertyInfo.PropertyType> propertyTypes;
+        private String type;
+        private Set<PropertyDependencyInfo> dependsOnProperties =
+                Collections.emptySet();
+
+        public ConfigProperty(ReadOnlyConfigurationResponse config) {
+            this.name = config.getPropertyName();
+            this.value = config.getPropertyValue();
+            this.attributes = config.getPropertyAttributes();
+            this.propertyTypes = config.getPropertyType();
+            this.type = normalizeType(config.getType());
+            this.dependsOnProperties = config.getDependsOnProperties();
+            this.propertyValueAttributes = config.getPropertyValueAttributes();
+        }
+
+        public ConfigProperty(String type, String name, String value) {
+            this.type = type;
+            this.name = name;
+            this.value = value;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public String getValue() {
+            return value;
+        }
+
+        public void setValue(String value) {
+            this.value = value;
+        }
+
+        public String getType() {
+            return type;
+        }
+
+        public Set<PropertyInfo.PropertyType> getPropertyTypes() {
+            return propertyTypes;
+        }
+
+        public void setPropertyTypes(Set<PropertyInfo.PropertyType> propertyTypes) {
+            this.propertyTypes = propertyTypes;
+        }
+
+        public Map<String, String> getAttributes() {
+            return attributes;
+        }
+
+        public void setAttributes(Map<String, String> attributes) {
+            this.attributes = attributes;
+        }
+
+        Set<PropertyDependencyInfo> getDependsOnProperties() {
+            return this.dependsOnProperties;
+        }
+
+        private String normalizeType(String type) {
+            //strip .xml from type
+            if (type.endsWith(".xml")) {
+                type = type.substring(0, type.length() - 4);
+            }
+            return type;
+        }
+
+        public ValueAttributesInfo getPropertyValueAttributes() {
+            return propertyValueAttributes;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
new file mode 100644
index 0000000..54e1e62
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
@@ -0,0 +1,219 @@
+/*
+ * 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.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.orm.entities.StackEntity;
+import org.apache.ambari.server.state.AutoDeployInfo;
+import org.apache.ambari.server.state.DependencyInfo;
+import org.apache.ambari.server.state.StackId;
+
+public class StackV2Factory {
+
+  private AmbariManagementController controller;
+
+  public StackV2Factory(AmbariManagementController controller) {
+    this.controller = controller;
+  }
+
+  public StackV2 create(StackEntity stack) throws AmbariException {
+    return create(stack.getStackName(), stack.getStackVersion());
+  }
+
+  public StackV2 create(String stackId) throws AmbariException {
+    StackId id = new StackId(stackId);
+    return create(id.getStackName(), id.getStackVersion());
+  }
+
+  public StackV2 create(String name, String version) throws AmbariException {
+    Set<StackServiceResponse> stackServices = controller.getStackServices(
+      Collections.singleton(new StackServiceRequest(name, version, null)));
+
+    StackData stackData = new StackData(name, version);
+    for (StackServiceResponse stackService : stackServices) {
+      String serviceName = stackService.getServiceName();
+      parseComponents(stackData, serviceName);
+      parseExcludedConfigurations(stackData, stackService);
+      parseConfigurations(stackData, stackService);
+      registerConditionalDependencies(stackData);
+    }
+
+    //todo: already done for each service
+    parseStackConfigurations(stackData);
+
+    return new StackV2(name, version, stackData.repoVersion /* TODO */, stackData.serviceComponents, stackData.dependencies,
+      stackData.dbDependencyInfo, stackData.componentAutoDeployInfo, stackData.serviceConfigurations,
+      stackData.requiredServiceConfigurations, stackData.stackConfigurations, stackData.excludedConfigurationTypes);
+  }
+
+  /**
+   * Parse configurations for the specified service from the stack definition.
+   *
+   * @param stackService  service to parse the stack configuration for
+   *
+   * @throws AmbariException an exception occurred getting configurations from the stack definition
+   */
+  private void parseConfigurations(StackData stackData,
+                                   StackServiceResponse stackService) throws AmbariException {
+    String service = stackService.getServiceName();
+    Map<String, Map<String, StackV2.ConfigProperty>> mapServiceConfig = new HashMap<>();
+    Map<String, Map<String, StackV2.ConfigProperty>> mapRequiredServiceConfig = new HashMap<>();
+
+    stackData.serviceConfigurations.put(service, mapServiceConfig);
+    stackData.requiredServiceConfigurations.put(service, mapRequiredServiceConfig);
+
+    Set<StackConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
+      Collections.singleton(new StackConfigurationRequest(stackData.stackName, stackData.stackVersion, service, null)));
+    Set<StackConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+      Collections.singleton(new StackLevelConfigurationRequest(stackData.stackName, stackData.stackVersion, null)));
+    serviceConfigs.addAll(stackLevelConfigs);
+
+    // shouldn't have any required properties in stack level configuration
+    for (StackConfigurationResponse config : serviceConfigs) {
+      StackV2.ConfigProperty configProperty = new StackV2.ConfigProperty(config);
+      String type = configProperty.getType();
+
+      Map<String, StackV2.ConfigProperty> mapTypeConfig = StackV2.getWithEmptyDefault(mapServiceConfig, type);
+
+      mapTypeConfig.put(config.getPropertyName(), configProperty);
+      if (config.isRequired()) {
+        Map<String, StackV2.ConfigProperty> requiredTypeConfig =
+          StackV2.getWithEmptyDefault(mapRequiredServiceConfig, type);
+        requiredTypeConfig.put(config.getPropertyName(), configProperty);
+      }
+    }
+
+    // So far we added only config types that have properties defined
+    // in stack service definition. Since there might be config types
+    // with no properties defined we need to add those separately
+    Set<String> configTypes = stackService.getConfigTypes().keySet();
+    for (String configType: configTypes) {
+      if (!mapServiceConfig.containsKey(configType)) {
+        mapServiceConfig.put(configType, Collections.emptyMap());
+      }
+    }
+  }
+
+  private void parseStackConfigurations (StackData stackData) throws AmbariException {
+    Set<StackConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+      Collections.singleton(new StackLevelConfigurationRequest(stackData.stackName, stackData.stackVersion, null)));
+
+    for (StackConfigurationResponse config : stackLevelConfigs) {
+      StackV2.ConfigProperty configProperty = new StackV2.ConfigProperty(config);
+      String type = configProperty.getType();
+
+      Map<String, StackV2.ConfigProperty> mapTypeConfig =
+        StackV2.getWithEmptyDefault(stackData.stackConfigurations, type);
+
+      mapTypeConfig.put(config.getPropertyName(),
+        configProperty);
+    }
+  }
+
+  /**
+   * Parse components for the specified service from the stack definition.
+   *
+   * @param service  service name
+   *
+   * @throws AmbariException an exception occurred getting components from the stack definition
+   */
+  private void parseComponents(StackData stackData, String service) throws AmbariException{
+    Collection<String> componentSet = new HashSet<>();
+
+    Set<StackServiceComponentResponse> components = controller.getStackComponents(
+      Collections.singleton(new StackServiceComponentRequest(stackData.stackName, stackData.stackVersion, service, null)));
+
+    // stack service components
+    for (StackServiceComponentResponse component : components) {
+      String componentName = component.getComponentName();
+      componentSet.add(componentName);
+      stackData.componentService.put(componentName, service);
+      String cardinality = component.getCardinality();
+      if (cardinality != null) {
+        stackData.cardinalityRequirements.put(componentName, cardinality);
+      }
+      AutoDeployInfo autoDeploy = component.getAutoDeploy();
+      if (autoDeploy != null) {
+        stackData.componentAutoDeployInfo.put(componentName, autoDeploy);
+      }
+
+      // populate component dependencies
+      //todo: remove usage of AmbariMetaInfo
+      Collection<DependencyInfo> componentDependencies = controller.getAmbariMetaInfo().getComponentDependencies(
+        stackData.stackName, stackData.stackVersion, service, componentName);
+
+      if (componentDependencies != null && ! componentDependencies.isEmpty()) {
+        stackData.dependencies.put(componentName, componentDependencies);
+      }
+      if (component.isMaster()) {
+        stackData.masterComponents.add(componentName);
+      }
+    }
+    stackData.serviceComponents.put(service, componentSet);
+  }
+
+
+  /**
+   * Obtain the excluded configuration types from the StackServiceResponse
+   *
+   * @param stackServiceResponse the response object associated with this stack service
+   */
+  private void parseExcludedConfigurations(StackData stackData, StackServiceResponse stackServiceResponse) {
+    stackData.excludedConfigurationTypes.put(stackServiceResponse.getServiceName(), stackServiceResponse.getExcludedConfigTypes());
+  }
+
+  /**
+   * Register conditional dependencies.
+   */
+  //todo: This information should be specified in the stack definition.
+  void registerConditionalDependencies(StackData stackData) {
+    stackData.dbDependencyInfo.put("MYSQL_SERVER", "global/hive_database");
+  }
+
+
+  private static final class StackData {
+    final String stackName;
+    final String stackVersion;
+
+    public StackData(String stackName, String stackVersion) {
+      this.stackName = stackName;
+      this.stackVersion = stackVersion;
+    }
+
+    String repoVersion;
+    final Map<String, String> componentService = new HashMap<>();
+    final Set<String> masterComponents = new HashSet<>();
+    final Map<String, AutoDeployInfo> componentAutoDeployInfo = new HashMap<>();
+    final Map<String, String> cardinalityRequirements = new HashMap<>();
+    final Map<String, Collection<DependencyInfo>> dependencies = new HashMap<>();
+    final Map<String, Collection<String>> serviceComponents = new HashMap<>();
+    final Map<String, Map<String, Map<String, StackV2.ConfigProperty>>> serviceConfigurations = new HashMap<>();
+    final Map<String, Map<String, Map<String, StackV2.ConfigProperty>>> requiredServiceConfigurations = new HashMap<>();
+    final Map<String, String> dbDependencyInfo = new HashMap<>();
+    final Map<String, Set<String>> excludedConfigurationTypes = new HashMap<>();
+    final Map<String, Map<String, StackV2.ConfigProperty>> stackConfigurations = new HashMap<>();
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java
new file mode 100644
index 0000000..8a21dc1
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java
@@ -0,0 +1,136 @@
+/*
+ * 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.orm.dao;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+
+import org.apache.ambari.server.orm.RequiresSession;
+import org.apache.ambari.server.orm.entities.BlueprintV2Entity;
+import org.apache.ambari.server.orm.entities.StackEntity;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import com.google.inject.persist.Transactional;
+
+/**
+ * Blueprint V2 Data Access Object.
+ */
+@Singleton
+public class BlueprintV2DAO {
+
+  /**
+   * JPA entity manager
+   */
+  @Inject
+  Provider<EntityManager> entityManagerProvider;
+
+  @Inject
+  StackDAO stackDAO;
+
+  /**
+   * Find a blueprint with a given name.
+   *
+   * @param blueprint_name name of blueprint to find
+   *
+   * @return  a matching blueprint or null
+   */
+  @RequiresSession
+  public BlueprintV2Entity findByName(String blueprint_name) {
+    return entityManagerProvider.get().find(BlueprintV2Entity.class, blueprint_name);
+  }
+
+  /**
+   * Find all blueprints.
+   *
+   * @return all blueprints or an empty List
+   */
+  @RequiresSession
+  public List<BlueprintV2Entity> findAll() {
+    TypedQuery<BlueprintV2Entity> query = entityManagerProvider.get().
+      createNamedQuery("allBlueprintsv2", BlueprintV2Entity.class);
+    return query.getResultList();
+  }
+
+  /**
+   * Refresh the state of the instance from the database,
+   * overwriting changes made to the entity, if any.
+   *
+   * @param blueprintEntity  entity to refresh
+   */
+  @Transactional
+  public void refresh(BlueprintV2Entity blueprintEntity) {
+    ensureStackIdSet(blueprintEntity);
+    entityManagerProvider.get().refresh(blueprintEntity);
+  }
+
+  /**
+   * Make an instance managed and persistent.
+   *
+   * @param blueprintEntity  entity to persist
+   */
+  @Transactional
+  public void create(BlueprintV2Entity blueprintEntity) {
+    ensureStackIdSet(blueprintEntity);
+    entityManagerProvider.get().persist(blueprintEntity);
+  }
+
+  /**
+   * Merge the state of the given entity into the current persistence context.
+   *
+   * @param blueprintEntity  entity to merge
+   * @return the merged entity
+   */
+  @Transactional
+  public BlueprintV2Entity merge(BlueprintV2Entity blueprintEntity) {
+    ensureStackIdSet(blueprintEntity);
+    return entityManagerProvider.get().merge(blueprintEntity);
+  }
+
+  /**
+   * Remove the entity instance.
+   *
+   * @param blueprintEntity  entity to remove
+   */
+  @Transactional
+  public void remove(BlueprintV2Entity blueprintEntity) {
+    ensureStackIdSet(blueprintEntity);
+    entityManagerProvider.get().remove(merge(blueprintEntity));
+  }
+
+  /**
+   * Remove entity instance by primary key
+   * @param blueprint_name Primary key: blueprint name
+   */
+  @Transactional
+  public void removeByName(String blueprint_name) {
+    entityManagerProvider.get().remove(findByName(blueprint_name));
+  }
+
+  private void ensureStackIdSet(BlueprintV2Entity entity) {
+    StackEntity stack = entity.getStack();
+    if (stack != null && stack.getStackId() == null) {
+      entity.setStack(stackDAO.find(stack.getStackName(), stack.getStackVersion()));
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintEntity.java
index bab393a..8141f07 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintEntity.java
@@ -75,7 +75,6 @@ public class BlueprintEntity {
   @OneToMany(cascade = CascadeType.ALL, mappedBy = "blueprint")
   private Collection<BlueprintSettingEntity> settings;
 
-
   /**
    * Get the blueprint name.
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintV2Entity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintV2Entity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintV2Entity.java
new file mode 100644
index 0000000..046c2e5
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/BlueprintV2Entity.java
@@ -0,0 +1,119 @@
+/*
+ * 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.orm.entities;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+import org.apache.ambari.server.state.SecurityType;
+
+/**
+ * Entity representing a Blueprint.
+ */
+@Table(name = "blueprintv2")
+@NamedQuery(name = "allBlueprintsv2",
+  query = "SELECT blueprint FROM BlueprintV2Entity blueprint")
+@Entity
+public class BlueprintV2Entity {
+
+  @Id
+  @Column(name = "blueprint_name", nullable = false, insertable = true,
+    updatable = false, unique = true, length = 100)
+  private String blueprintName;
+
+  @Basic
+  @Enumerated(value = EnumType.STRING)
+  @Column(name = "security_type", nullable = false, insertable = true, updatable = true)
+  private SecurityType securityType = SecurityType.NONE;
+
+  @Basic
+  @Column(name = "security_descriptor_reference", nullable = true, insertable = true, updatable = true)
+  private String securityDescriptorReference;
+
+  @Basic
+  @Column(name = "content", nullable = false, insertable = true, updatable = true)
+  private String content;
+
+  /**
+   * Unidirectional one-to-one association to {@link StackEntity}
+   */
+  @OneToOne
+  @JoinColumn(name = "stack_id", unique = false, nullable = false, insertable = true, updatable = false)
+  private StackEntity stack;
+
+  /**
+   * Gets the blueprint's stack.
+   *
+   * @return the stack.
+   */
+  public StackEntity getStack() {
+    return stack;
+  }
+
+  /**
+   * Sets the blueprint's stack.
+   *
+   * @param stack
+   *          the stack to set for the blueprint (not {@code null}).
+   */
+  public void setStack(StackEntity stack) {
+    this.stack = stack;
+  }
+
+
+  public String getBlueprintName() {
+    return blueprintName;
+  }
+
+  public void setBlueprintName(String blueprintName) {
+    this.blueprintName = blueprintName;
+  }
+
+  public SecurityType getSecurityType() {
+    return securityType;
+  }
+
+  public void setSecurityType(SecurityType securityType) {
+    this.securityType = securityType;
+  }
+
+  public String getSecurityDescriptorReference() {
+    return securityDescriptorReference;
+  }
+
+  public void setSecurityDescriptorReference(String securityDescriptorReference) {
+    this.securityDescriptorReference = securityDescriptorReference;
+  }
+
+  public String getContent() {
+    return content;
+  }
+
+  public void setContent(String content) {
+    this.content = content;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntity.java
index 6b75df7..186180b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntity.java
@@ -44,9 +44,22 @@ public class HostGroupComponentEntity {
   private String blueprintName;
 
   @Id
-  @Column(name = "name", nullable = false, insertable = true, updatable = false)
+  @Column(name = "service_group", nullable = true, insertable = true, updatable = false)
+  private String serviceGroup;
+
+  @Id
+  @Column(name = "service_name", nullable = true, insertable = true, updatable = false)
+  private String serviceName;
+
+  @Id
+  @Column(name = "instance_name", nullable = true, insertable = true, updatable = false)
   private String name;
 
+
+  @Id
+  @Column(name = "type", nullable = false, insertable = true, updatable = false)
+  private String type;
+
   @Column(name = "provision_action", nullable = true, insertable = true, updatable = false)
   private String provisionAction;
 
@@ -130,6 +143,8 @@ public class HostGroupComponentEntity {
     this.blueprintName = blueprintName;
   }
 
+
+
   /**
    * Get the provision action associated with this
    *   component.

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StackEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StackEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StackEntity.java
index bee53b6..c479cdd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StackEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StackEntity.java
@@ -60,11 +60,12 @@ public class StackEntity {
   @Column(name = "stack_version", length = 255, nullable = false)
   private String stackVersion;
 
+  @Column(name = "repo_version", length = 255, nullable = false)
+  private String repoVersion;
 
   @Column(name = "current_mpack_id")
   private Long currentMpackId;
 
-
   public Long getCurrentMpackId() {
     return currentMpackId;
   }
@@ -127,6 +128,14 @@ public class StackEntity {
     this.stackVersion = stackVersion;
   }
 
+  public String getRepoVersion() {
+    return repoVersion;
+  }
+
+  public void setRepoVersion(String repoVersion) {
+    this.repoVersion = repoVersion;
+  }
+
   /**
    *
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
index 26dc41d..827fa39 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
@@ -19,102 +19,196 @@
 
 package org.apache.ambari.server.topology;
 
+import java.io.File;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
 import java.util.stream.Collectors;
 
-import org.apache.ambari.server.controller.internal.StackV2;
+import javax.annotation.Nonnull;
+
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.orm.entities.BlueprintEntity;
+import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.state.StackId;
+import org.apache.commons.lang.StringUtils;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.Version;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
+import com.fasterxml.jackson.databind.module.SimpleModule;
 
 /**
  * Blueprint implementation.
  */
 public class BlueprintImplV2 implements BlueprintV2 {
-  public BlueprintImplV2(BlueprintEntity e) {
+
+  private String name;
+  private SecurityConfiguration securityConfiguration;
+  private Collection<RepositoryVersion> repositoryVersions;
+  private Collection<ServiceGroup> serviceGroups;
+  private Collection<? extends HostGroupV2> hostGroups;
+  private Setting setting;
+
+  // Transient fields
+  @JsonIgnore
+  private Map<String, HostGroupV2> hostGroupMap = new HashMap<>();
+
+
+  @JsonIgnore
+  private Map<StackId, StackV2> stacks;
+
+  @JsonIgnore
+  private List<RepositorySetting> repoSettings;
+
+  public void setStacks(Map<StackId, StackV2> stacks) {
+    this.stacks = stacks;
+  }
+
+  @JsonProperty("Blueprints")
+  public void setBlueprints(Blueprints blueprints) {
+    this.name = blueprints.name;
+    this.securityConfiguration = blueprints.securityConfiguration;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public void setSecurityConfiguration(SecurityConfiguration securityConfiguration) {
+    this.securityConfiguration = securityConfiguration;
+  }
+
+  @JsonProperty("repository_versions")
+  public void setRepositoryVersions(Collection<RepositoryVersion> repositoryVersions) {
+    this.repositoryVersions = repositoryVersions;
+  }
+
+  @JsonProperty("service_groups")
+  public void setServiceGroups(Collection<ServiceGroup> serviceGroups) {
+    this.serviceGroups = serviceGroups;
+  }
+
+  @JsonProperty("host_groups")
+  public void setHostGroups(Collection<HostGroupV2Impl> hostGroups) {
+    this.hostGroups = hostGroups;
+    this.hostGroupMap = hostGroups.stream().collect(Collectors.toMap(
+      hg -> hg.getName(),
+      hg -> hg
+    ));
+  }
+
+  @JsonProperty("cluster-settings")
+  public void setClusterSettings(Map<String, Set<HashMap<String, String>>> properties) {
+    this.setting = new Setting(properties);
   }
 
   @Override
   public String getName() {
-    return null;
+    return name;
   }
 
   @Override
   public HostGroupV2 getHostGroup(String name) {
-    return null;
+    return hostGroupMap.get(name);
   }
 
   @Override
   public Map<String, HostGroupV2> getHostGroups() {
-    return null;
+    return hostGroupMap;
   }
 
   @Override
   public Collection<StackV2> getStacks() {
-    return null;
+    return stacks.values();
+  }
+
+  @Override
+  public Collection<String> getStackIds() {
+    return repositoryVersions.stream().map(rv -> rv.getStackId()).collect(Collectors.toList());
   }
 
   @Override
   public Collection<ServiceGroup> getServiceGroups() {
-    return null;
+    return serviceGroups;
   }
 
   @Override
-  public Collection<Service> getAllServices() {
-    return null;
+  @JsonIgnore
+  public Collection<ServiceId> getAllServices() {
+    return hostGroups.stream().flatMap(hg -> hg.getServices().stream()).collect(Collectors.toSet());
   }
 
   @Override
+  @JsonIgnore
   public Collection<String> getAllServiceTypes() {
     return null;
   }
 
   @Override
+  @JsonIgnore
   public Collection<Service> getServicesByType(String serviceType) {
-    return getAllServices().stream().filter(
-      service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
+    return null;
+//    getAllServices().stream().filter(
+//            service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
   }
 
   @Override
+  @JsonIgnore
   public Collection<Service> getServicesFromServiceGroup(ServiceGroup serviceGroup, String serviceType) {
     if (serviceType == null) {
       return serviceGroup.getServices();
     } else {
       return serviceGroup.getServices().stream().filter(
-        service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
+              service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
     }
   }
 
   @Override
+  @JsonIgnore
   public Collection<ComponentV2> getComponents(Service service) {
     return null;
   }
 
   @Override
+  @JsonIgnore
   public Collection<ComponentV2> getComponentsByType(Service service, String componentType) {
     return getComponents(service).stream().filter(
-      compnoent -> compnoent.getType().equalsIgnoreCase(componentType)).collect(Collectors.toList());
+            compnoent -> compnoent.getType().equalsIgnoreCase(componentType)).collect(Collectors.toList());
   }
 
   @Override
-  public Collection<HostGroupV2> getHostGroupsForService(Service service) {
-    return null;
+  @JsonIgnore
+  public Collection<ComponentV2> getComponents(ServiceId serviceId) {
+    return getHostGroupsForService(serviceId).stream().flatMap(hg -> hg.getComponents().stream()).collect(Collectors.toSet());
+  }
+
+  @Override
+  @JsonIgnore
+  public Collection<HostGroupV2> getHostGroupsForService(ServiceId serviceId) {
+    return hostGroups.stream().filter(hg -> !hg.getComponents(serviceId).isEmpty()).collect(Collectors.toList());
   }
 
   @Override
+  @JsonIgnore
   public Collection<HostGroupV2> getHostGroupsForComponent(ComponentV2 component) {
-    return null;
+    return hostGroups.stream().filter(hg -> hg.getComponents().contains(component)).collect(Collectors.toList());
   }
 
   @Override
-  @Deprecated
   public Configuration getConfiguration() {
     return null;
   }
 
   @Override
   public Setting getSetting() {
-    return null;
+    return this.setting;
   }
 
   @Override
@@ -122,43 +216,147 @@ public class BlueprintImplV2 implements BlueprintV2 {
     return null;
   }
 
+  @Nonnull
   @Override
-  public String getCredentialStoreEnabled(String serviceName) {
-    return null;
+  @JsonIgnore
+  public Collection<String> getAllServiceNames() {
+    return getAllServices().stream().map(s -> s.getName()).collect(Collectors.toList());
   }
 
+  @Nonnull
   @Override
-  public boolean shouldSkipFailure() {
-    return false;
+  public Collection<String> getComponentNames(ServiceId serviceId) {
+    return getComponents(serviceId).stream().map(c -> c.getName()).collect(Collectors.toList());
   }
 
   @Override
-  public SecurityConfiguration getSecurity() {
+  public String getRecoveryEnabled(String serviceName, String componentName) {
+    // If component name was specified in the list of "component_settings",
+    // determine if recovery_enabled is true or false and return it.
+    Optional<String> recoveryEnabled = getSettingValue(Setting.SETTING_NAME_COMPONENT_SETTINGS,
+      Setting.SETTING_NAME_RECOVERY_ENABLED,
+      Optional.of(componentName));
+    if (recoveryEnabled.isPresent()) {
+      return recoveryEnabled.get();
+    }
+
+    // If component name was specified in the list of "component_settings",
+    // determine if recovery_enabled is true or false and return it.
+    recoveryEnabled = getSettingValue(Setting.SETTING_NAME_SERVICE_SETTINGS,
+      Setting.SETTING_NAME_RECOVERY_ENABLED,
+      Optional.of(serviceName));
+    if (recoveryEnabled.isPresent()) {
+      return recoveryEnabled.get();
+    }
+
+    // If service name is not specified, look up the cluster setting.
+    recoveryEnabled = getSettingValue(Setting.SETTING_NAME_RECOVERY_SETTINGS,
+      Setting.SETTING_NAME_RECOVERY_ENABLED,
+      Optional.empty());
+    if (recoveryEnabled.isPresent()) {
+      return recoveryEnabled.get();
+    }
+
     return null;
   }
 
-  @Override
-  public void validateTopology() throws InvalidTopologyException {
+  private Optional<String> getSettingValue(String settingCategory, String settingName, Optional<String> nameFilter) {
+    if (this.setting != null) {
+      Set<HashMap<String, String>> settingValue = this.setting.getSettingValue(settingCategory);
+      for (Map<String, String> setting : settingValue) {
+        String name = setting.get(Setting.SETTING_NAME_NAME);
+        if (!nameFilter.isPresent() || StringUtils.equals(name, nameFilter.get())) {
+          String value = setting.get(settingName);
+          if (!StringUtils.isEmpty(value)) {
+            return Optional.of(value);
+          }
+        }
+      }
+    }
+    return Optional.empty();
+  }
 
+  @Override
+  public String getCredentialStoreEnabled(String serviceName) {
+    // Look up the service and return the credential_store_enabled value.
+    Optional<String> credentialStoreEnabled = getSettingValue(Setting.SETTING_NAME_SERVICE_SETTINGS,
+      Setting.SETTING_NAME_CREDENTIAL_STORE_ENABLED,
+      Optional.of(serviceName));
+    return  credentialStoreEnabled.isPresent() ? credentialStoreEnabled.get() : null;
   }
 
   @Override
-  public void validateRequiredProperties() throws InvalidTopologyException {
+  public boolean shouldSkipFailure() {
+    Optional<String> shouldSkipFailure = getSettingValue(Setting.SETTING_NAME_DEPLOYMENT_SETTINGS,
+      Setting.SETTING_NAME_SKIP_FAILURE,
+      Optional.empty());
+    return shouldSkipFailure.isPresent() ? shouldSkipFailure.get().equalsIgnoreCase("true") : false;
+  }
 
+  @Override
+  public SecurityConfiguration getSecurity() {
+    return this.securityConfiguration;
   }
 
+
   @Override
   public boolean isValidConfigType(String configType) {
-    return false;
+    if (ConfigHelper.CLUSTER_ENV.equals(configType) || "global".equals(configType)) {
+      return true;
+    }
+    final Set<String> serviceNames =
+      getAllServices().stream().map(s -> s.getName()).collect(Collectors.toSet());
+    return getStacks().stream().anyMatch(
+      stack -> {
+        String service = stack.getServiceForConfigType(configType);
+        return serviceNames.contains(service);
+      }
+    );
   }
 
   @Override
   public BlueprintEntity toEntity() {
-    return null;
+    throw new UnsupportedOperationException("This is not supported here and will be removed. Pls. use BlueprintConverter");
   }
 
   @Override
   public List<RepositorySetting> getRepositorySettings() {
-    return null;
+    return repoSettings;
+  }
+
+  /**
+   * Class to support Jackson data binding. Instances are used only temporarily during serialization
+   */
+  public class Blueprints {
+    @JsonProperty("blueprint_name")
+    public String name;
+    @JsonProperty("security")
+    public SecurityConfiguration securityConfiguration;
+
+    public Blueprints() { }
   }
+
+  public static void main(String[] args) throws Exception {
+    ObjectMapper mapper = new ObjectMapper();
+    SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
+    SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
+    resolver.addMapping(HostGroupV2.class, HostGroupV2Impl.class);
+    module.setAbstractTypes(resolver);
+    mapper.registerModule(module);
+    mapper.enable(SerializationFeature.INDENT_OUTPUT);
+    BlueprintImplV2 bp = mapper.readValue(new File("/Users/bsari/develop/blueprints/blueprintv2.json"), BlueprintImplV2.class);
+    String bpJson = mapper.writeValueAsString(bp);
+    System.out.println(bpJson);
+    System.out.println("\n\n====================================================================================\n\n");
+    Map<String, Object> map = mapper.readValue(new File("/Users/bsari/develop/blueprints/blueprintv2.json"), HashMap.class);
+    System.out.println(map);
+    System.out.println("\n\n====================================================================================\n\n");
+    String bpJson2 = mapper.writeValueAsString(map);
+    System.out.println(bpJson2);
+    System.out.println("\n\n====================================================================================\n\n");
+    BlueprintImplV2 bp2 = mapper.readValue(bpJson2, BlueprintImplV2.class);
+    System.out.println(bp2);
+  }
+
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
index 10fa2fa..ea17e90 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
@@ -22,7 +22,11 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.ambari.server.controller.internal.StackV2;
+
+import javax.annotation.Nonnull;
+
+import org.apache.ambari.server.controller.StackV2;
+
 import org.apache.ambari.server.orm.entities.BlueprintEntity;
 
 
@@ -60,6 +64,10 @@ public interface BlueprintV2 {
    */
   Collection<StackV2> getStacks();
 
+  /**
+  * @return associated stack ids
+  **/
+  public Collection<String> getStackIds();
 
   Collection<ServiceGroup> getServiceGroups();
 
@@ -68,7 +76,16 @@ public interface BlueprintV2 {
    *
    * @return collection of all represented service names
    */
-  Collection<Service> getAllServices();
+  Collection<ServiceId> getAllServices();
+
+  /**
+   * Get the names of all the services represented in the blueprint.
+   *
+   * @return collection of all represented service names
+   */
+  @Nonnull
+  Collection<String> getAllServiceNames();
+
 
 
   /**
@@ -96,11 +113,22 @@ public interface BlueprintV2 {
   /**
    * Get the components that are included in the blueprint for the specified service.
    *
-   * @param service  service name
+   * @param serviceId  serviceId
+   *
+   * @return collection of component names for the service.  Will not return null.
+   */
+  @Nonnull
+  Collection<String> getComponentNames(ServiceId serviceId);
+
+  /**
+   * Get the component names s that are included in the blueprint for the specified service.
+   *
+   * @param serviceId  serviceId
    *
    * @return collection of component names for the service.  Will not return null.
    */
-  Collection<ComponentV2> getComponents(Service service);
+  Collection<ComponentV2> getComponents(ServiceId serviceId);
+
 
   /**
    * Get components by type from a service.
@@ -114,12 +142,12 @@ public interface BlueprintV2 {
   /**
    * Get the host groups which contain components for the specified service.
    *
-   * @param service  service name
+   * @param serviceId  service Id
    *
    * @return collection of host groups containing components for the specified service;
    *         will not return null
    */
-  Collection<HostGroupV2> getHostGroupsForService(Service service);
+  Collection<HostGroupV2> getHostGroupsForService(ServiceId serviceId);
 
   /**
    * Get the host groups which contain the give component.
@@ -130,6 +158,7 @@ public interface BlueprintV2 {
    */
   Collection<HostGroupV2> getHostGroupsForComponent(ComponentV2 component);
 
+
   /**
    * Get the Blueprint cluster scoped configuration.
    * The blueprint cluster scoped configuration has the stack
@@ -141,6 +170,7 @@ public interface BlueprintV2 {
   @Deprecated
   Configuration getConfiguration();
 
+
   /**
    * Get the Blueprint cluster scoped setting.
    * The blueprint cluster scoped setting has the setting properties
@@ -178,19 +208,6 @@ public interface BlueprintV2 {
 
   SecurityConfiguration getSecurity();
 
-  /**
-   * Validate the blueprint topology.
-   *
-   * @throws InvalidTopologyException if the topology is invalid
-   */
-  void validateTopology() throws InvalidTopologyException;
-
-  /**
-   * Validate that the blueprint contains all of the required properties.
-   *
-   * @throws InvalidTopologyException if the blueprint doesn't contain all required properties
-   */
-  void validateRequiredProperties() throws InvalidTopologyException;
 
   /**
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
new file mode 100644
index 0000000..a8c5b4c
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
@@ -0,0 +1,170 @@
+/*
+ * 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 distribut
+ * ed 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.topology;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.ObjectNotFoundException;
+import org.apache.ambari.server.StackAccessException;
+import org.apache.ambari.server.controller.StackV2;
+import org.apache.ambari.server.controller.StackV2Factory;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.orm.dao.BlueprintV2DAO;
+import org.apache.ambari.server.orm.dao.StackDAO;
+import org.apache.ambari.server.orm.entities.BlueprintV2Entity;
+import org.apache.ambari.server.orm.entities.StackEntity;
+import org.apache.ambari.server.stack.NoSuchStackException;
+import org.apache.ambari.server.state.StackId;
+
+import com.fasterxml.jackson.core.Version;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.google.inject.Inject;
+
+public class BlueprintV2Factory {
+  // Blueprints
+  protected static final String BLUEPRINT_NAME_PROPERTY_ID =
+    PropertyHelper.getPropertyId("Blueprints", "blueprint_name");
+  protected static final String STACK_NAME_PROPERTY_ID =
+    PropertyHelper.getPropertyId("Blueprints", "stack_name");
+  protected static final String STACK_VERSION_PROPERTY_ID =
+    PropertyHelper.getPropertyId("Blueprints", "stack_version");
+
+  // Host Groups
+  protected static final String HOST_GROUP_PROPERTY_ID = "host_groups";
+  protected static final String HOST_GROUP_NAME_PROPERTY_ID = "name";
+  protected static final String HOST_GROUP_CARDINALITY_PROPERTY_ID = "cardinality";
+
+  // Host Group Components
+  protected static final String COMPONENT_PROPERTY_ID ="components";
+  protected static final String COMPONENT_NAME_PROPERTY_ID ="name";
+  protected static final String COMPONENT_PROVISION_ACTION_PROPERTY_ID = "provision_action";
+
+  // Configurations
+  protected static final String CONFIGURATION_PROPERTY_ID = "configurations";
+  protected static final String PROPERTIES_PROPERTY_ID = "properties";
+  protected static final String PROPERTIES_ATTRIBUTES_PROPERTY_ID = "properties_attributes";
+
+  protected static final String SETTINGS_PROPERTY_ID = "settings";
+
+  private static BlueprintV2DAO blueprintDAO;
+  private static StackDAO stackDao;
+  private ConfigurationFactory configFactory = new ConfigurationFactory();
+
+  private final StackV2Factory stackFactory;
+
+  protected BlueprintV2Factory(StackV2Factory stackFactory) {
+    this.stackFactory = stackFactory;
+  }
+
+  public BlueprintV2 getBlueprint(String blueprintName) throws NoSuchStackException, NoSuchBlueprintException, IOException {
+    BlueprintV2Entity entity =
+      Optional.ofNullable(blueprintDAO.findByName(blueprintName)).orElseThrow(() -> new NoSuchBlueprintException(blueprintName));
+    return convertFromEntity(entity);
+  }
+
+  public BlueprintV2 convertFromEntity(BlueprintV2Entity blueprintEntity) throws NoSuchStackException, IOException {
+    BlueprintImplV2 blueprintV2 = createObjectMapper().readValue(blueprintEntity.getContent(), BlueprintImplV2.class);
+    Map<StackId, StackV2> stacks = new HashMap<>();
+    for (String stackIdString: blueprintV2.getStackIds()) {
+      StackId stackId = new StackId(stackIdString);
+      stacks.put(stackId, parseStack(stackDao.find(stackId)));
+    }
+    blueprintV2.setStacks(stacks);
+    return blueprintV2;
+  }
+
+
+  private StackV2 parseStack(StackEntity stackEntity) throws NoSuchStackException {
+    try {
+      return stackFactory.create(stackEntity.getStackName(), stackEntity.getStackVersion());
+    } catch (StackAccessException e) {
+      throw new NoSuchStackException(stackEntity.getStackName(), stackEntity.getStackVersion());
+    } catch (AmbariException e) {
+      //todo:
+      throw new RuntimeException("An error occurred parsing the stack information.", e);
+    }
+  }
+
+  /**
+   * Convert a map of properties to a blueprint entity.
+   *
+   * @param properties  property map
+   * @param securityConfiguration security related properties
+   * @return new blueprint entity
+   */
+  @SuppressWarnings("unchecked")
+  public BlueprintV2 createBlueprint(Map<String, Object> properties, SecurityConfiguration securityConfiguration) throws NoSuchStackException, IOException {
+    String name = String.valueOf(properties.get(BLUEPRINT_NAME_PROPERTY_ID));
+    // String.valueOf() will return "null" if value is null
+    if (name.equals("null") || name.isEmpty()) {
+      //todo: should throw a checked exception from here
+      throw new IllegalArgumentException("Blueprint name must be provided");
+    }
+    ObjectMapper om = createObjectMapper();
+    String json = om.writeValueAsString(properties);
+    BlueprintImplV2 blueprint = om.readValue(json, BlueprintImplV2.class);
+    Map<String, StackV2> stacks = new HashMap<>();
+    for (String stackId: blueprint.getStackIds()) {
+      stacks.put(stackId, stackFactory.create(stackId));
+    }
+    blueprint.setSecurityConfiguration(securityConfiguration);
+    return blueprint;
+  }
+
+  protected StackV2 createStack(Map<String, Object> properties) throws NoSuchStackException {
+    String stackName = String.valueOf(properties.get(STACK_NAME_PROPERTY_ID));
+    String stackVersion = String.valueOf(properties.get(STACK_VERSION_PROPERTY_ID));
+    try {
+      //todo: don't pass in controller
+      return stackFactory.create(stackName, stackVersion);
+    } catch (ObjectNotFoundException e) {
+      throw new NoSuchStackException(stackName, stackVersion);
+    } catch (AmbariException e) {
+      //todo:
+      throw new RuntimeException("An error occurred parsing the stack information.", e);
+    }
+  }
+
+  static ObjectMapper createObjectMapper() {
+    ObjectMapper mapper = new ObjectMapper();
+    SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
+    SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
+    resolver.addMapping(HostGroupV2.class, HostGroupV2Impl.class);
+    module.setAbstractTypes(resolver);
+    mapper.registerModule(module);
+    return mapper;
+  }
+
+  /**
+   * Static initialization.
+   *
+   * @param dao  blueprint data access object
+   */
+  @Inject
+  public static void init(BlueprintV2DAO dao) {
+    blueprintDAO = dao;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorV2.java
new file mode 100644
index 0000000..cfe083e
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorV2.java
@@ -0,0 +1,43 @@
+/*
+ * 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 distribut
+ * ed 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.topology;
+
+public interface BlueprintValidatorV2 {
+
+  /**
+   * Validate blueprint topology.
+   *
+   * @param blueprint The blueprint to validate
+   *
+   * @throws InvalidTopologyException if the topology is invalid
+   */
+  void validateTopology(BlueprintV2 blueprint) throws InvalidTopologyException;
+
+  /**
+   * Validate that required properties are provided.
+   * This doesn't include password properties.
+   *
+   * @param blueprint The blueprint to validate
+   *
+   * @throws InvalidTopologyException if required properties are not set in blueprint
+   */
+  void validateRequiredProperties(BlueprintV2 blueprint) throws InvalidTopologyException;
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
index d7c08f4..43dda1b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
@@ -18,37 +18,28 @@
 
 package org.apache.ambari.server.topology;
 
-
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.controller.internal.ProvisionAction;
 
-public class ComponentV2 {
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
 
-  private final String type;
+public class ComponentV2 implements Configurable {
 
-  private final String name;
+  private String type;
 
-  private final Service service;
+  private String name;
 
-  private final ProvisionAction provisionAction;
+  private ServiceId serviceId = new ServiceId();
 
-  private final Configuration configuration;
+  private ProvisionAction provisionAction = ProvisionAction.INSTALL_AND_START;
 
-  public ComponentV2(String type, Service service) {
-    this(type, type, service, null, null);
-  }
+  private Configuration configuration;
 
+  private boolean masterComponent = false;
 
-  public ComponentV2(String type, String name, Service service) {
-    this(type, name, service, null, null);
-  }
+  public ComponentV2() { }
 
-  public ComponentV2(String type, String name, Service service, ProvisionAction provisionAction, Configuration configuration) {
-    this.type = type;
-    this.name = name;
-    this.service = service;
-    this.provisionAction = provisionAction;
-    this.configuration = configuration;
-  }
 
   /**
    * Gets the name of this component
@@ -59,8 +50,9 @@ public class ComponentV2 {
     return this.name;
   }
 
-  public String getType() {
-    return type;
+  /** @return the masterComponent flag */
+  public boolean isMasterComponent() {
+    return masterComponent;
   }
 
   /**
@@ -73,11 +65,59 @@ public class ComponentV2 {
     return this.provisionAction;
   }
 
-  public Service getService() {
-    return service;
+  public ServiceId getServiceId() {
+    return serviceId;
   }
 
   public Configuration getConfiguration() {
     return configuration;
   }
+
+  public String getType() {
+    return type;
+  }
+
+  public void setType(String type) {
+    this.type = type;
+    if (null == this.name) {
+      this.name = type;
+    }
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getServiceGroup() {
+    return serviceId.getServiceGroup();
+  }
+
+  @JsonProperty("service_group")
+  public void setServiceGroup(String serviceGroup) {
+    serviceId.setServiceGroup(serviceGroup);
+  }
+
+  @JsonProperty("service_name")
+  public void setServiceName(String serviceName) {
+    serviceId.setName(serviceName);
+  }
+
+  public String getServiceName() {
+    return serviceId.getName();
+  }
+
+  @JsonProperty("provision_action")
+  public void setProvisionAction(ProvisionAction provisionAction) {
+    this.provisionAction = provisionAction;
+  }
+
+  public void setConfiguration(Configuration configuration) {
+    this.configuration = configuration;
+  }
+
+  @JsonIgnore
+  public void setMasterComponent(StackV2 stack) {
+    this.masterComponent = stack.isMasterComponent(this.type);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/Configurable.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Configurable.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Configurable.java
new file mode 100644
index 0000000..74308ab
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Configurable.java
@@ -0,0 +1,40 @@
+/*
+ * 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.topology;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public interface Configurable {
+  void setConfiguration(Configuration configuration);
+
+  @JsonProperty("configurations")
+  default void setConfigs(Collection<Map<String, Map<String, Map<String, String>>>> configs) {
+    Map<String, Map<String, String>> allProps = configs.stream().collect(Collectors.toMap(
+      config -> config.keySet().iterator().next(),
+      config -> config.values().iterator().next().get("properties")
+    ));
+    setConfiguration(new Configuration(allProps, new HashMap<>()));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Configuration.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Configuration.java
index 28b62bc..28dbbaa 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Configuration.java
@@ -24,6 +24,8 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
 /**
  * Configuration for a topology entity such as a blueprint, hostgroup or cluster.
  */
@@ -98,6 +100,7 @@ public class Configuration {
    *
    * @return complete map of merged properties keyed by config type
    */
+  @JsonIgnore
   public Map<String, Map<String, String>> getFullProperties() {
     return getFullProperties(Integer.MAX_VALUE);
   }
@@ -113,6 +116,7 @@ public class Configuration {
    *
    * @return map of merged properties keyed by config type
    */
+  @JsonIgnore
   public Map<String, Map<String, String>> getFullProperties(int depthLimit) {
     if (depthLimit == 0) {
       HashMap<String, Map<String, String>> propertiesCopy = new HashMap<>();
@@ -156,6 +160,7 @@ public class Configuration {
    *
    * @return complete map of merged attributes {configType -> {attributeName -> {propName, attributeValue}}}
    */
+  @JsonIgnore
   public Map<String, Map<String, Map<String, String>>> getFullAttributes() {
     Map<String, Map<String, Map<String, String>>> mergedAttributeMap = parentConfiguration == null ?
       new HashMap<>() :
@@ -314,6 +319,7 @@ public class Configuration {
    *
    * @return collection of all represented configuration types
    */
+  @JsonIgnore
   public Collection<String> getAllConfigTypes() {
     Collection<String> allTypes = new HashSet<>();
     for (String type : getFullProperties().keySet()) {
@@ -332,6 +338,7 @@ public class Configuration {
    *
    * @return the parent configuration or null if no parent is set
    */
+  @JsonIgnore
   public Configuration getParentConfiguration() {
     return parentConfiguration;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java
index 9aeadd1..9d3a1b8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java
@@ -255,8 +255,6 @@ public class HostGroupImpl implements HostGroup {
       } else {
         addComponent(componentEntity.getName());
       }
-
-
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
index fd0f966..0922e74 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
@@ -83,11 +83,11 @@ public interface HostGroupV2 {
   /**
    * Get the host group components which belong to the specified service.
    *
-   * @param service  service name
+   * @param serviceId  service id
    *
    * @return collection of component names for the specified service; will not return null
    */
-  Collection<ComponentV2> getComponents(Service service);
+  Collection<ComponentV2> getComponents(ServiceId serviceId);
 
   /**
    * Determine if the host group contains a master component.
@@ -97,11 +97,14 @@ public interface HostGroupV2 {
   boolean containsMasterComponent();
 
   /**
-   * Get all of the services associated with the host group components.
-   *
-   * @return collection of service names
+   * @return collection of service ids associated with the host group components.
+   */
+  Collection<ServiceId> getServices();
+
+  /**
+   * @return collection of service names associated with the host group components.
    */
-  Collection<Service> getServices();
+  Collection<String> getServiceNames();
 
   /**
    * Get the configuration associated with the host group.


[25/30] ambari git commit: AMBARI-22297 Fix DDL Scripts: fix stack table and add blueprintv2 table (benyoka)

Posted by mr...@apache.org.
AMBARI-22297 Fix DDL Scripts: fix stack table and add blueprintv2 table  (benyoka)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: b0f5639cb03be37d841b2b526be54a52d20e9d08
Parents: c118e51
Author: Balazs Bence Sari <be...@apache.org>
Authored: Wed Oct 25 14:24:47 2017 +0200
Committer: Balazs Bence Sari <be...@apache.org>
Committed: Wed Oct 25 14:25:03 2017 +0200

----------------------------------------------------------------------
 .../src/main/resources/Ambari-DDL-Derby-CREATE.sql       | 10 ++++++++++
 .../src/main/resources/Ambari-DDL-MySQL-CREATE.sql       | 10 ++++++++++
 .../src/main/resources/Ambari-DDL-Oracle-CREATE.sql      | 11 +++++++++++
 .../src/main/resources/Ambari-DDL-Postgres-CREATE.sql    | 10 ++++++++++
 .../src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 11 +++++++++++
 .../src/main/resources/Ambari-DDL-SQLServer-CREATE.sql   | 11 +++++++++++
 6 files changed, 63 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f5639c/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
index b8c0a42..0d82cd4 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -39,6 +39,7 @@ CREATE TABLE stack (
   stack_id BIGINT NOT NULL,
   stack_name VARCHAR(255) NOT NULL,
   stack_version VARCHAR(255) NOT NULL,
+  repo_version VARCHAR(255) NOT NULL,
   current_mpack_id BIGINT,
   CONSTRAINT PK_stack PRIMARY KEY (stack_id),
   CONSTRAINT FK_mpacks FOREIGN KEY (current_mpack_id) REFERENCES mpacks(id),
@@ -529,6 +530,15 @@ CREATE TABLE blueprint (
   CONSTRAINT PK_blueprint PRIMARY KEY (blueprint_name),
   CONSTRAINT FK_blueprint_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
 
+CREATE TABLE blueprintv2 (
+  blueprint_name VARCHAR(255) NOT NULL,
+  security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
+  security_descriptor_reference VARCHAR(255),
+  stack_id BIGINT NOT NULL,
+  content VARCHAR(32000) NOT NULL,
+  CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
+  CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
+
 CREATE TABLE hostgroup (
   blueprint_name VARCHAR(255) NOT NULL,
   name VARCHAR(255) NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f5639c/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index c56e486..d70d853 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -58,6 +58,7 @@ CREATE TABLE stack (
   stack_id BIGINT NOT NULL,
   stack_name VARCHAR(100) NOT NULL,
   stack_version VARCHAR(100) NOT NULL,
+  repo_version VARCHAR(255) NOT NULL,
   current_mpack_id BIGINT,
   CONSTRAINT PK_stack PRIMARY KEY (stack_id),
   CONSTRAINT FK_mpacks FOREIGN KEY (current_mpack_id) REFERENCES mpacks(id),
@@ -546,6 +547,15 @@ CREATE TABLE blueprint (
   CONSTRAINT PK_blueprint PRIMARY KEY (blueprint_name),
   CONSTRAINT FK_blueprint_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
 
+CREATE TABLE blueprintv2 (
+  blueprint_name VARCHAR(255) NOT NULL,
+  security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
+  security_descriptor_reference VARCHAR(255),
+  stack_id BIGINT NOT NULL,
+  content LONGTEXT NOT NULL,
+  CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
+  CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
+
 CREATE TABLE hostgroup (
   blueprint_name VARCHAR(100) NOT NULL,
   name VARCHAR(100) NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f5639c/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 8917d48..54e890d 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -39,6 +39,7 @@ CREATE TABLE stack (
   stack_id NUMBER(19) NOT NULL,
   stack_name VARCHAR2(255) NOT NULL,
   stack_version VARCHAR2(255) NOT NULL,
+  repo_version VARCHAR2(255) NOT NULL,
   current_mpack_id BIGINT,
   CONSTRAINT PK_stack PRIMARY KEY (stack_id),
   CONSTRAINT FK_mpacks FOREIGN KEY (current_mpack_id) REFERENCES mpacks(id),
@@ -528,6 +529,16 @@ CREATE TABLE blueprint (
   CONSTRAINT PK_blueprint PRIMARY KEY (blueprint_name),
   CONSTRAINT FK_blueprint_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
 
+CREATE TABLE blueprintv2 (
+  blueprint_name VARCHAR2(255) NOT NULL,
+  security_type VARCHAR2(32) NOT NULL DEFAULT 'NONE',
+  security_descriptor_reference VARCHAR2(255),
+  stack_id NUMBER(19) NOT NULL,
+  content CLOB NOT NULL,
+  CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
+  CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
+
+
 CREATE TABLE hostgroup (
   blueprint_name VARCHAR2(255) NOT NULL,
   name VARCHAR2(255) NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f5639c/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 482f5e8..437756a 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -39,6 +39,7 @@ CREATE TABLE stack (
   stack_id BIGINT NOT NULL,
   stack_name VARCHAR(255) NOT NULL,
   stack_version VARCHAR(255) NOT NULL,
+  repo_version VARCHAR(255) NOT NULL,
   current_mpack_id BIGINT,
   CONSTRAINT PK_stack PRIMARY KEY (stack_id),
   CONSTRAINT FK_mpacks FOREIGN KEY (current_mpack_id) REFERENCES mpacks(id),
@@ -527,6 +528,15 @@ CREATE TABLE blueprint (
   CONSTRAINT PK_blueprint PRIMARY KEY (blueprint_name),
   CONSTRAINT FK_blueprint_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
 
+CREATE TABLE blueprintv2 (
+  blueprint_name VARCHAR(255) NOT NULL,
+  security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
+  security_descriptor_reference VARCHAR(255),
+  stack_id BIGINT NOT NULL,
+  content VARCHAR(32000) NOT NULL,
+  CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
+  CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
+
 CREATE TABLE hostgroup (
   blueprint_name VARCHAR(255) NOT NULL,
   name VARCHAR(255) NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f5639c/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index e7c5c72..74e3e69 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -38,6 +38,7 @@ CREATE TABLE stack (
   stack_id NUMERIC(19) NOT NULL,
   stack_name VARCHAR(255) NOT NULL,
   stack_version VARCHAR(255) NOT NULL,
+  repo_version VARCHAR(255) NOT NULL,
   current_mpack_id BIGINT,
   CONSTRAINT PK_stack PRIMARY KEY (stack_id),
   CONSTRAINT FK_mpacks FOREIGN KEY (current_mpack_id) REFERENCES mpacks(id),
@@ -524,6 +525,16 @@ CREATE TABLE blueprint (
   CONSTRAINT PK_blueprint PRIMARY KEY (blueprint_name),
   CONSTRAINT FK_blueprint_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
 
+CREATE TABLE blueprintv2 (
+  blueprint_name VARCHAR(255) NOT NULL,
+  security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
+  security_descriptor_reference VARCHAR(255),
+  stack_id NUMERIC(19) NOT NULL,
+  content TEXT NOT NULL,
+  CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
+  CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
+
+
 CREATE TABLE hostgroup (
   blueprint_name VARCHAR(255) NOT NULL,
   name VARCHAR(255) NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0f5639c/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index f87af4c..cffe53d 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -51,6 +51,7 @@ CREATE TABLE stack (
   stack_id BIGINT NOT NULL,
   stack_name VARCHAR(255) NOT NULL,
   stack_version VARCHAR(255) NOT NULL,
+  repo_version VARCHAR(255) NOT NULL,
   current_mpack_id BIGINT,
   CONSTRAINT PK_stack PRIMARY KEY CLUSTERED (stack_id),
   CONSTRAINT FK_mpacks FOREIGN KEY (current_mpack_id) REFERENCES mpacks(id),
@@ -532,6 +533,16 @@ CREATE TABLE blueprint (
   CONSTRAINT PK_blueprint PRIMARY KEY CLUSTERED (blueprint_name),
   CONSTRAINT FK_blueprint_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
 
+
+CREATE TABLE blueprintv2 (
+  blueprint_name VARCHAR(255) NOT NULL,
+  security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
+  security_descriptor_reference VARCHAR(255),
+  stack_id BIGINT NOT NULL,
+  content VARCHAR(MAX) NOT NULL,
+  CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
+  CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
+
 CREATE TABLE hostgroup (
   blueprint_name VARCHAR(255) NOT NULL,
   NAME VARCHAR(255) NOT NULL,


[15/30] ambari git commit: AMBARI-22253. Modify TopologyManager to create service groups (magyari_sandor)

Posted by mr...@apache.org.
AMBARI-22253. Modify TopologyManager to create service groups (magyari_sandor)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 841cc7e12c9f6e689b7b97b7b75b92ed7744fa87
Parents: 37b1e6e
Author: Sandor Magyari <sm...@hortonworks.com>
Authored: Thu Oct 19 14:20:39 2017 +0200
Committer: Sandor Magyari <sm...@hortonworks.com>
Committed: Thu Oct 19 14:30:31 2017 +0200

----------------------------------------------------------------------
 .../StackAdvisorBlueprintProcessor.java         |   2 +-
 .../ambari/server/controller/AmbariServer.java  |   3 +-
 .../ambari/server/controller/StackV2.java       |  47 +-
 .../server/controller/StackV2Factory.java       |  10 +-
 .../controller/internal/BaseClusterRequest.java |   8 +-
 .../BlueprintConfigurationProcessor.java        |   4 +-
 .../internal/ConfigurationContext.java          |   1 +
 .../internal/ProvisionClusterRequest.java       |   7 +-
 .../internal/ScaleClusterRequest.java           |   6 +
 .../server/controller/internal/StackV2.java     | 834 -------------------
 .../server/controller/internal/UnitUpdater.java |   1 +
 .../ambari/server/topology/AmbariContext.java   |   5 +-
 .../server/topology/BlueprintFactory.java       |   4 +-
 .../ambari/server/topology/BlueprintImplV2.java |  49 +-
 .../ambari/server/topology/BlueprintV2.java     |  10 +-
 .../topology/ClusterConfigurationRequest.java   |   5 +-
 .../ambari/server/topology/ComponentV2.java     |  12 +-
 .../ambari/server/topology/HostGroupV2.java     |  11 +-
 .../ambari/server/topology/HostGroupV2Impl.java |  21 +-
 .../ambari/server/topology/HostRequest.java     |   2 +-
 .../server/topology/PersistedStateImpl.java     |   9 +-
 .../apache/ambari/server/topology/Service.java  |  21 +-
 .../ambari/server/topology/TopologyManager.java |   2 +-
 .../validators/ClusterConfigTypeValidator.java  |   5 +-
 .../RequiredConfigPropertiesValidator.java      |   2 +-
 .../validators/RequiredPasswordValidator.java   |   2 +-
 .../topology/validators/UnitValidator.java      |  12 +-
 27 files changed, 178 insertions(+), 917 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
index ba35cce..2e9ac9f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
@@ -28,8 +28,8 @@ import java.util.Set;
 import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest.StackAdvisorRequestType;
 import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse;
 import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse.BlueprintConfigurations;
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.controller.internal.ConfigurationTopologyException;
-import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.state.ValueAttributesInfo;
 import org.apache.ambari.server.topology.AdvisedConfiguration;
 import org.apache.ambari.server.topology.BlueprintV2;

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/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 6d4d1c9..f900452 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
@@ -115,6 +115,7 @@ import org.apache.ambari.server.stack.UpdateActiveRepoVersionOnStartup;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.topology.AmbariContext;
 import org.apache.ambari.server.topology.BlueprintFactory;
+import org.apache.ambari.server.topology.BlueprintV2Factory;
 import org.apache.ambari.server.topology.SecurityConfigurationFactory;
 import org.apache.ambari.server.topology.TopologyManager;
 import org.apache.ambari.server.topology.TopologyRequestFactoryImpl;
@@ -926,7 +927,7 @@ public class AmbariServer {
             .class), injector.getInstance(Gson.class));
     HostResourceProvider.setTopologyManager(injector.getInstance(TopologyManager.class));
     BlueprintFactory.init(injector.getInstance(BlueprintDAO.class));
-    BaseClusterRequest.init(injector.getInstance(BlueprintFactory.class));
+    BaseClusterRequest.init(injector.getInstance(BlueprintV2Factory.class));
     AmbariContext.init(injector.getInstance(HostRoleCommandFactory.class));
 
     PermissionResourceProvider.init(injector.getInstance(PermissionDAO.class));

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
index 8d7de5d..169bf6a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
@@ -26,6 +26,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.ambari.server.state.AutoDeployInfo;
+import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.DependencyInfo;
 import org.apache.ambari.server.state.PropertyDependencyInfo;
 import org.apache.ambari.server.state.PropertyInfo;
@@ -165,28 +166,28 @@ public class StackV2 {
         return serviceComponents;
     }
 
-//  /**
-//   * Get info for the specified component.
-//   *
-//   * @param component  component name
-//   *
-//   * @return component information for the requested component
-//   *         or null if the component doesn't exist in the stack
-//   */
-//  @Deprecated
-//  public ComponentInfo getComponentInfo(String component) {
-//    ComponentInfo componentInfo = null;
-//    String service = getServiceForComponent(component);
-//    if (service != null) {
-//      try {
-//        componentInfo = controller.getAmbariMetaInfo().getComponent(
-//            getName(), getVersion(), service, component);
-//      } catch (AmbariException e) {
-//        // just return null if component doesn't exist
-//      }
-//    }
-//    return componentInfo;
-//  }
+      /**
+       * Get info for the specified component.
+       *
+       * @param component  component name
+       *
+       * @return component information for the requested component
+       *         or null if the component doesn't exist in the stack
+       */
+      @Deprecated
+      public ComponentInfo getComponentInfo(String component) {
+        ComponentInfo componentInfo = null;
+//        String service = getServiceForComponent(component);
+//        if (service != null) {
+//          try {
+//            componentInfo = controller.getAmbariMetaInfo().getComponent(
+//                getName(), getVersion(), service, component);
+//          } catch (AmbariException e) {
+//            // just return null if component doesn't exist
+//          }
+//        }
+        return componentInfo;
+      }
 
     /**
      * Get all configuration types, including excluded types for the specified service.
@@ -586,7 +587,7 @@ public class StackV2 {
             this.attributes = attributes;
         }
 
-        Set<PropertyDependencyInfo> getDependsOnProperties() {
+        public Set<PropertyDependencyInfo> getDependsOnProperties() {
             return this.dependsOnProperties;
         }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
index 54e1e62..ed1bbf8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
@@ -85,14 +85,14 @@ public class StackV2Factory {
     stackData.serviceConfigurations.put(service, mapServiceConfig);
     stackData.requiredServiceConfigurations.put(service, mapRequiredServiceConfig);
 
-    Set<StackConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
+    Set<ReadOnlyConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
       Collections.singleton(new StackConfigurationRequest(stackData.stackName, stackData.stackVersion, service, null)));
-    Set<StackConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
       Collections.singleton(new StackLevelConfigurationRequest(stackData.stackName, stackData.stackVersion, null)));
     serviceConfigs.addAll(stackLevelConfigs);
 
     // shouldn't have any required properties in stack level configuration
-    for (StackConfigurationResponse config : serviceConfigs) {
+    for (ReadOnlyConfigurationResponse config : serviceConfigs) {
       StackV2.ConfigProperty configProperty = new StackV2.ConfigProperty(config);
       String type = configProperty.getType();
 
@@ -118,10 +118,10 @@ public class StackV2Factory {
   }
 
   private void parseStackConfigurations (StackData stackData) throws AmbariException {
-    Set<StackConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
       Collections.singleton(new StackLevelConfigurationRequest(stackData.stackName, stackData.stackVersion, null)));
 
-    for (StackConfigurationResponse config : stackLevelConfigs) {
+    for (ReadOnlyConfigurationResponse config : stackLevelConfigs) {
       StackV2.ConfigProperty configProperty = new StackV2.ConfigProperty(config);
       String type = configProperty.getType();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
index e3e0aa2..a38f478 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
@@ -30,8 +30,8 @@ import org.apache.ambari.server.api.predicate.Token;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
-import org.apache.ambari.server.topology.BlueprintFactory;
 import org.apache.ambari.server.topology.BlueprintV2;
+import org.apache.ambari.server.topology.BlueprintV2Factory;
 import org.apache.ambari.server.topology.Configuration;
 import org.apache.ambari.server.topology.HostGroupInfo;
 import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
@@ -74,7 +74,7 @@ public abstract class BaseClusterRequest implements TopologyRequest {
   /**
    * blueprint factory
    */
-  protected static BlueprintFactory blueprintFactory;
+  protected static BlueprintV2Factory blueprintFactory;
 
   /**
    * List of services
@@ -96,7 +96,7 @@ public abstract class BaseClusterRequest implements TopologyRequest {
    * inject blueprint factory
    * @param factory  blueprint factory
    */
-  public static void init(BlueprintFactory factory) {
+  public static void init(BlueprintV2Factory factory) {
     blueprintFactory = factory;
   }
 
@@ -179,7 +179,7 @@ public abstract class BaseClusterRequest implements TopologyRequest {
   /**
    * Get the blueprint factory.
    */
-  protected BlueprintFactory getBlueprintFactory() {
+  protected BlueprintV2Factory getBlueprintFactory() {
     return blueprintFactory;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
index 8c4a5eb..953155d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
@@ -38,6 +38,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.PropertyDependencyInfo;
@@ -2923,7 +2924,8 @@ public class BlueprintConfigurationProcessor {
     for (Service blueprintService : blueprintServices) {
 
       LOG.debug("Handling excluded properties for blueprint service: {}", blueprintService);
-      StackV2 stack = blueprintService.getStack();
+      String stackId = blueprintService.getStackId();
+      StackV2 stack = clusterTopology.getBlueprint().getStackById(stackId);
       Set<String> excludedConfigTypes = stack.getExcludedConfigurationTypes(blueprintService.getType());
 
       if (excludedConfigTypes.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
index a313f5e..aa63021 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.controller.internal;
 
 import java.util.Map;
 
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.topology.Configuration;
 
 /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
index 75ec9ba..bfa46d8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.ambari.server.controller.internal;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -295,7 +296,11 @@ public class ProvisionClusterRequest extends BaseClusterRequest {
   private void parseBlueprint(Map<String, Object> properties) throws NoSuchStackException, NoSuchBlueprintException {
     String blueprintName = String.valueOf(properties.get(ClusterResourceProvider.BLUEPRINT));
     // set blueprint field
-    setBlueprint(getBlueprintFactory().getBlueprint(blueprintName));
+    try {
+      setBlueprint(getBlueprintFactory().getBlueprint(blueprintName));
+    } catch (IOException e) {
+      throw new NoSuchBlueprintException(blueprintName);
+    }
 
     if (blueprint == null) {
       throw new NoSuchBlueprintException(blueprintName);

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
index c5cc061b..1284c26 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
@@ -19,6 +19,7 @@
 
 package org.apache.ambari.server.controller.internal;
 
+import java.io.IOException;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
@@ -29,6 +30,7 @@ import org.apache.ambari.server.topology.BlueprintV2;
 import org.apache.ambari.server.topology.Configuration;
 import org.apache.ambari.server.topology.HostGroupInfo;
 import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
+import org.apache.ambari.server.topology.NoSuchBlueprintException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -201,6 +203,10 @@ public class ScaleClusterRequest extends BaseClusterRequest {
     BlueprintV2 blueprint;
     try {
       blueprint = getBlueprintFactory().getBlueprint(blueprintName);
+    } catch (NoSuchBlueprintException e) {
+      throw new InvalidTopologyTemplateException("Invalid blueprint specified: " + blueprintName);
+    } catch (IOException e) {
+      throw new InvalidTopologyTemplateException("Error reading blueprint: " + blueprintName);
     } catch (NoSuchStackException e) {
       throw new InvalidTopologyTemplateException("Invalid stack specified in the blueprint: " + blueprintName);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
deleted file mode 100644
index fb5d02c..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
+++ /dev/null
@@ -1,834 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ambari.server.controller.internal;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.ReadOnlyConfigurationResponse;
-import org.apache.ambari.server.controller.StackConfigurationRequest;
-import org.apache.ambari.server.controller.StackLevelConfigurationRequest;
-import org.apache.ambari.server.controller.StackServiceComponentRequest;
-import org.apache.ambari.server.controller.StackServiceComponentResponse;
-import org.apache.ambari.server.controller.StackServiceRequest;
-import org.apache.ambari.server.controller.StackServiceResponse;
-import org.apache.ambari.server.orm.entities.StackEntity;
-import org.apache.ambari.server.state.AutoDeployInfo;
-import org.apache.ambari.server.state.ComponentInfo;
-import org.apache.ambari.server.state.DependencyInfo;
-import org.apache.ambari.server.state.PropertyDependencyInfo;
-import org.apache.ambari.server.state.PropertyInfo;
-import org.apache.ambari.server.state.ValueAttributesInfo;
-import org.apache.ambari.server.topology.Cardinality;
-import org.apache.ambari.server.topology.Configuration;
-
-/**
- * Encapsulates stack information.
- */
-public class StackV2 {
-  /**
-   * Stack name
-   */
-  private String name;
-
-  /**
-   * Stack version
-   */
-  private String version;
-
-  /**
-     * Repo version
-   */
-  private String repoVersion;
-
-  /**
-   * Map of service name to components
-   */
-  private Map<String, Collection<String>> serviceComponents =
-    new HashMap<>();
-
-  /**
-   * Map of component to service
-   */
-  private Map<String, String> componentService = new HashMap<>();
-
-  /**
-   * Map of component to dependencies
-   */
-  private Map<String, Collection<DependencyInfo>> dependencies =
-    new HashMap<>();
-
-  /**
-   * Map of dependency to conditional service
-   */
-  private Map<DependencyInfo, String> dependencyConditionalServiceMap =
-    new HashMap<>();
-
-  /**
-   * Map of database component name to configuration property which indicates whether
-   * the database in to be managed or if it is an external non-managed instance.
-   * If the value of the config property starts with 'New', the database is determined
-   * to be managed, otherwise it is non-managed.
-   */
-  private Map<String, String> dbDependencyInfo = new HashMap<>();
-
-  /**
-   * Map of component to required cardinality
-   */
-  private Map<String, String> cardinalityRequirements = new HashMap<>();
-
-  //todo: instead of all these maps from component -> * ,
-  //todo: we should use a Component object with all of these attributes
-  private Set<String> masterComponents = new HashSet<>();
-
-  /**
-   * Map of component to auto-deploy information
-   */
-  private Map<String, AutoDeployInfo> componentAutoDeployInfo =
-    new HashMap<>();
-
-  /**
-   * Map of service to config type properties
-   */
-  private Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations =
-    new HashMap<>();
-
-  /**
-   * Map of service to required type properties
-   */
-  private Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations =
-    new HashMap<>();
-
-  /**
-   * Map of service to config type properties
-   */
-  private Map<String, Map<String, ConfigProperty>> stackConfigurations =
-    new HashMap<>();
-
-  /**
-   * Map of service to set of excluded config types
-   */
-  private Map<String, Set<String>> excludedConfigurationTypes =
-    new HashMap<>();
-
-  /**
-   * Ambari Management Controller, used to obtain Stack definitions
-   */
-  private final AmbariManagementController controller;
-
-
-  /**
-   * Constructor.
-   *
-   * @param stack
-   *          the stack (not {@code null}).
-   * @param ambariManagementController
-   *          the management controller (not {@code null}).
-   * @throws AmbariException
-   */
-  public StackV2(StackEntity stack, AmbariManagementController ambariManagementController) throws AmbariException {
-    this(stack.getStackName(), stack.getStackVersion(), ambariManagementController);
-  }
-
-  /**
-   * Constructor.
-   *
-   * @param name     stack name
-   * @param version  stack version
-   *
-   * @throws AmbariException an exception occurred getting stack information
-   *                         for the specified name and version
-   */
-  //todo: don't pass management controller in constructor
-  public StackV2(String name, String version, AmbariManagementController controller) throws AmbariException {
-    this.name = name;
-    this.version = version;
-    this.controller = controller;
-
-    Set<StackServiceResponse> stackServices = controller.getStackServices(
-        Collections.singleton(new StackServiceRequest(name, version, null)));
-
-    for (StackServiceResponse stackService : stackServices) {
-      String serviceName = stackService.getServiceName();
-      parseComponents(serviceName);
-      parseExcludedConfigurations(stackService);
-      parseConfigurations(stackService);
-      registerConditionalDependencies();
-    }
-
-    //todo: already done for each service
-    parseStackConfigurations();
-  }
-
-  /**
-   * Obtain stack name.
-   *
-   * @return stack name
-   */
-  public String getName() {
-    return name;
-  }
-
-  /**
-   * Obtain stack version.
-   *
-   * @return stack version
-   */
-  public String getVersion() {
-    return version;
-  }
-
-  /**
-   * Obtain repo version.
-   * @return
-   */
-  public String getRepoVersion() { return repoVersion; }
-
-  Map<DependencyInfo, String> getDependencyConditionalServiceMap() {
-    return dependencyConditionalServiceMap;
-  }
-
-  /**
-   * Get services contained in the stack.
-   *
-   * @return collection of all services for the stack
-   */
-  public Collection<String> getServices() {
-    return serviceComponents.keySet();
-  }
-
-  /**
-   * Get components contained in the stack for the specified service.
-   *
-   * @param service  service name
-   *
-   * @return collection of component names for the specified service
-   */
-  public Collection<String> getComponents(String service) {
-    return serviceComponents.get(service);
-  }
-
-  /**
-   * Get all service components
-   *
-   * @return map of service to associated components
-   */
-  public Map<String, Collection<String>> getComponents() {
-    Map<String, Collection<String>> serviceComponents = new HashMap<>();
-    for (String service : getServices()) {
-      Collection<String> components = new HashSet<>();
-      components.addAll(getComponents(service));
-      serviceComponents.put(service, components);
-    }
-    return serviceComponents;
-  }
-
-  /**
-   * Get info for the specified component.
-   *
-   * @param component  component name
-   *
-   * @return component information for the requested component
-   *         or null if the component doesn't exist in the stack
-   */
-  public ComponentInfo getComponentInfo(String component) {
-    ComponentInfo componentInfo = null;
-    String service = getServiceForComponent(component);
-    if (service != null) {
-      try {
-        componentInfo = controller.getAmbariMetaInfo().getComponent(
-            getName(), getVersion(), service, component);
-      } catch (AmbariException e) {
-        // just return null if component doesn't exist
-      }
-    }
-    return componentInfo;
-  }
-
-  /**
-   * Get all configuration types, including excluded types for the specified service.
-   *
-   * @param service  service name
-   *
-   * @return collection of all configuration types for the specified service
-   */
-  public Collection<String> getAllConfigurationTypes(String service) {
-    return serviceConfigurations.get(service).keySet();
-  }
-
-  /**
-   * Get configuration types for the specified service.
-   * This doesn't include any service excluded types.
-   *
-   * @param service  service name
-   *
-   * @return collection of all configuration types for the specified service
-   */
-  public Collection<String> getConfigurationTypes(String service) {
-    Set<String> serviceTypes = new HashSet<>(serviceConfigurations.get(service).keySet());
-    serviceTypes.removeAll(getExcludedConfigurationTypes(service));
-
-    return serviceTypes;
-  }
-
-  /**
-   * Get the set of excluded configuration types for this service.
-   *
-   * @param service service name
-   *
-   * @return Set of names of excluded config types. Will not return null.
-   */
-  public Set<String> getExcludedConfigurationTypes(String service) {
-    return excludedConfigurationTypes.containsKey(service) ?
-        excludedConfigurationTypes.get(service) :
-        Collections.emptySet();
-  }
-
-  /**
-   * Get config properties for the specified service and configuration type.
-   *
-   * @param service  service name
-   * @param type     configuration type
-   *
-   * @return map of property names to values for the specified service and configuration type
-   */
-  public Map<String, String> getConfigurationProperties(String service, String type) {
-    Map<String, String> configMap = new HashMap<>();
-    Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
-    if (configProperties != null) {
-      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-        configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
-      }
-    }
-    return configMap;
-  }
-
-  public Map<String, ConfigProperty> getConfigurationPropertiesWithMetadata(String service, String type) {
-    return serviceConfigurations.get(service).get(type);
-  }
-
-  /**
-   * Get all required config properties for the specified service.
-   *
-   * @param service  service name
-   *
-   * @return collection of all required properties for the given service
-   */
-  public Collection<ConfigProperty> getRequiredConfigurationProperties(String service) {
-    Collection<ConfigProperty> requiredConfigProperties = new HashSet<>();
-    Map<String, Map<String, ConfigProperty>> serviceProperties = requiredServiceConfigurations.get(service);
-    if (serviceProperties != null) {
-      for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : serviceProperties.entrySet()) {
-        requiredConfigProperties.addAll(typePropertiesEntry.getValue().values());
-      }
-    }
-    return requiredConfigProperties;
-  }
-
-  /**
-   * Get required config properties for the specified service which belong to the specified property type.
-   *
-   * @param service       service name
-   * @param propertyType  property type
-   *
-   * @return collection of required properties for the given service and property type
-   */
-  public Collection<ConfigProperty> getRequiredConfigurationProperties(String service, org.apache.ambari.server.state.PropertyInfo.PropertyType propertyType) {
-    Collection<ConfigProperty> matchingProperties = new HashSet<>();
-    Map<String, Map<String, ConfigProperty>> requiredProperties = requiredServiceConfigurations.get(service);
-    if (requiredProperties != null) {
-      for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : requiredProperties.entrySet()) {
-        for (ConfigProperty configProperty : typePropertiesEntry.getValue().values()) {
-          if (configProperty.getPropertyTypes().contains(propertyType)) {
-            matchingProperties.add(configProperty);
-          }
-        }
-
-      }
-    }
-    return matchingProperties;
-  }
-
-  public boolean isPasswordProperty(String service, String type, String propertyName) {
-    return (serviceConfigurations.containsKey(service) &&
-            serviceConfigurations.get(service).containsKey(type) &&
-            serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
-            serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
-                contains(org.apache.ambari.server.state.PropertyInfo.PropertyType.PASSWORD));
-  }
-
-  //todo
-  public Map<String, String> getStackConfigurationProperties(String type) {
-    Map<String, String> configMap = new HashMap<>();
-    Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
-    if (configProperties != null) {
-      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-        configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
-      }
-    }
-    return configMap;
-  }
-
-  public boolean isKerberosPrincipalNameProperty(String service, String type, String propertyName) {
-    return (serviceConfigurations.containsKey(service) &&
-            serviceConfigurations.get(service).containsKey(type) &&
-            serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
-            serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
-                contains(org.apache.ambari.server.state.PropertyInfo.PropertyType.KERBEROS_PRINCIPAL));
-  }
-  /**
-   * Get config attributes for the specified service and configuration type.
-   *
-   * @param service  service name
-   * @param type     configuration type
-   *
-   * @return  map of attribute names to map of property names to attribute values
-   *          for the specified service and configuration type
-   */
-  public Map<String, Map<String, String>> getConfigurationAttributes(String service, String type) {
-    Map<String, Map<String, String>> attributesMap = new HashMap<>();
-    Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
-    if (configProperties != null) {
-      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-        String propertyName = configProperty.getKey();
-        Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
-        if (propertyAttributes != null) {
-          for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
-            String attributeName = propertyAttribute.getKey();
-            String attributeValue = propertyAttribute.getValue();
-            if (attributeValue != null) {
-              Map<String, String> attributes = attributesMap.get(attributeName);
-              if (attributes == null) {
-                  attributes = new HashMap<>();
-                  attributesMap.put(attributeName, attributes);
-              }
-              attributes.put(propertyName, attributeValue);
-            }
-          }
-        }
-      }
-    }
-    return attributesMap;
-  }
-
-  //todo:
-  public Map<String, Map<String, String>> getStackConfigurationAttributes(String type) {
-    Map<String, Map<String, String>> attributesMap = new HashMap<>();
-    Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
-    if (configProperties != null) {
-      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-        String propertyName = configProperty.getKey();
-        Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
-        if (propertyAttributes != null) {
-          for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
-            String attributeName = propertyAttribute.getKey();
-            String attributeValue = propertyAttribute.getValue();
-            Map<String, String> attributes = attributesMap.get(attributeName);
-            if (attributes == null) {
-              attributes = new HashMap<>();
-              attributesMap.put(attributeName, attributes);
-            }
-            attributes.put(propertyName, attributeValue);
-          }
-        }
-      }
-    }
-    return attributesMap;
-  }
-
-  /**
-   * Get the service for the specified component.
-   *
-   * @param component  component name
-   *
-   * @return service name that contains tha specified component
-   */
-  public String getServiceForComponent(String component) {
-    return componentService.get(component);
-  }
-
-  /**
-   * Get the names of the services which contains the specified components.
-   *
-   * @param components collection of components
-   *
-   * @return collection of services which contain the specified components
-   */
-  public Collection<String> getServicesForComponents(Collection<String> components) {
-    Set<String> services = new HashSet<>();
-    for (String component : components) {
-      services.add(getServiceForComponent(component));
-    }
-
-    return services;
-  }
-
-  /**
-   * Obtain the service name which corresponds to the specified configuration.
-   *
-   * @param config  configuration type
-   *
-   * @return name of service which corresponds to the specified configuration type
-   */
-  public String getServiceForConfigType(String config) {
-    for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) {
-      Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue();
-      String serviceName = entry.getKey();
-      if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) {
-        return serviceName;
-      }
-    }
-    throw new IllegalArgumentException(
-        "Specified configuration type is not associated with any service: " + config);
-  }
-
-  /**
-   * Return the dependencies specified for the given component.
-   *
-   * @param component  component to get dependency information for
-   *
-   * @return collection of dependency information for the specified component
-   */
-  //todo: full dependency graph
-  public Collection<DependencyInfo> getDependenciesForComponent(String component) {
-    return dependencies.containsKey(component) ? dependencies.get(component) :
-        Collections.emptySet();
-  }
-
-  /**
-   * Get the service, if any, that a component dependency is conditional on.
-   *
-   * @param dependency  dependency to get conditional service for
-   *
-   * @return conditional service for provided component or null if dependency
-   *         is not conditional on a service
-   */
-  public String getConditionalServiceForDependency(DependencyInfo dependency) {
-    return dependencyConditionalServiceMap.get(dependency);
-  }
-
-  public String getExternalComponentConfig(String component) {
-    return dbDependencyInfo.get(component);
-  }
-
-  /**
-   * Obtain the required cardinality for the specified component.
-   */
-  public Cardinality getCardinality(String component) {
-    return new Cardinality(cardinalityRequirements.get(component));
-  }
-
-  /**
-   * Obtain auto-deploy information for the specified component.
-   */
-  public AutoDeployInfo getAutoDeployInfo(String component) {
-    return componentAutoDeployInfo.get(component);
-  }
-
-  public boolean isMasterComponent(String component) {
-    return masterComponents.contains(component);
-  }
-
-  public Configuration getConfiguration(Collection<String> services) {
-    Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>();
-    Map<String, Map<String, String>> properties = new HashMap<>();
-
-    for (String service : services) {
-      Collection<String> serviceConfigTypes = getConfigurationTypes(service);
-      for (String type : serviceConfigTypes) {
-        Map<String, String> typeProps = properties.get(type);
-        if (typeProps == null) {
-          typeProps = new HashMap<>();
-          properties.put(type, typeProps);
-        }
-        typeProps.putAll(getConfigurationProperties(service, type));
-
-        Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
-        if (!stackTypeAttributes.isEmpty()) {
-          if (! attributes.containsKey(type)) {
-            attributes.put(type, new HashMap<>());
-          }
-          Map<String, Map<String, String>> typeAttributes = attributes.get(type);
-          for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
-            String attributeName = attribute.getKey();
-            Map<String, String> attributeProps = typeAttributes.get(attributeName);
-            if (attributeProps == null) {
-              attributeProps = new HashMap<>();
-              typeAttributes.put(attributeName, attributeProps);
-            }
-            attributeProps.putAll(attribute.getValue());
-          }
-        }
-      }
-    }
-    return new Configuration(properties, attributes);
-  }
-
-  public Configuration getConfiguration() {
-    Map<String, Map<String, Map<String, String>>> stackAttributes = new HashMap<>();
-    Map<String, Map<String, String>> stackConfigs = new HashMap<>();
-
-    for (String service : getServices()) {
-      for (String type : getAllConfigurationTypes(service)) {
-        Map<String, String> typeProps = stackConfigs.get(type);
-        if (typeProps == null) {
-          typeProps = new HashMap<>();
-          stackConfigs.put(type, typeProps);
-        }
-        typeProps.putAll(getConfigurationProperties(service, type));
-
-        Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
-        if (!stackTypeAttributes.isEmpty()) {
-          if (! stackAttributes.containsKey(type)) {
-            stackAttributes.put(type, new HashMap<>());
-          }
-          Map<String, Map<String, String>> typeAttrs = stackAttributes.get(type);
-          for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
-            String attributeName = attribute.getKey();
-            Map<String, String> attributes = typeAttrs.get(attributeName);
-            if (attributes == null) {
-              attributes = new HashMap<>();
-              typeAttrs.put(attributeName, attributes);
-            }
-            attributes.putAll(attribute.getValue());
-          }
-        }
-      }
-    }
-    return new Configuration(stackConfigs, stackAttributes);
-  }
-
-  /**
-   * Parse components for the specified service from the stack definition.
-   *
-   * @param service  service name
-   *
-   * @throws AmbariException an exception occurred getting components from the stack definition
-   */
-  private void parseComponents(String service) throws AmbariException{
-    Collection<String> componentSet = new HashSet<>();
-
-    Set<StackServiceComponentResponse> components = controller.getStackComponents(
-        Collections.singleton(new StackServiceComponentRequest(name, version, service, null)));
-
-    // stack service components
-    for (StackServiceComponentResponse component : components) {
-      String componentName = component.getComponentName();
-      componentSet.add(componentName);
-      componentService.put(componentName, service);
-      String cardinality = component.getCardinality();
-      if (cardinality != null) {
-        cardinalityRequirements.put(componentName, cardinality);
-      }
-      AutoDeployInfo autoDeploy = component.getAutoDeploy();
-      if (autoDeploy != null) {
-        componentAutoDeployInfo.put(componentName, autoDeploy);
-      }
-
-      // populate component dependencies
-      //todo: remove usage of AmbariMetaInfo
-      Collection<DependencyInfo> componentDependencies = controller.getAmbariMetaInfo().getComponentDependencies(
-          name, version, service, componentName);
-
-      if (componentDependencies != null && ! componentDependencies.isEmpty()) {
-        dependencies.put(componentName, componentDependencies);
-      }
-      if (component.isMaster()) {
-        masterComponents.add(componentName);
-      }
-    }
-    serviceComponents.put(service, componentSet);
-  }
-
-  /**
-   * Parse configurations for the specified service from the stack definition.
-   *
-   * @param stackService  service to parse the stack configuration for
-   *
-   * @throws AmbariException an exception occurred getting configurations from the stack definition
-   */
-  private void parseConfigurations(StackServiceResponse stackService) throws AmbariException {
-    String service = stackService.getServiceName();
-    Map<String, Map<String, ConfigProperty>> mapServiceConfig = new HashMap<>();
-    Map<String, Map<String, ConfigProperty>> mapRequiredServiceConfig = new HashMap<>();
-
-
-    serviceConfigurations.put(service, mapServiceConfig);
-    requiredServiceConfigurations.put(service, mapRequiredServiceConfig);
-
-    Set<ReadOnlyConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
-        Collections.singleton(new StackConfigurationRequest(name, version, service, null)));
-    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
-        Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
-    serviceConfigs.addAll(stackLevelConfigs);
-
-    // shouldn't have any required properties in stack level configuration
-    for (ReadOnlyConfigurationResponse config : serviceConfigs) {
-      ConfigProperty configProperty = new ConfigProperty(config);
-      String type = configProperty.getType();
-
-      Map<String, ConfigProperty> mapTypeConfig = mapServiceConfig.get(type);
-      if (mapTypeConfig == null) {
-        mapTypeConfig = new HashMap<>();
-        mapServiceConfig.put(type, mapTypeConfig);
-      }
-
-      mapTypeConfig.put(config.getPropertyName(), configProperty);
-      if (config.isRequired()) {
-        Map<String, ConfigProperty> requiredTypeConfig = mapRequiredServiceConfig.get(type);
-        if (requiredTypeConfig == null) {
-          requiredTypeConfig = new HashMap<>();
-          mapRequiredServiceConfig.put(type, requiredTypeConfig);
-        }
-        requiredTypeConfig.put(config.getPropertyName(), configProperty);
-      }
-    }
-
-    // So far we added only config types that have properties defined
-    // in stack service definition. Since there might be config types
-    // with no properties defined we need to add those separately
-    Set<String> configTypes = stackService.getConfigTypes().keySet();
-    for (String configType: configTypes) {
-      if (!mapServiceConfig.containsKey(configType)) {
-        mapServiceConfig.put(configType, Collections.emptyMap());
-      }
-    }
-  }
-
-  private void parseStackConfigurations () throws AmbariException {
-
-    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
-        Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
-
-    for (ReadOnlyConfigurationResponse config : stackLevelConfigs) {
-      ConfigProperty configProperty = new ConfigProperty(config);
-      String type = configProperty.getType();
-
-      Map<String, ConfigProperty> mapTypeConfig = stackConfigurations.get(type);
-      if (mapTypeConfig == null) {
-        mapTypeConfig = new HashMap<>();
-        stackConfigurations.put(type, mapTypeConfig);
-      }
-
-      mapTypeConfig.put(config.getPropertyName(),
-          configProperty);
-    }
-  }
-
-  /**
-   * Obtain the excluded configuration types from the StackServiceResponse
-   *
-   * @param stackServiceResponse the response object associated with this stack service
-   */
-  private void parseExcludedConfigurations(StackServiceResponse stackServiceResponse) {
-    excludedConfigurationTypes.put(stackServiceResponse.getServiceName(), stackServiceResponse.getExcludedConfigTypes());
-  }
-
-  /**
-   * Register conditional dependencies.
-   */
-  //todo: This information should be specified in the stack definition.
-  void registerConditionalDependencies() {
-    dbDependencyInfo.put("MYSQL_SERVER", "global/hive_database");
-  }
-
-  /**
-   * Contains a configuration property's value and attributes.
-   */
-  public static class ConfigProperty {
-    private ValueAttributesInfo propertyValueAttributes = null;
-    private String name;
-    private String value;
-    private Map<String, String> attributes;
-    private Set<org.apache.ambari.server.state.PropertyInfo.PropertyType> propertyTypes;
-    private String type;
-    private Set<PropertyDependencyInfo> dependsOnProperties =
-      Collections.emptySet();
-
-    public ConfigProperty(ReadOnlyConfigurationResponse config) {
-      this.name = config.getPropertyName();
-      this.value = config.getPropertyValue();
-      this.attributes = config.getPropertyAttributes();
-      this.propertyTypes = config.getPropertyType();
-      this.type = normalizeType(config.getType());
-      this.dependsOnProperties = config.getDependsOnProperties();
-      this.propertyValueAttributes = config.getPropertyValueAttributes();
-    }
-
-    public ConfigProperty(String type, String name, String value) {
-      this.type = type;
-      this.name = name;
-      this.value = value;
-    }
-
-    public String getName() {
-      return name;
-    }
-
-    public String getValue() {
-      return value;
-    }
-
-    public void setValue(String value) {
-      this.value = value;
-    }
-
-    public String getType() {
-      return type;
-    }
-
-    public Set<org.apache.ambari.server.state.PropertyInfo.PropertyType> getPropertyTypes() {
-      return propertyTypes;
-    }
-
-    public void setPropertyTypes(Set<PropertyInfo.PropertyType> propertyTypes) {
-      this.propertyTypes = propertyTypes;
-    }
-
-    public Map<String, String> getAttributes() {
-      return attributes;
-    }
-
-    public void setAttributes(Map<String, String> attributes) {
-      this.attributes = attributes;
-    }
-
-    Set<PropertyDependencyInfo> getDependsOnProperties() {
-      return this.dependsOnProperties;
-    }
-
-    private String normalizeType(String type) {
-      //strip .xml from type
-      if (type.endsWith(".xml")) {
-        type = type.substring(0, type.length() - 4);
-      }
-      return type;
-    }
-
-    public ValueAttributesInfo getPropertyValueAttributes() {
-      return propertyValueAttributes;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
index a566625..3a70f81 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.Map;
 import java.util.Optional;
 
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.topology.ClusterTopology;
 import org.apache.ambari.server.topology.validators.UnitValidatedProperty;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
index 0434728..9270e7d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
@@ -53,6 +53,7 @@ import org.apache.ambari.server.controller.ServiceComponentHostRequest;
 import org.apache.ambari.server.controller.ServiceComponentRequest;
 import org.apache.ambari.server.controller.ServiceGroupRequest;
 import org.apache.ambari.server.controller.ServiceRequest;
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.controller.internal.AbstractResourceProvider;
 import org.apache.ambari.server.controller.internal.ComponentResourceProvider;
 import org.apache.ambari.server.controller.internal.ConfigGroupResourceProvider;
@@ -62,7 +63,6 @@ import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
 import org.apache.ambari.server.controller.internal.RequestImpl;
 import org.apache.ambari.server.controller.internal.ServiceGroupResourceProvider;
 import org.apache.ambari.server.controller.internal.ServiceResourceProvider;
-import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.controller.internal.VersionDefinitionResourceProvider;
 import org.apache.ambari.server.controller.predicate.EqualsPredicate;
 import org.apache.ambari.server.controller.spi.ClusterController;
@@ -242,7 +242,8 @@ public class AmbariContext {
       for (Service service : serviceGroup.getServices()) {
         String credentialStoreEnabled = topology.getBlueprint().getCredentialStoreEnabled(service.getType());
 
-        StackV2 stack = service.getStack();
+        String stackIdStr = service.getStackId();
+        StackV2 stack = topology.getBlueprint().getStackById(stackIdStr);
         StackId stackId = new StackId(stack.getName(), stack.getVersion());
         RepositoryVersionEntity repoVersion = repositoryVersionDAO.findByStackAndVersion(stackId, stack.getRepoVersion());
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
index fc419cb..404068d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
@@ -82,10 +82,10 @@ public class BlueprintFactory {
     this.stackFactory = stackFactory;
   }
 
-  public BlueprintV2 getBlueprint(String blueprintName) throws NoSuchStackException {
+  public Blueprint getBlueprint(String blueprintName) throws NoSuchStackException {
     BlueprintEntity entity = blueprintDAO.findByName(blueprintName);
     //todo: just return null?
-    return entity == null ? null : new BlueprintImplV2(entity);
+    return entity == null ? null : new BlueprintImpl(entity);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
index b2119e6..4b7dd32 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
@@ -135,33 +135,45 @@ public class BlueprintImplV2 implements BlueprintV2 {
 
   @Override
   @JsonIgnore
-  public Collection<ServiceId> getAllServices() {
-    return hostGroups.stream().flatMap(hg -> hg.getServices().stream()).collect(Collectors.toSet());
+  public Collection<ServiceId> getAllServiceIds() {
+    return hostGroups.stream().flatMap(hg -> hg.getServiceIds().stream()).collect(Collectors.toSet());
   }
 
   @Override
   @JsonIgnore
-  public Collection<String> getAllServiceTypes() {
+  public Collection<Service> getServicesFromServiceGroup(ServiceGroup serviceGroup, String serviceType) {
+    if (serviceType == null) {
+      return serviceGroup.getServices();
+    } else {
+      return serviceGroup.getServices().stream().filter(
+              service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
+    }
+  }
+
+  @Override
+  @JsonIgnore
+  public StackV2 getStackById(String stackId) {
     return null;
   }
 
   @Override
   @JsonIgnore
-  public Collection<Service> getServicesByType(String serviceType) {
+  public Collection<Service> getAllServices() {
     return null;
-//    getAllServices().stream().filter(
-//            service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
   }
 
   @Override
   @JsonIgnore
-  public Collection<Service> getServicesFromServiceGroup(ServiceGroup serviceGroup, String serviceType) {
-    if (serviceType == null) {
-      return serviceGroup.getServices();
-    } else {
-      return serviceGroup.getServices().stream().filter(
-              service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
-    }
+  public Collection<String> getAllServiceTypes() {
+    return null;
+  }
+
+  @Override
+  @JsonIgnore
+  public Collection<Service> getServicesByType(String serviceType) {
+    return null;
+//    getAllServices().stream().filter(
+//            service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
   }
 
   @Override
@@ -186,7 +198,7 @@ public class BlueprintImplV2 implements BlueprintV2 {
   @Override
   @JsonIgnore
   public Collection<HostGroupV2> getHostGroupsForService(ServiceId serviceId) {
-    return hostGroups.stream().filter(hg -> !hg.getComponents(serviceId).isEmpty()).collect(Collectors.toList());
+    return hostGroups.stream().filter(hg -> !hg.getComponentsByServiceId(serviceId).isEmpty()).collect(Collectors.toList());
   }
 
   @Override
@@ -205,10 +217,7 @@ public class BlueprintImplV2 implements BlueprintV2 {
     return this.setting;
   }
 
-  @Override
-  public String getRecoveryEnabled(ComponentV2 component) {
-    return null;
-  }
+
 
   @Nonnull
   @Override
@@ -224,6 +233,10 @@ public class BlueprintImplV2 implements BlueprintV2 {
   }
 
   @Override
+  public String getRecoveryEnabled(ComponentV2 component) {
+    return null;
+  }
+
   public String getRecoveryEnabled(String serviceName, String componentName) {
     // If component name was specified in the list of "component_settings",
     // determine if recovery_enabled is true or false and return it.

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
index ea17e90..29539db 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
@@ -22,11 +22,9 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
-
 import javax.annotation.Nonnull;
 
 import org.apache.ambari.server.controller.StackV2;
-
 import org.apache.ambari.server.orm.entities.BlueprintEntity;
 
 
@@ -69,6 +67,8 @@ public interface BlueprintV2 {
   **/
   public Collection<String> getStackIds();
 
+  StackV2 getStackById(String stackId);
+
   Collection<ServiceGroup> getServiceGroups();
 
   /**
@@ -76,7 +76,9 @@ public interface BlueprintV2 {
    *
    * @return collection of all represented service names
    */
-  Collection<ServiceId> getAllServices();
+  Collection<ServiceId> getAllServiceIds();
+
+  ;Collection<Service> getAllServices();
 
   /**
    * Get the names of all the services represented in the blueprint.
@@ -129,6 +131,8 @@ public interface BlueprintV2 {
    */
   Collection<ComponentV2> getComponents(ServiceId serviceId);
 
+  Collection<ComponentV2> getComponents(Service service);
+
 
   /**
    * Get components by type from a service.

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
index 6b86ba5..b3ce044 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
@@ -33,11 +33,11 @@ import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorBlueprintProcessor;
 import org.apache.ambari.server.controller.ClusterRequest;
 import org.apache.ambari.server.controller.ConfigurationRequest;
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.controller.internal.BlueprintConfigurationProcessor;
 import org.apache.ambari.server.controller.internal.ClusterResourceProvider;
 import org.apache.ambari.server.controller.internal.ConfigurationContext;
 import org.apache.ambari.server.controller.internal.ConfigurationTopologyException;
-import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.serveraction.kerberos.KerberosInvalidConfigurationException;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.SecurityType;
@@ -361,7 +361,8 @@ public class ClusterConfigurationRequest {
       //todo: remove intermediate request type
       // one bp config request per service
       BlueprintServiceConfigRequest blueprintConfigRequest = new BlueprintServiceConfigRequest(service.getType());
-      StackV2 serviceStack = service.getStack();
+      String serviceStackId = service.getStackId();
+      StackV2 serviceStack = blueprint.getStackById(serviceStackId);
       for (String serviceConfigType : serviceStack.getAllConfigurationTypes(service.getType())) {
         Set<String> excludedConfigTypes = serviceStack.getExcludedConfigurationTypes(service.getType());
         if (!excludedConfigTypes.contains(serviceConfigType)) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
index 43dda1b..e59b1f9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
@@ -69,6 +69,16 @@ public class ComponentV2 implements Configurable {
     return serviceId;
   }
 
+  //TODO
+  public Service getService() {
+    return null;
+  }
+
+  //TODO
+  public ServiceGroup getServiceGroup() {
+    return null;
+  }
+
   public Configuration getConfiguration() {
     return configuration;
   }
@@ -88,7 +98,7 @@ public class ComponentV2 implements Configurable {
     this.name = name;
   }
 
-  public String getServiceGroup() {
+  public String getServiceGroupName() {
     return serviceId.getServiceGroup();
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
index 0922e74..4745f59 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
@@ -87,7 +87,9 @@ public interface HostGroupV2 {
    *
    * @return collection of component names for the specified service; will not return null
    */
-  Collection<ComponentV2> getComponents(ServiceId serviceId);
+  Collection<ComponentV2> getComponentsByServiceId(ServiceId serviceId);
+
+  Collection<ComponentV2> getComponents(Service serviceId);
 
   /**
    * Determine if the host group contains a master component.
@@ -99,7 +101,12 @@ public interface HostGroupV2 {
   /**
    * @return collection of service ids associated with the host group components.
    */
-  Collection<ServiceId> getServices();
+  Collection<ServiceId> getServiceIds();
+
+  /**
+   * @return collection of service ids associated with the host group components.
+   */
+  Collection<Service> getServices();
 
   /**
    * @return collection of service names associated with the host group components.

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
index 351351b..e9f4f4b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
@@ -67,7 +67,12 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
   }
 
   @Override
-  public Collection<ComponentV2> getComponents(ServiceId serviceId) {
+  public Collection<ComponentV2> getComponents(Service serviceId) {
+    return null;
+  }
+
+  @Override
+  public Collection<ComponentV2> getComponentsByServiceId(ServiceId serviceId) {
     return components.stream().filter(c -> c.getServiceId().equals(serviceId)).collect(Collectors.toList());
   }
 
@@ -77,13 +82,18 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
   }
 
   @Override
-  @JsonIgnore
-  public Collection<ServiceId> getServices() {
+  public Collection<ServiceId> getServiceIds() {
     return services;
   }
 
   @Override
   @JsonIgnore
+  public Collection<Service> getServices() {
+    return null;
+  }
+
+  @Override
+  @JsonIgnore
   public Collection<String> getServiceNames() {
     return services.stream().map(s -> s.getName()).collect(Collectors.toList());
   }
@@ -94,6 +104,11 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
   }
 
   @Override
+  public Collection<Service> getServiceConfigs() {
+    return null;
+  }
+
+  @Override
   public String getCardinality() {
     return cardinality;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
index 3243359..685d208 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
@@ -31,9 +31,9 @@ import java.util.Map;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.api.predicate.PredicateCompiler;
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.controller.internal.HostResourceProvider;
 import org.apache.ambari.server.controller.internal.ResourceImpl;
-import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
index 8b51fab..a9a132b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.topology;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -93,7 +94,7 @@ public class PersistedStateImpl implements PersistedState {
   private HostRoleCommandDAO physicalTaskDAO;
 
   @Inject
-  private BlueprintFactory blueprintFactory;
+  private BlueprintV2Factory blueprintFactory;
 
   @Inject
   private LogicalRequestFactory logicalRequestFactory;
@@ -382,13 +383,17 @@ public class PersistedStateImpl implements PersistedState {
     private final Collection<Service> services;
     private final Map<String, HostGroupInfo> hostGroupInfoMap = new HashMap<>();
 
-    public ReplayedTopologyRequest(TopologyRequestEntity entity, BlueprintFactory blueprintFactory) {
+    public ReplayedTopologyRequest(TopologyRequestEntity entity, BlueprintV2Factory blueprintFactory) {
       clusterId = entity.getClusterId();
       type = Type.valueOf(entity.getAction());
       description = entity.getDescription();
 
       try {
         blueprint = blueprintFactory.getBlueprint(entity.getBlueprintName());
+      } catch (NoSuchBlueprintException e) {
+        throw new RuntimeException("Unable to load blueprint while replaying topology request: " + e, e);
+      } catch (IOException e) {
+        throw new RuntimeException("Unable to load blueprint while replaying topology request: " + e, e);
       } catch (NoSuchStackException e) {
         throw new RuntimeException("Unable to load blueprint while replaying topology request: " + e, e);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
index 1dde7ea..81f235c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
@@ -21,6 +21,8 @@ package org.apache.ambari.server.topology;
 
 import java.util.Set;
 
+import org.apache.ambari.server.controller.StackV2;
+
 import com.fasterxml.jackson.annotation.JsonProperty;
 
 public class Service implements Configurable {
@@ -44,10 +46,15 @@ public class Service implements Configurable {
     return this.id.getName();
   }
 
-  public String getServiceGroup() {
+  public String getServiceGroupId() {
     return this.id.getServiceGroup();
   }
 
+  //TODO
+  public ServiceGroup getServiceGroup() {
+    return null;
+  }
+
   public String getType() {
     return type;
   }
@@ -56,10 +63,20 @@ public class Service implements Configurable {
     return stackId;
   }
 
-  public Set<ServiceId> getDependencies() {
+  //TODO
+  public StackV2 getStack() {
+    return null;
+  }
+
+  public Set<ServiceId> getDependentServiceIds() {
     return dependencies;
   }
 
+  //TODO
+  public Set<Service> getDependencies() {
+    return null;
+  }
+
   public Configuration getConfiguration() {
     return configuration;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
index 7691619..3b7dcc8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
@@ -42,6 +42,7 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.AmbariServer;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.ShortTaskStatus;
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.controller.internal.ArtifactResourceProvider;
 import org.apache.ambari.server.controller.internal.BaseClusterRequest;
 import org.apache.ambari.server.controller.internal.CalculatedStatus;
@@ -49,7 +50,6 @@ import org.apache.ambari.server.controller.internal.CredentialResourceProvider;
 import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
 import org.apache.ambari.server.controller.internal.RequestImpl;
 import org.apache.ambari.server.controller.internal.ScaleClusterRequest;
-import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
 import org.apache.ambari.server.controller.spi.RequestStatus;
 import org.apache.ambari.server.controller.spi.Resource;

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
index 94a1a5c..7ac75e9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
@@ -16,6 +16,7 @@ package org.apache.ambari.server.topology.validators;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.topology.ClusterTopology;
 import org.apache.ambari.server.topology.InvalidTopologyException;
 import org.apache.ambari.server.topology.Service;
@@ -46,7 +47,9 @@ public class ClusterConfigTypeValidator implements TopologyValidator {
     // collecting all config types for services in the blueprint (from the related stack)
     Set<String> stackServiceConfigTypes = new HashSet<>();
     for (Service service : topology.getBlueprint().getAllServices()) {
-      stackServiceConfigTypes.addAll(service.getStack().getConfigurationTypes(service.getType()));
+      String stackId = service.getStackId();
+      StackV2 stack = topology.getBlueprint().getStackById(stackId);
+      stackServiceConfigTypes.addAll(stack.getConfigurationTypes(service.getType()));
     }
 
     // identifying invalid config types

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
index 05c063c..fd07572 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
@@ -21,7 +21,7 @@ import java.util.Map;
 import java.util.TreeMap;
 import java.util.TreeSet;
 
-import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.topology.ClusterTopology;
 import org.apache.ambari.server.topology.HostGroupV2;

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
index 41dee07..2258d97 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
@@ -19,7 +19,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
-import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.topology.BlueprintV2;
 import org.apache.ambari.server.topology.ClusterTopology;

http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
index 8c8475a..00b9838 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
@@ -22,7 +22,7 @@ import static org.apache.ambari.server.controller.internal.UnitUpdater.PropertyV
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.controller.internal.UnitUpdater.PropertyUnit;
 import org.apache.ambari.server.topology.ClusterTopology;
 import org.apache.ambari.server.topology.InvalidTopologyException;
@@ -42,11 +42,13 @@ public class UnitValidator implements TopologyValidator {
   @Override
   public void validate(ClusterTopology topology) throws InvalidTopologyException {
     topology.getServiceConfigs().forEach(service -> {
-      validateConfig(service.getConfiguration().getFullProperties(), service.getStack());
-      topology.getHostGroupInfo().values().forEach(hostGroup ->
-        validateConfig(hostGroup.getConfiguration().getFullProperties(), service.getStack()));
+      String stackId = service.getStackId();
+      validateConfig(service.getConfiguration().getFullProperties(), topology.getBlueprint().getStackById(stackId));
+      topology.getHostGroupInfo().values().forEach(hostGroup -> {
+        String stackId2 = service.getStackId();
+        validateConfig(hostGroup.getConfiguration().getFullProperties(), topology.getBlueprint().getStackById(stackId2));
+      });
     });
-
   }
 
   private void validateConfig(Map<String, Map<String, String>> configuration, StackV2 stack) {


[20/30] ambari git commit: AMBARI-22067 : Registry API should sort versions with latest at index 0 (mradhakrishnan)

Posted by mr...@apache.org.
AMBARI-22067 : Registry API should sort versions with latest at index 0 (mradhakrishnan)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: f50d9a2aa67d38712b36990d4047b400fafa4a68
Parents: 1c6de79
Author: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Authored: Mon Oct 23 11:20:09 2017 -0700
Committer: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Committed: Mon Oct 23 11:20:09 2017 -0700

----------------------------------------------------------------------
 .../RegistryMpackVersionResourceProvider.java   | 56 ++++++++++++++++++--
 1 file changed, 51 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f50d9a2a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackVersionResourceProvider.java
index 32cf234..3b8a3f5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RegistryMpackVersionResourceProvider.java
@@ -19,8 +19,12 @@ package org.apache.ambari.server.controller.internal;
 
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -30,9 +34,11 @@ import org.apache.ambari.server.ParentObjectNotFoundException;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.RegistryMpackVersionRequest;
 import org.apache.ambari.server.controller.RegistryMpackVersionResponse;
+import org.apache.ambari.server.controller.spi.ExtendedResourceProvider;
 import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
 import org.apache.ambari.server.controller.spi.NoSuchResourceException;
 import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.QueryResponse;
 import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.SystemException;
@@ -42,11 +48,12 @@ import org.apache.ambari.server.exceptions.RegistryMpackNotFoundException;
 import org.apache.ambari.server.registry.Registry;
 import org.apache.ambari.server.registry.RegistryMpack;
 import org.apache.ambari.server.registry.RegistryMpackVersion;
+import org.apache.ambari.server.utils.VersionUtils;
 
 /**
  * ResourceProvider for mpacks in software registry
  */
-public class RegistryMpackVersionResourceProvider extends AbstractControllerResourceProvider {
+public class RegistryMpackVersionResourceProvider extends AbstractControllerResourceProvider implements ExtendedResourceProvider {
   public static final String RESPONSE_KEY = "RegistryMpackVersionInfo";
   public static final String ALL_PROPERTIES = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "*";
 
@@ -72,6 +79,11 @@ public class RegistryMpackVersionResourceProvider extends AbstractControllerReso
    */
   private static final Map<Resource.Type, String> KEY_PROPERTY_IDS = new HashMap<>();
 
+  /***
+   * Resource count for get resources
+   */
+  private static int resourceCount;
+
   static {
     // properties
     PROPERTY_IDS.add(REGISTRY_ID);
@@ -96,6 +108,7 @@ public class RegistryMpackVersionResourceProvider extends AbstractControllerReso
    */
   protected RegistryMpackVersionResourceProvider(final AmbariManagementController managementController) {
     super(PROPERTY_IDS, KEY_PROPERTY_IDS, managementController);
+    resourceCount = 0;
   }
 
   /**
@@ -133,7 +146,7 @@ public class RegistryMpackVersionResourceProvider extends AbstractControllerReso
       }
     });
 
-    Set<Resource> resources = new HashSet<>();
+    List<Resource> sortedResources = new LinkedList<>();
     for (RegistryMpackVersionResponse response : responses) {
       Resource resource = new ResourceImpl(Resource.Type.RegistryMpackVersion);
       setResourceProperty(resource, REGISTRY_ID, response.getRegistryId(), requestedIds);
@@ -144,9 +157,25 @@ public class RegistryMpackVersionResourceProvider extends AbstractControllerReso
       setResourceProperty(resource, REGISTRY_MPACK_DOC_URL, response.getMpackDocUrl(), requestedIds);
       setResourceProperty(resource, REGISTRY_MPACK_SERVICES, response.getMpackServices(), requestedIds);
       setResourceProperty(resource, REGISTRY_MPACK_COMPATIBLE_MPACKS, response.getCompatibleMpacks(), requestedIds);
-      resources.add(resource);
+      sortedResources.add(resource);
     }
-    return resources;
+    sortedResources.sort(new Comparator<Resource>() {
+      @Override
+      public int compare(final Resource o1, final Resource o2) {
+        int o1Wins = 0;
+        int o2Wins = 0;
+          int compareResult = VersionUtils.compareVersions((String)o1.getPropertyValue(REGISTRY_MPACK_VERSION), (String)o2.getPropertyValue(REGISTRY_MPACK_VERSION));
+          if(compareResult > 0) {
+            o1Wins++;
+          } else if(compareResult < 0) {
+            o2Wins++;
+          }
+        // Order in reverse order
+        return o2Wins - o1Wins;
+      }
+    });
+    resourceCount = sortedResources.size();
+    return new LinkedHashSet<>(sortedResources);
   }
 
   private RegistryMpackVersionRequest getRequest(Map<String, Object> properties) {
@@ -231,5 +260,22 @@ public class RegistryMpackVersionResourceProvider extends AbstractControllerReso
       }
     }
     return responses;
-  }  
+  }
+
+  @Override
+  public QueryResponse queryForResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+    return new QueryResponseImpl(
+            getResourcesAuthorized(request, predicate),
+            true,
+            request.getPageRequest() != null,
+            getResourceCount());
+  }
+
+  /***
+   *
+   * @return number of resources returned in response to GET calls.
+   */
+  private int getResourceCount() {
+    return resourceCount;
+  }
 }


[08/30] ambari git commit: use V2 objects in TopologyManager

Posted by mr...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
index 03f84a5..4c51762 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
@@ -37,30 +37,19 @@ import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Sets;
+
 import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.ConfigHelper;
-import org.apache.ambari.server.state.PropertyDependencyInfo;
-import org.apache.ambari.server.state.StackId;
-import org.apache.ambari.server.state.ValueAttributesInfo;
-import org.apache.ambari.server.topology.AdvisedConfiguration;
-import org.apache.ambari.server.topology.Blueprint;
-import org.apache.ambari.server.topology.Cardinality;
-import org.apache.ambari.server.topology.ClusterTopology;
-import org.apache.ambari.server.topology.ConfigRecommendationStrategy;
-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.state.*;
+import org.apache.ambari.server.topology.*;
+import org.apache.ambari.server.topology.Service;
 import org.apache.ambari.server.topology.validators.UnitValidatedProperty;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
 /**
  * Updates configuration properties based on cluster topology.  This is done when exporting
  * a blueprint and when a cluster is provisioned via a blueprint.
@@ -213,10 +202,11 @@ public class BlueprintConfigurationProcessor {
       new HawqHAFilter() };
 
   private ClusterTopology clusterTopology;
+  public final ConfigurationContext configurationContext;
 
-
-  public BlueprintConfigurationProcessor(ClusterTopology clusterTopology) {
+  public BlueprintConfigurationProcessor(ClusterTopology clusterTopology, ConfigurationContext configurationContext) {
     this.clusterTopology = clusterTopology;
+    this.configurationContext = configurationContext;
     initRemovePropertyUpdaters();
   }
 
@@ -309,7 +299,7 @@ public class BlueprintConfigurationProcessor {
           Map<String, String> typeMap = clusterProps.get(type);
           if (typeMap != null && typeMap.containsKey(propertyName) && typeMap.get(propertyName) != null) {
             requiredHostGroups.addAll(updater.getRequiredHostGroups(
-                propertyName, typeMap.get(propertyName), clusterProps, clusterTopology));
+                propertyName, typeMap.get(propertyName), clusterProps, clusterTopology, configurationContext));
           }
 
           // host group configs
@@ -318,7 +308,7 @@ public class BlueprintConfigurationProcessor {
             Map<String, String> hgTypeMap = hgConfigProps.get(type);
             if (hgTypeMap != null && hgTypeMap.containsKey(propertyName)) {
               requiredHostGroups.addAll(updater.getRequiredHostGroups(
-                  propertyName, hgTypeMap.get(propertyName), hgConfigProps, clusterTopology));
+                  propertyName, hgTypeMap.get(propertyName), hgConfigProps, clusterTopology, configurationContext));
             }
           }
         }
@@ -361,7 +351,7 @@ public class BlueprintConfigurationProcessor {
           if (typeMap != null && typeMap.containsKey(propertyName) && typeMap.get(propertyName) != null) {
             final String originalValue = typeMap.get(propertyName);
             final String updatedValue =
-              updater.updateForClusterCreate(propertyName, originalValue, clusterProps, clusterTopology);
+              updater.updateForClusterCreate(propertyName, originalValue, clusterProps, clusterTopology, configurationContext);
 
             if(updatedValue == null ) {
               continue;
@@ -382,7 +372,7 @@ public class BlueprintConfigurationProcessor {
             if (hgTypeMap != null && hgTypeMap.containsKey(propertyName)) {
               final String originalValue = hgTypeMap.get(propertyName);
               final String updatedValue =
-                updater.updateForClusterCreate(propertyName, originalValue, hgConfigProps, clusterTopology);
+                updater.updateForClusterCreate(propertyName, originalValue, hgConfigProps, clusterTopology, configurationContext);
 
               if (!updatedValue.equals(originalValue)) {
                 configTypesUpdated.add(type);
@@ -396,7 +386,7 @@ public class BlueprintConfigurationProcessor {
     }
 
     //todo: lots of hard coded HA rules included here
-    if (clusterTopology.isNameNodeHAEnabled()) {
+    if (clusterTopology.isNameNodeHAEnabled(configurationContext)) {
 
       // add "dfs.internal.nameservices" if it's not specified
       Map<String, String> hdfsSiteConfig = clusterConfig.getFullProperties().get("hdfs-site");
@@ -428,7 +418,7 @@ public class BlueprintConfigurationProcessor {
     setStackToolsAndFeatures(clusterConfig, configTypesUpdated);
     setRetryConfiguration(clusterConfig, configTypesUpdated);
     setupHDFSProxyUsers(clusterConfig, configTypesUpdated);
-    addExcludedConfigProperties(clusterConfig, configTypesUpdated, clusterTopology.getBlueprint().getStack());
+    addExcludedConfigProperties(clusterConfig, configTypesUpdated);
 
     trimProperties(clusterConfig, clusterTopology);
 
@@ -436,15 +426,15 @@ public class BlueprintConfigurationProcessor {
   }
 
   private void trimProperties(Configuration clusterConfig, ClusterTopology clusterTopology) {
-    Blueprint blueprint = clusterTopology.getBlueprint();
-    Stack stack = blueprint.getStack();
+    BlueprintV2 blueprint = clusterTopology.getBlueprint();
+    //Stack stack = blueprint.getStack();
 
     Map<String, Map<String, String>> configTypes = clusterConfig.getFullProperties();
     for (String configType : configTypes.keySet()) {
       Map<String,String> properties = configTypes.get(configType);
-      for (String propertyName : properties.keySet()) {
-        trimPropertyValue(clusterConfig, stack, configType, properties, propertyName);
-      }
+//      for (String propertyName : properties.keySet()) {
+//        trimPropertyValue(clusterConfig, stack, configType, properties, propertyName);
+//      }
     }
   }
 
@@ -485,11 +475,11 @@ public class BlueprintConfigurationProcessor {
    */
   public void doUpdateForBlueprintExport() {
     // HA configs are only processed in cluster configuration, not HG configurations
-    if (clusterTopology.isNameNodeHAEnabled()) {
+    if (clusterTopology.isNameNodeHAEnabled(configurationContext)) {
       doNameNodeHAUpdate();
     }
 
-    if (clusterTopology.isYarnResourceManagerHAEnabled()) {
+    if (clusterTopology.isYarnResourceManagerHAEnabled(configurationContext)) {
       doYarnResourceManagerHAUpdate();
     }
 
@@ -547,7 +537,7 @@ public class BlueprintConfigurationProcessor {
     for (Map.Entry<String, Map<String, String>> configEntry : properties.entrySet()) {
       String type = configEntry.getKey();
       try {
-          clusterTopology.getBlueprint().getStack().getServiceForConfigType(type);
+        //  clusterTopology.getBlueprint().getStack().getServiceForConfigType(type);
         } catch (IllegalArgumentException illegalArgumentException) {
             LOG.error(new StringBuilder(String.format("Error encountered while trying to obtain the service name for config type [%s]. ", type))
             .append("Further processing on this config type will be skipped. ")
@@ -576,7 +566,7 @@ public class BlueprintConfigurationProcessor {
 
       for (Map.Entry<String, String> propertyEntry : configPropertiesPerType.entrySet()) {
         String propName = propertyEntry.getKey();
-        if (shouldPropertyBeExcludedForClusterUpdate(propName, propertyEntry.getValue(), configType, clusterTopology)) {
+        if (shouldPropertyBeExcludedForClusterUpdate(propName, propertyEntry.getValue(), configType, clusterTopology, configurationContext)) {
           configuration.removeProperty(configType, propName);
           configTypesUpdated.add(configType);
         }
@@ -621,29 +611,29 @@ public class BlueprintConfigurationProcessor {
    * @param advisedConfigurations advised configuration instance
    */
   private void doFilterStackDefaults(Map<String, AdvisedConfiguration> advisedConfigurations) {
-    Blueprint blueprint = clusterTopology.getBlueprint();
-    Configuration stackDefaults = blueprint.getStack().getConfiguration(blueprint.getServices());
-    Map<String, Map<String, String>> stackDefaultProps = stackDefaults.getProperties();
-    for (Map.Entry<String, AdvisedConfiguration> adConfEntry : advisedConfigurations.entrySet()) {
-      AdvisedConfiguration advisedConfiguration = adConfEntry.getValue();
-      if (stackDefaultProps.containsKey(adConfEntry.getKey())) {
-        Map<String, String> defaultProps = stackDefaultProps.get(adConfEntry.getKey());
-        if (advisedConfiguration.getProperties() != null) {
-          Map<String, String> outFilteredProps = Maps.filterKeys(advisedConfiguration.getProperties(),
-            Predicates.not(Predicates.in(defaultProps.keySet())));
-          advisedConfiguration.getProperties().keySet().removeAll(Sets.newCopyOnWriteArraySet(outFilteredProps.keySet()));
-        }
-
-        if (advisedConfiguration.getPropertyValueAttributes() != null) {
-          Map<String, ValueAttributesInfo> outFilteredValueAttrs = Maps.filterKeys(advisedConfiguration.getPropertyValueAttributes(),
-            Predicates.not(Predicates.in(defaultProps.keySet())));
-          advisedConfiguration.getPropertyValueAttributes().keySet().removeAll(
-            Sets.newCopyOnWriteArraySet(outFilteredValueAttrs.keySet()));
-        }
-      } else {
-        advisedConfiguration.getProperties().clear();
-      }
-    }
+//    BlueprintV2 blueprint = clusterTopology.getBlueprint();
+//    Configuration stackDefaults = blueprint.getStack().getConfiguration(blueprint.getServices());
+//    Map<String, Map<String, String>> stackDefaultProps = stackDefaults.getProperties();
+//    for (Map.Entry<String, AdvisedConfiguration> adConfEntry : advisedConfigurations.entrySet()) {
+//      AdvisedConfiguration advisedConfiguration = adConfEntry.getValue();
+//      if (stackDefaultProps.containsKey(adConfEntry.getKey())) {
+//        Map<String, String> defaultProps = stackDefaultProps.get(adConfEntry.getKey());
+//        if (advisedConfiguration.getProperties() != null) {
+//          Map<String, String> outFilteredProps = Maps.filterKeys(advisedConfiguration.getProperties(),
+//            Predicates.not(Predicates.in(defaultProps.keySet())));
+//          advisedConfiguration.getProperties().keySet().removeAll(Sets.newCopyOnWriteArraySet(outFilteredProps.keySet()));
+//        }
+//
+//        if (advisedConfiguration.getPropertyValueAttributes() != null) {
+//          Map<String, ValueAttributesInfo> outFilteredValueAttrs = Maps.filterKeys(advisedConfiguration.getPropertyValueAttributes(),
+//            Predicates.not(Predicates.in(defaultProps.keySet())));
+//          advisedConfiguration.getPropertyValueAttributes().keySet().removeAll(
+//            Sets.newCopyOnWriteArraySet(outFilteredValueAttrs.keySet()));
+//        }
+//      } else {
+//        advisedConfiguration.getProperties().clear();
+//      }
+//    }
   }
 
   /**
@@ -700,11 +690,11 @@ public class BlueprintConfigurationProcessor {
   private Collection<Map<String, Map<String, PropertyUpdater>>> createCollectionOfUpdaters() {
     Collection<Map<String, Map<String, PropertyUpdater>>> updaters = allUpdaters;
 
-    if (clusterTopology.isNameNodeHAEnabled()) {
+    if (clusterTopology.isNameNodeHAEnabled(configurationContext)) {
       updaters = addNameNodeHAUpdaters(updaters);
     }
 
-    if (clusterTopology.isYarnResourceManagerHAEnabled()) {
+    if (clusterTopology.isYarnResourceManagerHAEnabled(configurationContext)) {
       updaters = addYarnResourceManagerHAUpdaters(updaters);
     }
 
@@ -1060,7 +1050,7 @@ public class BlueprintConfigurationProcessor {
    */
   private boolean shouldPropertyBeExcludedForBlueprintExport(String propertyName, String propertyValue, String propertyType, ClusterTopology topology, PropertyFilter [] exportPropertyFilters ) {
     for(PropertyFilter filter : exportPropertyFilters) {
-      if (!filter.isPropertyIncluded(propertyName, propertyValue, propertyType, topology)) {
+      if (!filter.isPropertyIncluded(propertyName, propertyValue, propertyType, topology, configurationContext)) {
         return true;
       }
     }
@@ -1084,11 +1074,12 @@ public class BlueprintConfigurationProcessor {
   private static boolean shouldPropertyBeExcludedForClusterUpdate(String propertyName,
                                                                   String propertyValue,
                                                                   String propertyType,
-                                                                  ClusterTopology topology) {
+                                                                  ClusterTopology topology,
+                                                                  ConfigurationContext configurationContext) {
 
     for(PropertyFilter filter : clusterUpdatePropertyFilters) {
       try {
-        if (!filter.isPropertyIncluded(propertyName, propertyValue, propertyType, topology)) {
+        if (!filter.isPropertyIncluded(propertyName, propertyValue, propertyType, topology, configurationContext)) {
           if (!shouldPropertyBeStoredWithDefault(propertyName)) {
             return true;
           }
@@ -1326,7 +1317,8 @@ public class BlueprintConfigurationProcessor {
         Map<String, String> typeProperties = properties.get(type);
 
         if (typeProperties != null && typeProperties.containsKey(propertyName)) {
-          String newValue = npu.updateForBlueprintExport(propertyName, typeProperties.get(propertyName), properties, clusterTopology);
+          String newValue = npu.updateForBlueprintExport(propertyName, typeProperties.get(propertyName),
+            properties, clusterTopology, configurationContext);
           configuration.setProperty(type, propertyName, newValue);
         }
       }
@@ -1350,7 +1342,8 @@ public class BlueprintConfigurationProcessor {
     String updateForClusterCreate(String propertyName,
                                          String origValue,
                                          Map<String, Map<String, String>> properties,
-                                         ClusterTopology topology);
+                                         ClusterTopology topology,
+                                         ConfigurationContext configurationContext);
 
     /**
      * Determine the required host groups for the provided property.
@@ -1365,7 +1358,8 @@ public class BlueprintConfigurationProcessor {
     Collection<String> getRequiredHostGroups(String propertyName,
                                              String origValue,
                                              Map<String, Map<String, String>> properties,
-                                             ClusterTopology topology);
+                                             ClusterTopology topology,
+                                             ConfigurationContext configurationContext);
   }
 
   private static class HostGroupUpdater implements PropertyUpdater {
@@ -1376,7 +1370,9 @@ public class BlueprintConfigurationProcessor {
     public String updateForClusterCreate(String propertyName,
       String origValue,
       Map<String, Map<String, String>> properties,
-      ClusterTopology topology) {
+      ClusterTopology topology,
+      ConfigurationContext configurationContext
+    ) {
 
       //todo: getHostStrings
       Matcher m = HostGroup.HOSTGROUP_REGEX.matcher(origValue);
@@ -1402,7 +1398,7 @@ public class BlueprintConfigurationProcessor {
     public Collection<String> getRequiredHostGroups(String propertyName,
       String origValue,
       Map<String, Map<String, String>> properties,
-      ClusterTopology topology) {
+      ClusterTopology topology, ConfigurationContext configurationContext) {
       //todo: getHostStrings
       Matcher m = HostGroup.HOSTGROUP_REGEX.matcher(origValue);
       if (m.find()) {
@@ -1446,9 +1442,10 @@ public class BlueprintConfigurationProcessor {
     public String updateForClusterCreate(String propertyName,
                                          String origValue,
                                          Map<String, Map<String, String>> properties,
-                                         ClusterTopology topology)  {
+                                         ClusterTopology topology,
+                                         ConfigurationContext configurationContext)  {
 
-      String replacedValue = super.updateForClusterCreate(propertyName, origValue, properties, topology);
+      String replacedValue = super.updateForClusterCreate(propertyName, origValue, properties, topology, configurationContext);
       if (!Objects.equals(origValue, replacedValue)) {
         return replacedValue;
       } else {
@@ -1459,7 +1456,8 @@ public class BlueprintConfigurationProcessor {
               topology.getHostAssignmentsForComponent(component).iterator().next(), properties);
         } else {
           //todo: extract all hard coded HA logic
-          Cardinality cardinality = topology.getBlueprint().getStack().getCardinality(component);
+
+          Cardinality cardinality = configurationContext.getStack().getCardinality(component);
           // if no matching host groups are found for a component whose configuration
           // is handled by this updater, check the stack first to determine if
           // zero is a valid cardinality for this component.  This is necessary
@@ -1468,7 +1466,7 @@ public class BlueprintConfigurationProcessor {
           if (matchingGroupCount == 0 && cardinality.isValidCount(0)) {
             return origValue;
           } else {
-            if (topology.isNameNodeHAEnabled() && isComponentNameNode() && (matchingGroupCount == 2)) {
+            if (topology.isNameNodeHAEnabled(configurationContext) && isComponentNameNode() && (matchingGroupCount == 2)) {
               // if this is the defaultFS property, it should reflect the nameservice name,
               // rather than a hostname (used in non-HA scenarios)
               if (properties.containsKey("core-site") && properties.get("core-site").get("fs.defaultFS").equals(origValue)) {
@@ -1494,13 +1492,13 @@ public class BlueprintConfigurationProcessor {
 
             }
 
-            if (topology.isNameNodeHAEnabled() && isComponentSecondaryNameNode() && (matchingGroupCount == 0)) {
+            if (topology.isNameNodeHAEnabled(configurationContext) && isComponentSecondaryNameNode() && (matchingGroupCount == 0)) {
               // if HDFS HA is enabled, then no replacement is necessary for properties that refer to the SECONDARY_NAMENODE
               // eventually this type of information should be encoded in the stacks
               return origValue;
             }
 
-            if (topology.isYarnResourceManagerHAEnabled() && isComponentResourceManager() && (matchingGroupCount == 2)) {
+            if (topology.isYarnResourceManagerHAEnabled(configurationContext) && isComponentResourceManager() && (matchingGroupCount == 2)) {
               if (!origValue.contains("localhost")) {
                 // if this Yarn property is a FQDN, then simply return it
                 return origValue;
@@ -1558,8 +1556,10 @@ public class BlueprintConfigurationProcessor {
     public Collection<String> getRequiredHostGroups(String propertyName,
                                                     String origValue,
                                                     Map<String, Map<String, String>> properties,
-                                                    ClusterTopology topology) {
-      Collection<String> result = super.getRequiredHostGroups(propertyName, origValue, properties, topology);
+                                                    ClusterTopology topology,
+                                                    ConfigurationContext configurationContext) {
+      Collection<String> result = super.getRequiredHostGroups(propertyName,
+        origValue, properties, topology, configurationContext);
       if (!result.isEmpty()) {
         return result;
       } else {
@@ -1568,7 +1568,7 @@ public class BlueprintConfigurationProcessor {
         if (matchingGroupCount != 0) {
           return new HashSet<>(matchingGroups);
         } else {
-          Cardinality cardinality = topology.getBlueprint().getStack().getCardinality(component);
+          Cardinality cardinality = configurationContext.getStack().getCardinality(component);
           // if no matching host groups are found for a component whose configuration
           // is handled by this updater, return an empty set
           if (! cardinality.isValidCount(0)) {
@@ -1715,9 +1715,10 @@ public class BlueprintConfigurationProcessor {
     public String updateForClusterCreate(String propertyName,
                                          String origValue,
                                          Map<String, Map<String, String>> properties,
-                                         ClusterTopology topology) {
+                                         ClusterTopology topology,
+                                         ConfigurationContext configurationContext) {
       try {
-        return super.updateForClusterCreate(propertyName, origValue, properties, topology);
+        return super.updateForClusterCreate(propertyName, origValue, properties, topology, configurationContext);
       } catch (IllegalArgumentException illegalArgumentException) {
         // return the original value, since the optional component is not available in this cluster
         return origValue;
@@ -1728,10 +1729,11 @@ public class BlueprintConfigurationProcessor {
     public Collection<String> getRequiredHostGroups(String propertyName,
                                                     String origValue,
                                                     Map<String, Map<String, String>> properties,
-                                                    ClusterTopology topology) {
+                                                    ClusterTopology topology,
+                                                    ConfigurationContext configurationContext) {
 
       try {
-        return super.getRequiredHostGroups(propertyName, origValue, properties, topology);
+        return super.getRequiredHostGroups(propertyName, origValue, properties, topology, configurationContext);
       } catch (IllegalArgumentException e) {
         return Collections.emptySet();
       }
@@ -1786,10 +1788,11 @@ public class BlueprintConfigurationProcessor {
     public String updateForClusterCreate(String propertyName,
                                          String origValue,
                                          Map<String, Map<String, String>> properties,
-                                         ClusterTopology topology) {
+                                         ClusterTopology topology,
+                                         ConfigurationContext configurationContext) {
 
       if (isDatabaseManaged(properties)) {
-        return super.updateForClusterCreate(propertyName, origValue, properties, topology);
+        return super.updateForClusterCreate(propertyName, origValue, properties, topology, configurationContext);
       } else {
         return origValue;
       }
@@ -1799,9 +1802,10 @@ public class BlueprintConfigurationProcessor {
     public Collection<String> getRequiredHostGroups(String propertyName,
                                                     String origValue,
                                                     Map<String, Map<String, String>> properties,
-                                                    ClusterTopology topology) {
+                                                    ClusterTopology topology,
+                                                    ConfigurationContext configurationContext) {
       if (isDatabaseManaged(properties)) {
-        return super.getRequiredHostGroups(propertyName, origValue, properties, topology);
+        return super.getRequiredHostGroups(propertyName, origValue, properties, topology, configurationContext);
       } else {
         return Collections.emptySet();
       }
@@ -1886,7 +1890,8 @@ public class BlueprintConfigurationProcessor {
     public String updateForClusterCreate(String propertyName,
                                          String origValue,
                                          Map<String, Map<String, String>> properties,
-                                         ClusterTopology topology) {
+                                         ClusterTopology topology,
+                                         ConfigurationContext configurationContext) {
 
       StringBuilder sb = new StringBuilder();
 
@@ -2053,7 +2058,8 @@ public class BlueprintConfigurationProcessor {
     public Collection<String> getRequiredHostGroups(String propertyName,
                                                     String origValue,
                                                     Map<String, Map<String, String>> properties,
-                                                    ClusterTopology topology) {
+                                                    ClusterTopology topology,
+                                                    ConfigurationContext configurationContext) {
 
       Collection<String> requiredHostGroups = new HashSet<>();
 
@@ -2108,14 +2114,15 @@ public class BlueprintConfigurationProcessor {
     public String updateForClusterCreate(String propertyName,
                                          String origValue,
                                          Map<String, Map<String, String>> properties,
-                                         ClusterTopology topology) {
+                                         ClusterTopology topology,
+                                         ConfigurationContext configurationContext) {
 
       // return customer-supplied properties without updating them
       if (isFQDNValue(origValue)) {
         return origValue;
       }
 
-      return doFormat(propertyUpdater.updateForClusterCreate(propertyName, origValue, properties, topology));
+      return doFormat(propertyUpdater.updateForClusterCreate(propertyName, origValue, properties, topology, configurationContext));
     }
 
     /**
@@ -2131,9 +2138,10 @@ public class BlueprintConfigurationProcessor {
     public Collection<String> getRequiredHostGroups(String propertyName,
                                                     String origValue,
                                                     Map<String, Map<String, String>> properties,
-                                                    ClusterTopology topology) {
+                                                    ClusterTopology topology,
+                                                    ConfigurationContext configurationContext) {
 
-      return propertyUpdater.getRequiredHostGroups(propertyName, origValue, properties, topology);
+      return propertyUpdater.getRequiredHostGroups(propertyName, origValue, properties, topology, configurationContext);
     }
 
     /**
@@ -2245,7 +2253,8 @@ public class BlueprintConfigurationProcessor {
     public String updateForClusterCreate(String propertyName,
                                          String origValue,
                                          Map<String, Map<String, String>> properties,
-                                         ClusterTopology topology) {
+                                         ClusterTopology topology,
+                                         ConfigurationContext configurationContext) {
       // always return the original value, since these properties do not require update handling
       return origValue;
     }
@@ -2254,7 +2263,8 @@ public class BlueprintConfigurationProcessor {
     public Collection<String> getRequiredHostGroups(String propertyName,
                                                     String origValue,
                                                     Map<String, Map<String, String>> properties,
-                                                    ClusterTopology topology) {
+                                                    ClusterTopology topology,
+                                                    ConfigurationContext configurationContext) {
 
       return Collections.emptySet();
     }
@@ -2284,7 +2294,8 @@ public class BlueprintConfigurationProcessor {
     public String updateForClusterCreate(String propertyName,
                                          String origValue,
                                          Map<String, Map<String, String>> properties,
-                                         ClusterTopology topology) {
+                                         ClusterTopology topology,
+                                         ConfigurationContext configurationContext) {
 
       // short-circuit out any custom property values defined by the deployer
       if (!origValue.contains("%HOSTGROUP") &&
@@ -2309,7 +2320,7 @@ public class BlueprintConfigurationProcessor {
         String key = keyValuePair.split("=")[0].trim();
         if (mapOfKeysToUpdaters.containsKey(key)) {
           String result = mapOfKeysToUpdaters.get(key).updateForClusterCreate(
-              key, keyValuePair.split("=")[1].trim(), properties, topology);
+              key, keyValuePair.split("=")[1].trim(), properties, topology, configurationContext);
           // append the internal property result, escape out any commas in the internal property,
           // this is required due to the specific syntax of templeton.hive.properties
           updatedResult.append(key);
@@ -2327,7 +2338,8 @@ public class BlueprintConfigurationProcessor {
     public Collection<String> getRequiredHostGroups(String propertyName,
                                                     String origValue,
                                                     Map<String, Map<String, String>> properties,
-                                                    ClusterTopology topology) {
+                                                    ClusterTopology topology,
+                                                    ConfigurationContext configurationContext) {
 
       // short-circuit out any custom property values defined by the deployer
       if (!origValue.contains("%HOSTGROUP") &&
@@ -2344,7 +2356,7 @@ public class BlueprintConfigurationProcessor {
         String key = keyValuePair.split("=")[0];
         if (mapOfKeysToUpdaters.containsKey(key)) {
           requiredGroups.addAll(mapOfKeysToUpdaters.get(key).getRequiredHostGroups(
-              propertyName, keyValuePair.split("=")[1], properties, topology));
+              propertyName, keyValuePair.split("=")[1], properties, topology, configurationContext));
         }
       }
       return requiredGroups;
@@ -2360,14 +2372,16 @@ public class BlueprintConfigurationProcessor {
     public Collection<String> getRequiredHostGroups(String propertyName,
                                                     String origValue,
                                                     Map<String, Map<String, String>> properties,
-                                                    ClusterTopology topology) {
+                                                    ClusterTopology topology,
+                                                    ConfigurationContext configurationContext) {
       return Collections.emptyList();
     }
 
     public String updateForBlueprintExport(String propertyName,
                                            String origValue,
                                            Map<String, Map<String, String>> properties,
-                                           ClusterTopology topology) {
+                                           ClusterTopology topology,
+                                           ConfigurationContext configurationContext) {
       return origValue;
     }
   }
@@ -2570,7 +2584,8 @@ public class BlueprintConfigurationProcessor {
       public String updateForClusterCreate(String propertyName,
                                            String origValue,
                                            Map<String, Map<String, String>> properties,
-                                           ClusterTopology topology) {
+                                           ClusterTopology topology,
+                                           ConfigurationContext configurationContext) {
         String atlasHookClass = "org.apache.atlas.hive.hook.HiveHook";
         String[] hiveHooks = origValue.split(",");
 
@@ -2581,7 +2596,7 @@ public class BlueprintConfigurationProcessor {
           }
         }
 
-        boolean isAtlasInCluster = topology.getBlueprint().getServices().contains("ATLAS");
+        boolean isAtlasInCluster = topology.getBlueprint().getAllServiceTypes().contains("ATLAS");
         boolean isAtlasHiveHookEnabled = Boolean.parseBoolean(properties.get("hive-env").get("hive.atlas.hook"));
 
         // Append atlas hook if not already present.
@@ -2610,9 +2625,10 @@ public class BlueprintConfigurationProcessor {
       public String updateForClusterCreate(String propertyName,
                                            String origValue,
                                            Map<String, Map<String, String>> properties,
-                                           ClusterTopology topology) {
+                                           ClusterTopology topology,
+                                           ConfigurationContext configurationContext) {
 
-        if (topology.getBlueprint().getServices().contains("ATLAS")) {
+        if (topology.getBlueprint().getAllServiceTypes().contains("ATLAS")) {
           // if original value is not set or is the default "primary" set the cluster id
           if (origValue == null || origValue.trim().isEmpty() || origValue.equals("primary")) {
             //use cluster id because cluster name may change
@@ -2630,7 +2646,7 @@ public class BlueprintConfigurationProcessor {
       public String updateForBlueprintExport(String propertyName,
                                             String origValue,
                                             Map<String, Map<String, String>> properties,
-                                            ClusterTopology topology) {
+                                            ClusterTopology topology, ConfigurationContext configurationContext) {
 
         // if the value is the cluster id, then update to primary
         if (origValue.equals(String.valueOf(topology.getClusterId()))) {
@@ -2646,8 +2662,9 @@ public class BlueprintConfigurationProcessor {
       public String updateForClusterCreate(String propertyName,
                                            String origValue,
                                            Map<String, Map<String, String>> properties,
-                                           ClusterTopology topology) {
-        if (topology.getBlueprint().getServices().contains("ATLAS")) {
+                                           ClusterTopology topology,
+                                           ConfigurationContext configurationContext) {
+        if (topology.getBlueprint().getAllServiceTypes().contains("ATLAS")) {
           String host = topology.getHostAssignmentsForComponent("ATLAS_SERVER").iterator().next();
 
           boolean tlsEnabled = Boolean.parseBoolean(properties.get("application-properties").get("atlas.enableTLS"));
@@ -2706,9 +2723,10 @@ public class BlueprintConfigurationProcessor {
       public String updateForClusterCreate(String propertyName,
                                            String origValue,
                                            Map<String, Map<String, String>> properties,
-                                           ClusterTopology topology) {
+                                           ClusterTopology topology,
+                                           ConfigurationContext configurationContext) {
 
-        if (topology.getBlueprint().getServices().contains("AMBARI_METRICS")) {
+        if (topology.getBlueprint().getAllServiceTypes().contains("AMBARI_METRICS")) {
           final String amsReporterClass = "org.apache.hadoop.metrics2.sink.storm.StormTimelineMetricsReporter";
           if (origValue == null || origValue.isEmpty()) {
             return amsReporterClass;
@@ -2739,9 +2757,10 @@ public class BlueprintConfigurationProcessor {
       public String updateForClusterCreate(String propertyName,
                                            String origValue,
                                            Map<String, Map<String, String>> properties,
-                                           ClusterTopology topology) {
+                                           ClusterTopology topology,
+                                           ConfigurationContext configurationContext) {
 
-        if (topology.getBlueprint().getServices().contains("AMBARI_METRICS")) {
+        if (topology.getBlueprint().getAllServiceTypes().contains("AMBARI_METRICS")) {
           final String amsReportesClass = "org.apache.hadoop.metrics2.sink.kafka.KafkaTimelineMetricsReporter";
           if (origValue == null || origValue.isEmpty()) {
             return amsReportesClass;
@@ -2801,7 +2820,8 @@ public class BlueprintConfigurationProcessor {
     // AMS
     amsSiteMap.put("timeline.metrics.service.webapp.address", new SingleHostTopologyUpdater("METRICS_COLLECTOR") {
       @Override
-      public String updateForClusterCreate(String propertyName, String origValue, Map<String, Map<String, String>> properties, ClusterTopology topology) {
+      public String updateForClusterCreate(String propertyName, String origValue, Map<String, Map<String, String>> properties,
+                                           ClusterTopology topology, ConfigurationContext configurationContext) {
         if (!origValue.startsWith(BIND_ALL_IP_ADDRESS)) {
           return origValue.replace(origValue.split(":")[0], BIND_ALL_IP_ADDRESS);
         } else {
@@ -2833,7 +2853,7 @@ public class BlueprintConfigurationProcessor {
     // AMBARI-5206
     final Map<String , String> userProps = new HashMap<>();
 
-    Collection<String> services = clusterTopology.getBlueprint().getServices();
+    Collection<String> services = clusterTopology.getBlueprint().getAllServiceTypes();
     if (services.contains("HDFS")) {
       // only add user properties to the map for
       // services actually included in the blueprint definition
@@ -2884,17 +2904,17 @@ public class BlueprintConfigurationProcessor {
    * In case the excluded config-type related service is not present in the blueprint, excluded configs are ignored
    * @param configuration
    * @param configTypesUpdated
-   * @param stack
    */
-  private void addExcludedConfigProperties(Configuration configuration, Set<String> configTypesUpdated, Stack stack) {
-    Collection<String> blueprintServices = clusterTopology.getBlueprint().getServices();
+  private void addExcludedConfigProperties(Configuration configuration, Set<String> configTypesUpdated) {
+    Collection<Service> blueprintServices = clusterTopology.getBlueprint().getAllServices();
 
     LOG.debug("Handling excluded properties for blueprint services: {}", blueprintServices);
 
-    for (String blueprintService : blueprintServices) {
+    for (Service blueprintService : blueprintServices) {
 
       LOG.debug("Handling excluded properties for blueprint service: {}", blueprintService);
-      Set<String> excludedConfigTypes = stack.getExcludedConfigurationTypes(blueprintService);
+      StackV2 stack = blueprintService.getStack();
+      Set<String> excludedConfigTypes = stack.getExcludedConfigurationTypes(blueprintService.getType());
 
       if (excludedConfigTypes.isEmpty()) {
         LOG.debug("There are no excluded config types for blueprint service: {}", blueprintService);
@@ -2924,7 +2944,7 @@ public class BlueprintConfigurationProcessor {
           continue;
         }
 
-        Map<String, String> configProperties = stack.getConfigurationProperties(blueprintService, configType);
+        Map<String, String> configProperties = stack.getConfigurationProperties(blueprintService.getType(), configType);
         for(Map.Entry<String, String> entry: configProperties.entrySet()) {
           LOG.debug("ADD property {} {} {}", configType, entry.getKey(), entry.getValue());
           ensureProperty(configuration, configType, entry.getKey(), entry.getValue(), configTypesUpdated);
@@ -2982,9 +3002,8 @@ public class BlueprintConfigurationProcessor {
   private void setStackToolsAndFeatures(Configuration configuration, Set<String> configTypesUpdated)
       throws ConfigurationTopologyException {
     ConfigHelper configHelper = clusterTopology.getAmbariContext().getConfigHelper();
-    Stack stack = clusterTopology.getBlueprint().getStack();
-    String stackName = stack.getName();
-    String stackVersion = stack.getVersion();
+    String stackName = configurationContext.getStack().getName();
+    String stackVersion = configurationContext.getStack().getVersion();
 
     StackId stackId = new StackId(stackName, stackVersion);
 
@@ -3047,7 +3066,8 @@ public class BlueprintConfigurationProcessor {
      * @return true if the property should be included
      *         false if the property should not be included
      */
-    boolean isPropertyIncluded(String propertyName, String propertyValue, String configType, ClusterTopology topology);
+    boolean isPropertyIncluded(String propertyName, String propertyValue,
+                               String configType, ClusterTopology topology, ConfigurationContext configurationContext);
   }
 
   /**
@@ -3081,7 +3101,8 @@ public class BlueprintConfigurationProcessor {
      *         false if the property should not be included
      */
     @Override
-    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType, ClusterTopology topology) {
+    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType,
+                                      ClusterTopology topology, ConfigurationContext configurationContext) {
       return !PASSWORD_NAME_REGEX.matcher(propertyName).matches();
     }
   }
@@ -3106,8 +3127,9 @@ public class BlueprintConfigurationProcessor {
      *         false if the property should not be included
      */
     @Override
-    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType, ClusterTopology topology) {
-        Stack stack = topology.getBlueprint().getStack();
+    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType,
+                                      ClusterTopology topology, ConfigurationContext configurationContext) {
+        StackV2 stack = configurationContext.getStack();
         final String serviceName = stack.getServiceForConfigType(configType);
         return !(stack.isPasswordProperty(serviceName, configType, propertyName) ||
                 stack.isKerberosPrincipalNameProperty(serviceName, configType, propertyName));
@@ -3138,8 +3160,10 @@ public class BlueprintConfigurationProcessor {
       this.authToLocalPerClusterMap = authToLocalPerClusterMap;
     }
     @Override
-    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType, ClusterTopology topology) {
-      return (authToLocalPerClusterMap == null || authToLocalPerClusterMap.get(topology.getClusterId()) == null || !authToLocalPerClusterMap.get(topology.getClusterId()).contains(String.format("%s/%s", configType, propertyName)));
+    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType,
+                                      ClusterTopology topology, ConfigurationContext configurationContext) {
+      return (authToLocalPerClusterMap == null || authToLocalPerClusterMap.get(topology.getClusterId()) == null ||
+        !authToLocalPerClusterMap.get(topology.getClusterId()).contains(String.format("%s/%s", configType, propertyName)));
     }
   }
 
@@ -3161,7 +3185,8 @@ public class BlueprintConfigurationProcessor {
     }
 
     @Override
-    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType, ClusterTopology topology) {
+    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType,
+                                      ClusterTopology topology, ConfigurationContext configurationContext) {
       return !(propertyConfigType.equals(configType) &&
              this.propertyName.equals(propertyName));
     }
@@ -3203,15 +3228,15 @@ public class BlueprintConfigurationProcessor {
      *         false if the property should not be included
      */
     @Override
-    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType, ClusterTopology topology) {
-      Stack stack = topology.getBlueprint().getStack();
+    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType,
+                                      ClusterTopology topology, ConfigurationContext configurationContext) {
       Configuration configuration = topology.getConfiguration();
 
-      final String serviceName = stack.getServiceForConfigType(configType);
-      Map<String, Stack.ConfigProperty> typeProperties =
-        stack.getConfigurationPropertiesWithMetadata(serviceName, configType);
+      final String serviceName = configurationContext.getStack().getServiceForConfigType(configType);
+      Map<String, StackV2.ConfigProperty> typeProperties =
+        configurationContext.getStack().getConfigurationPropertiesWithMetadata(serviceName, configType);
 
-      Stack.ConfigProperty configProperty = typeProperties.get(propertyName);
+      StackV2.ConfigProperty configProperty = typeProperties.get(propertyName);
       if (configProperty != null) {
         Set<PropertyDependencyInfo> dependencyInfos = configProperty.getDependsOnProperties();
         if (dependencyInfos != null) {
@@ -3332,8 +3357,9 @@ public class BlueprintConfigurationProcessor {
      *         false if the property should not be included
      */
     @Override
-    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType, ClusterTopology topology) {
-      if (topology.isNameNodeHAEnabled()) {
+    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType,
+                                      ClusterTopology topology, ConfigurationContext configurationContext) {
+      if (topology.isNameNodeHAEnabled(configurationContext)) {
         if (setOfHDFSPropertyNamesNonHA.contains(propertyName)) {
           return false;
         }
@@ -3369,7 +3395,8 @@ public class BlueprintConfigurationProcessor {
      *         false if the property should not be included
      */
     @Override
-    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType, ClusterTopology topology) {
+    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType,
+                                      ClusterTopology topology, ConfigurationContext configurationContext) {
       if (configType.equals(this.configType) && propertyName.equals(this.propertyName) && propertyValue.equals(this
         .propertyValue)) {
         return false;
@@ -3402,7 +3429,8 @@ public class BlueprintConfigurationProcessor {
      *         false if the property should not be included
      */
     @Override
-    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType, ClusterTopology topology) {
+    public boolean isPropertyIncluded(String propertyName, String propertyValue, String configType,
+                                      ClusterTopology topology, ConfigurationContext configurationContext) {
       int matchingGroupCount = topology.getHostGroupsForComponent(HAWQSTANDBY).size();
       if (matchingGroupCount == 0) {
         if (setOfHawqPropertyNamesNonHA.contains(propertyName)) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
new file mode 100644
index 0000000..983bb9f
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+import org.apache.ambari.server.topology.Configuration;
+
+import java.util.Map;
+
+/**
+ * Provides a context for configuration.
+ */
+public class ConfigurationContext  {
+
+  private final Configuration configuration;
+
+  private final StackV2 stack;
+
+  public ConfigurationContext(StackV2 stack, Configuration configuration){
+    this.stack = stack;
+    this.configuration = configuration;
+  }
+
+  public Configuration getConfiguration() {
+    return configuration;
+  }
+
+  public StackV2 getStack() {
+    return stack;
+  }
+
+  public boolean isNameNodeHAEnabled() {
+    Map<String, Map<String, String>> configurationProperties = getConfiguration().getProperties();
+    return configurationProperties.containsKey("hdfs-site") &&
+      (configurationProperties.get("hdfs-site").containsKey("dfs.nameservices") ||
+        configurationProperties.get("hdfs-site").containsKey("dfs.internal.nameservices"));
+  }
+
+  public boolean isYarnResourceManagerHAEnabled() {
+    Map<String, Map<String, String>> configProperties = getConfiguration().getProperties();
+    return configProperties.containsKey("yarn-site") && configProperties.get("yarn-site").containsKey("yarn.resourcemanager.ha.enabled")
+      && configProperties.get("yarn-site").get("yarn.resourcemanager.ha.enabled").equals("true");
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java
index 16d3114..800e2ff 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java
@@ -19,17 +19,6 @@
 
 package org.apache.ambari.server.controller.internal;
 
-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.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.util.TreeNode;
 import org.apache.ambari.server.controller.AmbariManagementController;
@@ -38,18 +27,14 @@ 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.topology.Blueprint;
-import org.apache.ambari.server.topology.BlueprintImpl;
-import org.apache.ambari.server.topology.Component;
-import org.apache.ambari.server.topology.Configuration;
-import org.apache.ambari.server.topology.HostGroup;
-import org.apache.ambari.server.topology.HostGroupImpl;
-import org.apache.ambari.server.topology.HostGroupInfo;
-import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
-import org.apache.ambari.server.topology.TopologyRequest;
+import org.apache.ambari.server.topology.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.*;
+
 /**
  * Request to export a blueprint from an existing cluster.
  */
@@ -60,8 +45,12 @@ public class ExportBlueprintRequest implements TopologyRequest {
 
   private String clusterName;
   private Long clusterId;
-  private Blueprint blueprint;
-  private Configuration configuration;
+  private BlueprintV2 blueprint;
+  /**
+   * List of services
+   */
+  protected Collection<Service> services;
+
   //todo: Should this map be represented by a new class?
   private Map<String, HostGroupInfo> hostGroupInfo = new HashMap<>();
 
@@ -98,13 +87,18 @@ public class ExportBlueprintRequest implements TopologyRequest {
   }
 
   @Override
-  public Blueprint getBlueprint() {
+  public BlueprintV2 getBlueprint() {
     return blueprint;
   }
 
   @Override
+  public Collection<Service> getServiceConfigs() {
+    return services;
+  }
+
+  @Override
   public Configuration getConfiguration() {
-    return configuration;
+    return null;
   }
 
   @Override
@@ -135,7 +129,7 @@ public class ExportBlueprintRequest implements TopologyRequest {
       hostGroups.add(new HostGroupImpl(exportedHostGroup.getName(), bpName, stack, componentList,
           exportedHostGroup.getConfiguration(), String.valueOf(exportedHostGroup.getCardinality())));
     }
-    blueprint = new BlueprintImpl(bpName, hostGroups, stack, configuration, null);
+    //blueprint = new BlueprintImplV2(bpName, hostGroups, stack, configuration, null);
   }
 
   private void createHostGroupInfo(Collection<ExportedHostGroup> exportedHostGroups) {
@@ -183,11 +177,12 @@ public class ExportBlueprintRequest implements TopologyRequest {
         attributes.put(configuration.getType(), configuration.getPropertyAttributes());
       }
     }
-    configuration = new Configuration(properties, attributes);
-    // empty parent configuration when exporting as all properties are included in this configuration
-    configuration.setParentConfiguration(new Configuration(
-        Collections.emptyMap(),
-        Collections.emptyMap()));
+//    configuration = new Configuration(properties, attributes);
+//    // empty parent configuration when exporting as all properties are included in this configuration
+//    configuration.setParentConfiguration(new Configuration(
+//        Collections.emptyMap(),
+//        Collections.emptyMap()));
+
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
index 1fd6091..6d72b21 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
@@ -17,31 +17,19 @@
  */
 package org.apache.ambari.server.controller.internal;
 
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.common.base.Enums;
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.security.encryption.CredentialStoreType;
 import org.apache.ambari.server.stack.NoSuchStackException;
 import org.apache.ambari.server.state.quicklinksprofile.QuickLinksProfileBuilder;
 import org.apache.ambari.server.state.quicklinksprofile.QuickLinksProfileEvaluationException;
-import org.apache.ambari.server.topology.ConfigRecommendationStrategy;
-import org.apache.ambari.server.topology.Configuration;
-import org.apache.ambari.server.topology.ConfigurationFactory;
-import org.apache.ambari.server.topology.Credential;
-import org.apache.ambari.server.topology.HostGroupInfo;
-import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
-import org.apache.ambari.server.topology.NoSuchBlueprintException;
-import org.apache.ambari.server.topology.SecurityConfiguration;
+import org.apache.ambari.server.topology.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Enums;
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
+import java.util.*;
 
 /**
  * Request for provisioning a cluster.
@@ -183,10 +171,14 @@ public class ProvisionClusterRequest extends BaseClusterRequest {
 
     this.securityConfiguration = securityConfiguration;
 
-    Configuration configuration = configurationFactory.getConfiguration(
-      (Collection<Map<String, String>>) properties.get(CONFIGURATIONS_PROPERTY));
-    configuration.setParentConfiguration(blueprint.getConfiguration());
-    setConfiguration(configuration);
+//    Configuration configuration = configurationFactory.getConfiguration(
+//      (Collection<Map<String, String>>) properties.get(CONFIGURATIONS_PROPERTY));
+//    configuration.setParentConfiguration(blueprint.getConfiguration());
+//    setConfiguration(configuration);
+
+    //TODO load services, merge servie configs from Cluster template with service configs from Blueprint
+    serviceConfigs = new ArrayList<>();
+
 
     parseHostGroupInfo(properties);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
index fe33f93..314fb26 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
@@ -19,19 +19,19 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.stack.NoSuchStackException;
-import org.apache.ambari.server.topology.Blueprint;
+import org.apache.ambari.server.topology.BlueprintV2;
 import org.apache.ambari.server.topology.Configuration;
 import org.apache.ambari.server.topology.HostGroupInfo;
 import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * A request for a scaling an existing cluster.
  */
@@ -58,8 +58,8 @@ public class ScaleClusterRequest extends BaseClusterRequest {
         setClusterName(String.valueOf(properties.get(HostResourceProvider.HOST_CLUSTER_NAME_PROPERTY_ID)));
       }
       // currently don't allow cluster scoped configuration in scaling operation
-      setConfiguration(new Configuration(Collections.emptyMap(),
-          Collections.emptyMap()));
+//      setConfiguration(new Configuration(Collections.emptyMap(),
+//          Collections.emptyMap()));
 
       parseHostGroups(properties);
     }
@@ -110,7 +110,7 @@ public class ScaleClusterRequest extends BaseClusterRequest {
       throw new InvalidTopologyTemplateException("A name must be specified for all host groups");
     }
 
-    Blueprint blueprint = getBlueprint();
+    BlueprintV2 blueprint = getBlueprint();
     if (getBlueprint() == null) {
       blueprint = parseBlueprint(blueprintName);
       setBlueprint(blueprint);
@@ -197,8 +197,8 @@ public class ScaleClusterRequest extends BaseClusterRequest {
    *
    * @throws InvalidTopologyTemplateException if specified blueprint or stack doesn't exist
    */
-  private Blueprint parseBlueprint(String blueprintName) throws InvalidTopologyTemplateException  {
-    Blueprint blueprint;
+  private BlueprintV2 parseBlueprint(String blueprintName) throws InvalidTopologyTemplateException  {
+    BlueprintV2 blueprint;
     try {
       blueprint = getBlueprintFactory().getBlueprint(blueprintName);
     } catch (NoSuchStackException e) {


[28/30] ambari git commit: AMBARI-22325 Blueprint Service uses Blueprint V2 resource provider (benyoka)

Posted by mr...@apache.org.
AMBARI-22325 Blueprint Service uses Blueprint V2 resource provider (benyoka)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 93a6dbf94f9016a101550df20fc9ec4bab1756b3
Parents: 36013fe
Author: Balazs Bence Sari <be...@apache.org>
Authored: Fri Oct 27 14:44:37 2017 +0200
Committer: Balazs Bence Sari <be...@apache.org>
Committed: Fri Oct 27 14:45:44 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/ambari/server/controller/AmbariServer.java  | 5 +++++
 .../controller/internal/AbstractControllerResourceProvider.java | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/93a6dbf9/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 afe5647..e2553cb 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
@@ -64,6 +64,7 @@ import org.apache.ambari.server.controller.internal.AbstractControllerResourcePr
 import org.apache.ambari.server.controller.internal.AmbariPrivilegeResourceProvider;
 import org.apache.ambari.server.controller.internal.BaseClusterRequest;
 import org.apache.ambari.server.controller.internal.BlueprintResourceProvider;
+import org.apache.ambari.server.controller.internal.BlueprintV2ResourceProvider;
 import org.apache.ambari.server.controller.internal.ClusterPrivilegeResourceProvider;
 import org.apache.ambari.server.controller.internal.ClusterResourceProvider;
 import org.apache.ambari.server.controller.internal.HostResourceProvider;
@@ -82,6 +83,7 @@ import org.apache.ambari.server.metrics.system.MetricsService;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.PersistenceType;
 import org.apache.ambari.server.orm.dao.BlueprintDAO;
+import org.apache.ambari.server.orm.dao.BlueprintV2DAO;
 import org.apache.ambari.server.orm.dao.ClusterDAO;
 import org.apache.ambari.server.orm.dao.GroupDAO;
 import org.apache.ambari.server.orm.dao.MetainfoDAO;
@@ -921,6 +923,9 @@ public class AmbariServer {
     BlueprintResourceProvider.init(injector.getInstance(BlueprintFactory.class),
         injector.getInstance(BlueprintDAO.class), injector.getInstance(SecurityConfigurationFactory.class),
         injector.getInstance(Gson.class), ambariMetaInfo);
+    BlueprintV2ResourceProvider.init(injector.getInstance(BlueprintV2Factory.class),
+      injector.getInstance(BlueprintV2DAO.class), injector.getInstance(SecurityConfigurationFactory.class),
+      ambariMetaInfo);
     StackDependencyResourceProvider.init(ambariMetaInfo);
     ClusterResourceProvider.init(injector.getInstance(TopologyManager.class),
         injector.getInstance(TopologyRequestFactoryImpl.class), injector.getInstance(SecurityConfigurationFactory

http://git-wip-us.apache.org/repos/asf/ambari/blob/93a6dbf9/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
index afca803..4ffd8d1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
@@ -233,7 +233,7 @@ public abstract class AbstractControllerResourceProvider extends AbstractAuthori
       case HostComponentProcess:
         return new HostComponentProcessResourceProvider(propertyIds, keyPropertyIds, managementController);
       case Blueprint:
-        return new BlueprintResourceProvider(propertyIds, keyPropertyIds, managementController);
+        return new BlueprintV2ResourceProvider(propertyIds, keyPropertyIds, managementController);
       case KerberosDescriptor:
         return resourceProviderFactory.getKerberosDescriptorResourceProvider(managementController, propertyIds, keyPropertyIds);
       case Recommendation:


[11/30] ambari git commit: AMBARI-22244. Update service component API call to work for second service instance (adoroszlai)

Posted by mr...@apache.org.
AMBARI-22244. Update service component API call to work for second service instance (adoroszlai)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 17e4330db3f4813db035e31cd0d4be254c6ecd02
Parents: 58c8339
Author: Attila Doroszlai <ad...@hortonworks.com>
Authored: Mon Oct 9 13:46:56 2017 +0200
Committer: Attila Doroszlai <ad...@hortonworks.com>
Committed: Tue Oct 17 20:23:05 2017 +0200

----------------------------------------------------------------------
 .../actionmanager/ExecutionCommandWrapper.java       |  6 ++++--
 .../apache/ambari/server/agent/HeartBeatHandler.java |  2 +-
 .../server/alerts/ComponentVersionAlertRunnable.java |  2 +-
 .../ambari/server/api/services/AmbariMetaInfo.java   |  2 +-
 .../ambari/server/api/services/ComponentService.java |  8 ++++----
 .../server/checks/ComponentsExistInRepoCheck.java    |  7 ++++---
 .../apache/ambari/server/checks/ServicesUpCheck.java |  4 +---
 .../controller/AmbariActionExecutionHelper.java      |  6 +++---
 .../AmbariCustomCommandExecutionHelper.java          |  8 ++++----
 .../controller/AmbariManagementControllerImpl.java   | 10 +++++-----
 .../internal/ClientConfigResourceProvider.java       | 15 ++++++---------
 .../ClusterStackVersionResourceProvider.java         |  7 ++++---
 .../internal/ComponentResourceProvider.java          |  8 ++++----
 .../internal/HostStackVersionResourceProvider.java   |  4 ++--
 .../controller/internal/ServiceResourceProvider.java |  2 +-
 .../internal/StackDefinedPropertyProvider.java       |  2 +-
 .../logging/LoggingSearchPropertyProvider.java       |  2 +-
 .../metrics/timeline/AMSPropertyProvider.java        |  2 +-
 .../server/controller/utilities/DatabaseChecker.java |  2 +-
 .../state/DefaultServiceCalculatedState.java         |  2 +-
 .../utilities/state/HBaseServiceCalculatedState.java |  2 +-
 .../utilities/state/HDFSServiceCalculatedState.java  |  2 +-
 .../utilities/state/HiveServiceCalculatedState.java  |  2 +-
 .../utilities/state/OozieServiceCalculatedState.java |  2 +-
 .../utilities/state/YARNServiceCalculatedState.java  |  2 +-
 .../alerts/AlertMaintenanceModeListener.java         |  2 +-
 .../listeners/alerts/AlertServiceStateListener.java  |  2 +-
 .../upgrade/HostVersionOutOfSyncListener.java        |  3 +--
 .../listeners/upgrade/StackVersionListener.java      |  2 +-
 .../org/apache/ambari/server/mpack/MpackManager.java |  2 +-
 .../serveraction/upgrades/FinalizeUpgradeAction.java |  2 +-
 .../org/apache/ambari/server/state/ConfigHelper.java | 10 +++++-----
 .../ambari/server/state/ServiceComponentImpl.java    |  4 ++--
 .../org/apache/ambari/server/state/ServiceImpl.java  |  3 ++-
 .../apache/ambari/server/state/UpgradeHelper.java    |  2 +-
 .../server/state/alert/AlertDefinitionHash.java      |  4 ++--
 .../ambari/server/state/cluster/ClusterImpl.java     |  2 +-
 .../apache/ambari/server/state/host/HostImpl.java    |  2 +-
 .../state/stack/upgrade/HostOrderGrouping.java       |  2 +-
 .../state/stack/upgrade/ServiceCheckGrouping.java    |  2 +-
 .../state/svccomphost/ServiceComponentHostImpl.java  |  2 +-
 .../svccomphost/ServiceComponentHostSummary.java     |  1 -
 42 files changed, 78 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
index ff13d0b..ed2819a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
@@ -237,11 +237,13 @@ public class ExecutionCommandWrapper {
     // set the repository version for the component this command is for -
     // always use the current desired version
     String serviceName = executionCommand.getServiceName();
+    String serviceType = null;
     try {
       RepositoryVersionEntity repositoryVersion = null;
       if (!StringUtils.isEmpty(serviceName)) {
         Service service = cluster.getService(serviceName);
         if (null != service) {
+          serviceType = service.getServiceType();
           repositoryVersion = service.getDesiredRepositoryVersion();
 
           String componentName = executionCommand.getComponentName();
@@ -273,9 +275,9 @@ public class ExecutionCommandWrapper {
         }
 
         if (!commandParams.containsKey(SERVICE_PACKAGE_FOLDER)) {
-          if (!StringUtils.isEmpty(serviceName)) {
+          if (!StringUtils.isEmpty(serviceType)) {
             ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
-              stackId.getStackVersion(), serviceName);
+              stackId.getStackVersion(), serviceType);
 
             commandParams.put(SERVICE_PACKAGE_FOLDER, serviceInfo.getServicePackageFolder());
           }

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
index bb298d5..daff89f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
@@ -542,7 +542,7 @@ public class HeartBeatHandler {
         StackId stackId = component.getDesiredStackId();
 
         ComponentInfo componentInfo = ambariMetaInfo.getComponent(
-            stackId.getStackName(), stackId.getStackVersion(), service.getName(), component.getName());
+            stackId.getStackName(), stackId.getStackVersion(), service.getServiceType(), component.getName());
 
         componentsMap.get(service.getName()).put(component.getName(), componentInfo.getCategory());
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/alerts/ComponentVersionAlertRunnable.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/alerts/ComponentVersionAlertRunnable.java b/ambari-server/src/main/java/org/apache/ambari/server/alerts/ComponentVersionAlertRunnable.java
index 45cc973..977dc9e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/alerts/ComponentVersionAlertRunnable.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/alerts/ComponentVersionAlertRunnable.java
@@ -119,7 +119,7 @@ public class ComponentVersionAlertRunnable extends AlertRunnable {
         final ComponentInfo componentInfo;
         try {
           componentInfo = m_metaInfo.getComponent(desiredStackId.getStackName(),
-              desiredStackId.getStackVersion(), hostComponent.getServiceName(),
+              desiredStackId.getStackVersion(), hostComponent.getServiceType(),
               hostComponent.getServiceComponentName());
         } catch (AmbariException ambariException) {
           // throw an UNKNOWN response if we can't load component info

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
index 2bb450b..1c0a555 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
@@ -1184,7 +1184,7 @@ public class AmbariMetaInfo {
 
       for (Service service : cluster.getServices().values()) {
         ServiceInfo stackService = getService(service.getDesiredStackId().getStackName(),
-            service.getDesiredStackId().getStackVersion(), service.getName());
+            service.getDesiredStackId().getStackVersion(), service.getServiceType());
 
         if (null == stackService) {
           continue;

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/api/services/ComponentService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ComponentService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ComponentService.java
index 60230f6..fc73a53 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ComponentService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ComponentService.java
@@ -222,10 +222,10 @@ public class ComponentService extends BaseService {
    * @return a component resource instance
    */
   ResourceInstance createComponentResource(String componentName) {
-    Map<Resource.Type,String> mapIds = new HashMap<Resource.Type, String>();
-    mapIds.put(Resource.Type.Cluster, m_clusterName == null? null : m_clusterName.toString());
-    mapIds.put(Resource.Type.ServiceGroup, m_serviceGroupName == null? null : m_serviceGroupName.toString());
-    mapIds.put(Resource.Type.Service, m_serviceName == null? null : m_serviceName.toString());
+    Map<Resource.Type,String> mapIds = new HashMap<>();
+    mapIds.put(Resource.Type.Cluster, m_clusterName);
+    mapIds.put(Resource.Type.ServiceGroup, m_serviceGroupName);
+    mapIds.put(Resource.Type.Service, m_serviceName);
     mapIds.put(Resource.Type.Component, componentName);
 
     return createResource(Resource.Type.Component, mapIds);

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/checks/ComponentsExistInRepoCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/ComponentsExistInRepoCheck.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/ComponentsExistInRepoCheck.java
index 6949257..3ec3268 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/ComponentsExistInRepoCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/ComponentsExistInRepoCheck.java
@@ -74,20 +74,21 @@ public class ComponentsExistInRepoCheck extends AbstractCheckDescriptor {
     Set<String> servicesInUpgrade = getServicesInUpgrade(request);
     for (String serviceName : servicesInUpgrade) {
       try {
+        Service service = cluster.getService(serviceName);
+        String serviceType = service.getServiceType();
         ServiceInfo serviceInfo = ambariMetaInfo.get().getService(targetStack.getStackName(),
-            targetStack.getStackVersion(), serviceName);
+            targetStack.getStackVersion(), serviceType);
 
         if (serviceInfo.isDeleted() || !serviceInfo.isValid()) {
           failedServices.add(serviceName);
           continue;
         }
 
-        Service service = cluster.getService(serviceName);
         Map<String, ServiceComponent> componentsInUpgrade = service.getServiceComponents();
         for (String componentName : componentsInUpgrade.keySet()) {
           try {
             ComponentInfo componentInfo = ambariMetaInfo.get().getComponent(
-                targetStack.getStackName(), targetStack.getStackVersion(), serviceName,
+                targetStack.getStackName(), targetStack.getStackVersion(), serviceType,
                 componentName);
 
             // if this component isn't included in the upgrade, then skip it

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesUpCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesUpCheck.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesUpCheck.java
index 5ecce88..6106325 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesUpCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServicesUpCheck.java
@@ -133,7 +133,7 @@ public class ServicesUpCheck extends AbstractCheckDescriptor {
         if (!serviceComponent.isMasterComponent()) {
           StackId stackId = service.getDesiredStackId();
           ComponentInfo componentInfo = ambariMetaInfo.get().getComponent(stackId.getStackName(),
-              stackId.getStackVersion(), serviceComponent.getServiceName(),
+              stackId.getStackVersion(), serviceComponent.getServiceType(),
               serviceComponent.getName());
 
           String cardinality = componentInfo.getCardinality();
@@ -195,8 +195,6 @@ public class ServicesUpCheck extends AbstractCheckDescriptor {
    * purposes of this check. Component type, maintenance mode, and state are
    * taken into account.
    *
-   * @param clusters
-   *          the clusters instance
    * @param cluster
    *          the cluster
    * @param serviceComponent

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/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 0f6eb90..ee582b3 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
@@ -168,7 +168,7 @@ public class AmbariActionExecutionHelper {
         ServiceInfo serviceInfo;
         try {
           serviceInfo = ambariMetaInfo.getService(stackId.getStackName(), stackId.getStackVersion(),
-            targetService);
+            service.getServiceType());
         } catch (StackAccessException se) {
           serviceInfo = null;
         }
@@ -204,7 +204,7 @@ public class AmbariActionExecutionHelper {
         ComponentInfo compInfo;
         try {
           compInfo = ambariMetaInfo.getComponent(stackId.getStackName(), stackId.getStackVersion(),
-            targetService, targetComponent);
+            service.getServiceType(), targetComponent);
         } catch (StackAccessException se) {
           compInfo = null;
         }
@@ -300,7 +300,7 @@ public class AmbariActionExecutionHelper {
 
           try {
             componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-                stackId.getStackVersion(), serviceName, componentName);
+                stackId.getStackVersion(), service.getServiceType(), componentName);
           } catch (ObjectNotFoundException e) {
             // do nothing, componentId is checked for null later
             LOG.error("Did not find service {} and component {} in stack {}.", serviceName, componentName, stackId.getStackName());

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/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 ff35e80..b9416d1 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
@@ -205,7 +205,7 @@ public class AmbariCustomCommandExecutionHelper {
 
     ComponentInfo componentInfo = ambariMetaInfo.getComponent(
         stackId.getStackName(), stackId.getStackVersion(),
-        serviceName, componentName);
+        service.getServiceType(), componentName);
 
     return !(!componentInfo.isCustomCommand(commandName) &&
       !actionMetadata.isDefaultHostComponentCommand(commandName));
@@ -452,7 +452,7 @@ public class AmbariCustomCommandExecutionHelper {
 
       ComponentInfo componentInfo = ambariMetaInfo.getComponent(
           stackId.getStackName(), stackId.getStackVersion(),
-          serviceName, componentName);
+          service.getServiceType(), componentName);
 
       if (serviceInfo.getSchemaVersion().equals(AmbariMetaInfo.SCHEMA_VERSION_2)) {
         // Service check command is not custom command
@@ -723,7 +723,7 @@ public class AmbariCustomCommandExecutionHelper {
 
     AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();
     ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
-        stackId.getStackVersion(), serviceName);
+        stackId.getStackVersion(), service.getServiceType());
     StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(),
         stackId.getStackVersion());
 
@@ -1445,7 +1445,7 @@ public class AmbariCustomCommandExecutionHelper {
 
         ComponentInfo componentInfo = ambariMetaInfo.getComponent(
                 stackId.getStackName(), stackId.getStackVersion(),
-                serviceName, componentName);
+                service.getServiceType(), componentName);
         List<String> clientsToUpdateConfigsList = componentInfo.getClientsToUpdateConfigs();
         if (clientsToUpdateConfigsList == null) {
           clientsToUpdateConfigsList = new ArrayList<>();

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/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 58f1cbd..8a038cc 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
@@ -2262,7 +2262,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
           getServiceComponent(componentName);
         StackId stackId = sc.getDesiredStackId();
         ComponentInfo compInfo = ambariMetaInfo.getComponent(
-          stackId.getStackName(), stackId.getStackVersion(), serviceName,
+          stackId.getStackName(), stackId.getStackVersion(), s.getServiceType(),
           componentName);
         if (runSmokeTest && compInfo.isMaster() &&
                 // op lvl handling for service component
@@ -2409,10 +2409,10 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     StackId stackId = scHost.getServiceComponent().getDesiredStackId();
 
     ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
-        stackId.getStackVersion(), serviceName);
+        stackId.getStackVersion(), scHost.getServiceType());
     ComponentInfo componentInfo = ambariMetaInfo.getComponent(
       stackId.getStackName(), stackId.getStackVersion(),
-      serviceName, componentName);
+      scHost.getServiceType(), componentName);
     StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(),
         stackId.getStackVersion());
 
@@ -2997,7 +2997,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
               case STARTED:
                 StackId stackId = serviceComponent.getDesiredStackId();
                 ComponentInfo compInfo = ambariMetaInfo.getComponent(
-                    stackId.getStackName(), stackId.getStackVersion(), scHost.getServiceName(),
+                    stackId.getStackName(), stackId.getStackVersion(), scHost.getServiceType(),
                     scHost.getServiceComponentName());
 
                 if (oldSchState == State.INSTALLED ||
@@ -4115,7 +4115,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     StackId stackId = service.getDesiredStackId();
     ComponentInfo compInfo =
         ambariMetaInfo.getService(stackId.getStackName(),
-            stackId.getStackVersion(), service.getName()).getClientComponent();
+            stackId.getStackVersion(), service.getServiceType()).getClientComponent();
     if (compInfo != null) {
       try {
         ServiceComponent serviceComponent =

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
index ca80961..28acdb3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java
@@ -234,10 +234,10 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
         StackId stackId = component.getDesiredStackId();
 
         componentInfo = managementController.getAmbariMetaInfo().
-          getComponent(stackId.getStackName(), stackId.getStackVersion(), serviceName, componentName);
+          getComponent(stackId.getStackName(), stackId.getStackVersion(), service.getServiceType(), componentName);
 
         packageFolder = managementController.getAmbariMetaInfo().
-          getService(stackId.getStackName(), stackId.getStackVersion(), serviceName).getServicePackageFolder();
+          getService(stackId.getStackName(), stackId.getStackVersion(), service.getServiceType()).getServicePackageFolder();
 
         String commandScript = componentInfo.getCommandScript().getScript();
         List<ClientConfigFileDefinition> clientConfigFiles = componentInfo.getClientConfigFiles();
@@ -341,12 +341,9 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
           SecretReference.replacePasswordsWithReferences(propertiesTypes, configProperties, configType, configVersion);
         }
 
-        Map<String, Set<String>> clusterHostInfo = null;
-        ServiceInfo serviceInfo = null;
-        String osFamily = null;
-        clusterHostInfo = StageUtils.getClusterHostInfo(cluster);
-        serviceInfo = managementController.getAmbariMetaInfo().getService(stackId.getStackName(),
-          stackId.getStackVersion(), serviceName);
+        Map<String, Set<String>> clusterHostInfo = StageUtils.getClusterHostInfo(cluster);
+        ServiceInfo serviceInfo = managementController.getAmbariMetaInfo().getService(stackId.getStackName(),
+          stackId.getStackVersion(), response.getServiceType());
         try {
           clusterHostInfo = StageUtils.substituteHostIndexes(clusterHostInfo);
         } catch (AmbariException e) {
@@ -357,7 +354,7 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
           // translated to a SystemException.
           throw new SystemException(e.getMessage(), e);
         }
-        osFamily = clusters.getHost(hostName).getOsFamily();
+        String osFamily = clusters.getHost(hostName).getOsFamily();
 
         TreeMap<String, String> hostLevelParams = new TreeMap<>();
         StageUtils.useStackJdkIfExists(hostLevelParams, configs);

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
index ba5a4e7..da6cbdf 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
@@ -696,8 +696,9 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
     Set<String> servicesOnHost = new HashSet<>();
     List<ServiceComponentHost> components = cluster.getServiceComponentHosts(host.getHostName());
     for (ServiceComponentHost component : components) {
-      if (repoServices.isEmpty() || repoServices.contains(component.getServiceName())) {
-        servicesOnHost.add(component.getServiceName());
+      String serviceType = component.getServiceType();
+      if (repoServices.isEmpty() || repoServices.contains(serviceType)) {
+        servicesOnHost.add(serviceType);
       }
     }
 
@@ -742,7 +743,7 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
       ComponentInfo componentInfo;
       try {
         componentInfo = ami.getComponent(stackId.getStackName(),
-                stackId.getStackVersion(), component.getServiceName(), component.getServiceComponentName());
+                stackId.getStackVersion(), component.getServiceType(), component.getServiceComponentName());
       } catch (AmbariException e) {
         // It is possible that the component has been removed from the new stack
         // (example: STORM_REST_API has been removed from HDP-2.2)

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
index f7559c6..7ef18ed 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
@@ -470,10 +470,10 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
       } else {
         StackId stackId = s.getDesiredStackId();
         ComponentInfo componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-                stackId.getStackVersion(), s.getName(), request.getComponentName());
+                stackId.getStackVersion(), s.getServiceType(), request.getComponentName());
         if (componentInfo == null) {
             throw new AmbariException("Could not get component information from stack definition: Stack=" +
-              stackId + ", Service=" + s.getName() + ", Component=" + request.getComponentName());
+              stackId + ", Service=" + s.getServiceType() + ", Component=" + request.getComponentName());
         }
         sc.setRecoveryEnabled(componentInfo.isRecoveryEnabled());
         LOG.info("Component: {}, recovery_enabled from stack definition:{}", componentInfo.getName(),
@@ -531,7 +531,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
 
       try {
         ComponentInfo componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-            stackId.getStackVersion(), s.getName(), request.getComponentName());
+            stackId.getStackVersion(), s.getServiceType(), request.getComponentName());
         category = componentInfo.getCategory();
         if (category != null) {
           serviceComponentResponse.setCategory(category);
@@ -565,7 +565,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
         ServiceComponentResponse serviceComponentResponse = sc.convertToResponse();
         try {
           ComponentInfo componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-              stackId.getStackVersion(), s.getName(), sc.getName());
+              stackId.getStackVersion(), s.getServiceType(), sc.getName());
           category = componentInfo.getCategory();
           if (category != null) {
             serviceComponentResponse.setCategory(category);

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
index ba5fccc..405d608 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
@@ -410,7 +410,7 @@ public class HostStackVersionResourceProvider extends AbstractControllerResource
           throw new IllegalArgumentException("Components list contains a component with no 'name' property");
         }
 
-        String serviceName = null;
+        String serviceName;
         try {
           serviceName = ami.getComponentToService(stackName, stackVersion, componentName.trim().toUpperCase());
           if (serviceName == null) {
@@ -426,7 +426,7 @@ public class HostStackVersionResourceProvider extends AbstractControllerResource
     } else {
       List<ServiceComponentHost> components = cluster.getServiceComponentHosts(host.getHostName());
       for (ServiceComponentHost component : components) {
-        servicesOnHost.add(component.getServiceName());
+        servicesOnHost.add(component.getServiceType());
       }
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
index 252d772..4ea7a7c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
@@ -920,7 +920,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
           StackId sid = service.getDesiredStackId();
 
           if ( ambariMetaInfo.getComponent(
-              sid.getStackName(), sid.getStackVersion(), sc.getServiceName(),
+              sid.getStackName(), sid.getStackVersion(), sc.getServiceType(),
               sch.getServiceComponentName()).isMaster()) {
             throw new IllegalArgumentException(error);
           } else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
index 8c2198b..2b57d17 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProvider.java
@@ -174,7 +174,7 @@ public class StackDefinedPropertyProvider implements PropertyProvider {
         StackId stack = service.getDesiredStackId();
 
         List<MetricDefinition> defs = metaInfo.getMetrics(
-            stack.getStackName(), stack.getStackVersion(), service.getName(), componentName, type.name());
+            stack.getStackName(), stack.getStackVersion(), service.getServiceType(), componentName, type.name());
 
         if (null == defs || 0 == defs.size()) {
           continue;

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java
index 0cd55c3..70d9654 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingSearchPropertyProvider.java
@@ -196,7 +196,7 @@ public class LoggingSearchPropertyProvider implements PropertyProvider {
       final String stackVersion = stackId.getStackVersion();
 
       ComponentInfo componentInfo =
-        metaInfo.getComponent(stackName, stackVersion, serviceName, componentName);
+        metaInfo.getComponent(stackName, stackVersion, service.getServiceType(), componentName);
       if (componentInfo != null) {
         List<LogDefinition> listOfLogs =
           componentInfo.getLogs();

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
index cae330b..f6e50c9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/timeline/AMSPropertyProvider.java
@@ -318,7 +318,7 @@ public abstract class AMSPropertyProvider extends MetricsPropertyProvider {
             String stackName = stackId.getStackName();
             String version = stackId.getStackVersion();
             AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();
-            String serviceName = service.getName();
+            String serviceName = service.getServiceType();
             String timeLineAppId = ambariMetaInfo.getComponent(stackName, version, serviceName, componentName).getTimelineAppid();
             if (timeLineAppId != null){
               timelineAppIdCache.put(componentName, timeLineAppId);

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
index e3f4e1a..2620f38 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
@@ -110,7 +110,7 @@ public class DatabaseChecker {
 
             ComponentInfo componentInfo = ambariMetaInfo.getComponent(
               stackId.getStackName(), stackId.getStackVersion(),
-              clusterServiceEntity.getServiceName(), scDesiredStateEnity.getComponentName());
+              clusterServiceEntity.getServiceType(), scDesiredStateEnity.getComponentName());
 
             boolean zeroCardinality = componentInfo.getCardinality() == null
               || componentInfo.getCardinality().startsWith("0")

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedState.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedState.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedState.java
index 603e650..70871d0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedState.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedState.java
@@ -108,7 +108,7 @@ public class DefaultServiceCalculatedState implements ServiceCalculatedState {
           for (ServiceComponentHostResponse hostComponentResponse : hostComponentResponses ) {
             try {
               ComponentInfo componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-                stackId.getStackVersion(), hostComponentResponse.getServiceName(),
+                stackId.getStackVersion(), hostComponentResponse.getServiceType(),
                 hostComponentResponse.getComponentName());
 
               State state = getHostComponentState(hostComponentResponse);

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedState.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedState.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedState.java
index 765e6fc..dd15461 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedState.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedState.java
@@ -61,7 +61,7 @@ public final class HBaseServiceCalculatedState extends DefaultServiceCalculatedS
         for (ServiceComponentHostResponse hostComponentResponse : hostComponentResponses ) {
           try {
             ComponentInfo componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-              stackId.getStackVersion(), hostComponentResponse.getServiceName(),
+              stackId.getStackVersion(), hostComponentResponse.getServiceType(),
               hostComponentResponse.getComponentName());
 
             if (componentInfo.isMaster()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedState.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedState.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedState.java
index 704b4b9..ce8b98c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedState.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedState.java
@@ -64,7 +64,7 @@ public final class HDFSServiceCalculatedState extends DefaultServiceCalculatedSt
         for (ServiceComponentHostResponse hostComponentResponse : hostComponentResponses ) {
           try {
             ComponentInfo componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-              stackId.getStackVersion(), hostComponentResponse.getServiceName(),
+              stackId.getStackVersion(), hostComponentResponse.getServiceType(),
               hostComponentResponse.getComponentName());
 
             if (componentInfo.isMaster()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedState.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedState.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedState.java
index 5e23f0b..440dd53 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedState.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedState.java
@@ -66,7 +66,7 @@ public final class HiveServiceCalculatedState extends DefaultServiceCalculatedSt
         for (ServiceComponentHostResponse hostComponentResponse : hostComponentResponses ) {
           try {
             ComponentInfo componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-              stackId.getStackVersion(), hostComponentResponse.getServiceName(),
+              stackId.getStackVersion(), hostComponentResponse.getServiceType(),
               hostComponentResponse.getComponentName());
 
             if (componentInfo.isMaster()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedState.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedState.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedState.java
index 6c5eab4..2d9356c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedState.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedState.java
@@ -61,7 +61,7 @@ public final class OozieServiceCalculatedState extends DefaultServiceCalculatedS
         for (ServiceComponentHostResponse hostComponentResponse : hostComponentResponses ) {
           try {
             ComponentInfo componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-              stackId.getStackVersion(), hostComponentResponse.getServiceName(),
+              stackId.getStackVersion(), hostComponentResponse.getServiceType(),
               hostComponentResponse.getComponentName());
 
             if (componentInfo.isMaster()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/YARNServiceCalculatedState.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/YARNServiceCalculatedState.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/YARNServiceCalculatedState.java
index 2fd99e4..b7a14b5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/YARNServiceCalculatedState.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/state/YARNServiceCalculatedState.java
@@ -63,7 +63,7 @@ public final class YARNServiceCalculatedState extends DefaultServiceCalculatedSt
         for (ServiceComponentHostResponse hostComponentResponse : hostComponentResponses ) {
           try {
             ComponentInfo componentInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-              stackId.getStackVersion(), hostComponentResponse.getServiceName(),
+              stackId.getStackVersion(), hostComponentResponse.getServiceType(),
               hostComponentResponse.getComponentName());
 
             if (componentInfo.isMaster()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertMaintenanceModeListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertMaintenanceModeListener.java b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertMaintenanceModeListener.java
index f73d7c9..602d0b8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertMaintenanceModeListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertMaintenanceModeListener.java
@@ -139,7 +139,7 @@ public class AlertMaintenanceModeListener {
         } else if( null != serviceComponentHost ){
           // component level maintenance
           String hostName = serviceComponentHost.getHostName();
-          String serviceName = serviceComponentHost.getServiceName();
+          String serviceName = serviceComponentHost.getServiceType();
           String componentName = serviceComponentHost.getServiceComponentName();
 
           // match on all 3 for a service component

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertServiceStateListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertServiceStateListener.java b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertServiceStateListener.java
index 053fb54..41ae4e8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertServiceStateListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertServiceStateListener.java
@@ -154,7 +154,7 @@ public class AlertServiceStateListener {
       // which hosts are invalidated; do that in another impl
       try {
         Set<AlertDefinition> alertDefinitions = m_metaInfoProvider.get().getAlertDefinitions(
-            stackName, stackVersion, serviceName);
+            stackName, stackVersion, event.getServiceType());
 
         for (AlertDefinition definition : alertDefinitions) {
           AlertDefinitionEntity entity = m_alertDefinitionFactory.coerce(

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListener.java b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListener.java
index 4846eb1..b4a1529 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListener.java
@@ -259,11 +259,10 @@ public class HostVersionOutOfSyncListener {
           // We perform check per-stack version, because component may be not versionAdvertised in current
           // stack, but become versionAdvertised in some future (installed, but not yet upgraded to) stack
           boolean hasChangedComponentsWithVersions = false;
-          String serviceName = event.getServiceName();
           for (ServiceComponent comp : affectedHosts.get(hostName)) {
             String componentName = comp.getName();
             ComponentInfo component = ami.get().getComponent(repositoryVersion.getStackName(),
-                    repositoryVersion.getStackVersion(), serviceName, componentName);
+                    repositoryVersion.getStackVersion(), comp.getServiceType(), componentName);
             if (component.isVersionAdvertised()) {
               hasChangedComponentsWithVersions = true;
             }

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
index e5298dc..df038b4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/upgrade/StackVersionListener.java
@@ -121,7 +121,7 @@ public class StackVersionListener {
 
       AmbariMetaInfo ambariMetaInfo = ambariMetaInfoProvider.get();
       ComponentInfo componentInfo = ambariMetaInfo.getComponent(desiredStackId.getStackName(),
-          desiredStackId.getStackVersion(), sch.getServiceName(), sch.getServiceComponentName());
+          desiredStackId.getStackVersion(), sch.getServiceType(), sch.getServiceComponentName());
 
       // not advertising a version, do nothing
       if (!componentInfo.isVersionAdvertised()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java b/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java
index 0fcc285..1036926 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/mpack/MpackManager.java
@@ -117,7 +117,7 @@ public class MpackManager {
           }
         }
       }
-    } catch (IOException e) {
+    } catch (NullPointerException|IOException e) {
       e.printStackTrace();
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
index d6876d9..4f11ab0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
@@ -378,7 +378,7 @@ public class FinalizeUpgradeAction extends AbstractUpgradeServerAction {
       for (ServiceComponent serviceComponent : service.getServiceComponents().values()) {
         for (ServiceComponentHost serviceComponentHost : serviceComponent.getServiceComponentHosts().values()) {
           ComponentInfo componentInfo = ambariMetaInfo.getComponent(targetStackId.getStackName(),
-                  targetStackId.getStackVersion(), service.getName(), serviceComponent.getName());
+                  targetStackId.getStackVersion(), service.getServiceType(), serviceComponent.getName());
 
           if (!componentInfo.isVersionAdvertised()) {
             continue;

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/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 e89f3dc..d729cb8 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
@@ -943,7 +943,7 @@ public class ConfigHelper {
     // below, no attempt will be made to remove properties that exist in excluded types.
     Service service = cluster.getService(serviceName);
 
-    return getServiceProperties(service.getDesiredStackId(), serviceName, false);
+    return getServiceProperties(service.getDesiredStackId(), service.getServiceType(), false);
   }
 
   /**
@@ -955,15 +955,15 @@ public class ConfigHelper {
    * PropertyInfos will be returned.
    *
    * @param stackId        a StackId declaring the relevant stack
-   * @param serviceName    a String containing the requested service's name
+   * @param stackServiceName    a String containing the requested service's name
    * @param removeExcluded a boolean value indicating whether to remove properties from excluded
    *                       configuration types (<code>true</code>) or return the complete set of properties regardless of exclusions (<code>false</code>)
    * @return a Set of PropertyInfo objects for the requested service
    * @throws AmbariException if the requested stack or the requested service is not found
    */
-  public Set<PropertyInfo> getServiceProperties(StackId stackId, String serviceName, boolean removeExcluded)
+  public Set<PropertyInfo> getServiceProperties(StackId stackId, String stackServiceName, boolean removeExcluded)
       throws AmbariException {
-    ServiceInfo service = ambariMetaInfo.getService(stackId.getStackName(), stackId.getStackVersion(), serviceName);
+    ServiceInfo service = ambariMetaInfo.getService(stackId.getStackName(), stackId.getStackVersion(), stackServiceName);
     Set<PropertyInfo> properties = new HashSet<>(service.getProperties());
 
     if (removeExcluded) {
@@ -1319,7 +1319,7 @@ public class ConfigHelper {
     StackInfo stackInfo = ambariMetaInfo.getStack(stackId);
 
     ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
-            stackId.getStackVersion(), sch.getServiceName());
+            stackId.getStackVersion(), sch.getServiceType());
 
     ComponentInfo componentInfo = serviceInfo.getComponentByName(sch.getServiceComponentName());
     // Configs are considered stale when:

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
index df6437e..b4b4ea1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
@@ -138,7 +138,7 @@ public class ServiceComponentImpl implements ServiceComponent {
     StackId stackId = service.getDesiredStackId();
     try {
       ComponentInfo compInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
-          stackId.getStackVersion(), service.getName(), componentName);
+          stackId.getStackVersion(), service.getServiceType(), componentName);
       isClientComponent = compInfo.isClient();
       isMasterComponent = compInfo.isMaster();
       isVersionAdvertised = compInfo.isVersionAdvertised();
@@ -147,7 +147,7 @@ public class ServiceComponentImpl implements ServiceComponent {
       throw new RuntimeException("Trying to create a ServiceComponent"
           + " not recognized in stack info"
           + ", clusterName=" + service.getCluster().getClusterName()
-          + ", serviceName=" + service.getName()
+          + ", serviceName=" + service.getServiceType()
           + ", componentName=" + componentName
           + ", stackInfo=" + stackId.getStackId());
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
index 70344b0..167e4ca 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
@@ -201,7 +201,7 @@ public class ServiceImpl implements Service {
 
     StackId stackId = getDesiredStackId();
     ServiceInfo sInfo = ambariMetaInfo.getService(stackId.getStackName(),
-        stackId.getStackVersion(), getName());
+        stackId.getStackVersion(), getServiceType());
     isClientOnlyService = sInfo.isClientOnlyService();
     isCredentialStoreSupported = sInfo.isCredentialStoreSupported();
     isCredentialStoreRequired = sInfo.isCredentialStoreRequired();
@@ -279,6 +279,7 @@ public class ServiceImpl implements Service {
       throw new AmbariException("Cannot add duplicate ServiceComponent"
           + ", clusterName=" + cluster.getClusterName()
           + ", clusterId=" + cluster.getClusterId()
+          + ", serviceType=" + getServiceType()
           + ", serviceName=" + getName()
           + ", serviceComponentName=" + component.getName());
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
index ebc82ee..510072a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
@@ -877,7 +877,7 @@ public class UpgradeHelper {
         boolean versionAdvertised = false;
         try {
           ComponentInfo ci = m_ambariMetaInfoProvider.get().getComponent(targetStack.getStackName(),
-              targetStack.getStackVersion(), serviceComponent.getServiceName(),
+              targetStack.getStackVersion(), serviceComponent.getServiceType(),
               serviceComponent.getName());
 
           versionAdvertised = ci.isVersionAdvertised();

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java
index 15f7048..025015a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java
@@ -399,7 +399,7 @@ public class AlertDefinitionHash {
 
       // if a host has a matching service/component, invalidate it
       for (ServiceComponentHost component : hostComponents) {
-        String serviceName = component.getServiceName();
+        String serviceName = component.getServiceType();
         String componentName = component.getServiceComponentName();
         if (serviceName.equals(definitionServiceName)
             && componentName.equals(definitionComponentName)) {
@@ -645,7 +645,7 @@ public class AlertDefinitionHash {
       List<ServiceComponentHost> serviceComponents = cluster.getServiceComponentHosts(hostName);
       if (null == serviceComponents || !serviceComponents.isEmpty()) {
         for (ServiceComponentHost serviceComponent : serviceComponents) {
-          String serviceName = serviceComponent.getServiceName();
+          String serviceName = serviceComponent.getServiceType();
           String componentName = serviceComponent.getServiceComponentName();
 
           // add all alerts for this service/component pair

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index fcc07b6..1e4d81f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -437,7 +437,7 @@ public class ClusterImpl implements Cluster {
       StackId stackId = new StackId(stackEntity);
       try {
         if (ambariMetaInfo.getService(stackId.getStackName(),
-          stackId.getStackVersion(), serviceEntity.getServiceName()) != null) {
+          stackId.getStackVersion(), serviceEntity.getServiceType()) != null) {
           services.put(serviceEntity.getServiceName(),
             serviceFactory.createExisting(this, getServiceGroup(serviceEntity.getServiceGroupId()), serviceEntity));
            stackId = getService(serviceEntity.getServiceName()).getDesiredStackId();

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
index 13ceeb9..4285ba9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
@@ -1194,7 +1194,7 @@ public class HostImpl implements Host {
       Service s = cluster.getService(hostComponentState.getServiceId());
       ComponentInfo componentInfo = ambariMetaInfo.getComponent(
           desiredRepositoryVersion.getStackName(), desiredRepositoryVersion.getStackVersion(),
-          s.getName(), hostComponentState.getComponentName());
+          s.getServiceType(), hostComponentState.getComponentName());
 
       // skip components which don't advertise a version
       if (!componentInfo.isVersionAdvertised()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/HostOrderGrouping.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/HostOrderGrouping.java b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/HostOrderGrouping.java
index acf0639..3f6ad60 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/HostOrderGrouping.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/HostOrderGrouping.java
@@ -342,7 +342,7 @@ public class HostOrderGrouping extends Grouping {
       try {
         ComponentInfo component = upgradeContext.getAmbariMetaInfo().getComponent(
             targetStack.getStackName(), targetStack.getStackVersion(),
-            sch.getServiceName(), sch.getServiceComponentName());
+            sch.getServiceType(), sch.getServiceComponentName());
 
         return component.isVersionAdvertised();
       } catch (AmbariException e) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServiceCheckGrouping.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServiceCheckGrouping.java b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServiceCheckGrouping.java
index 9c47e5d..0587de4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServiceCheckGrouping.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/stack/upgrade/ServiceCheckGrouping.java
@@ -182,7 +182,7 @@ public class ServiceCheckGrouping extends Grouping {
           // Services that only have clients such as Pig can still have service check scripts.
           StackId stackId = svc.getDesiredStackId();
           try {
-            ServiceInfo si = m_metaInfo.getService(stackId.getStackName(), stackId.getStackVersion(), service);
+            ServiceInfo si = m_metaInfo.getService(stackId.getStackName(), stackId.getStackVersion(), svc.getServiceType());
             CommandScriptDefinition script = si.getCommandScript();
             if (null != script && null != script.getScript() && !script.getScript().isEmpty()) {
               ctx.setServiceDisplay(service, si.getDisplayName());

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
index 6190a03..0b9811e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
@@ -1198,7 +1198,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
     try {
       StackId stackVersion = serviceComponent.getDesiredStackId();
       ComponentInfo compInfo = ambariMetaInfo.getComponent(stackVersion.getStackName(),
-              stackVersion.getStackVersion(), serviceName, serviceComponentName);
+              stackVersion.getStackVersion(), service.getServiceType(), serviceComponentName);
       displayName = compInfo.getDisplayName();
     } catch (AmbariException e) {
       displayName = serviceComponentName;

http://git-wip-us.apache.org/repos/asf/ambari/blob/17e4330d/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostSummary.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostSummary.java b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostSummary.java
index 7edabc6..a9b8a2c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostSummary.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostSummary.java
@@ -69,7 +69,6 @@ public class ServiceComponentHostSummary {
 
     for (HostComponentStateEntity hostComponentStateEntity : allHostComponents) {
       ClusterServiceEntity serviceEntity = hostComponentStateEntity.getServiceComponentDesiredStateEntity().getClusterServiceEntity();
-      String serviceName = serviceEntity.getServiceName();
       String serviceType  = serviceEntity.getServiceType();
       ComponentInfo compInfo = ambariMetaInfo.getComponent(stackName, stackVersion, serviceType,
                                                            hostComponentStateEntity.getComponentName());


[30/30] ambari git commit: Merge branch 'branch-feature-AMBARI-14714' into branch-feature-AMBARI-14714-ui

Posted by mr...@apache.org.
Merge branch 'branch-feature-AMBARI-14714' into branch-feature-AMBARI-14714-ui


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 272e5006c6364544719b3ed2a65e9c6800567b66
Parents: 96959e9 259036f
Author: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Authored: Mon Oct 30 11:43:17 2017 -0700
Committer: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Committed: Mon Oct 30 11:43:17 2017 -0700

----------------------------------------------------------------------
 .../server/PropertyNotFoundException.java       |  27 ++
 .../server/ResourcesPathNotFoundException.java  |  25 ++
 .../actionmanager/ExecutionCommandWrapper.java  |   6 +-
 .../ambari/server/agent/HeartBeatHandler.java   |   2 +-
 .../alerts/ComponentVersionAlertRunnable.java   |   2 +-
 .../query/render/ClusterBlueprintRenderer.java  |  21 +-
 .../resources/ResourceInstanceFactoryImpl.java  |   4 +
 .../RootClusterSettingsResourceDefinition.java  |  52 +++
 .../server/api/services/AmbariMetaInfo.java     |  51 ++-
 .../server/api/services/ComponentService.java   |   8 +-
 .../api/services/RootClusterSettingService.java | 135 ++++++
 .../server/api/services/ServiceService.java     |   2 +-
 .../server/api/services/StacksService.java      |  10 +-
 .../StackAdvisorBlueprintProcessor.java         |  14 +-
 .../users/ActiveWidgetLayoutService.java        |   2 +-
 .../api/services/views/ViewInstanceService.java |   2 +-
 .../server/checks/AbstractCheckDescriptor.java  |   8 +-
 .../checks/ComponentsExistInRepoCheck.java      |   7 +-
 .../ambari/server/checks/ServicesUpCheck.java   |   4 +-
 .../controller/AmbariActionExecutionHelper.java |   6 +-
 .../AmbariCustomCommandExecutionHelper.java     |  10 +-
 .../controller/AmbariManagementController.java  |  12 +-
 .../AmbariManagementControllerImpl.java         |  85 ++--
 .../ambari/server/controller/AmbariServer.java  |  10 +-
 .../server/controller/ControllerModule.java     |   2 +
 .../controller/DeleteIdentityHandler.java       |   4 +-
 .../ReadOnlyConfigurationResponse.java          | 272 +++++++++++
 .../controller/RootClusterSettingRequest.java   |  39 ++
 .../controller/StackConfigurationResponse.java  | 266 -----------
 .../StackLevelConfigurationRequest.java         |   2 +-
 .../StackLevelConfigurationResponse.java        |  20 +-
 .../ambari/server/controller/StackV2.java       | 447 +++++--------------
 .../server/controller/StackV2Factory.java       | 251 +++++++++++
 .../AbstractControllerResourceProvider.java     |   4 +-
 .../controller/internal/BaseClusterRequest.java |  38 +-
 .../BlueprintConfigurationProcessor.java        | 286 +++++++-----
 .../internal/BlueprintV2ResourceProvider.java   | 391 ++++++++++++++++
 .../internal/ClientConfigResourceProvider.java  |  15 +-
 .../internal/ClusterResourceProvider.java       |   2 +-
 .../ClusterStackVersionResourceProvider.java    |   7 +-
 .../internal/ComponentResourceProvider.java     |   8 +-
 .../internal/ConfigurationContext.java          |  60 +++
 .../internal/ExportBlueprintRequest.java        |  34 +-
 .../HostStackVersionResourceProvider.java       |   4 +-
 .../internal/MpackResourceProvider.java         |   2 -
 .../internal/ProvisionClusterRequest.java       |  49 +-
 .../RootClusterSettingsResourceProvider.java    | 167 +++++++
 .../internal/ScaleClusterRequest.java           |  18 +-
 .../internal/ServiceResourceProvider.java       |   2 +-
 .../server/controller/internal/Stack.java       |  14 +-
 .../StackConfigurationResourceProvider.java     |   8 +-
 .../internal/StackDefinedPropertyProvider.java  |   2 +-
 ...StackLevelConfigurationResourceProvider.java |   8 +-
 .../server/controller/internal/UnitUpdater.java |  15 +-
 .../logging/LoggingSearchPropertyProvider.java  |   2 +-
 .../metrics/timeline/AMSPropertyProvider.java   |   2 +-
 .../ambari/server/controller/spi/Resource.java  |   2 +
 .../controller/utilities/DatabaseChecker.java   |   2 +-
 .../state/DefaultServiceCalculatedState.java    |   2 +-
 .../state/HBaseServiceCalculatedState.java      |   2 +-
 .../state/HDFSServiceCalculatedState.java       |   2 +-
 .../state/HiveServiceCalculatedState.java       |   2 +-
 .../state/OozieServiceCalculatedState.java      |   2 +-
 .../state/YARNServiceCalculatedState.java       |   2 +-
 .../alerts/AlertMaintenanceModeListener.java    |   2 +-
 .../alerts/AlertServiceStateListener.java       |   2 +-
 .../upgrade/HostVersionOutOfSyncListener.java   |   3 +-
 .../listeners/upgrade/StackVersionListener.java |   2 +-
 .../ambari/server/mpack/MpackManager.java       |   2 +-
 .../ambari/server/orm/dao/BlueprintV2DAO.java   | 124 +++++
 .../server/orm/entities/BlueprintEntity.java    |   1 -
 .../server/orm/entities/BlueprintV2Entity.java  |  90 ++++
 .../orm/entities/HostGroupComponentEntity.java  |  16 +-
 .../entities/HostGroupComponentEntityPK.java    |  36 ++
 .../ambari/server/orm/entities/StackEntity.java |  11 +-
 .../entities/TopologyConfigurationsEntity.java  | 148 ++++++
 .../orm/entities/TopologyRequestEntity.java     |  40 +-
 .../ResourceLevelClusterSettingManager.java     | 168 +++++++
 ...sourceLevelClusterSettingManagerFactory.java |  34 ++
 .../upgrades/FinalizeUpgradeAction.java         |   2 +-
 .../ambari/server/state/ConfigHelper.java       |  83 ++--
 .../ambari/server/state/ConfigMergeHelper.java  |   4 +-
 .../ambari/server/state/PropertyInfo.java       |   6 +-
 .../server/state/ServiceComponentImpl.java      |   4 +-
 .../apache/ambari/server/state/ServiceImpl.java |   3 +-
 .../apache/ambari/server/state/ServiceInfo.java |  28 +-
 .../ambari/server/state/UpgradeHelper.java      |  19 +-
 .../server/state/alert/AlertDefinitionHash.java |   4 +-
 .../server/state/cluster/ClusterImpl.java       |   9 +-
 .../ambari/server/state/host/HostImpl.java      |   2 +-
 .../state/stack/upgrade/HostOrderGrouping.java  |   2 +-
 .../stack/upgrade/ServiceCheckGrouping.java     |   2 +-
 .../svccomphost/ServiceComponentHostImpl.java   |   2 +-
 .../ServiceComponentHostSummary.java            |   1 -
 .../ambari/server/topology/AmbariContext.java   | 233 ++++------
 .../ambari/server/topology/BlueprintImplV2.java | 308 ++++++++++++-
 .../ambari/server/topology/BlueprintV2.java     | 110 ++++-
 .../server/topology/BlueprintV2Factory.java     | 196 ++++++++
 .../server/topology/BlueprintValidatorImpl.java |  68 +--
 .../server/topology/BlueprintValidatorV2.java   |  43 ++
 .../topology/ClusterConfigurationRequest.java   |  64 +--
 .../ambari/server/topology/ClusterTopology.java |  15 +-
 .../server/topology/ClusterTopologyImpl.java    |  84 ++--
 .../ambari/server/topology/ComponentV2.java     |  96 +++-
 .../ambari/server/topology/Configurable.java    |  40 ++
 .../ambari/server/topology/Configuration.java   |   7 +
 .../ambari/server/topology/HostGroupImpl.java   |   2 -
 .../ambari/server/topology/HostGroupInfo.java   |  17 +-
 .../ambari/server/topology/HostGroupV2.java     |  23 +-
 .../ambari/server/topology/HostGroupV2Impl.java | 169 +++++++
 .../ambari/server/topology/HostRequest.java     |  38 +-
 .../ambari/server/topology/LogicalRequest.java  |   4 +-
 .../server/topology/PersistedStateImpl.java     |  58 ++-
 .../server/topology/RepositoryVersion.java      |  71 +++
 .../server/topology/SecurityConfiguration.java  |   7 +-
 .../apache/ambari/server/topology/Service.java  | 131 ++++--
 .../ambari/server/topology/ServiceGroup.java    |  61 ++-
 .../ambari/server/topology/ServiceId.java       |  79 ++++
 .../apache/ambari/server/topology/Setting.java  |  18 +-
 .../ambari/server/topology/TopologyManager.java |  20 +-
 .../ambari/server/topology/TopologyRequest.java |  10 +-
 .../tasks/PersistHostResourcesTask.java         |  12 +-
 .../validators/ClusterConfigTypeValidator.java  |   8 +-
 .../validators/HiveServiceValidator.java        |  47 +-
 .../RequiredConfigPropertiesValidator.java      |  91 ++--
 .../validators/RequiredPasswordValidator.java   |  27 +-
 .../validators/StackConfigTypeValidator.java    |  31 +-
 .../topology/validators/UnitValidator.java      |  34 +-
 .../main/resources/Ambari-DDL-Derby-CREATE.sql  |  22 +
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |  22 +
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |  23 +
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  25 ++
 .../resources/Ambari-DDL-SQLAnywhere-CREATE.sql |  23 +
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |  23 +
 .../src/main/resources/META-INF/persistence.xml |   1 +
 .../src/main/resources/cluster-settings.xml     | 322 +++++++++++++
 ...tryRecommendationResourceDefinitionTest.java |  37 ++
 .../RegistryResourceDefinitionTest.java         |  62 +++
 ...egistryValidationResourceDefinitionTest.java |  37 ++
 .../server/api/services/AmbariMetaInfoTest.java |   2 +-
 .../api/services/RegistryServiceTest.java       |  94 ++++
 .../api/services/RootServiceServiceTest.java    |   2 +-
 .../server/api/services/ServiceServiceTest.java |   2 +-
 .../AmbariManagementControllerTest.java         |   6 +-
 .../server/controller/RegistryRequestTest.java  |  37 ++
 .../internal/BlueprintResourceProviderTest.java |   5 +-
 .../server/state/cluster/ClusterTest.java       |   2 +-
 .../server/topology/BlueprintImplTest.java      |  10 +-
 .../topology/ClusterTopologyImplTest.java       |  40 +-
 .../validators/BlueprintImplV2Test.java         |  79 ++++
 .../test/resources/blueprintv2/blueprintv2.json | 146 ++++++
 151 files changed, 5476 insertions(+), 1580 deletions(-)
----------------------------------------------------------------------



[07/30] ambari git commit: use V2 objects in TopologyManager

Posted by mr...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
new file mode 100644
index 0000000..c5a6064
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
@@ -0,0 +1,829 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.*;
+import org.apache.ambari.server.orm.entities.StackEntity;
+
+import org.apache.ambari.server.state.AutoDeployInfo;
+import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.DependencyInfo;
+import org.apache.ambari.server.state.PropertyDependencyInfo;
+import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.ValueAttributesInfo;
+
+import org.apache.ambari.server.topology.Cardinality;
+import org.apache.ambari.server.topology.Configuration;
+
+/**
+ * Encapsulates stack information.
+ */
+public class StackV2 {
+  /**
+   * Stack name
+   */
+  private String name;
+
+  /**
+   * Stack version
+   */
+  private String version;
+
+  /**
+     * Repo version
+   */
+  private String repoVersion;
+
+  /**
+   * Map of service name to components
+   */
+  private Map<String, Collection<String>> serviceComponents =
+    new HashMap<>();
+
+  /**
+   * Map of component to service
+   */
+  private Map<String, String> componentService = new HashMap<>();
+
+  /**
+   * Map of component to dependencies
+   */
+  private Map<String, Collection<DependencyInfo>> dependencies =
+    new HashMap<>();
+
+  /**
+   * Map of dependency to conditional service
+   */
+  private Map<DependencyInfo, String> dependencyConditionalServiceMap =
+    new HashMap<>();
+
+  /**
+   * Map of database component name to configuration property which indicates whether
+   * the database in to be managed or if it is an external non-managed instance.
+   * If the value of the config property starts with 'New', the database is determined
+   * to be managed, otherwise it is non-managed.
+   */
+  private Map<String, String> dbDependencyInfo = new HashMap<>();
+
+  /**
+   * Map of component to required cardinality
+   */
+  private Map<String, String> cardinalityRequirements = new HashMap<>();
+
+  //todo: instead of all these maps from component -> * ,
+  //todo: we should use a Component object with all of these attributes
+  private Set<String> masterComponents = new HashSet<>();
+
+  /**
+   * Map of component to auto-deploy information
+   */
+  private Map<String, AutoDeployInfo> componentAutoDeployInfo =
+    new HashMap<>();
+
+  /**
+   * Map of service to config type properties
+   */
+  private Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations =
+    new HashMap<>();
+
+  /**
+   * Map of service to required type properties
+   */
+  private Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations =
+    new HashMap<>();
+
+  /**
+   * Map of service to config type properties
+   */
+  private Map<String, Map<String, ConfigProperty>> stackConfigurations =
+    new HashMap<>();
+
+  /**
+   * Map of service to set of excluded config types
+   */
+  private Map<String, Set<String>> excludedConfigurationTypes =
+    new HashMap<>();
+
+  /**
+   * Ambari Management Controller, used to obtain Stack definitions
+   */
+  private final AmbariManagementController controller;
+
+
+  /**
+   * Constructor.
+   *
+   * @param stack
+   *          the stack (not {@code null}).
+   * @param ambariManagementController
+   *          the management controller (not {@code null}).
+   * @throws AmbariException
+   */
+  public StackV2(StackEntity stack, AmbariManagementController ambariManagementController) throws AmbariException {
+    this(stack.getStackName(), stack.getStackVersion(), ambariManagementController);
+  }
+
+  /**
+   * Constructor.
+   *
+   * @param name     stack name
+   * @param version  stack version
+   *
+   * @throws AmbariException an exception occurred getting stack information
+   *                         for the specified name and version
+   */
+  //todo: don't pass management controller in constructor
+  public StackV2(String name, String version, AmbariManagementController controller) throws AmbariException {
+    this.name = name;
+    this.version = version;
+    this.controller = controller;
+
+    Set<StackServiceResponse> stackServices = controller.getStackServices(
+        Collections.singleton(new StackServiceRequest(name, version, null)));
+
+    for (StackServiceResponse stackService : stackServices) {
+      String serviceName = stackService.getServiceName();
+      parseComponents(serviceName);
+      parseExcludedConfigurations(stackService);
+      parseConfigurations(stackService);
+      registerConditionalDependencies();
+    }
+
+    //todo: already done for each service
+    parseStackConfigurations();
+  }
+
+  /**
+   * Obtain stack name.
+   *
+   * @return stack name
+   */
+  public String getName() {
+    return name;
+  }
+
+  /**
+   * Obtain stack version.
+   *
+   * @return stack version
+   */
+  public String getVersion() {
+    return version;
+  }
+
+  /**
+   * Obtain repo version.
+   * @return
+   */
+  public String getRepoVersion() { return repoVersion; }
+
+  Map<DependencyInfo, String> getDependencyConditionalServiceMap() {
+    return dependencyConditionalServiceMap;
+  }
+
+  /**
+   * Get services contained in the stack.
+   *
+   * @return collection of all services for the stack
+   */
+  public Collection<String> getServices() {
+    return serviceComponents.keySet();
+  }
+
+  /**
+   * Get components contained in the stack for the specified service.
+   *
+   * @param service  service name
+   *
+   * @return collection of component names for the specified service
+   */
+  public Collection<String> getComponents(String service) {
+    return serviceComponents.get(service);
+  }
+
+  /**
+   * Get all service components
+   *
+   * @return map of service to associated components
+   */
+  public Map<String, Collection<String>> getComponents() {
+    Map<String, Collection<String>> serviceComponents = new HashMap<>();
+    for (String service : getServices()) {
+      Collection<String> components = new HashSet<>();
+      components.addAll(getComponents(service));
+      serviceComponents.put(service, components);
+    }
+    return serviceComponents;
+  }
+
+  /**
+   * Get info for the specified component.
+   *
+   * @param component  component name
+   *
+   * @return component information for the requested component
+   *         or null if the component doesn't exist in the stack
+   */
+  public ComponentInfo getComponentInfo(String component) {
+    ComponentInfo componentInfo = null;
+    String service = getServiceForComponent(component);
+    if (service != null) {
+      try {
+        componentInfo = controller.getAmbariMetaInfo().getComponent(
+            getName(), getVersion(), service, component);
+      } catch (AmbariException e) {
+        // just return null if component doesn't exist
+      }
+    }
+    return componentInfo;
+  }
+
+  /**
+   * Get all configuration types, including excluded types for the specified service.
+   *
+   * @param service  service name
+   *
+   * @return collection of all configuration types for the specified service
+   */
+  public Collection<String> getAllConfigurationTypes(String service) {
+    return serviceConfigurations.get(service).keySet();
+  }
+
+  /**
+   * Get configuration types for the specified service.
+   * This doesn't include any service excluded types.
+   *
+   * @param service  service name
+   *
+   * @return collection of all configuration types for the specified service
+   */
+  public Collection<String> getConfigurationTypes(String service) {
+    Set<String> serviceTypes = new HashSet<>(serviceConfigurations.get(service).keySet());
+    serviceTypes.removeAll(getExcludedConfigurationTypes(service));
+
+    return serviceTypes;
+  }
+
+  /**
+   * Get the set of excluded configuration types for this service.
+   *
+   * @param service service name
+   *
+   * @return Set of names of excluded config types. Will not return null.
+   */
+  public Set<String> getExcludedConfigurationTypes(String service) {
+    return excludedConfigurationTypes.containsKey(service) ?
+        excludedConfigurationTypes.get(service) :
+        Collections.emptySet();
+  }
+
+  /**
+   * Get config properties for the specified service and configuration type.
+   *
+   * @param service  service name
+   * @param type     configuration type
+   *
+   * @return map of property names to values for the specified service and configuration type
+   */
+  public Map<String, String> getConfigurationProperties(String service, String type) {
+    Map<String, String> configMap = new HashMap<>();
+    Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
+    if (configProperties != null) {
+      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+        configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
+      }
+    }
+    return configMap;
+  }
+
+  public Map<String, ConfigProperty> getConfigurationPropertiesWithMetadata(String service, String type) {
+    return serviceConfigurations.get(service).get(type);
+  }
+
+  /**
+   * Get all required config properties for the specified service.
+   *
+   * @param service  service name
+   *
+   * @return collection of all required properties for the given service
+   */
+  public Collection<ConfigProperty> getRequiredConfigurationProperties(String service) {
+    Collection<ConfigProperty> requiredConfigProperties = new HashSet<>();
+    Map<String, Map<String, ConfigProperty>> serviceProperties = requiredServiceConfigurations.get(service);
+    if (serviceProperties != null) {
+      for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : serviceProperties.entrySet()) {
+        requiredConfigProperties.addAll(typePropertiesEntry.getValue().values());
+      }
+    }
+    return requiredConfigProperties;
+  }
+
+  /**
+   * Get required config properties for the specified service which belong to the specified property type.
+   *
+   * @param service       service name
+   * @param propertyType  property type
+   *
+   * @return collection of required properties for the given service and property type
+   */
+  public Collection<ConfigProperty> getRequiredConfigurationProperties(String service, org.apache.ambari.server.state.PropertyInfo.PropertyType propertyType) {
+    Collection<ConfigProperty> matchingProperties = new HashSet<>();
+    Map<String, Map<String, ConfigProperty>> requiredProperties = requiredServiceConfigurations.get(service);
+    if (requiredProperties != null) {
+      for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : requiredProperties.entrySet()) {
+        for (ConfigProperty configProperty : typePropertiesEntry.getValue().values()) {
+          if (configProperty.getPropertyTypes().contains(propertyType)) {
+            matchingProperties.add(configProperty);
+          }
+        }
+
+      }
+    }
+    return matchingProperties;
+  }
+
+  public boolean isPasswordProperty(String service, String type, String propertyName) {
+    return (serviceConfigurations.containsKey(service) &&
+            serviceConfigurations.get(service).containsKey(type) &&
+            serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
+            serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
+                contains(org.apache.ambari.server.state.PropertyInfo.PropertyType.PASSWORD));
+  }
+
+  //todo
+  public Map<String, String> getStackConfigurationProperties(String type) {
+    Map<String, String> configMap = new HashMap<>();
+    Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
+    if (configProperties != null) {
+      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+        configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
+      }
+    }
+    return configMap;
+  }
+
+  public boolean isKerberosPrincipalNameProperty(String service, String type, String propertyName) {
+    return (serviceConfigurations.containsKey(service) &&
+            serviceConfigurations.get(service).containsKey(type) &&
+            serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
+            serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
+                contains(org.apache.ambari.server.state.PropertyInfo.PropertyType.KERBEROS_PRINCIPAL));
+  }
+  /**
+   * Get config attributes for the specified service and configuration type.
+   *
+   * @param service  service name
+   * @param type     configuration type
+   *
+   * @return  map of attribute names to map of property names to attribute values
+   *          for the specified service and configuration type
+   */
+  public Map<String, Map<String, String>> getConfigurationAttributes(String service, String type) {
+    Map<String, Map<String, String>> attributesMap = new HashMap<>();
+    Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
+    if (configProperties != null) {
+      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+        String propertyName = configProperty.getKey();
+        Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
+        if (propertyAttributes != null) {
+          for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
+            String attributeName = propertyAttribute.getKey();
+            String attributeValue = propertyAttribute.getValue();
+            if (attributeValue != null) {
+              Map<String, String> attributes = attributesMap.get(attributeName);
+              if (attributes == null) {
+                  attributes = new HashMap<>();
+                  attributesMap.put(attributeName, attributes);
+              }
+              attributes.put(propertyName, attributeValue);
+            }
+          }
+        }
+      }
+    }
+    return attributesMap;
+  }
+
+  //todo:
+  public Map<String, Map<String, String>> getStackConfigurationAttributes(String type) {
+    Map<String, Map<String, String>> attributesMap = new HashMap<>();
+    Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
+    if (configProperties != null) {
+      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+        String propertyName = configProperty.getKey();
+        Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
+        if (propertyAttributes != null) {
+          for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
+            String attributeName = propertyAttribute.getKey();
+            String attributeValue = propertyAttribute.getValue();
+            Map<String, String> attributes = attributesMap.get(attributeName);
+            if (attributes == null) {
+              attributes = new HashMap<>();
+              attributesMap.put(attributeName, attributes);
+            }
+            attributes.put(propertyName, attributeValue);
+          }
+        }
+      }
+    }
+    return attributesMap;
+  }
+
+  /**
+   * Get the service for the specified component.
+   *
+   * @param component  component name
+   *
+   * @return service name that contains tha specified component
+   */
+  public String getServiceForComponent(String component) {
+    return componentService.get(component);
+  }
+
+  /**
+   * Get the names of the services which contains the specified components.
+   *
+   * @param components collection of components
+   *
+   * @return collection of services which contain the specified components
+   */
+  public Collection<String> getServicesForComponents(Collection<String> components) {
+    Set<String> services = new HashSet<>();
+    for (String component : components) {
+      services.add(getServiceForComponent(component));
+    }
+
+    return services;
+  }
+
+  /**
+   * Obtain the service name which corresponds to the specified configuration.
+   *
+   * @param config  configuration type
+   *
+   * @return name of service which corresponds to the specified configuration type
+   */
+  public String getServiceForConfigType(String config) {
+    for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) {
+      Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue();
+      String serviceName = entry.getKey();
+      if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) {
+        return serviceName;
+      }
+    }
+    throw new IllegalArgumentException(
+        "Specified configuration type is not associated with any service: " + config);
+  }
+
+  /**
+   * Return the dependencies specified for the given component.
+   *
+   * @param component  component to get dependency information for
+   *
+   * @return collection of dependency information for the specified component
+   */
+  //todo: full dependency graph
+  public Collection<DependencyInfo> getDependenciesForComponent(String component) {
+    return dependencies.containsKey(component) ? dependencies.get(component) :
+        Collections.emptySet();
+  }
+
+  /**
+   * Get the service, if any, that a component dependency is conditional on.
+   *
+   * @param dependency  dependency to get conditional service for
+   *
+   * @return conditional service for provided component or null if dependency
+   *         is not conditional on a service
+   */
+  public String getConditionalServiceForDependency(DependencyInfo dependency) {
+    return dependencyConditionalServiceMap.get(dependency);
+  }
+
+  public String getExternalComponentConfig(String component) {
+    return dbDependencyInfo.get(component);
+  }
+
+  /**
+   * Obtain the required cardinality for the specified component.
+   */
+  public Cardinality getCardinality(String component) {
+    return new Cardinality(cardinalityRequirements.get(component));
+  }
+
+  /**
+   * Obtain auto-deploy information for the specified component.
+   */
+  public AutoDeployInfo getAutoDeployInfo(String component) {
+    return componentAutoDeployInfo.get(component);
+  }
+
+  public boolean isMasterComponent(String component) {
+    return masterComponents.contains(component);
+  }
+
+  public Configuration getConfiguration(Collection<String> services) {
+    Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>();
+    Map<String, Map<String, String>> properties = new HashMap<>();
+
+    for (String service : services) {
+      Collection<String> serviceConfigTypes = getConfigurationTypes(service);
+      for (String type : serviceConfigTypes) {
+        Map<String, String> typeProps = properties.get(type);
+        if (typeProps == null) {
+          typeProps = new HashMap<>();
+          properties.put(type, typeProps);
+        }
+        typeProps.putAll(getConfigurationProperties(service, type));
+
+        Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
+        if (!stackTypeAttributes.isEmpty()) {
+          if (! attributes.containsKey(type)) {
+            attributes.put(type, new HashMap<>());
+          }
+          Map<String, Map<String, String>> typeAttributes = attributes.get(type);
+          for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
+            String attributeName = attribute.getKey();
+            Map<String, String> attributeProps = typeAttributes.get(attributeName);
+            if (attributeProps == null) {
+              attributeProps = new HashMap<>();
+              typeAttributes.put(attributeName, attributeProps);
+            }
+            attributeProps.putAll(attribute.getValue());
+          }
+        }
+      }
+    }
+    return new Configuration(properties, attributes);
+  }
+
+  public Configuration getConfiguration() {
+    Map<String, Map<String, Map<String, String>>> stackAttributes = new HashMap<>();
+    Map<String, Map<String, String>> stackConfigs = new HashMap<>();
+
+    for (String service : getServices()) {
+      for (String type : getAllConfigurationTypes(service)) {
+        Map<String, String> typeProps = stackConfigs.get(type);
+        if (typeProps == null) {
+          typeProps = new HashMap<>();
+          stackConfigs.put(type, typeProps);
+        }
+        typeProps.putAll(getConfigurationProperties(service, type));
+
+        Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
+        if (!stackTypeAttributes.isEmpty()) {
+          if (! stackAttributes.containsKey(type)) {
+            stackAttributes.put(type, new HashMap<>());
+          }
+          Map<String, Map<String, String>> typeAttrs = stackAttributes.get(type);
+          for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
+            String attributeName = attribute.getKey();
+            Map<String, String> attributes = typeAttrs.get(attributeName);
+            if (attributes == null) {
+              attributes = new HashMap<>();
+              typeAttrs.put(attributeName, attributes);
+            }
+            attributes.putAll(attribute.getValue());
+          }
+        }
+      }
+    }
+    return new Configuration(stackConfigs, stackAttributes);
+  }
+
+  /**
+   * Parse components for the specified service from the stack definition.
+   *
+   * @param service  service name
+   *
+   * @throws AmbariException an exception occurred getting components from the stack definition
+   */
+  private void parseComponents(String service) throws AmbariException{
+    Collection<String> componentSet = new HashSet<>();
+
+    Set<StackServiceComponentResponse> components = controller.getStackComponents(
+        Collections.singleton(new StackServiceComponentRequest(name, version, service, null)));
+
+    // stack service components
+    for (StackServiceComponentResponse component : components) {
+      String componentName = component.getComponentName();
+      componentSet.add(componentName);
+      componentService.put(componentName, service);
+      String cardinality = component.getCardinality();
+      if (cardinality != null) {
+        cardinalityRequirements.put(componentName, cardinality);
+      }
+      AutoDeployInfo autoDeploy = component.getAutoDeploy();
+      if (autoDeploy != null) {
+        componentAutoDeployInfo.put(componentName, autoDeploy);
+      }
+
+      // populate component dependencies
+      //todo: remove usage of AmbariMetaInfo
+      Collection<DependencyInfo> componentDependencies = controller.getAmbariMetaInfo().getComponentDependencies(
+          name, version, service, componentName);
+
+      if (componentDependencies != null && ! componentDependencies.isEmpty()) {
+        dependencies.put(componentName, componentDependencies);
+      }
+      if (component.isMaster()) {
+        masterComponents.add(componentName);
+      }
+    }
+    serviceComponents.put(service, componentSet);
+  }
+
+  /**
+   * Parse configurations for the specified service from the stack definition.
+   *
+   * @param stackService  service to parse the stack configuration for
+   *
+   * @throws AmbariException an exception occurred getting configurations from the stack definition
+   */
+  private void parseConfigurations(StackServiceResponse stackService) throws AmbariException {
+    String service = stackService.getServiceName();
+    Map<String, Map<String, ConfigProperty>> mapServiceConfig = new HashMap<>();
+    Map<String, Map<String, ConfigProperty>> mapRequiredServiceConfig = new HashMap<>();
+
+
+    serviceConfigurations.put(service, mapServiceConfig);
+    requiredServiceConfigurations.put(service, mapRequiredServiceConfig);
+
+    Set<ReadOnlyConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
+        Collections.singleton(new StackConfigurationRequest(name, version, service, null)));
+    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+        Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
+    serviceConfigs.addAll(stackLevelConfigs);
+
+    // shouldn't have any required properties in stack level configuration
+    for (ReadOnlyConfigurationResponse config : serviceConfigs) {
+      ConfigProperty configProperty = new ConfigProperty(config);
+      String type = configProperty.getType();
+
+      Map<String, ConfigProperty> mapTypeConfig = mapServiceConfig.get(type);
+      if (mapTypeConfig == null) {
+        mapTypeConfig = new HashMap<>();
+        mapServiceConfig.put(type, mapTypeConfig);
+      }
+
+      mapTypeConfig.put(config.getPropertyName(), configProperty);
+      if (config.isRequired()) {
+        Map<String, ConfigProperty> requiredTypeConfig = mapRequiredServiceConfig.get(type);
+        if (requiredTypeConfig == null) {
+          requiredTypeConfig = new HashMap<>();
+          mapRequiredServiceConfig.put(type, requiredTypeConfig);
+        }
+        requiredTypeConfig.put(config.getPropertyName(), configProperty);
+      }
+    }
+
+    // So far we added only config types that have properties defined
+    // in stack service definition. Since there might be config types
+    // with no properties defined we need to add those separately
+    Set<String> configTypes = stackService.getConfigTypes().keySet();
+    for (String configType: configTypes) {
+      if (!mapServiceConfig.containsKey(configType)) {
+        mapServiceConfig.put(configType, Collections.emptyMap());
+      }
+    }
+  }
+
+  private void parseStackConfigurations () throws AmbariException {
+
+    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+        Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
+
+    for (ReadOnlyConfigurationResponse config : stackLevelConfigs) {
+      ConfigProperty configProperty = new ConfigProperty(config);
+      String type = configProperty.getType();
+
+      Map<String, ConfigProperty> mapTypeConfig = stackConfigurations.get(type);
+      if (mapTypeConfig == null) {
+        mapTypeConfig = new HashMap<>();
+        stackConfigurations.put(type, mapTypeConfig);
+      }
+
+      mapTypeConfig.put(config.getPropertyName(),
+          configProperty);
+    }
+  }
+
+  /**
+   * Obtain the excluded configuration types from the StackServiceResponse
+   *
+   * @param stackServiceResponse the response object associated with this stack service
+   */
+  private void parseExcludedConfigurations(StackServiceResponse stackServiceResponse) {
+    excludedConfigurationTypes.put(stackServiceResponse.getServiceName(), stackServiceResponse.getExcludedConfigTypes());
+  }
+
+  /**
+   * Register conditional dependencies.
+   */
+  //todo: This information should be specified in the stack definition.
+  void registerConditionalDependencies() {
+    dbDependencyInfo.put("MYSQL_SERVER", "global/hive_database");
+  }
+
+  /**
+   * Contains a configuration property's value and attributes.
+   */
+  public static class ConfigProperty {
+    private ValueAttributesInfo propertyValueAttributes = null;
+    private String name;
+    private String value;
+    private Map<String, String> attributes;
+    private Set<org.apache.ambari.server.state.PropertyInfo.PropertyType> propertyTypes;
+    private String type;
+    private Set<PropertyDependencyInfo> dependsOnProperties =
+      Collections.emptySet();
+
+    public ConfigProperty(ReadOnlyConfigurationResponse config) {
+      this.name = config.getPropertyName();
+      this.value = config.getPropertyValue();
+      this.attributes = config.getPropertyAttributes();
+      this.propertyTypes = config.getPropertyType();
+      this.type = normalizeType(config.getType());
+      this.dependsOnProperties = config.getDependsOnProperties();
+      this.propertyValueAttributes = config.getPropertyValueAttributes();
+    }
+
+    public ConfigProperty(String type, String name, String value) {
+      this.type = type;
+      this.name = name;
+      this.value = value;
+    }
+
+    public String getName() {
+      return name;
+    }
+
+    public String getValue() {
+      return value;
+    }
+
+    public void setValue(String value) {
+      this.value = value;
+    }
+
+    public String getType() {
+      return type;
+    }
+
+    public Set<org.apache.ambari.server.state.PropertyInfo.PropertyType> getPropertyTypes() {
+      return propertyTypes;
+    }
+
+    public void setPropertyTypes(Set<PropertyInfo.PropertyType> propertyTypes) {
+      this.propertyTypes = propertyTypes;
+    }
+
+    public Map<String, String> getAttributes() {
+      return attributes;
+    }
+
+    public void setAttributes(Map<String, String> attributes) {
+      this.attributes = attributes;
+    }
+
+    Set<PropertyDependencyInfo> getDependsOnProperties() {
+      return this.dependsOnProperties;
+    }
+
+    private String normalizeType(String type) {
+      //strip .xml from type
+      if (type.endsWith(".xml")) {
+        type = type.substring(0, type.length() - 4);
+      }
+      return type;
+    }
+
+    public ValueAttributesInfo getPropertyValueAttributes() {
+      return propertyValueAttributes;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
index 8b7cb67..37725b1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
@@ -17,15 +17,15 @@
  */
 package org.apache.ambari.server.controller.internal;
 
-import static org.apache.commons.lang.StringUtils.isBlank;
+import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.validators.UnitValidatedProperty;
 
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Optional;
 
-import org.apache.ambari.server.topology.ClusterTopology;
-import org.apache.ambari.server.topology.validators.UnitValidatedProperty;
+import static org.apache.commons.lang.StringUtils.isBlank;
 
 /**
  * I append the stack defined unit to the original property value.
@@ -48,8 +48,9 @@ public class UnitUpdater implements BlueprintConfigurationProcessor.PropertyUpda
   public String updateForClusterCreate(String propertyName,
                                        String origValue,
                                        Map<String, Map<String, String>> properties,
-                                       ClusterTopology topology) {
-      PropertyUnit stackUnit = PropertyUnit.of(topology.getBlueprint().getStack(), serviceName, configType, propertyName);
+                                       ClusterTopology topology,
+                                       ConfigurationContext configurationContext) {
+      PropertyUnit stackUnit = PropertyUnit.of(configurationContext.getStack(), serviceName, configType, propertyName);
       PropertyValue value = PropertyValue.of(propertyName, origValue);
       if (value.hasUnit(stackUnit)) {
         return value.toString();
@@ -61,7 +62,8 @@ public class UnitUpdater implements BlueprintConfigurationProcessor.PropertyUpda
   }
 
   @Override
-  public Collection<String> getRequiredHostGroups(String propertyName, String origValue, Map<String, Map<String, String>> properties, ClusterTopology topology) {
+  public Collection<String> getRequiredHostGroups(String propertyName, String origValue, Map<String, Map<String, String>> properties,
+                                                  ClusterTopology topology, ConfigurationContext configurationContext) {
     return Collections.emptySet();
   }
 
@@ -69,18 +71,18 @@ public class UnitUpdater implements BlueprintConfigurationProcessor.PropertyUpda
     private static final String DEFAULT_UNIT = "m";
     private final String unit;
 
-    public static PropertyUnit of(Stack stack, UnitValidatedProperty property) {
+    public static PropertyUnit of(StackV2 stack, UnitValidatedProperty property) {
       return PropertyUnit.of(stack, property.getServiceName(), property.getConfigType(), property.getPropertyName());
     }
 
-    public static PropertyUnit of(Stack stack, String serviceName, String configType, String propertyName) {
+    public static PropertyUnit of(StackV2 stack, String serviceName, String configType, String propertyName) {
       return new PropertyUnit(
         stackUnit(stack, serviceName, configType, propertyName)
           .map(PropertyUnit::toJvmUnit)
           .orElse(DEFAULT_UNIT));
     }
 
-    private static Optional<String> stackUnit(Stack stack, String serviceName, String configType, String propertyName) {
+    private static Optional<String> stackUnit(StackV2 stack, String serviceName, String configType, String propertyName) {
       try {
         return Optional.ofNullable(
           stack.getConfigurationPropertiesWithMetadata(serviceName, configType)

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
index 5af2a86..3a65662 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
@@ -18,82 +18,36 @@
 
 package org.apache.ambari.server.topology;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Lock;
-
-import javax.annotation.Nullable;
-import javax.inject.Inject;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.ClusterNotFoundException;
-import org.apache.ambari.server.DuplicateResourceException;
-import org.apache.ambari.server.Role;
-import org.apache.ambari.server.RoleCommand;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.Striped;
+import com.google.inject.Provider;
+import org.apache.ambari.server.*;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleCommandFactory;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
-import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.AmbariServer;
-import org.apache.ambari.server.controller.ClusterRequest;
-import org.apache.ambari.server.controller.ConfigGroupRequest;
-import org.apache.ambari.server.controller.ConfigurationRequest;
-import org.apache.ambari.server.controller.RequestStatusResponse;
-import org.apache.ambari.server.controller.ServiceComponentHostRequest;
-import org.apache.ambari.server.controller.ServiceComponentRequest;
-import org.apache.ambari.server.controller.ServiceRequest;
-import org.apache.ambari.server.controller.internal.AbstractResourceProvider;
-import org.apache.ambari.server.controller.internal.ComponentResourceProvider;
-import org.apache.ambari.server.controller.internal.ConfigGroupResourceProvider;
-import org.apache.ambari.server.controller.internal.HostComponentResourceProvider;
-import org.apache.ambari.server.controller.internal.HostResourceProvider;
-import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
-import org.apache.ambari.server.controller.internal.RequestImpl;
-import org.apache.ambari.server.controller.internal.ServiceResourceProvider;
-import org.apache.ambari.server.controller.internal.Stack;
-import org.apache.ambari.server.controller.internal.VersionDefinitionResourceProvider;
+import org.apache.ambari.server.controller.*;
+import org.apache.ambari.server.controller.internal.*;
 import org.apache.ambari.server.controller.predicate.EqualsPredicate;
 import org.apache.ambari.server.controller.spi.ClusterController;
 import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.RequestStatus;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.security.authorization.AuthorizationException;
-import org.apache.ambari.server.state.Cluster;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.Config;
-import org.apache.ambari.server.state.ConfigFactory;
-import org.apache.ambari.server.state.ConfigHelper;
-import org.apache.ambari.server.state.DesiredConfig;
-import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.state.RepositoryType;
-import org.apache.ambari.server.state.SecurityType;
-import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.*;
 import org.apache.ambari.server.state.configgroup.ConfigGroup;
 import org.apache.ambari.server.utils.RetryHelper;
-import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Function;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.Striped;
-import com.google.inject.Provider;
+import javax.annotation.Nullable;
+import javax.inject.Inject;
+import java.util.*;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Lock;
 
 
 /**
@@ -130,6 +84,7 @@ public class AmbariContext {
 
   private static HostRoleCommandFactory hostRoleCommandFactory;
   private static HostResourceProvider hostResourceProvider;
+  private static ServiceGroupResourceProvider serviceGroupResourceProvider;
   private static ServiceResourceProvider serviceResourceProvider;
   private static ComponentResourceProvider componentResourceProvider;
   private static HostComponentResourceProvider hostComponentResourceProvider;
@@ -200,95 +155,12 @@ public class AmbariContext {
     return getController().getActionManager().getTasks(ids);
   }
 
-  public void createAmbariResources(ClusterTopology topology, String clusterName, SecurityType securityType,
-                                    String repoVersionString, Long repoVersionId) {
-    Stack stack = topology.getBlueprint().getStack();
-    StackId stackId = new StackId(stack.getName(), stack.getVersion());
-
-    RepositoryVersionEntity repoVersion = null;
-    if (StringUtils.isEmpty(repoVersionString) && null == repoVersionId) {
-      List<RepositoryVersionEntity> stackRepoVersions = repositoryVersionDAO.findByStack(stackId);
-
-      if (stackRepoVersions.isEmpty()) {
-        // !!! no repos, try to get the version for the stack
-        VersionDefinitionResourceProvider vdfProvider = getVersionDefinitionResourceProvider();
-
-        Map<String, Object> properties = new HashMap<>();
-        properties.put(VersionDefinitionResourceProvider.VERSION_DEF_AVAILABLE_DEFINITION, stackId.toString());
-
-        Request request = new RequestImpl(Collections.<String>emptySet(),
-            Collections.singleton(properties), Collections.<String, String>emptyMap(), null);
-
-        Long defaultRepoVersionId = null;
-
-        try {
-          RequestStatus requestStatus = vdfProvider.createResources(request);
-          if (!requestStatus.getAssociatedResources().isEmpty()) {
-            Resource resource = requestStatus.getAssociatedResources().iterator().next();
-            defaultRepoVersionId = (Long) resource.getPropertyValue(VersionDefinitionResourceProvider.VERSION_DEF_ID);
-          }
-        } catch (Exception e) {
-          throw new IllegalArgumentException(String.format(
-              "Failed to create a default repository version definition for stack %s. "
-              + "This typically is a result of not loading the stack correctly or being able "
-              + "to load information about released versions.  Create a repository version "
-              + " and try again.", stackId), e);
-        }
-
-        repoVersion = repositoryVersionDAO.findByPK(defaultRepoVersionId);
-        // !!! better not!
-        if (null == repoVersion) {
-          throw new IllegalArgumentException(String.format(
-              "Failed to load the default repository version definition for stack %s. "
-              + "Check for a valid repository version and try again.", stackId));
-        }
-
-      } else if (stackRepoVersions.size() > 1) {
-
-        Function<RepositoryVersionEntity, String> function = new Function<RepositoryVersionEntity, String>() {
-          @Override
-          public String apply(RepositoryVersionEntity input) {
-            return input.getVersion();
-          }
-        };
-
-        Collection<String> versions = Collections2.transform(stackRepoVersions, function);
-
-        throw new IllegalArgumentException(String.format("Several repositories were found for %s:  %s.  Specify the version"
-            + " with '%s'", stackId, StringUtils.join(versions, ", "), ProvisionClusterRequest.REPO_VERSION_PROPERTY));
-      } else {
-        repoVersion = stackRepoVersions.get(0);
-        LOG.warn("Cluster is being provisioned using the single matching repository version {}", repoVersion.getVersion());
-      }
-    } else if (null != repoVersionId){
-      repoVersion = repositoryVersionDAO.findByPK(repoVersionId);
-
-      if (null == repoVersion) {
-        throw new IllegalArgumentException(String.format(
-          "Could not identify repository version with repository version id %s for installing services. "
-            + "Specify a valid repository version id with '%s'",
-          repoVersionId, ProvisionClusterRequest.REPO_VERSION_ID_PROPERTY));
-      }
-    } else {
-      repoVersion = repositoryVersionDAO.findByStackAndVersion(stackId, repoVersionString);
-
-      if (null == repoVersion) {
-        throw new IllegalArgumentException(String.format(
-          "Could not identify repository version with stack %s and version %s for installing services. "
-            + "Specify a valid version with '%s'",
-          stackId, repoVersionString, ProvisionClusterRequest.REPO_VERSION_PROPERTY));
-      }
-    }
+  public void createAmbariResources(ClusterTopology topology, String clusterName, SecurityType securityType) {
 
-    // only use a STANDARD repo when creating a new cluster
-    if (repoVersion.getType() != RepositoryType.STANDARD) {
-      throw new IllegalArgumentException(String.format(
-          "Unable to create a cluster using the following repository since it is not a STANDARD type: %s",
-          repoVersion));
-    }
+    StackV2 stack = topology.getBlueprint().getStacks().iterator().next();
 
     createAmbariClusterResource(clusterName, stack.getName(), stack.getVersion(), securityType);
-    createAmbariServiceAndComponentResources(topology, clusterName, stackId, repoVersion.getId());
+    createAmbariServiceAndComponentResources(topology, clusterName);
   }
 
   public void createAmbariClusterResource(String clusterName, String stackName, String stackVersion, SecurityType securityType) {
@@ -314,34 +186,56 @@ public class AmbariContext {
     }
   }
 
-  public void createAmbariServiceAndComponentResources(ClusterTopology topology, String clusterName,
-      StackId stackId, Long repositoryVersionId) {
-    Collection<String> services = topology.getBlueprint().getServices();
+  public void createAmbariServiceAndComponentResources(ClusterTopology topology, String clusterName) {
 
-    try {
-      Cluster cluster = getController().getClusters().getCluster(clusterName);
-      services.removeAll(cluster.getServices().keySet());
-    } catch (AmbariException e) {
-      throw new RuntimeException("Failed to persist service and component resources: " + e, e);
-    }
+    Collection<ServiceGroup> serviceGroups = topology.getBlueprint().getServiceGroups();
+    Set<ServiceGroupRequest> serviceGroupRequests = new HashSet<>();
     Set<ServiceRequest> serviceRequests = new HashSet<>();
     Set<ServiceComponentRequest> componentRequests = new HashSet<>();
-    for (String service : services) {
-      String credentialStoreEnabled = topology.getBlueprint().getCredentialStoreEnabled(service);
-      serviceRequests.add(new ServiceRequest(clusterName, null, service, service,
-              repositoryVersionId, null, credentialStoreEnabled, null));
-
-      for (String component : topology.getBlueprint().getComponents(service)) {
-        String recoveryEnabled = topology.getBlueprint().getRecoveryEnabled(service, component);
-        componentRequests.add(new ServiceComponentRequest(clusterName, service, component, null, recoveryEnabled));
+
+    for (ServiceGroup serviceGroup : serviceGroups) {
+      serviceGroupRequests.add(new ServiceGroupRequest(clusterName, serviceGroup.getName()));
+
+      for (Service service : serviceGroup.getServices()) {
+        String credentialStoreEnabled = topology.getBlueprint().getCredentialStoreEnabled(service.getType());
+
+        StackV2 stack = service.getStack();
+        StackId stackId = new StackId(stack.getName(), stack.getVersion());
+        RepositoryVersionEntity repoVersion = repositoryVersionDAO.findByStackAndVersion(stackId, stack.getRepoVersion());
+
+        if (null == repoVersion) {
+          throw new IllegalArgumentException(String.format(
+            "Could not identify repository version with stack %s and version %s for installing services. "
+              + "Specify a valid version with '%s'",
+            stackId, stack.getRepoVersion(), ProvisionClusterRequest.REPO_VERSION_PROPERTY));
+        }
+
+        // only use a STANDARD repo when creating a new cluster
+        if (repoVersion.getType() != RepositoryType.STANDARD) {
+          throw new IllegalArgumentException(String.format(
+            "Unable to create a cluster using the following repository since it is not a STANDARD type: %s",
+            repoVersion));
+        }
+
+        serviceRequests.add(new ServiceRequest(clusterName, serviceGroup.getName(), service.getType(), service.getName(),
+          repoVersion.getId(), null, credentialStoreEnabled, null));
+
+        for (ComponentV2 component : topology.getBlueprint().getComponents(service)) {
+          String recoveryEnabled = topology.getBlueprint().getRecoveryEnabled(component);
+          componentRequests.add(new ServiceComponentRequest(clusterName, serviceGroup.getName(), service.getName(),
+            component.getName(), null, recoveryEnabled));
+        }
       }
+
     }
     try {
+      getServiceGroupResourceProvider().createServiceGroups(serviceGroupRequests);
       getServiceResourceProvider().createServices(serviceRequests);
       getComponentResourceProvider().createComponents(componentRequests);
     } catch (AmbariException | AuthorizationException e) {
       throw new RuntimeException("Failed to persist service and component resources: " + e, e);
     }
+
     // set all services state to INSTALLED->STARTED
     // this is required so the user can start failed services at the service level
     Map<String, Object> installProps = new HashMap<>();
@@ -351,20 +245,20 @@ public class AmbariContext {
     startProps.put(ServiceResourceProvider.SERVICE_SERVICE_STATE_PROPERTY_ID, "STARTED");
     startProps.put(ServiceResourceProvider.SERVICE_CLUSTER_NAME_PROPERTY_ID, clusterName);
     Predicate predicate = new EqualsPredicate<>(
-      ServiceResourceProvider.SERVICE_CLUSTER_NAME_PROPERTY_ID, clusterName);
+    ServiceResourceProvider.SERVICE_CLUSTER_NAME_PROPERTY_ID, clusterName);
     try {
       getServiceResourceProvider().updateResources(
-          new RequestImpl(null, Collections.singleton(installProps), null, null), predicate);
+      new RequestImpl(null, Collections.singleton(installProps), null, null), predicate);
 
       getServiceResourceProvider().updateResources(
-        new RequestImpl(null, Collections.singleton(startProps), null, null), predicate);
+      new RequestImpl(null, Collections.singleton(startProps), null, null), predicate);
     } catch (Exception e) {
       // just log as this won't prevent cluster from being provisioned correctly
       LOG.error("Unable to update state of services during cluster provision: " + e, e);
     }
   }
 
-  public void createAmbariHostResources(long  clusterId, String hostName, Map<String, Collection<String>> components)  {
+  public void createAmbariHostResources(long  clusterId, String hostName, Map<Service, Collection<ComponentV2>> components)  {
     Host host;
     try {
       host = getController().getClusters().getHost(hostName);
@@ -398,13 +292,14 @@ public class AmbariContext {
 
     final Set<ServiceComponentHostRequest> requests = new HashSet<>();
 
-    for (Map.Entry<String, Collection<String>> entry : components.entrySet()) {
-      String service = entry.getKey();
-      for (String component : entry.getValue()) {
+    for (Map.Entry<Service, Collection<ComponentV2>> entry : components.entrySet()) {
+      Service service = entry.getKey();
+      for (ComponentV2 component : entry.getValue()) {
         //todo: handle this in a generic manner.  These checks are all over the code
         try {
-          if (cluster.getService(service) != null && !component.equals("AMBARI_SERVER")) {
-            requests.add(new ServiceComponentHostRequest(clusterName, null, service, component, hostName, null));
+          if (cluster.getService(service.getName()) != null && !component.getType().equals("AMBARI_SERVER")) {
+            requests.add(new ServiceComponentHostRequest(clusterName, service.getServiceGroup().getName(),
+              service.getName(), component.getName(), hostName, null));
           }
         } catch(AmbariException se) {
           LOG.warn("Service already deleted from cluster: {}", service);
@@ -718,34 +613,32 @@ public class AmbariContext {
    * and the hosts associated with the host group are assigned to the config group.
    */
   private void createConfigGroupsAndRegisterHost(ClusterTopology topology, String groupName) throws AmbariException {
-    Map<String, Map<String, Config>> groupConfigs = new HashMap<>();
-    Stack stack = topology.getBlueprint().getStack();
-
-    // get the host-group config with cluster creation template overrides
-    Configuration topologyHostGroupConfig = topology.
-        getHostGroupInfo().get(groupName).getConfiguration();
-
-    // only get user provided configuration for host group which includes only CCT/HG and BP/HG properties
-    Map<String, Map<String, String>> userProvidedGroupProperties =
-        topologyHostGroupConfig.getFullProperties(1);
-
-    // iterate over topo host group configs which were defined in
-    for (Map.Entry<String, Map<String, String>> entry : userProvidedGroupProperties.entrySet()) {
-      String type = entry.getKey();
-      String service = stack.getServiceForConfigType(type);
-      Config config = configFactory.createReadOnly(type, groupName, entry.getValue(), null);
-      //todo: attributes
-      Map<String, Config> serviceConfigs = groupConfigs.get(service);
-      if (serviceConfigs == null) {
-        serviceConfigs = new HashMap<>();
-        groupConfigs.put(service, serviceConfigs);
+
+    Map<Service, Map<String, Config>> groupConfigs = new HashMap<>();
+
+
+    // only get user provided configuration for host group per service which includes only CCT/HG and BP/HG properties
+    Collection<Service> serviceConfigurations = topology.getHostGroupInfo().get(groupName).getServiceConfigs();
+    serviceConfigurations.forEach(service -> {
+      Map<String, Map<String, String>> userProvidedGroupProperties = service.getConfiguration().getProperties();
+
+      // iterate over topo host group configs which were defined in
+      for (Map.Entry<String, Map<String, String>> entry : userProvidedGroupProperties.entrySet()) {
+        String type = entry.getKey();
+        Config config = configFactory.createReadOnly(type, groupName, entry.getValue(), null);
+        //todo: attributes
+        Map<String, Config> serviceConfigs = groupConfigs.get(service);
+        if (serviceConfigs == null) {
+          serviceConfigs = new HashMap<>();
+          groupConfigs.put(service, serviceConfigs);
+        }
+        serviceConfigs.put(type, config);
       }
-      serviceConfigs.put(type, config);
-    }
+    });
 
     String bpName = topology.getBlueprint().getName();
-    for (Map.Entry<String, Map<String, Config>> entry : groupConfigs.entrySet()) {
-      String service = entry.getKey();
+    for (Map.Entry<Service, Map<String, Config>> entry : groupConfigs.entrySet()) {
+      Service service = entry.getKey();
       Map<String, Config> serviceConfigs = entry.getValue();
       String absoluteGroupName = getConfigurationGroupName(bpName, groupName);
       Collection<String> groupHosts;
@@ -771,7 +664,7 @@ public class AmbariContext {
       });
 
       ConfigGroupRequest request = new ConfigGroupRequest(null, clusterName,
-        absoluteGroupName, service, service, "Host Group Configuration",
+        absoluteGroupName, service.getName(), service.getName(), "Host Group Configuration",
         Sets.newHashSet(filteredGroupHosts), serviceConfigs);
 
       // get the config group provider and create config group resource
@@ -826,6 +719,14 @@ public class AmbariContext {
     return hostComponentResourceProvider;
   }
 
+  private synchronized ServiceGroupResourceProvider getServiceGroupResourceProvider() {
+    if (serviceGroupResourceProvider == null) {
+      serviceGroupResourceProvider = (ServiceGroupResourceProvider) ClusterControllerHelper.
+      getClusterController().ensureResourceProvider(Resource.Type.ServiceGroup);
+    }
+    return serviceGroupResourceProvider;
+  }
+
   private synchronized ServiceResourceProvider getServiceResourceProvider() {
     if (serviceResourceProvider == null) {
       serviceResourceProvider = (ServiceResourceProvider) ClusterControllerHelper.

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
index 404068d..c8860f6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
@@ -19,13 +19,7 @@
 
 package org.apache.ambari.server.topology;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.inject.Inject;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ObjectNotFoundException;
 import org.apache.ambari.server.controller.AmbariManagementController;
@@ -37,7 +31,7 @@ import org.apache.ambari.server.orm.dao.BlueprintDAO;
 import org.apache.ambari.server.orm.entities.BlueprintEntity;
 import org.apache.ambari.server.stack.NoSuchStackException;
 
-import com.google.inject.Inject;
+import java.util.*;
 
 /**
  * Create a Blueprint instance.
@@ -82,10 +76,10 @@ public class BlueprintFactory {
     this.stackFactory = stackFactory;
   }
 
-  public Blueprint getBlueprint(String blueprintName) throws NoSuchStackException {
+  public BlueprintV2 getBlueprint(String blueprintName) throws NoSuchStackException {
     BlueprintEntity entity = blueprintDAO.findByName(blueprintName);
     //todo: just return null?
-    return entity == null ? null : new BlueprintImpl(entity);
+    return entity == null ? null : new BlueprintImplV2(entity);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
index 9bde795..79456e5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
@@ -19,18 +19,20 @@
 
 package org.apache.ambari.server.topology;
 
+import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.orm.entities.BlueprintEntity;
+
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-
-import org.apache.ambari.server.controller.StackV2;
-import org.apache.ambari.server.orm.entities.BlueprintEntity;
+import java.util.stream.Collectors;
 
 /**
  * Blueprint implementation.
  */
 public class BlueprintImplV2 implements BlueprintV2 {
-
+  public BlueprintImplV2(BlueprintEntity e) {
+  }
 
   @Override
   public String getName() {
@@ -63,11 +65,38 @@ public class BlueprintImplV2 implements BlueprintV2 {
   }
 
   @Override
+  public Collection<String> getAllServiceTypes() {
+    return null;
+  }
+
+  @Override
+  public Collection<Service> getServicesByType(String serviceType) {
+    return getAllServices().stream().filter(
+      service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
+  }
+
+  @Override
+  public Collection<Service> getServicesFromServiceGroup(ServiceGroup serviceGroup, String serviceType) {
+    if (serviceType == null) {
+      return serviceGroup.getServices();
+    } else {
+      return serviceGroup.getServices().stream().filter(
+        service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
+    }
+  }
+
+  @Override
   public Collection<ComponentV2> getComponents(Service service) {
     return null;
   }
 
   @Override
+  public Collection<ComponentV2> getComponentsByType(Service service, String componentType) {
+    return getComponents(service).stream().filter(
+      compnoent -> compnoent.getType().equalsIgnoreCase(componentType)).collect(Collectors.toList());
+  }
+
+  @Override
   public Collection<HostGroupV2> getHostGroupsForService(Service service) {
     return null;
   }
@@ -78,6 +107,7 @@ public class BlueprintImplV2 implements BlueprintV2 {
   }
 
   @Override
+  @Deprecated
   public Configuration getConfiguration() {
     return null;
   }
@@ -88,7 +118,7 @@ public class BlueprintImplV2 implements BlueprintV2 {
   }
 
   @Override
-  public String getRecoveryEnabled(String serviceName, String componentName) {
+  public String getRecoveryEnabled(ComponentV2 component) {
     return null;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
index 1fea966..3c71e41 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
@@ -18,12 +18,13 @@
 
 package org.apache.ambari.server.topology;
 
+import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.orm.entities.BlueprintEntity;
+
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.ambari.server.controller.StackV2;
-import org.apache.ambari.server.orm.entities.BlueprintEntity;
 
 /**
  * Blueprint representation.
@@ -69,6 +70,29 @@ public interface BlueprintV2 {
    */
   Collection<Service> getAllServices();
 
+
+  /**
+   * Get all of the service types represented in the blueprint.
+   *
+   * @return collection of all represented service types
+   */
+  Collection<String> getAllServiceTypes();
+
+  /**
+   * Get all of the services represented in the blueprint with a given type.
+   *
+   * @return collection of all represented services represented in the blueprint with a given type.
+   */
+  Collection<Service> getServicesByType(String serviceType);
+
+  /**
+   * Get services by type from a service group.
+   * @param serviceGroup
+   * @param serviceType
+   * @return
+   */
+  Collection<Service> getServicesFromServiceGroup(ServiceGroup serviceGroup, String serviceType);
+
   /**
    * Get the components that are included in the blueprint for the specified service.
    *
@@ -78,6 +102,14 @@ public interface BlueprintV2 {
    */
   Collection<ComponentV2> getComponents(Service service);
 
+  /**
+   * Get components by type from a service.
+   * @param service
+   * @param componentType
+   * @return
+   */
+  Collection<ComponentV2> getComponentsByType(Service service, String componentType);
+
 
   /**
    * Get the host groups which contain components for the specified service.
@@ -106,6 +138,7 @@ public interface BlueprintV2 {
    *
    * @return blueprint cluster scoped configuration
    */
+  @Deprecated
   Configuration getConfiguration();
 
   /**
@@ -121,12 +154,11 @@ public interface BlueprintV2 {
   /**
    * Get whether a component is enabled for auto start.
    *
-   * @param serviceName - Service name.
-   * @param componentName - Component name.
+   * @param component - Component.
    *
    * @return null if value is not specified; true or false if specified.
    */
-  String getRecoveryEnabled(String serviceName, String componentName);
+  String getRecoveryEnabled(ComponentV2 component);
 
   /**
    * Get whether a service is enabled for credential store use.

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
index 1a43b85..0244d7b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
@@ -18,14 +18,6 @@
 
 package org.apache.ambari.server.topology;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.ambari.server.controller.internal.Stack;
 import org.apache.ambari.server.state.AutoDeployInfo;
 import org.apache.ambari.server.state.DependencyConditionInfo;
@@ -35,6 +27,11 @@ import org.apache.ambari.server.utils.VersionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
 /**
  * Default blueprint validator.
  */
@@ -85,6 +82,8 @@ public class BlueprintValidatorImpl implements BlueprintValidator {
 
   @Override
   public void validateRequiredProperties() throws InvalidTopologyException {
+    //TODO
+   // ConfigurationContext configurationContext = new ConfigurationContext(blueprint.getStacks().iterator().next(), blueprint.getConfiguration());
 
     // we don't want to include default stack properties so we can't just use hostGroup full properties
     Map<String, Map<String, String>> clusterConfigurations = blueprint.getConfiguration().getProperties();
@@ -131,31 +130,31 @@ public class BlueprintValidatorImpl implements BlueprintValidator {
               " using existing db!");
           }
         }
-        if (ClusterTopologyImpl.isNameNodeHAEnabled(clusterConfigurations) && component.equals("NAMENODE")) {
-            Map<String, String> hadoopEnvConfig = clusterConfigurations.get("hadoop-env");
-            if(hadoopEnvConfig != null && !hadoopEnvConfig.isEmpty() && hadoopEnvConfig.containsKey("dfs_ha_initial_namenode_active") && hadoopEnvConfig.containsKey("dfs_ha_initial_namenode_standby")) {
-              ArrayList<HostGroup> hostGroupsForComponent = new ArrayList<>(blueprint.getHostGroupsForComponent(component));
-              Set<String> givenHostGroups = new HashSet<>();
-              givenHostGroups.add(hadoopEnvConfig.get("dfs_ha_initial_namenode_active"));
-              givenHostGroups.add(hadoopEnvConfig.get("dfs_ha_initial_namenode_standby"));
-              if(givenHostGroups.size() != hostGroupsForComponent.size()) {
-                 throw new IllegalArgumentException("NAMENODE HA host groups mapped incorrectly for properties 'dfs_ha_initial_namenode_active' and 'dfs_ha_initial_namenode_standby'. Expected Host groups are :" + hostGroupsForComponent);
-              }
-              if(HostGroup.HOSTGROUP_REGEX.matcher(hadoopEnvConfig.get("dfs_ha_initial_namenode_active")).matches() && HostGroup.HOSTGROUP_REGEX.matcher(hadoopEnvConfig.get("dfs_ha_initial_namenode_standby")).matches()){
-                for (HostGroup hostGroupForComponent : hostGroupsForComponent) {
-                   Iterator<String> itr = givenHostGroups.iterator();
-                   while(itr.hasNext()){
-                      if(itr.next().contains(hostGroupForComponent.getName())){
-                         itr.remove();
-                      }
-                   }
-                 }
-                 if(!givenHostGroups.isEmpty()){
-                    throw new IllegalArgumentException("NAMENODE HA host groups mapped incorrectly for properties 'dfs_ha_initial_namenode_active' and 'dfs_ha_initial_namenode_standby'. Expected Host groups are :" + hostGroupsForComponent);
-                 }
-                }
-              }
-          }
+//        if (configurationContext.isNameNodeHAEnabled(clusterConfigurations) && component.equals("NAMENODE")) {
+//            Map<String, String> hadoopEnvConfig = clusterConfigurations.get("hadoop-env");
+//            if(hadoopEnvConfig != null && !hadoopEnvConfig.isEmpty() && hadoopEnvConfig.containsKey("dfs_ha_initial_namenode_active") && hadoopEnvConfig.containsKey("dfs_ha_initial_namenode_standby")) {
+//              ArrayList<HostGroup> hostGroupsForComponent = new ArrayList<>(blueprint.getHostGroupsForComponent(component));
+//              Set<String> givenHostGroups = new HashSet<>();
+//              givenHostGroups.add(hadoopEnvConfig.get("dfs_ha_initial_namenode_active"));
+//              givenHostGroups.add(hadoopEnvConfig.get("dfs_ha_initial_namenode_standby"));
+//              if(givenHostGroups.size() != hostGroupsForComponent.size()) {
+//                 throw new IllegalArgumentException("NAMENODE HA host groups mapped incorrectly for properties 'dfs_ha_initial_namenode_active' and 'dfs_ha_initial_namenode_standby'. Expected Host groups are :" + hostGroupsForComponent);
+//              }
+//              if(HostGroup.HOSTGROUP_REGEX.matcher(hadoopEnvConfig.get("dfs_ha_initial_namenode_active")).matches() && HostGroup.HOSTGROUP_REGEX.matcher(hadoopEnvConfig.get("dfs_ha_initial_namenode_standby")).matches()){
+//                for (HostGroup hostGroupForComponent : hostGroupsForComponent) {
+//                   Iterator<String> itr = givenHostGroups.iterator();
+//                   while(itr.hasNext()){
+//                      if(itr.next().contains(hostGroupForComponent.getName())){
+//                         itr.remove();
+//                      }
+//                   }
+//                 }
+//                 if(!givenHostGroups.isEmpty()){
+//                    throw new IllegalArgumentException("NAMENODE HA host groups mapped incorrectly for properties 'dfs_ha_initial_namenode_active' and 'dfs_ha_initial_namenode_standby'. Expected Host groups are :" + hostGroupsForComponent);
+//                 }
+//                }
+//              }
+//        }
 
         if (component.equals("HIVE_METASTORE")) {
           Map<String, String> hiveEnvConfig = clusterConfigurations.get("hive-env");
@@ -293,12 +292,13 @@ public class BlueprintValidatorImpl implements BlueprintValidator {
     Map<String, Map<String, String>> configProperties = blueprint.getConfiguration().getProperties();
     Collection<String> cardinalityFailures = new HashSet<>();
     //todo: don't hard code this HA logic here
-    if (ClusterTopologyImpl.isNameNodeHAEnabled(configProperties) &&
-        (component.equals("SECONDARY_NAMENODE"))) {
-      // override the cardinality for this component in an HA deployment,
-      // since the SECONDARY_NAMENODE should not be started in this scenario
-      cardinality = new Cardinality("0");
-    }
+//TODO
+//    if (ClusterTopologyImpl.isNameNodeHAEnabled(configProperties) &&
+//        (component.equals("SECONDARY_NAMENODE"))) {
+//      // override the cardinality for this component in an HA deployment,
+//      // since the SECONDARY_NAMENODE should not be started in this scenario
+//      cardinality = new Cardinality("0");
+//    }
 
     int actualCount = blueprint.getHostGroupsForComponent(component).size();
     if (! cardinality.isValidCount(actualCount)) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
index 7bd377f..48f8fec 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
@@ -18,25 +18,11 @@
 
 package org.apache.ambari.server.topology;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorBlueprintProcessor;
 import org.apache.ambari.server.controller.ClusterRequest;
 import org.apache.ambari.server.controller.ConfigurationRequest;
-import org.apache.ambari.server.controller.internal.BlueprintConfigurationProcessor;
-import org.apache.ambari.server.controller.internal.ClusterResourceProvider;
-import org.apache.ambari.server.controller.internal.ConfigurationTopologyException;
-import org.apache.ambari.server.controller.internal.Stack;
+import org.apache.ambari.server.controller.internal.*;
 import org.apache.ambari.server.serveraction.kerberos.KerberosInvalidConfigurationException;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.SecurityType;
@@ -46,6 +32,10 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 /**
  * Responsible for cluster configuration.
  */
@@ -63,7 +53,6 @@ public class ClusterConfigurationRequest {
   private ClusterTopology clusterTopology;
   private BlueprintConfigurationProcessor configurationProcessor;
   private StackAdvisorBlueprintProcessor stackAdvisorBlueprintProcessor;
-  private Stack stack;
   private boolean configureSecurity = false;
 
   public ClusterConfigurationRequest(AmbariContext ambariContext, ClusterTopology topology, boolean setInitial, StackAdvisorBlueprintProcessor stackAdvisorBlueprintProcessor, boolean configureSecurity) {
@@ -75,10 +64,11 @@ public class ClusterConfigurationRequest {
                                      StackAdvisorBlueprintProcessor stackAdvisorBlueprintProcessor) {
     this.ambariContext = ambariContext;
     this.clusterTopology = clusterTopology;
-    Blueprint blueprint = clusterTopology.getBlueprint();
-    this.stack = blueprint.getStack();
+    BlueprintV2 blueprint = clusterTopology.getBlueprint();
     // set initial configuration (not topology resolved)
-    this.configurationProcessor = new BlueprintConfigurationProcessor(clusterTopology);
+    //TODO set up proper ConfigurationContext
+    ConfigurationContext configurationContext = new ConfigurationContext(blueprint.getStacks().iterator().next(), blueprint.getConfiguration());
+    this.configurationProcessor = new BlueprintConfigurationProcessor(clusterTopology, configurationContext);
     this.stackAdvisorBlueprintProcessor = stackAdvisorBlueprintProcessor;
     removeOrphanConfigTypes();
     if (setInitial) {
@@ -90,7 +80,7 @@ public class ClusterConfigurationRequest {
    * Remove config-types from the given configuration if there is no any services related to them (except cluster-env and global).
    */
   private void removeOrphanConfigTypes(Configuration configuration) {
-    Blueprint blueprint = clusterTopology.getBlueprint();
+    BlueprintV2 blueprint = clusterTopology.getBlueprint();
 
     Collection<String> configTypes = configuration.getAllConfigTypes();
     for (String configType : configTypes) {
@@ -162,10 +152,11 @@ public class ClusterConfigurationRequest {
     Set<String> updatedConfigTypes = new HashSet<>();
 
     Cluster cluster = getCluster();
-    Blueprint blueprint = clusterTopology.getBlueprint();
+    BlueprintV2 blueprint = clusterTopology.getBlueprint();
 
-    Configuration stackDefaults = blueprint.getStack().getConfiguration(blueprint.getServices());
-    Map<String, Map<String, String>> stackDefaultProps = stackDefaults.getProperties();
+    //Configuration stackDefaults = blueprint.getStack().getConfiguration(blueprint.getAllServices());
+    //Map<String, Map<String, String>> stackDefaultProps = stackDefaults.getProperties();
+    Map<String, Map<String, String>> stackDefaultProps = new Configuration(new HashMap<>(), new HashMap<>()).getProperties();
 
     // add clusterHostInfo containing components to hosts map, based on Topology, to use this one instead of
     // StageUtils.getClusterInfo()
@@ -176,7 +167,7 @@ public class ClusterConfigurationRequest {
       // generate principals & keytabs for headless identities
       AmbariContext.getController().getKerberosHelper()
         .ensureHeadlessIdentities(cluster, existingConfigurations,
-          new HashSet<>(blueprint.getServices()));
+          new HashSet(blueprint.getAllServices()));
 
       // apply Kerberos specific configurations
       Map<String, Map<String, String>> updatedConfigs = AmbariContext.getController().getKerberosHelper()
@@ -231,17 +222,17 @@ public class ClusterConfigurationRequest {
    * @param blueprint the blueprint
    * @return a map of service names to component names
    */
-  private Map<String, Set<String>> createServiceComponentMap(Blueprint blueprint) {
+  private Map<String, Set<String>> createServiceComponentMap(BlueprintV2 blueprint) {
     Map<String, Set<String>> serviceComponents = new HashMap<>();
-    Collection<String> services = blueprint.getServices();
+    Collection<Service> services = blueprint.getAllServices();
 
     if(services != null) {
-      for (String service : services) {
-        Collection<String> components = blueprint.getComponents(service);
-        serviceComponents.put(service,
+      for (Service service : services) {
+        Collection<ComponentV2> components = blueprint.getComponents(service);
+        serviceComponents.put(service.getType(),
             (components == null)
                 ? Collections.emptySet()
-                : new HashSet<>(blueprint.getComponents(service)));
+                : new HashSet(blueprint.getComponents(service)));
       }
     }
 
@@ -278,16 +269,16 @@ public class ClusterConfigurationRequest {
     return propertyHasCustomValue;
   }
 
-  private Map<String, String> createComponentHostMap(Blueprint blueprint) {
+  private Map<String, String> createComponentHostMap(BlueprintV2 blueprint) {
     Map<String, String> componentHostsMap = new HashMap<>();
-    for (String service : blueprint.getServices()) {
-      Collection<String> components = blueprint.getComponents(service);
-      for (String component : components) {
-        Collection<String> componentHost = clusterTopology.getHostAssignmentsForComponent(component);
+    for (Service service : blueprint.getAllServices()) {
+      Collection<ComponentV2> components = blueprint.getComponents(service);
+      for (ComponentV2 component : components) {
+        Collection<String> componentHost = clusterTopology.getHostAssignmentsForComponent(component.getType());
         // retrieve corresponding clusterInfoKey for component using StageUtils
-        String clusterInfoKey = StageUtils.getComponentToClusterInfoKeyMap().get(component);
+        String clusterInfoKey = StageUtils.getComponentToClusterInfoKeyMap().get(component.getType());
         if (clusterInfoKey == null) {
-          clusterInfoKey = component.toLowerCase() + "_hosts";
+          clusterInfoKey = component.getType().toLowerCase() + "_hosts";
         }
         componentHostsMap.put(clusterInfoKey, StringUtils.join(componentHost, ","));
       }
@@ -300,7 +291,7 @@ public class ClusterConfigurationRequest {
 
     try {
       Cluster cluster = getCluster();
-      Blueprint blueprint = clusterTopology.getBlueprint();
+      BlueprintV2 blueprint = clusterTopology.getBlueprint();
 
       Configuration clusterConfiguration = clusterTopology.getConfiguration();
       Map<String, Map<String, String>> existingConfigurations = clusterConfiguration.getFullProperties();
@@ -352,16 +343,16 @@ public class ClusterConfigurationRequest {
     //todo: also handle setting of host group scoped configuration which is updated by config processor
     List<BlueprintServiceConfigRequest> configurationRequests = new LinkedList<>();
 
-    Blueprint blueprint = clusterTopology.getBlueprint();
+    BlueprintV2 blueprint = clusterTopology.getBlueprint();
     Configuration clusterConfiguration = clusterTopology.getConfiguration();
 
-    for (String service : blueprint.getServices()) {
+    for (Service service : blueprint.getAllServices()) {
       //todo: remove intermediate request type
       // one bp config request per service
-      BlueprintServiceConfigRequest blueprintConfigRequest = new BlueprintServiceConfigRequest(service);
-
-      for (String serviceConfigType : stack.getAllConfigurationTypes(service)) {
-        Set<String> excludedConfigTypes = stack.getExcludedConfigurationTypes(service);
+      BlueprintServiceConfigRequest blueprintConfigRequest = new BlueprintServiceConfigRequest(service.getType());
+      StackV2 serviceStack = service.getStack();
+      for (String serviceConfigType : serviceStack.getAllConfigurationTypes(service.getType())) {
+        Set<String> excludedConfigTypes = serviceStack.getExcludedConfigurationTypes(service.getType());
         if (!excludedConfigTypes.contains(serviceConfigType)) {
           // skip handling of cluster-env here
           if (! serviceConfigType.equals("cluster-env")) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
index 69ccb61..f0d6e59 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
@@ -18,12 +18,13 @@
 
 package org.apache.ambari.server.topology;
 
-import java.util.Collection;
-import java.util.Map;
-
 import org.apache.ambari.server.controller.RequestStatusResponse;
+import org.apache.ambari.server.controller.internal.ConfigurationContext;
 import org.apache.ambari.server.controller.internal.ProvisionAction;
 
+import java.util.Collection;
+import java.util.Map;
+
 /**
  * Represents a full cluster topology including all instance information as well as the associated
  * blueprint which provides all abstract topology information.
@@ -49,7 +50,7 @@ public interface ClusterTopology {
    *
    * @return assocaited blueprint
    */
-  Blueprint getBlueprint();
+  BlueprintV2 getBlueprint();
 
   /**
    * Get the cluster scoped configuration for the cluster.
@@ -58,8 +59,12 @@ public interface ClusterTopology {
    *
    * @return cluster scoped configuration
    */
+  @Deprecated
   Configuration getConfiguration();
 
+
+  Collection<Service> getServiceConfigs();
+
   /**
    * Get host group information.
    *
@@ -118,18 +123,18 @@ public interface ClusterTopology {
   void addHostToTopology(String hostGroupName, String host) throws InvalidTopologyException, NoSuchHostGroupException;
 
   /**
-   * Determine if NameNode HA is enabled.
+   * Determine if NameNode HA is enabled within ConfigurationContext.
    *
    * @return true if NameNode HA is enabled; false otherwise
    */
-  boolean isNameNodeHAEnabled();
+  boolean isNameNodeHAEnabled(ConfigurationContext configuration);
 
   /**
-   * Determine if Yarn ResourceManager HA is enabled.
+   * Determine if Yarn ResourceManager HA is enabled within ConfigurationContext.
    *
    * @return true if Yarn ResourceManager HA is enabled; false otherwise
    */
-  boolean isYarnResourceManagerHAEnabled();
+  boolean isYarnResourceManagerHAEnabled(ConfigurationContext configuration);
 
   /**
    * Determine if the cluster is kerberos enabled.


[12/30] ambari git commit: Blueprint V2 data model (benyoka)

Posted by mr...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
new file mode 100644
index 0000000..351351b
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
@@ -0,0 +1,124 @@
+package org.apache.ambari.server.topology;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.annotation.Nullable;
+
+import org.apache.ambari.server.controller.internal.ProvisionAction;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.google.common.base.Function;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
+
+public class HostGroupV2Impl implements HostGroupV2, Configurable {
+
+  private String name;
+  private String blueprintName;
+  private List<ComponentV2> components;
+  private List<ServiceId> services;
+  private Configuration configuration;
+  private String cardinality;
+  private boolean containsMasterComponent;
+
+  public HostGroupV2Impl() { }
+
+  @Override
+  public String getName() {
+    return name;
+  }
+
+  @Override
+  public String getBlueprintName() {
+    return blueprintName;
+  }
+
+  @Override
+  public String getFullyQualifiedName() {
+    return blueprintName + ":" + name;
+  }
+
+  @Override
+  public Collection<ComponentV2> getComponents() {
+    return components;
+  }
+
+  @Override
+  public Collection<String> getComponentNames() {
+    return getComponentNames(components);
+  }
+
+  private Collection<String> getComponentNames(List<ComponentV2> components) {
+    return Lists.transform(components,
+      new Function<ComponentV2, String>() {
+        @Override public String apply(@Nullable ComponentV2 input) { return input.getName(); }
+      });
+  }
+
+  @Override
+  public Collection<String> getComponentNames(ProvisionAction provisionAction) {
+    List<ComponentV2> filtered =
+      ImmutableList.copyOf(Collections2.filter(components, Predicates.equalTo(provisionAction)));
+    return getComponentNames(filtered);
+  }
+
+  @Override
+  public Collection<ComponentV2> getComponents(ServiceId serviceId) {
+    return components.stream().filter(c -> c.getServiceId().equals(serviceId)).collect(Collectors.toList());
+  }
+
+  @Override
+  public boolean containsMasterComponent() {
+    return containsMasterComponent;
+  }
+
+  @Override
+  @JsonIgnore
+  public Collection<ServiceId> getServices() {
+    return services;
+  }
+
+  @Override
+  @JsonIgnore
+  public Collection<String> getServiceNames() {
+    return services.stream().map(s -> s.getName()).collect(Collectors.toList());
+  }
+
+  @Override
+  public Configuration getConfiguration() {
+    return configuration;
+  }
+
+  @Override
+  public String getCardinality() {
+    return cardinality;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public void setBlueprintName(String blueprintName) {
+    this.blueprintName = blueprintName;
+  }
+
+  public void setComponents(List<ComponentV2> components) {
+    this.components = components;
+    this.containsMasterComponent = components.stream().anyMatch(c -> c.isMasterComponent());
+    this.services = components.stream().map(c -> c.getServiceId()).collect(Collectors.toList());
+  }
+
+  public void setConfiguration(Configuration configuration) {
+    this.configuration = configuration;
+  }
+
+  public void setCardinality(String cardinality) {
+    this.cardinality = cardinality;
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/RepositoryVersion.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/RepositoryVersion.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/RepositoryVersion.java
new file mode 100644
index 0000000..8eb6663
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/RepositoryVersion.java
@@ -0,0 +1,71 @@
+/*
+ * 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 distribut
+ * ed 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.topology;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class RepositoryVersion {
+  @JsonProperty("stack_id")
+  private String stackId;
+
+  @JsonProperty("repository_version")
+  private String repositoryVersion;
+
+  public RepositoryVersion() { }
+
+  public RepositoryVersion(String stackId, String repositoryVersion) {
+    this.stackId = stackId;
+    this.repositoryVersion = repositoryVersion;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    RepositoryVersion that = (RepositoryVersion) o;
+
+    if (stackId != null ? !stackId.equals(that.stackId) : that.stackId != null) return false;
+    return repositoryVersion != null ? repositoryVersion.equals(that.repositoryVersion) : that.repositoryVersion == null;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = stackId != null ? stackId.hashCode() : 0;
+    result = 31 * result + (repositoryVersion != null ? repositoryVersion.hashCode() : 0);
+    return result;
+  }
+
+  public String getStackId() {
+    return stackId;
+  }
+
+  public void setStackId(String stackId) {
+    this.stackId = stackId;
+  }
+
+  public String getRepositoryVersion() {
+    return repositoryVersion;
+  }
+
+  public void setRepositoryVersion(String repositoryVersion) {
+    this.repositoryVersion = repositoryVersion;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfiguration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfiguration.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfiguration.java
index 4ff5504..7955169 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfiguration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/SecurityConfiguration.java
@@ -21,6 +21,9 @@ package org.apache.ambari.server.topology;
 
 import org.apache.ambari.server.state.SecurityType;
 
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
 /**
  * Holds security related properties, the securityType and security descriptor (in case of KERBEROS
  * kerberos_descriptor) either contains the whole descriptor or just the reference to it.
@@ -43,7 +46,9 @@ public class SecurityConfiguration {
    */
   private String descriptor;
 
-  public SecurityConfiguration(SecurityType type) {
+
+  @JsonCreator
+  public SecurityConfiguration(@JsonProperty("type") SecurityType type) {
     this.type = type;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
index 1505107..1dde7ea 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
@@ -21,45 +21,19 @@ package org.apache.ambari.server.topology;
 
 import java.util.Set;
 
-import org.apache.ambari.server.controller.internal.StackV2;
+import com.fasterxml.jackson.annotation.JsonProperty;
 
-public class Service {
+public class Service implements Configurable {
 
-  private final String type;
+  private String type;
 
-  private final String name;
+  private ServiceId id = new ServiceId();
 
-  private final StackV2 stack;
+  private String stackId;
 
-  private final Configuration configuration;
+  private Configuration configuration;
 
-  private final ServiceGroup serviceGroup;
-
-  private final Set<Service> dependentServices;
-
-  public Service(String type, StackV2 stack, ServiceGroup serviceGroup) {
-    this(type, type, stack, serviceGroup,  null, null);
-  }
-
-  /**
-   * In case there's no name specified name will be set to type.
-   * @param type
-   * @param name
-   * @param stack
-   * @param configuration
-   */
-  public Service(String type, String name, StackV2 stack, ServiceGroup serviceGroup, Configuration configuration, Set<Service> dependentServices) {
-    this.type = type;
-    if (name == null) {
-      this.name = type;
-    } else {
-      this.name = name;
-    }
-    this.stack = stack;
-    this.serviceGroup = serviceGroup;
-    this.configuration = configuration;
-    this.dependentServices = dependentServices;
-  }
+  private Set<ServiceId> dependencies;
 
   /**
    * Gets the name of this service
@@ -67,26 +41,57 @@ public class Service {
    * @return component name
    */
   public String getName() {
-    return this.name;
+    return this.id.getName();
+  }
+
+  public String getServiceGroup() {
+    return this.id.getServiceGroup();
   }
 
   public String getType() {
     return type;
   }
 
-  public StackV2 getStack() {
-    return stack;
+  public String getStackId() {
+    return stackId;
+  }
+
+  public Set<ServiceId> getDependencies() {
+    return dependencies;
   }
 
   public Configuration getConfiguration() {
     return configuration;
   }
 
-  public ServiceGroup getServiceGroup() {
-    return serviceGroup;
+
+  public void setType(String type) {
+    this.type = type;
+  }
+
+  public void setName(String name) {
+    this.id.setName(name);
   }
 
-  public Set<Service> getDependentServices() {
-    return dependentServices;
+  public void setServiceGroup(String serviceGroup) {
+    this.id.setServiceGroup(serviceGroup);
   }
+
+  @JsonProperty("stack_id")
+  public void setStackId(String stackId) {
+    this.stackId = stackId;
+  }
+
+  public void setConfiguration(Configuration configuration) {
+    this.configuration = configuration;
+  }
+
+  public void setDependencies(Set<ServiceId> dependencies) {
+    this.dependencies = dependencies;
+  }
+
+  public ServiceId getId() {
+    return id;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
index 4b59293..13967c0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
@@ -19,29 +19,22 @@
 package org.apache.ambari.server.topology;
 
 
+import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.Set;
 
 public class ServiceGroup {
 
-  private final String name;
+  private String name = null;
 
-  private final Collection<Service> services;
+  private Collection<Service> services = new ArrayList<>();
 
-  private final Configuration configuration;
+  private Configuration configuration = null;
 
-  private final Set<ServiceGroup> dependencies;
+  private Set<String> dependencies = new HashSet<>();
 
-  public ServiceGroup(String name, Collection<Service> services) {
-    this(name, services, null, null);
-  }
-
-  public ServiceGroup(String name, Collection<Service> services, Configuration configuration, Set<ServiceGroup> dependencies) {
-    this.name = name;
-    this.services = services;
-    this.configuration = configuration;
-    this.dependencies = dependencies;
-  }
+  public ServiceGroup() { }
 
   /**
    * Gets the name of this service group
@@ -52,7 +45,6 @@ public class ServiceGroup {
     return this.name;
   }
 
-
   public Collection<Service> getServices() {
     return services;
   }
@@ -61,8 +53,26 @@ public class ServiceGroup {
     return configuration;
   }
 
-  public Set<ServiceGroup> getDependencies() {
+  public Set<String> getDependencies() {
     return dependencies;
   }
 
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public void setServices(Collection<Service> services) {
+    this.services = services;
+    services.forEach(s -> s.setServiceGroup(this.name));
+  }
+
+  public void setConfiguration(Configuration configuration) {
+    this.configuration = configuration;
+  }
+
+  public void setDependencies(Set<String> dependencies) {
+    this.dependencies = dependencies;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java
new file mode 100644
index 0000000..2aae1d3
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java
@@ -0,0 +1,52 @@
+package org.apache.ambari.server.topology;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class ServiceId {
+  private String serviceGroup;
+  private String name;
+
+  public static ServiceId of(String name, String serviceGroup) {
+    ServiceId id = new ServiceId();
+    id.name = name;
+    id.serviceGroup = serviceGroup;
+    return id;
+  }
+
+  public String getServiceGroup() {
+    return serviceGroup;
+  }
+
+  @JsonProperty("service_group")
+  public void setServiceGroup(String serviceGroup) {
+    this.serviceGroup = serviceGroup;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  @JsonProperty("service_name")
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ServiceId serviceId = (ServiceId) o;
+
+    if (serviceGroup != null ? !serviceGroup.equals(serviceId.serviceGroup) : serviceId.serviceGroup != null)
+      return false;
+    return name != null ? name.equals(serviceId.name) : serviceId.name == null;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = serviceGroup != null ? serviceGroup.hashCode() : 0;
+    result = 31 * result + (name != null ? name.hashCode() : 0);
+    return result;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/f82497d4/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
new file mode 100644
index 0000000..dbe269a
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
@@ -0,0 +1,9 @@
+package org.apache.ambari.server.topology.validators;
+
+public class BlueprintImplV2Test {
+
+  private static final String BLUEPRINT_LOCATION = "";
+
+
+
+}


[09/30] ambari git commit: use V2 objects in TopologyManager

Posted by mr...@apache.org.
use V2 objects in TopologyManager


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 65d44cd505f5056499dc29f91d911e604a0b72d8
Parents: b0ff5da
Author: Sandor Magyari <sm...@hortonworks.com>
Authored: Mon Oct 16 16:27:50 2017 +0200
Committer: Sandor Magyari <sm...@hortonworks.com>
Committed: Mon Oct 16 20:14:17 2017 +0200

----------------------------------------------------------------------
 .../query/render/ClusterBlueprintRenderer.java  |  60 +-
 .../server/api/services/ServiceService.java     |   2 +-
 .../StackAdvisorBlueprintProcessor.java         |  37 +-
 .../users/ActiveWidgetLayoutService.java        |   2 +-
 .../api/services/views/ViewInstanceService.java |   2 +-
 .../ambari/server/controller/StackV2.java       | 826 ------------------
 .../controller/internal/BaseClusterRequest.java |  41 +-
 .../BlueprintConfigurationProcessor.java        | 304 ++++---
 .../internal/ConfigurationContext.java          |  59 ++
 .../internal/ExportBlueprintRequest.java        |  55 +-
 .../internal/ProvisionClusterRequest.java       |  34 +-
 .../internal/ScaleClusterRequest.java           |  20 +-
 .../server/controller/internal/StackV2.java     | 829 +++++++++++++++++++
 .../server/controller/internal/UnitUpdater.java |  20 +-
 .../ambari/server/topology/AmbariContext.java   | 297 +++----
 .../server/topology/BlueprintFactory.java       |  14 +-
 .../ambari/server/topology/BlueprintImplV2.java |  40 +-
 .../ambari/server/topology/BlueprintV2.java     |  42 +-
 .../server/topology/BlueprintValidatorImpl.java |  78 +-
 .../topology/ClusterConfigurationRequest.java   |  79 +-
 .../ambari/server/topology/ClusterTopology.java |  21 +-
 .../server/topology/ClusterTopologyImpl.java    |  93 +--
 .../ambari/server/topology/ComponentV2.java     |  17 +-
 .../ambari/server/topology/HostGroupInfo.java   |  27 +-
 .../ambari/server/topology/HostGroupV2.java     |   6 +
 .../ambari/server/topology/HostRequest.java     |  58 +-
 .../ambari/server/topology/LogicalRequest.java  |  26 +-
 .../server/topology/PersistedStateImpl.java     |  55 +-
 .../apache/ambari/server/topology/Service.java  |  25 +-
 .../ambari/server/topology/ServiceGroup.java    |   1 +
 .../ambari/server/topology/TopologyManager.java |  62 +-
 .../ambari/server/topology/TopologyRequest.java |  10 +-
 .../tasks/PersistHostResourcesTask.java         |  23 +-
 .../validators/ClusterConfigTypeValidator.java  |  11 +-
 .../validators/HiveServiceValidator.java        |  50 +-
 .../RequiredConfigPropertiesValidator.java      | 102 +--
 .../validators/RequiredPasswordValidator.java   |  32 +-
 .../validators/StackConfigTypeValidator.java    |  37 +-
 .../topology/validators/UnitValidator.java      |  42 +-
 .../server/api/services/AmbariMetaInfoTest.java |   2 +-
 .../api/services/RootServiceServiceTest.java    |   2 +-
 .../server/api/services/ServiceServiceTest.java |   2 +-
 .../AmbariManagementControllerTest.java         |   6 +-
 .../server/state/cluster/ClusterTest.java       |   2 +-
 .../server/topology/BlueprintImplTest.java      |  10 +-
 .../topology/ClusterTopologyImplTest.java       |  58 +-
 46 files changed, 1782 insertions(+), 1839 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/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 acdf9ed..4f71255 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,57 +18,24 @@
 
 package org.apache.ambari.server.api.query.render;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.query.QueryInfo;
 import org.apache.ambari.server.api.services.Request;
-import org.apache.ambari.server.api.services.Result;
-import org.apache.ambari.server.api.services.ResultImpl;
-import org.apache.ambari.server.api.services.ResultPostProcessor;
-import org.apache.ambari.server.api.services.ResultPostProcessorImpl;
+import org.apache.ambari.server.api.services.*;
 import org.apache.ambari.server.api.util.TreeNode;
 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.ArtifactResourceProvider;
-import org.apache.ambari.server.controller.internal.BlueprintConfigurationProcessor;
-import org.apache.ambari.server.controller.internal.BlueprintResourceProvider;
-import org.apache.ambari.server.controller.internal.ExportBlueprintRequest;
-import org.apache.ambari.server.controller.internal.RequestImpl;
-import org.apache.ambari.server.controller.internal.ResourceImpl;
-import org.apache.ambari.server.controller.internal.Stack;
-import org.apache.ambari.server.controller.spi.ClusterController;
-import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
-import org.apache.ambari.server.controller.spi.NoSuchResourceException;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.ResourceProvider;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.internal.*;
+import org.apache.ambari.server.controller.spi.*;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.state.SecurityType;
-import org.apache.ambari.server.topology.AmbariContext;
-import org.apache.ambari.server.topology.ClusterTopology;
-import org.apache.ambari.server.topology.ClusterTopologyImpl;
-import org.apache.ambari.server.topology.Component;
-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.SecurityConfigurationFactory;
+import org.apache.ambari.server.topology.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.*;
+
 /**
  * Renderer which renders a cluster resource as a blueprint.
  */
@@ -193,12 +160,15 @@ public class ClusterBlueprintRenderer extends BaseRenderer implements Renderer {
       throw new RuntimeException("Unable to process blueprint export request: " + e, e);
     }
 
-    BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology);
+    ConfigurationContext configurationContext = new ConfigurationContext(topology.getBlueprint().getStacks().iterator().next(),
+      topology.getBlueprint().getConfiguration());
+    BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology, configurationContext);
     configProcessor.doUpdateForBlueprintExport();
 
-    Stack stack = topology.getBlueprint().getStack();
-    blueprintResource.setProperty("Blueprints/stack_name", stack.getName());
-    blueprintResource.setProperty("Blueprints/stack_version", stack.getVersion());
+    //TODO add service groups
+    //Stack stack = topology.getBlueprint().getStack();
+    //blueprintResource.setProperty("Blueprints/stack_name", stack.getName());
+    //blueprintResource.setProperty("Blueprints/stack_version", stack.getVersion());
 
     if (topology.isClusterKerberosEnabled()) {
       Map<String, Object> securityConfigMap = new LinkedHashMap<>();
@@ -443,9 +413,9 @@ public class ClusterBlueprintRenderer extends BaseRenderer implements Renderer {
    *
    * @return list of component names for the host
    */
-  private List<Map<String, String>> processHostGroupComponents(HostGroup group) {
+  private List<Map<String, String>> processHostGroupComponents(HostGroupV2 group) {
     List<Map<String, String>> listHostGroupComponents = new ArrayList<>();
-    for (Component component : group.getComponents()) {
+    for (ComponentV2 component : group.getComponents()) {
       Map<String, String> mapComponentProperties = new HashMap<>();
       listHostGroupComponents.add(mapComponentProperties);
       mapComponentProperties.put("name", component.getName());

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
index 12f4bca..cb0ad20 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceService.java
@@ -122,7 +122,7 @@ public class ServiceService extends BaseService {
   @Path("") // This is needed if class level path is not present otherwise no Swagger docs will be generated for this method
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Get all services",
-      nickname = "ServiceService#getServices",
+      nickname = "ServiceService#getServiceConfigs",
       notes = "Returns all services.",
       response = ServiceResponse.ServiceResponseSwagger.class,
       responseContainer = RESPONSE_CONTAINER_LIST)

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
index 273c0ff..441f71d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
@@ -18,34 +18,23 @@
 
 package org.apache.ambari.server.api.services.stackadvisor;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.inject.Singleton;
 import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest.StackAdvisorRequestType;
 import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse;
 import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse.BlueprintConfigurations;
 import org.apache.ambari.server.controller.internal.ConfigurationTopologyException;
-import org.apache.ambari.server.controller.internal.Stack;
+import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.state.ValueAttributesInfo;
-import org.apache.ambari.server.topology.AdvisedConfiguration;
-import org.apache.ambari.server.topology.Blueprint;
-import org.apache.ambari.server.topology.ClusterTopology;
-import org.apache.ambari.server.topology.ConfigRecommendationStrategy;
-import org.apache.ambari.server.topology.HostGroup;
-import org.apache.ambari.server.topology.HostGroupInfo;
+import org.apache.ambari.server.topology.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.inject.Singleton;
+import java.util.*;
 
 /**
  * Generate advised configurations for blueprint cluster provisioning by the stack advisor.
@@ -89,14 +78,14 @@ public class StackAdvisorBlueprintProcessor {
   }
 
   private StackAdvisorRequest createStackAdvisorRequest(ClusterTopology clusterTopology, StackAdvisorRequestType requestType) {
-    Stack stack = clusterTopology.getBlueprint().getStack();
+    StackV2 stack = clusterTopology.getBlueprint().getStacks().iterator().next();
     Map<String, Set<String>> hgComponentsMap = gatherHostGroupComponents(clusterTopology);
     Map<String, Set<String>> hgHostsMap = gatherHostGroupBindings(clusterTopology);
     Map<String, Set<String>> componentHostsMap = gatherComponentsHostsMap(hgComponentsMap,
             hgHostsMap);
     return StackAdvisorRequest.StackAdvisorRequestBuilder
       .forStack(stack.getName(), stack.getVersion())
-      .forServices(new ArrayList<>(clusterTopology.getBlueprint().getServices()))
+      .forServices(new ArrayList<>(clusterTopology.getBlueprint().getAllServiceTypes()))
       .forHosts(gatherHosts(clusterTopology))
       .forHostsGroupBindings(gatherHostGroupBindings(clusterTopology))
       .forHostComponents(gatherHostGroupComponents(clusterTopology))
@@ -117,7 +106,7 @@ public class StackAdvisorBlueprintProcessor {
 
   private Map<String, Set<String>> gatherHostGroupComponents(ClusterTopology clusterTopology) {
     Map<String, Set<String>> hgComponentsMap = Maps.newHashMap();
-    for (Map.Entry<String, HostGroup> hgEnrty: clusterTopology.getBlueprint().getHostGroups().entrySet()) {
+    for (Map.Entry<String, HostGroupV2> hgEnrty: clusterTopology.getBlueprint().getHostGroups().entrySet()) {
       hgComponentsMap.put(hgEnrty.getKey(), Sets.newCopyOnWriteArraySet(hgEnrty.getValue().getComponentNames()));
     }
     return hgComponentsMap;
@@ -176,7 +165,7 @@ public class StackAdvisorBlueprintProcessor {
 
     Map<String, BlueprintConfigurations> recommendedConfigurations =
       response.getRecommendations().getBlueprint().getConfigurations();
-    Blueprint blueprint = topology.getBlueprint();
+    BlueprintV2 blueprint = topology.getBlueprint();
 
     for (Map.Entry<String, BlueprintConfigurations> configEntry : recommendedConfigurations.entrySet()) {
       String configType = configEntry.getKey();

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/api/services/users/ActiveWidgetLayoutService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/users/ActiveWidgetLayoutService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/users/ActiveWidgetLayoutService.java
index e7cdabb..2667a0c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/users/ActiveWidgetLayoutService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/users/ActiveWidgetLayoutService.java
@@ -64,7 +64,7 @@ public class ActiveWidgetLayoutService extends BaseService {
    */
   @GET
   @Produces("text/plain")
-  @ApiOperation(value = "Get user widget layouts", nickname = "ActiveWidgetLayoutService#getServices", notes = "Returns all active widget layouts for user.", response = ActiveWidgetLayoutResponse.class, responseContainer = "List")
+  @ApiOperation(value = "Get user widget layouts", nickname = "ActiveWidgetLayoutService#getServiceConfigs", notes = "Returns all active widget layouts for user.", response = ActiveWidgetLayoutResponse.class, responseContainer = "List")
   @ApiImplicitParams({
     @ApiImplicitParam(name = "fields", value = "Filter user layout details", defaultValue = "WidgetLayoutInfo/*", dataType = "string", paramType = "query"),
     @ApiImplicitParam(name = "sortBy", value = "Sort layouts (asc | desc)", defaultValue = "WidgetLayoutInfo/user_name.asc", dataType = "string", paramType = "query"),

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/api/services/views/ViewInstanceService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/views/ViewInstanceService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/views/ViewInstanceService.java
index e4ebedb..036f1bd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/views/ViewInstanceService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/views/ViewInstanceService.java
@@ -76,7 +76,7 @@ public class ViewInstanceService extends BaseService {
    */
   @GET
   @Produces("text/plain")
-  @ApiOperation(value = "Get all view instances", nickname = "ViewInstanceService#getServices", notes = "Returns all instances for a view version.", response = ViewInstanceResponse.class, responseContainer = "List")
+  @ApiOperation(value = "Get all view instances", nickname = "ViewInstanceService#getServiceConfigs", notes = "Returns all instances for a view version.", response = ViewInstanceResponse.class, responseContainer = "List")
   @ApiImplicitParams({
     @ApiImplicitParam(name = "fields", value = "Filter view instance details", defaultValue = "ViewInstanceInfo/*", dataType = "string", paramType = "query"),
     @ApiImplicitParam(name = "sortBy", value = "Sort users (asc | desc)", defaultValue = "ViewInstanceInfo/instance_name.desc", dataType = "string", paramType = "query"),

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
deleted file mode 100644
index a6d8979..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
+++ /dev/null
@@ -1,826 +0,0 @@
-/*
- * 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.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.orm.entities.StackEntity;
-import org.apache.ambari.server.state.AutoDeployInfo;
-import org.apache.ambari.server.state.ComponentInfo;
-import org.apache.ambari.server.state.DependencyInfo;
-import org.apache.ambari.server.state.PropertyDependencyInfo;
-import org.apache.ambari.server.state.PropertyInfo;
-import org.apache.ambari.server.state.ValueAttributesInfo;
-import org.apache.ambari.server.topology.Cardinality;
-import org.apache.ambari.server.topology.Configuration;
-
-/**
- * Encapsulates stack information.
- */
-public class StackV2 {
-  /**
-   * Stack name
-   */
-  private String name;
-
-  /**
-   * Stack version
-   */
-  private String version;
-
-    /**
-     * Repo version
-   */
-  private String repoVersion;
-
-  /**
-   * Map of service name to components
-   */
-  private Map<String, Collection<String>> serviceComponents =
-    new HashMap<>();
-
-  /**
-   * Map of component to service
-   */
-  private Map<String, String> componentService = new HashMap<>();
-
-  /**
-   * Map of component to dependencies
-   */
-  private Map<String, Collection<DependencyInfo>> dependencies =
-    new HashMap<>();
-
-  /**
-   * Map of dependency to conditional service
-   */
-  private Map<DependencyInfo, String> dependencyConditionalServiceMap =
-    new HashMap<>();
-
-  /**
-   * Map of database component name to configuration property which indicates whether
-   * the database in to be managed or if it is an external non-managed instance.
-   * If the value of the config property starts with 'New', the database is determined
-   * to be managed, otherwise it is non-managed.
-   */
-  private Map<String, String> dbDependencyInfo = new HashMap<>();
-
-  /**
-   * Map of component to required cardinality
-   */
-  private Map<String, String> cardinalityRequirements = new HashMap<>();
-
-  //todo: instead of all these maps from component -> * ,
-  //todo: we should use a Component object with all of these attributes
-  private Set<String> masterComponents = new HashSet<>();
-
-  /**
-   * Map of component to auto-deploy information
-   */
-  private Map<String, AutoDeployInfo> componentAutoDeployInfo =
-    new HashMap<>();
-
-  /**
-   * Map of service to config type properties
-   */
-  private Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations =
-    new HashMap<>();
-
-  /**
-   * Map of service to required type properties
-   */
-  private Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations =
-    new HashMap<>();
-
-  /**
-   * Map of service to config type properties
-   */
-  private Map<String, Map<String, ConfigProperty>> stackConfigurations =
-    new HashMap<>();
-
-  /**
-   * Map of service to set of excluded config types
-   */
-  private Map<String, Set<String>> excludedConfigurationTypes =
-    new HashMap<>();
-
-  /**
-   * Ambari Management Controller, used to obtain Stack definitions
-   */
-  private final AmbariManagementController controller;
-
-
-  /**
-   * Constructor.
-   *
-   * @param stack
-   *          the stack (not {@code null}).
-   * @param ambariManagementController
-   *          the management controller (not {@code null}).
-   * @throws AmbariException
-   */
-  public StackV2(StackEntity stack, AmbariManagementController ambariManagementController) throws AmbariException {
-    this(stack.getStackName(), stack.getStackVersion(), ambariManagementController);
-  }
-
-  /**
-   * Constructor.
-   *
-   * @param name     stack name
-   * @param version  stack version
-   *
-   * @throws AmbariException an exception occurred getting stack information
-   *                         for the specified name and version
-   */
-  //todo: don't pass management controller in constructor
-  public StackV2(String name, String version, AmbariManagementController controller) throws AmbariException {
-    this.name = name;
-    this.version = version;
-    this.controller = controller;
-
-    Set<StackServiceResponse> stackServices = controller.getStackServices(
-        Collections.singleton(new StackServiceRequest(name, version, null)));
-
-    for (StackServiceResponse stackService : stackServices) {
-      String serviceName = stackService.getServiceName();
-      parseComponents(serviceName);
-      parseExcludedConfigurations(stackService);
-      parseConfigurations(stackService);
-      registerConditionalDependencies();
-    }
-
-    //todo: already done for each service
-    parseStackConfigurations();
-  }
-
-  /**
-   * Obtain stack name.
-   *
-   * @return stack name
-   */
-  public String getName() {
-    return name;
-  }
-
-  /**
-   * Obtain stack version.
-   *
-   * @return stack version
-   */
-  public String getVersion() {
-    return version;
-  }
-
-  /**
-   * Obtain repo version.
-   * @return
-   */
-  public String getRepoVersion() { return repoVersion; }
-
-  Map<DependencyInfo, String> getDependencyConditionalServiceMap() {
-    return dependencyConditionalServiceMap;
-  }
-
-  /**
-   * Get services contained in the stack.
-   *
-   * @return collection of all services for the stack
-   */
-  public Collection<String> getServices() {
-    return serviceComponents.keySet();
-  }
-
-  /**
-   * Get components contained in the stack for the specified service.
-   *
-   * @param service  service name
-   *
-   * @return collection of component names for the specified service
-   */
-  public Collection<String> getComponents(String service) {
-    return serviceComponents.get(service);
-  }
-
-  /**
-   * Get all service components
-   *
-   * @return map of service to associated components
-   */
-  public Map<String, Collection<String>> getComponents() {
-    Map<String, Collection<String>> serviceComponents = new HashMap<>();
-    for (String service : getServices()) {
-      Collection<String> components = new HashSet<>();
-      components.addAll(getComponents(service));
-      serviceComponents.put(service, components);
-    }
-    return serviceComponents;
-  }
-
-  /**
-   * Get info for the specified component.
-   *
-   * @param component  component name
-   *
-   * @return component information for the requested component
-   *         or null if the component doesn't exist in the stack
-   */
-  public ComponentInfo getComponentInfo(String component) {
-    ComponentInfo componentInfo = null;
-    String service = getServiceForComponent(component);
-    if (service != null) {
-      try {
-        componentInfo = controller.getAmbariMetaInfo().getComponent(
-            getName(), getVersion(), service, component);
-      } catch (AmbariException e) {
-        // just return null if component doesn't exist
-      }
-    }
-    return componentInfo;
-  }
-
-  /**
-   * Get all configuration types, including excluded types for the specified service.
-   *
-   * @param service  service name
-   *
-   * @return collection of all configuration types for the specified service
-   */
-  public Collection<String> getAllConfigurationTypes(String service) {
-    return serviceConfigurations.get(service).keySet();
-  }
-
-  /**
-   * Get configuration types for the specified service.
-   * This doesn't include any service excluded types.
-   *
-   * @param service  service name
-   *
-   * @return collection of all configuration types for the specified service
-   */
-  public Collection<String> getConfigurationTypes(String service) {
-    Set<String> serviceTypes = new HashSet<>(serviceConfigurations.get(service).keySet());
-    serviceTypes.removeAll(getExcludedConfigurationTypes(service));
-
-    return serviceTypes;
-  }
-
-  /**
-   * Get the set of excluded configuration types for this service.
-   *
-   * @param service service name
-   *
-   * @return Set of names of excluded config types. Will not return null.
-   */
-  public Set<String> getExcludedConfigurationTypes(String service) {
-    return excludedConfigurationTypes.containsKey(service) ?
-        excludedConfigurationTypes.get(service) :
-        Collections.emptySet();
-  }
-
-  /**
-   * Get config properties for the specified service and configuration type.
-   *
-   * @param service  service name
-   * @param type     configuration type
-   *
-   * @return map of property names to values for the specified service and configuration type
-   */
-  public Map<String, String> getConfigurationProperties(String service, String type) {
-    Map<String, String> configMap = new HashMap<>();
-    Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
-    if (configProperties != null) {
-      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-        configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
-      }
-    }
-    return configMap;
-  }
-
-  public Map<String, ConfigProperty> getConfigurationPropertiesWithMetadata(String service, String type) {
-    return serviceConfigurations.get(service).get(type);
-  }
-
-  /**
-   * Get all required config properties for the specified service.
-   *
-   * @param service  service name
-   *
-   * @return collection of all required properties for the given service
-   */
-  public Collection<ConfigProperty> getRequiredConfigurationProperties(String service) {
-    Collection<ConfigProperty> requiredConfigProperties = new HashSet<>();
-    Map<String, Map<String, ConfigProperty>> serviceProperties = requiredServiceConfigurations.get(service);
-    if (serviceProperties != null) {
-      for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : serviceProperties.entrySet()) {
-        requiredConfigProperties.addAll(typePropertiesEntry.getValue().values());
-      }
-    }
-    return requiredConfigProperties;
-  }
-
-  /**
-   * Get required config properties for the specified service which belong to the specified property type.
-   *
-   * @param service       service name
-   * @param propertyType  property type
-   *
-   * @return collection of required properties for the given service and property type
-   */
-  public Collection<ConfigProperty> getRequiredConfigurationProperties(String service, PropertyInfo.PropertyType propertyType) {
-    Collection<ConfigProperty> matchingProperties = new HashSet<>();
-    Map<String, Map<String, ConfigProperty>> requiredProperties = requiredServiceConfigurations.get(service);
-    if (requiredProperties != null) {
-      for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : requiredProperties.entrySet()) {
-        for (ConfigProperty configProperty : typePropertiesEntry.getValue().values()) {
-          if (configProperty.getPropertyTypes().contains(propertyType)) {
-            matchingProperties.add(configProperty);
-          }
-        }
-
-      }
-    }
-    return matchingProperties;
-  }
-
-  public boolean isPasswordProperty(String service, String type, String propertyName) {
-    return (serviceConfigurations.containsKey(service) &&
-            serviceConfigurations.get(service).containsKey(type) &&
-            serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
-            serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
-                contains(PropertyInfo.PropertyType.PASSWORD));
-  }
-
-  //todo
-  public Map<String, String> getStackConfigurationProperties(String type) {
-    Map<String, String> configMap = new HashMap<>();
-    Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
-    if (configProperties != null) {
-      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-        configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
-      }
-    }
-    return configMap;
-  }
-
-  public boolean isKerberosPrincipalNameProperty(String service, String type, String propertyName) {
-    return (serviceConfigurations.containsKey(service) &&
-            serviceConfigurations.get(service).containsKey(type) &&
-            serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
-            serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
-                contains(PropertyInfo.PropertyType.KERBEROS_PRINCIPAL));
-  }
-  /**
-   * Get config attributes for the specified service and configuration type.
-   *
-   * @param service  service name
-   * @param type     configuration type
-   *
-   * @return  map of attribute names to map of property names to attribute values
-   *          for the specified service and configuration type
-   */
-  public Map<String, Map<String, String>> getConfigurationAttributes(String service, String type) {
-    Map<String, Map<String, String>> attributesMap = new HashMap<>();
-    Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
-    if (configProperties != null) {
-      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-        String propertyName = configProperty.getKey();
-        Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
-        if (propertyAttributes != null) {
-          for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
-            String attributeName = propertyAttribute.getKey();
-            String attributeValue = propertyAttribute.getValue();
-            if (attributeValue != null) {
-              Map<String, String> attributes = attributesMap.get(attributeName);
-              if (attributes == null) {
-                  attributes = new HashMap<>();
-                  attributesMap.put(attributeName, attributes);
-              }
-              attributes.put(propertyName, attributeValue);
-            }
-          }
-        }
-      }
-    }
-    return attributesMap;
-  }
-
-  //todo:
-  public Map<String, Map<String, String>> getStackConfigurationAttributes(String type) {
-    Map<String, Map<String, String>> attributesMap = new HashMap<>();
-    Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
-    if (configProperties != null) {
-      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-        String propertyName = configProperty.getKey();
-        Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
-        if (propertyAttributes != null) {
-          for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
-            String attributeName = propertyAttribute.getKey();
-            String attributeValue = propertyAttribute.getValue();
-            Map<String, String> attributes = attributesMap.get(attributeName);
-            if (attributes == null) {
-              attributes = new HashMap<>();
-              attributesMap.put(attributeName, attributes);
-            }
-            attributes.put(propertyName, attributeValue);
-          }
-        }
-      }
-    }
-    return attributesMap;
-  }
-
-  /**
-   * Get the service for the specified component.
-   *
-   * @param component  component name
-   *
-   * @return service name that contains tha specified component
-   */
-  public String getServiceForComponent(String component) {
-    return componentService.get(component);
-  }
-
-  /**
-   * Get the names of the services which contains the specified components.
-   *
-   * @param components collection of components
-   *
-   * @return collection of services which contain the specified components
-   */
-  public Collection<String> getServicesForComponents(Collection<String> components) {
-    Set<String> services = new HashSet<>();
-    for (String component : components) {
-      services.add(getServiceForComponent(component));
-    }
-
-    return services;
-  }
-
-  /**
-   * Obtain the service name which corresponds to the specified configuration.
-   *
-   * @param config  configuration type
-   *
-   * @return name of service which corresponds to the specified configuration type
-   */
-  public String getServiceForConfigType(String config) {
-    for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) {
-      Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue();
-      String serviceName = entry.getKey();
-      if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) {
-        return serviceName;
-      }
-    }
-    throw new IllegalArgumentException(
-        "Specified configuration type is not associated with any service: " + config);
-  }
-
-  /**
-   * Return the dependencies specified for the given component.
-   *
-   * @param component  component to get dependency information for
-   *
-   * @return collection of dependency information for the specified component
-   */
-  //todo: full dependency graph
-  public Collection<DependencyInfo> getDependenciesForComponent(String component) {
-    return dependencies.containsKey(component) ? dependencies.get(component) :
-        Collections.emptySet();
-  }
-
-  /**
-   * Get the service, if any, that a component dependency is conditional on.
-   *
-   * @param dependency  dependency to get conditional service for
-   *
-   * @return conditional service for provided component or null if dependency
-   *         is not conditional on a service
-   */
-  public String getConditionalServiceForDependency(DependencyInfo dependency) {
-    return dependencyConditionalServiceMap.get(dependency);
-  }
-
-  public String getExternalComponentConfig(String component) {
-    return dbDependencyInfo.get(component);
-  }
-
-  /**
-   * Obtain the required cardinality for the specified component.
-   */
-  public Cardinality getCardinality(String component) {
-    return new Cardinality(cardinalityRequirements.get(component));
-  }
-
-  /**
-   * Obtain auto-deploy information for the specified component.
-   */
-  public AutoDeployInfo getAutoDeployInfo(String component) {
-    return componentAutoDeployInfo.get(component);
-  }
-
-  public boolean isMasterComponent(String component) {
-    return masterComponents.contains(component);
-  }
-
-  public Configuration getConfiguration(Collection<String> services) {
-    Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>();
-    Map<String, Map<String, String>> properties = new HashMap<>();
-
-    for (String service : services) {
-      Collection<String> serviceConfigTypes = getConfigurationTypes(service);
-      for (String type : serviceConfigTypes) {
-        Map<String, String> typeProps = properties.get(type);
-        if (typeProps == null) {
-          typeProps = new HashMap<>();
-          properties.put(type, typeProps);
-        }
-        typeProps.putAll(getConfigurationProperties(service, type));
-
-        Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
-        if (!stackTypeAttributes.isEmpty()) {
-          if (! attributes.containsKey(type)) {
-            attributes.put(type, new HashMap<>());
-          }
-          Map<String, Map<String, String>> typeAttributes = attributes.get(type);
-          for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
-            String attributeName = attribute.getKey();
-            Map<String, String> attributeProps = typeAttributes.get(attributeName);
-            if (attributeProps == null) {
-              attributeProps = new HashMap<>();
-              typeAttributes.put(attributeName, attributeProps);
-            }
-            attributeProps.putAll(attribute.getValue());
-          }
-        }
-      }
-    }
-    return new Configuration(properties, attributes);
-  }
-
-  public Configuration getConfiguration() {
-    Map<String, Map<String, Map<String, String>>> stackAttributes = new HashMap<>();
-    Map<String, Map<String, String>> stackConfigs = new HashMap<>();
-
-    for (String service : getServices()) {
-      for (String type : getAllConfigurationTypes(service)) {
-        Map<String, String> typeProps = stackConfigs.get(type);
-        if (typeProps == null) {
-          typeProps = new HashMap<>();
-          stackConfigs.put(type, typeProps);
-        }
-        typeProps.putAll(getConfigurationProperties(service, type));
-
-        Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
-        if (!stackTypeAttributes.isEmpty()) {
-          if (! stackAttributes.containsKey(type)) {
-            stackAttributes.put(type, new HashMap<>());
-          }
-          Map<String, Map<String, String>> typeAttrs = stackAttributes.get(type);
-          for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
-            String attributeName = attribute.getKey();
-            Map<String, String> attributes = typeAttrs.get(attributeName);
-            if (attributes == null) {
-              attributes = new HashMap<>();
-              typeAttrs.put(attributeName, attributes);
-            }
-            attributes.putAll(attribute.getValue());
-          }
-        }
-      }
-    }
-    return new Configuration(stackConfigs, stackAttributes);
-  }
-
-  /**
-   * Parse components for the specified service from the stack definition.
-   *
-   * @param service  service name
-   *
-   * @throws AmbariException an exception occurred getting components from the stack definition
-   */
-  private void parseComponents(String service) throws AmbariException{
-    Collection<String> componentSet = new HashSet<>();
-
-    Set<StackServiceComponentResponse> components = controller.getStackComponents(
-        Collections.singleton(new StackServiceComponentRequest(name, version, service, null)));
-
-    // stack service components
-    for (StackServiceComponentResponse component : components) {
-      String componentName = component.getComponentName();
-      componentSet.add(componentName);
-      componentService.put(componentName, service);
-      String cardinality = component.getCardinality();
-      if (cardinality != null) {
-        cardinalityRequirements.put(componentName, cardinality);
-      }
-      AutoDeployInfo autoDeploy = component.getAutoDeploy();
-      if (autoDeploy != null) {
-        componentAutoDeployInfo.put(componentName, autoDeploy);
-      }
-
-      // populate component dependencies
-      //todo: remove usage of AmbariMetaInfo
-      Collection<DependencyInfo> componentDependencies = controller.getAmbariMetaInfo().getComponentDependencies(
-          name, version, service, componentName);
-
-      if (componentDependencies != null && ! componentDependencies.isEmpty()) {
-        dependencies.put(componentName, componentDependencies);
-      }
-      if (component.isMaster()) {
-        masterComponents.add(componentName);
-      }
-    }
-    serviceComponents.put(service, componentSet);
-  }
-
-  /**
-   * Parse configurations for the specified service from the stack definition.
-   *
-   * @param stackService  service to parse the stack configuration for
-   *
-   * @throws AmbariException an exception occurred getting configurations from the stack definition
-   */
-  private void parseConfigurations(StackServiceResponse stackService) throws AmbariException {
-    String service = stackService.getServiceName();
-    Map<String, Map<String, ConfigProperty>> mapServiceConfig = new HashMap<>();
-    Map<String, Map<String, ConfigProperty>> mapRequiredServiceConfig = new HashMap<>();
-
-
-    serviceConfigurations.put(service, mapServiceConfig);
-    requiredServiceConfigurations.put(service, mapRequiredServiceConfig);
-
-    Set<ReadOnlyConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
-        Collections.singleton(new StackConfigurationRequest(name, version, service, null)));
-    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
-        Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
-    serviceConfigs.addAll(stackLevelConfigs);
-
-    // shouldn't have any required properties in stack level configuration
-    for (ReadOnlyConfigurationResponse config : serviceConfigs) {
-      ConfigProperty configProperty = new ConfigProperty(config);
-      String type = configProperty.getType();
-
-      Map<String, ConfigProperty> mapTypeConfig = mapServiceConfig.get(type);
-      if (mapTypeConfig == null) {
-        mapTypeConfig = new HashMap<>();
-        mapServiceConfig.put(type, mapTypeConfig);
-      }
-
-      mapTypeConfig.put(config.getPropertyName(), configProperty);
-      if (config.isRequired()) {
-        Map<String, ConfigProperty> requiredTypeConfig = mapRequiredServiceConfig.get(type);
-        if (requiredTypeConfig == null) {
-          requiredTypeConfig = new HashMap<>();
-          mapRequiredServiceConfig.put(type, requiredTypeConfig);
-        }
-        requiredTypeConfig.put(config.getPropertyName(), configProperty);
-      }
-    }
-
-    // So far we added only config types that have properties defined
-    // in stack service definition. Since there might be config types
-    // with no properties defined we need to add those separately
-    Set<String> configTypes = stackService.getConfigTypes().keySet();
-    for (String configType: configTypes) {
-      if (!mapServiceConfig.containsKey(configType)) {
-        mapServiceConfig.put(configType, Collections.emptyMap());
-      }
-    }
-  }
-
-  private void parseStackConfigurations () throws AmbariException {
-
-    Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
-        Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
-
-    for (ReadOnlyConfigurationResponse config : stackLevelConfigs) {
-      ConfigProperty configProperty = new ConfigProperty(config);
-      String type = configProperty.getType();
-
-      Map<String, ConfigProperty> mapTypeConfig = stackConfigurations.get(type);
-      if (mapTypeConfig == null) {
-        mapTypeConfig = new HashMap<>();
-        stackConfigurations.put(type, mapTypeConfig);
-      }
-
-      mapTypeConfig.put(config.getPropertyName(),
-          configProperty);
-    }
-  }
-
-  /**
-   * Obtain the excluded configuration types from the StackServiceResponse
-   *
-   * @param stackServiceResponse the response object associated with this stack service
-   */
-  private void parseExcludedConfigurations(StackServiceResponse stackServiceResponse) {
-    excludedConfigurationTypes.put(stackServiceResponse.getServiceName(), stackServiceResponse.getExcludedConfigTypes());
-  }
-
-  /**
-   * Register conditional dependencies.
-   */
-  //todo: This information should be specified in the stack definition.
-  void registerConditionalDependencies() {
-    dbDependencyInfo.put("MYSQL_SERVER", "global/hive_database");
-  }
-
-  /**
-   * Contains a configuration property's value and attributes.
-   */
-  public static class ConfigProperty {
-    private ValueAttributesInfo propertyValueAttributes = null;
-    private String name;
-    private String value;
-    private Map<String, String> attributes;
-    private Set<PropertyInfo.PropertyType> propertyTypes;
-    private String type;
-    private Set<PropertyDependencyInfo> dependsOnProperties =
-      Collections.emptySet();
-
-    public ConfigProperty(ReadOnlyConfigurationResponse config) {
-      this.name = config.getPropertyName();
-      this.value = config.getPropertyValue();
-      this.attributes = config.getPropertyAttributes();
-      this.propertyTypes = config.getPropertyType();
-      this.type = normalizeType(config.getType());
-      this.dependsOnProperties = config.getDependsOnProperties();
-      this.propertyValueAttributes = config.getPropertyValueAttributes();
-    }
-
-    public ConfigProperty(String type, String name, String value) {
-      this.type = type;
-      this.name = name;
-      this.value = value;
-    }
-
-    public String getName() {
-      return name;
-    }
-
-    public String getValue() {
-      return value;
-    }
-
-    public void setValue(String value) {
-      this.value = value;
-    }
-
-    public String getType() {
-      return type;
-    }
-
-    public Set<PropertyInfo.PropertyType> getPropertyTypes() {
-      return propertyTypes;
-    }
-
-    public void setPropertyTypes(Set<PropertyInfo.PropertyType> propertyTypes) {
-      this.propertyTypes = propertyTypes;
-    }
-
-    public Map<String, String> getAttributes() {
-      return attributes;
-    }
-
-    public void setAttributes(Map<String, String> attributes) {
-      this.attributes = attributes;
-    }
-
-    Set<PropertyDependencyInfo> getDependsOnProperties() {
-      return this.dependsOnProperties;
-    }
-
-    private String normalizeType(String type) {
-      //strip .xml from type
-      if (type.endsWith(".xml")) {
-        type = type.substring(0, type.length() - 4);
-      }
-      return type;
-    }
-
-    public ValueAttributesInfo getPropertyValueAttributes() {
-      return propertyValueAttributes;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
index 77eafeb..c3858ba 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
@@ -18,24 +18,15 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.api.predicate.QueryLexer;
 import org.apache.ambari.server.api.predicate.Token;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
-import org.apache.ambari.server.topology.Blueprint;
-import org.apache.ambari.server.topology.BlueprintFactory;
-import org.apache.ambari.server.topology.Configuration;
-import org.apache.ambari.server.topology.HostGroupInfo;
-import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
-import org.apache.ambari.server.topology.SecurityConfiguration;
-import org.apache.ambari.server.topology.TopologyRequest;
+import org.apache.ambari.server.topology.*;
+
+import java.util.*;
 
 /**
  * Provides common cluster request functionality.
@@ -62,12 +53,7 @@ public abstract class BaseClusterRequest implements TopologyRequest {
    * blueprint
    */
   //todo: change interface to only return blueprint name
-  protected Blueprint blueprint;
-
-  /**
-   * configuration
-   */
-  protected Configuration configuration;
+  protected BlueprintV2 blueprint;
 
   /**
    * security configuration
@@ -80,6 +66,11 @@ public abstract class BaseClusterRequest implements TopologyRequest {
   protected static BlueprintFactory blueprintFactory;
 
   /**
+   * List of services
+   */
+  protected Collection<Service> serviceConfigs;
+
+  /**
    * Lexer used to obtain property names from a predicate string
    */
   private static final QueryLexer queryLexer = new QueryLexer();
@@ -104,13 +95,19 @@ public abstract class BaseClusterRequest implements TopologyRequest {
   }
 
   @Override
-  public Blueprint getBlueprint() {
+  public BlueprintV2 getBlueprint() {
     return blueprint;
   }
 
   @Override
+  public Collection<Service> getServiceConfigs() {
+    return serviceConfigs;
+  }
+
+  @Override
+  @Deprecated
   public Configuration getConfiguration() {
-    return configuration;
+    return null;
   }
 
   @Override
@@ -155,7 +152,7 @@ public abstract class BaseClusterRequest implements TopologyRequest {
    *
    * @param blueprint blueprint
    */
-  protected void setBlueprint(Blueprint blueprint) {
+  protected void setBlueprint(BlueprintV2 blueprint) {
     this.blueprint = blueprint;
   }
 
@@ -164,8 +161,8 @@ public abstract class BaseClusterRequest implements TopologyRequest {
    *
    * @param configuration  configuration
    */
+  @Deprecated
   protected void setConfiguration(Configuration configuration) {
-    this.configuration = configuration;
   }
 
   /**


[05/30] ambari git commit: AMBARI-22181 : Remove cluster-stackid dependency related to Configs (mradhakrishnan)

Posted by mr...@apache.org.
AMBARI-22181 : Remove cluster-stackid dependency related to Configs (mradhakrishnan)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: b0ff5da4606ae194390c20491a6d8b779c898820
Parents: a5d0f0c
Author: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Authored: Fri Oct 13 09:33:33 2017 -0700
Committer: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Committed: Fri Oct 13 09:33:33 2017 -0700

----------------------------------------------------------------------
 .../server/checks/AbstractCheckDescriptor.java  |  8 +--
 .../AmbariCustomCommandExecutionHelper.java     |  2 +-
 .../AmbariManagementControllerImpl.java         | 21 +++---
 .../controller/DeleteIdentityHandler.java       |  4 +-
 .../ambari/server/state/ConfigHelper.java       | 72 +++++++++++---------
 .../ambari/server/state/ConfigMergeHelper.java  |  4 +-
 .../ambari/server/state/UpgradeHelper.java      | 17 +++--
 .../server/state/cluster/ClusterImpl.java       |  7 +-
 8 files changed, 75 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
index 6726d30..ae23897 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
@@ -35,7 +35,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.DesiredConfig;
-import org.apache.ambari.server.state.ServiceInfo;
+import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.repository.ClusterVersionSummary;
 import org.apache.ambari.server.state.repository.VersionDefinitionXml;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
@@ -238,14 +238,12 @@ public abstract class AbstractCheckDescriptor {
         AmbariMetaInfo metaInfo = ambariMetaInfo.get();
 
         Cluster c = clusters.getCluster(request.getClusterName());
-        Map<String, ServiceInfo> services = metaInfo.getServices(
-            c.getDesiredStackVersion().getStackName(),
-            c.getDesiredStackVersion().getStackVersion());
+        Map<String, Service> services = c.getServices();
 
         LinkedHashSet<String> displays = new LinkedHashSet<>();
         for (String name : names) {
           if (services.containsKey(name)) {
-            displays.add(services.get(name).getDisplayName());
+            displays.add(services.get(name).getName());
           } else {
             displays.add(name);
           }

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/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 e12477e..ff35e80 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
@@ -1544,7 +1544,7 @@ public class AmbariCustomCommandExecutionHelper {
       }
 
       if (stackId == null) {
-        stackId = cluster.getDesiredStackVersion();
+        throw new AmbariException("StackId should not be null. Service " + serviceName + " should have a desiredStackId");
       }
 
       AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo();

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/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 28b5c28..58f1cbd 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
@@ -2401,7 +2401,11 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     HostEntity hostEntity = host.getHostEntity();
     Map<String, String> hostAttributes = gson.fromJson(hostEntity.getHostAttributes(), hostAttributesType);
     String osFamily = host.getOSFamilyFromHostAttributes(hostAttributes);
-
+    Map<String, Service> services = cluster.getServices();
+    Map<String, ServiceInfo> servicesMap = new HashMap<>();
+    for(String clusterServiceName : services.keySet() ){
+      servicesMap.put(clusterServiceName, ambariMetaInfo.getService(services.get(clusterServiceName)));
+    }
     StackId stackId = scHost.getServiceComponent().getDesiredStackId();
 
     ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
@@ -2411,7 +2415,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
       serviceName, componentName);
     StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(),
         stackId.getStackVersion());
-    Map<String, ServiceInfo> servicesMap = ambariMetaInfo.getServices(stackInfo.getName(), stackInfo.getVersion());
 
     ExecutionCommandWrapper execCmdWrapper = stage.getExecutionCommandWrapper(hostname, componentName);
     ExecutionCommand execCmd = execCmdWrapper.getExecutionCommand();
@@ -2445,12 +2448,14 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     // Propagate HCFS service type info
     for (Service service : cluster.getServices().values()) {
       ServiceInfo serviceInfoInstance = servicesMap.get(service.getName());
-      LOG.debug("Iterating service type Instance in createHostAction: {}", serviceInfoInstance.getName());
-      String serviceType = serviceInfoInstance.getServiceType();
-      if (serviceType != null) {
-        LOG.info("Adding service type info in createHostAction: {}", serviceType);
-        commandParams.put("dfs_type", serviceType);
-        break;
+      if(serviceInfoInstance != null){
+        LOG.debug("Iterating service type Instance in createHostAction: {}", serviceInfoInstance.getName());
+        String serviceType = serviceInfoInstance.getServiceType();
+        if (serviceType != null) {
+          LOG.info("Adding service type info in createHostAction: {}", serviceType);
+          commandParams.put("dfs_type", serviceType);
+          break;
+        }
       }
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java
index 29f8e2a..f5d51c3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java
@@ -47,6 +47,7 @@ import org.apache.ambari.server.serveraction.kerberos.KerberosOperationHandler;
 import org.apache.ambari.server.serveraction.kerberos.KerberosServerAction;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.kerberos.KerberosDescriptor;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostServerActionEvent;
@@ -263,7 +264,8 @@ class DeleteIdentityHandler {
 
     private Set<String> configTypesOfService(String serviceName) {
       try {
-        StackId stackId = getCluster().getCurrentStackVersion();
+        Service service = getCluster().getService(serviceName);
+        StackId stackId = service.getDesiredStackId();
         StackServiceRequest stackServiceRequest = new StackServiceRequest(stackId.getStackName(), stackId.getStackVersion(), serviceName);
         return AmbariServer.getController().getStackServices(singleton(stackServiceRequest)).stream()
           .findFirst()

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/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 58b0300..e89f3dc 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
@@ -684,24 +684,26 @@ public class ConfigHelper {
     }
 
     for (Service service : cluster.getServices().values()) {
-      Set<PropertyInfo> serviceProperties = new HashSet<>(servicesMap.get(service.getName()).getProperties());
-      for (PropertyInfo serviceProperty : serviceProperties) {
-        if (serviceProperty.getPropertyTypes().contains(propertyType)) {
-          String stackPropertyConfigType = fileNameToConfigType(serviceProperty.getFilename());
-          try {
-            String property = actualConfigs.get(stackPropertyConfigType).getProperties().get(serviceProperty.getName());
-            if (null == property){
-              LOG.error(String.format("Unable to obtain property values for %s with property attribute %s. "
-                  + "The property does not exist in version %s of %s configuration.",
-                serviceProperty.getName(),
-                propertyType,
-                desiredConfigs.get(stackPropertyConfigType),
-                stackPropertyConfigType
-              ));
-            } else {
-              result.put(serviceProperty, property);
+      if (servicesMap.containsKey(service.getName())) {
+        Set<PropertyInfo> serviceProperties = new HashSet<>(servicesMap.get(service.getName()).getProperties());
+        for (PropertyInfo serviceProperty : serviceProperties) {
+          if (serviceProperty.getPropertyTypes().contains(propertyType)) {
+            String stackPropertyConfigType = fileNameToConfigType(serviceProperty.getFilename());
+            try {
+              String property = actualConfigs.get(stackPropertyConfigType).getProperties().get(serviceProperty.getName());
+              if (null == property) {
+                LOG.error(String.format("Unable to obtain property values for %s with property attribute %s. "
+                                + "The property does not exist in version %s of %s configuration.",
+                        serviceProperty.getName(),
+                        propertyType,
+                        desiredConfigs.get(stackPropertyConfigType),
+                        stackPropertyConfigType
+                ));
+              } else {
+                result.put(serviceProperty, property);
+              }
+            } catch (Exception ignored) {
             }
-          } catch (Exception ignored) {
           }
         }
       }
@@ -763,24 +765,26 @@ public class ConfigHelper {
     }
 
     for (Service service : cluster.getServices().values()) {
-      Set<PropertyInfo> serviceProperties = new HashSet<>(servicesMap.get(service.getName()).getProperties());
-      for (PropertyInfo serviceProperty : serviceProperties) {
-        if (serviceProperty.getPropertyTypes().contains(propertyType)) {
-          String stackPropertyConfigType = fileNameToConfigType(serviceProperty.getFilename());
-          try {
-            String property = actualConfigs.get(stackPropertyConfigType).getProperties().get(serviceProperty.getName());
-            if (null == property){
-              LOG.error(String.format("Unable to obtain property values for %s with property attribute %s. "
-                  + "The property does not exist in version %s of %s configuration.",
-                  serviceProperty.getName(),
-                  propertyType,
-                  desiredConfigs.get(stackPropertyConfigType),
-                  stackPropertyConfigType
-                  ));
-            } else {
-              result.add(property);
+      if (servicesMap.containsKey(service.getName())) {
+        Set<PropertyInfo> serviceProperties = new HashSet<>(servicesMap.get(service.getName()).getProperties());
+        for (PropertyInfo serviceProperty : serviceProperties) {
+          if (serviceProperty.getPropertyTypes().contains(propertyType)) {
+            String stackPropertyConfigType = fileNameToConfigType(serviceProperty.getFilename());
+            try {
+              String property = actualConfigs.get(stackPropertyConfigType).getProperties().get(serviceProperty.getName());
+              if (null == property) {
+                LOG.error(String.format("Unable to obtain property values for %s with property attribute %s. "
+                                + "The property does not exist in version %s of %s configuration.",
+                        serviceProperty.getName(),
+                        propertyType,
+                        desiredConfigs.get(stackPropertyConfigType),
+                        stackPropertyConfigType
+                ));
+              } else {
+                result.add(property);
+              }
+            } catch (Exception ignored) {
             }
-          } catch (Exception ignored) {
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigMergeHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigMergeHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigMergeHelper.java
index cf55660..36918cc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigMergeHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigMergeHelper.java
@@ -53,13 +53,15 @@ public class ConfigMergeHelper {
   @SuppressWarnings("unchecked")
   public Map<String, Map<String, ThreeWayValue>> getConflicts(String clusterName, StackId targetStack) throws AmbariException {
     Cluster cluster = m_clusters.get().getCluster(clusterName);
-    StackId oldStack = cluster.getCurrentStackVersion();
+    StackId oldStack = null;
 
     Map<String, Map<String, String>> oldMap = new HashMap<>();
     Map<String, Map<String, String>> newMap = new HashMap<>();
 
     // Collect service-level properties for old and new stack
     for (String serviceName : cluster.getServices().keySet()) {
+      Service service = cluster.getService(serviceName);
+      oldStack = service.getDesiredStackId();
       Set<PropertyInfo> oldStackProperties = m_ambariMetaInfo.get().getServiceProperties(
           oldStack.getStackName(), oldStack.getStackVersion(), serviceName);
       addToMap(oldMap, oldStackProperties);

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
index 8f9d8e1..ebc82ee 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
@@ -219,8 +219,6 @@ public class UpgradeHelper {
    *          {@code Direction} of the upgrade
    * @param upgradeType
    *          The {@code UpgradeType}
-   * @param targetStackName
-   *          The destination target stack name.
    * @param preferredUpgradePackName
    *          For unit test, need to prefer an upgrade pack since multiple
    *          matches can be found.
@@ -805,18 +803,19 @@ public class UpgradeHelper {
   /**
    * Helper to set service and component display names on the context
    * @param context   the context to update
-   * @param service   the service name
+   * @param serviceName   the service name
    * @param component the component name
    */
-  private void setDisplayNames(UpgradeContext context, String service, String component) {
-    StackId stackId = context.getCluster().getDesiredStackVersion();
+  private void setDisplayNames(UpgradeContext context, String serviceName, String component) {
+    Cluster c = context.getCluster();
+
     try {
-      ServiceInfo serviceInfo = m_ambariMetaInfoProvider.get().getService(stackId.getStackName(),
-          stackId.getStackVersion(), service);
-      context.setServiceDisplay(service, serviceInfo.getDisplayName());
+      Service service = c.getService(serviceName);
+      ServiceInfo serviceInfo = m_ambariMetaInfoProvider.get().getService(service);
+      context.setServiceDisplay(serviceName, serviceInfo.getDisplayName());
 
       ComponentInfo compInfo = serviceInfo.getComponentByName(component);
-      context.setComponentDisplay(service, component, compInfo.getDisplayName());
+      context.setComponentDisplay(serviceName, component, compInfo.getDisplayName());
 
     } catch (AmbariException e) {
       LOG.debug("Could not get service detail", e);

http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 3bde889..fcc07b6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -97,6 +97,7 @@ import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.orm.entities.RequestScheduleEntity;
 import org.apache.ambari.server.orm.entities.ResourceEntity;
 import org.apache.ambari.server.orm.entities.ServiceConfigEntity;
+import org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity;
 import org.apache.ambari.server.orm.entities.ServiceGroupEntity;
 import org.apache.ambari.server.orm.entities.StackEntity;
 import org.apache.ambari.server.orm.entities.TopologyRequestEntity;
@@ -431,13 +432,17 @@ public class ClusterImpl implements Cluster {
     }
 
     for (ClusterServiceEntity serviceEntity : clusterEntity.getClusterServiceEntities()) {
-      StackId stackId = getCurrentStackVersion();
+      ServiceDesiredStateEntity serviceDesiredStateEntity = serviceEntity.getServiceDesiredStateEntity();
+      StackEntity stackEntity = serviceDesiredStateEntity.getDesiredStack();
+      StackId stackId = new StackId(stackEntity);
       try {
         if (ambariMetaInfo.getService(stackId.getStackName(),
           stackId.getStackVersion(), serviceEntity.getServiceName()) != null) {
           services.put(serviceEntity.getServiceName(),
             serviceFactory.createExisting(this, getServiceGroup(serviceEntity.getServiceGroupId()), serviceEntity));
+           stackId = getService(serviceEntity.getServiceName()).getDesiredStackId();
         }
+
       } catch (AmbariException e) {
         LOG.error(String.format(
           "Can not get service info: stackName=%s, stackVersion=%s, serviceName=%s",


[26/30] ambari git commit: AMBARI-22253. Add topology_configurations tabel to all sql scripts (magyari_sandor)

Posted by mr...@apache.org.
AMBARI-22253. Add topology_configurations tabel to all sql scripts (magyari_sandor)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: d8406d0be5f3c8e1c3aa3ebef762b107c51cff73
Parents: b0f5639
Author: Sandor Magyari <sm...@hortonworks.com>
Authored: Thu Oct 26 17:44:21 2017 +0200
Committer: Sandor Magyari <sm...@hortonworks.com>
Committed: Thu Oct 26 17:47:08 2017 +0200

----------------------------------------------------------------------
 .../internal/ClusterResourceProvider.java       |  2 +-
 .../internal/ProvisionClusterRequest.java       | 41 ++++++++++++++------
 .../server/topology/PersistedStateImpl.java     |  5 ++-
 .../main/resources/Ambari-DDL-Derby-CREATE.sql  | 12 ++++++
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  | 12 ++++++
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql | 12 ++++++
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  2 +-
 .../resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 12 ++++++
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   | 12 ++++++
 9 files changed, 95 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d8406d0b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
index 54c8360..ed80291 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
@@ -202,7 +202,7 @@ public class ClusterResourceProvider extends AbstractControllerResourceProvider
     baseUnsupported.remove("blueprint");
     baseUnsupported.remove("host_groups");
     baseUnsupported.remove("default_password");
-    baseUnsupported.remove("configurations");
+    baseUnsupported.remove("services");
     baseUnsupported.remove("credentials");
     baseUnsupported.remove("config_recommendation_strategy");
     baseUnsupported.remove("provision_action");

http://git-wip-us.apache.org/repos/asf/ambari/blob/d8406d0b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
index 0e1753b..f773fc8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
@@ -31,12 +31,16 @@ import org.apache.ambari.server.stack.NoSuchStackException;
 import org.apache.ambari.server.state.quicklinksprofile.QuickLinksProfileBuilder;
 import org.apache.ambari.server.state.quicklinksprofile.QuickLinksProfileEvaluationException;
 import org.apache.ambari.server.topology.ConfigRecommendationStrategy;
+import org.apache.ambari.server.topology.Configuration;
 import org.apache.ambari.server.topology.ConfigurationFactory;
 import org.apache.ambari.server.topology.Credential;
 import org.apache.ambari.server.topology.HostGroupInfo;
 import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
 import org.apache.ambari.server.topology.NoSuchBlueprintException;
 import org.apache.ambari.server.topology.SecurityConfiguration;
+import org.apache.ambari.server.topology.Service;
+import org.apache.ambari.server.topology.ServiceId;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -124,6 +128,8 @@ public class ProvisionClusterRequest extends BaseClusterRequest {
    * The service and component level quick link filters property
    */
   public static final String QUICKLINKS_PROFILE_SERVICES_PROPERTY = "quicklinks_profile/services";
+  public static final String SERVICE_GROUP_NAME_PROPERETY = "service_group";
+  public static final String SERVICE_NAME_PROPERTY = "name";
 
 
   /**
@@ -189,21 +195,34 @@ public class ProvisionClusterRequest extends BaseClusterRequest {
 
     this.securityConfiguration = securityConfiguration;
 
-    //TODO parse service configs and mereg with BP service configs
-//    Collection<Map<String, String>> services = properties.get(SERVICES_PROPERTY);
-//    Configuration configuration = configurationFactory.getConfiguration(
-//      (Collection<Map<String, String>>) properties.get(CONFIGURATIONS_PROPERTY));
-//    configuration.setParentConfiguration(blueprint.getConfiguration());
-//    setConfiguration(configuration);
-
-    //TODO load services, merge servie configs from Cluster template with service configs from Blueprint
+    // parse service configs and merge with BP service configs
     serviceConfigs = new ArrayList<>();
-
+    Collection<Map> services = (Collection<Map>) properties.get(SERVICES_PROPERTY);
+    for (Map serviceMap : services) {
+      String serviceName = (String) serviceMap.get(SERVICE_NAME_PROPERTY);
+      if (StringUtils.isEmpty(serviceName)) {
+        throw new InvalidTopologyTemplateException("Service name must be specified.");
+      }
+      String serviceGroupName = (String) serviceMap.get(SERVICE_GROUP_NAME_PROPERETY);
+      if (StringUtils.isEmpty(serviceGroupName)) {
+        throw new InvalidTopologyTemplateException("Service group name must be specified for service: " + serviceName);
+      }
+      Configuration configuration = configurationFactory.getConfiguration((Collection<Map<String, String>>)
+              serviceMap.get(CONFIGURATIONS_PROPERTY));
+      ServiceId serviceId = ServiceId.of(serviceName, serviceGroupName);
+      Service service = blueprint.getServiceById(serviceId);
+      if (service == null) {
+        throw new InvalidTopologyTemplateException("Service: " + serviceName + " in service group: "
+                + serviceGroupName + " not found.");
+      }
+      service.getConfiguration().setParentConfiguration(service.getStack().getConfiguration());
+      configuration.setParentConfiguration(service.getConfiguration());
+      service.setConfiguration(configuration);
+      serviceConfigs.add(service);
+    }
 
     parseHostGroupInfo(properties);
-
     this.credentialsMap = parseCredentials(properties);
-
     this.configRecommendationStrategy = parseConfigRecommendationStrategy(properties);
 
     setProvisionAction(parseProvisionAction(properties));

http://git-wip-us.apache.org/repos/asf/ambari/blob/d8406d0b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
index b18915c..3bfa644 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
@@ -414,11 +414,12 @@ public class PersistedStateImpl implements PersistedState {
                 && topologyConfigurationsEntity.getHostGroupName() == null))
               .forEach(topologyConfigurationsEntity -> {
 
-        ServiceId serviceId = ServiceId.of(topologyConfigurationsEntity.getServiceGroupName(),
-                topologyConfigurationsEntity.getServiceName());
+        ServiceId serviceId = ServiceId.of(topologyConfigurationsEntity.getServiceName(),
+                topologyConfigurationsEntity.getServiceGroupName());
         Service service = blueprint.getServiceById(serviceId);
         Configuration configuration = createConfiguration(topologyConfigurationsEntity.getConfigProperties(),
                 topologyConfigurationsEntity.getConfigAttributes());
+        service.getConfiguration().setParentConfiguration(service.getStack().getConfiguration());
         configuration.setParentConfiguration(service.getConfiguration());
 
         service.setConfiguration(configuration);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d8406d0b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
index 0d82cd4..ff0c587 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -766,6 +766,18 @@ CREATE TABLE topology_request (
   CONSTRAINT PK_topology_request PRIMARY KEY (id),
   CONSTRAINT FK_topology_request_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id));
 
+CREATE TABLE topology_configurations (
+  id BIGINT NOT NULL,
+  request_id BIGINT NOT NULL,
+  service_group_name VARCHAR(100) NOT NULL,
+  service_name VARCHAR(100) NOT NULL,
+  component_name VARCHAR(100),
+  host_group_name VARCHAR(100),
+  cluster_properties VARCHAR(3000),
+  cluster_attributes VARCHAR(3000),
+  CONSTRAINT PK_topology_configurations PRIMARY KEY (id),
+  CONSTRAINT FK_hostgroup_req_id FOREIGN KEY (request_id) REFERENCES topology_request(id));
+
 CREATE TABLE topology_hostgroup (
   id BIGINT NOT NULL,
   name VARCHAR(255) NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/d8406d0b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index d70d853..cbe0f97 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -782,6 +782,18 @@ CREATE TABLE topology_request (
   CONSTRAINT PK_topology_request PRIMARY KEY (id),
   CONSTRAINT FK_topology_request_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id));
 
+CREATE TABLE topology_configurations (
+  id BIGINT NOT NULL,
+  request_id BIGINT NOT NULL,
+  service_group_name VARCHAR(100) NOT NULL,
+  service_name VARCHAR(100) NOT NULL,
+  component_name VARCHAR(100),
+  host_group_name VARCHAR(100),
+  cluster_properties LONGTEXT,
+  cluster_attributes LONGTEXT,
+  CONSTRAINT PK_topology_configurations PRIMARY KEY (id),
+  CONSTRAINT FK_hostgroup_req_id FOREIGN KEY (request_id) REFERENCES topology_request(id));
+
 CREATE TABLE topology_hostgroup (
   id BIGINT NOT NULL,
   name VARCHAR(255) NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/d8406d0b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 54e890d..d0fffeb 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -763,6 +763,18 @@ CREATE TABLE topology_request (
   CONSTRAINT PK_topology_request PRIMARY KEY (id),
   CONSTRAINT FK_topology_request_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id));
 
+CREATE TABLE topology_configurations (
+  id NUMBER(19) NOT NULL,
+  request_id NUMBER(19) NOT NULL,
+  service_group_name VARCHAR(100) NOT NULL,
+  service_name VARCHAR(100) NOT NULL,
+  component_name VARCHAR(100),
+  host_group_name VARCHAR(100),
+  cluster_properties CLOB,
+  cluster_attributes CLOB,
+  CONSTRAINT PK_topology_configurations PRIMARY KEY (id),
+  CONSTRAINT FK_hostgroup_req_id FOREIGN KEY (request_id) REFERENCES topology_request(id));
+
 CREATE TABLE topology_hostgroup (
   id NUMBER(19) NOT NULL,
   name VARCHAR(255) NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/d8406d0b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 437756a..2f91323 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -39,7 +39,7 @@ CREATE TABLE stack (
   stack_id BIGINT NOT NULL,
   stack_name VARCHAR(255) NOT NULL,
   stack_version VARCHAR(255) NOT NULL,
-  repo_version VARCHAR(255) NOT NULL,
+  repo_version VARCHAR(255),
   current_mpack_id BIGINT,
   CONSTRAINT PK_stack PRIMARY KEY (stack_id),
   CONSTRAINT FK_mpacks FOREIGN KEY (current_mpack_id) REFERENCES mpacks(id),

http://git-wip-us.apache.org/repos/asf/ambari/blob/d8406d0b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index 74e3e69..ceb269e 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -761,6 +761,18 @@ CREATE TABLE topology_request (
   CONSTRAINT PK_topology_request PRIMARY KEY (id),
   CONSTRAINT FK_topology_request_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id));
 
+CREATE TABLE topology_configurations (
+  id NUMERIC(19) NOT NULL,
+  request_id NUMERIC(19) NOT NULL,
+  service_group_name VARCHAR(100) NOT NULL,
+  service_name VARCHAR(100) NOT NULL,
+  component_name VARCHAR(100),
+  host_group_name VARCHAR(100),
+  cluster_properties TEXT,
+  cluster_attributes TEXT,
+  CONSTRAINT PK_topology_configurations PRIMARY KEY (id),
+  CONSTRAINT FK_hostgroup_req_id FOREIGN KEY (request_id) REFERENCES topology_request(id));
+
 CREATE TABLE topology_hostgroup (
   id NUMERIC(19) NOT NULL,
   name VARCHAR(255) NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/d8406d0b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index cffe53d..cc86d50 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -782,6 +782,18 @@ CREATE TABLE topology_request (
   CONSTRAINT PK_topology_request PRIMARY KEY CLUSTERED (id),
   CONSTRAINT FK_topology_request_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id));
 
+CREATE TABLE topology_configurations (
+  id BIGINT NOT NULL,
+  request_id BIGINT NOT NULL,
+  service_group_name VARCHAR(100) NOT NULL,
+  service_name VARCHAR(100) NOT NULL,
+  component_name VARCHAR(100),
+  host_group_name VARCHAR(100),
+  cluster_properties TEXT,
+  cluster_attributes TEXT,
+  CONSTRAINT PK_topology_configurations PRIMARY KEY CLUSTERED(id),
+  CONSTRAINT FK_hostgroup_req_id FOREIGN KEY (request_id) REFERENCES topology_request(id));
+
 CREATE TABLE topology_hostgroup (
   id BIGINT NOT NULL,
   name VARCHAR(255) NOT NULL,


[21/30] ambari git commit: AMBARI-22297 Enrich deserialized v2 blueprint (benyoka)

Posted by mr...@apache.org.
AMBARI-22297 Enrich deserialized v2 blueprint (benyoka)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: acab46dc626d7eef9fdf610c8379b34645bcd758
Parents: f50d9a2
Author: Balazs Bence Sari <be...@apache.org>
Authored: Tue Oct 24 13:52:46 2017 +0200
Committer: Balazs Bence Sari <be...@apache.org>
Committed: Tue Oct 24 13:52:46 2017 +0200

----------------------------------------------------------------------
 .../StackAdvisorBlueprintProcessor.java         |    2 +-
 .../ambari/server/controller/StackV2.java       | 1029 +++++++++---------
 .../ambari/server/topology/BlueprintImplV2.java |  211 ++--
 .../ambari/server/topology/BlueprintV2.java     |    8 +-
 .../server/topology/BlueprintV2Factory.java     |    2 +
 .../ambari/server/topology/ComponentV2.java     |    9 +-
 .../ambari/server/topology/HostGroupV2.java     |    9 +-
 .../ambari/server/topology/HostGroupV2Impl.java |   37 +-
 .../apache/ambari/server/topology/Service.java  |   58 +-
 .../ambari/server/topology/ServiceGroup.java    |   28 +-
 .../ambari/server/topology/ServiceId.java       |   10 +
 .../apache/ambari/server/topology/Setting.java  |   18 +-
 .../validators/BlueprintImplV2Test.java         |   11 +
 .../test/resources/blueprintv2/blueprintv2.json |   24 +-
 14 files changed, 800 insertions(+), 656 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
index 2e9ac9f..9bbdc37 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
@@ -117,7 +117,7 @@ public class StackAdvisorBlueprintProcessor {
 
   private Map<String, Set<String>> gatherHostGroupComponents(ClusterTopology clusterTopology) {
     Map<String, Set<String>> hgComponentsMap = Maps.newHashMap();
-    for (Map.Entry<String, HostGroupV2> hgEnrty: clusterTopology.getBlueprint().getHostGroups().entrySet()) {
+    for (Map.Entry<String, ? extends HostGroupV2> hgEnrty: clusterTopology.getBlueprint().getHostGroups().entrySet()) {
       hgComponentsMap.put(hgEnrty.getKey(), Sets.newCopyOnWriteArraySet(hgEnrty.getValue().getComponentNames()));
     }
     return hgComponentsMap;

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
index 169bf6a..040e604 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
@@ -7,7 +7,7 @@
  * "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
+ *   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,
@@ -30,6 +30,7 @@ import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.DependencyInfo;
 import org.apache.ambari.server.state.PropertyDependencyInfo;
 import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.ValueAttributesInfo;
 import org.apache.ambari.server.topology.Cardinality;
 import org.apache.ambari.server.topology.Configuration;
@@ -39,568 +40,572 @@ import org.apache.ambari.server.topology.Configuration;
  */
 public class StackV2 {
 
-    /** Stack name */
-    private final String name;
-
-    /** Stack version */
-    private final String version;
-
-    /** Repo version */
-    private final String repoVersion;
-
-    /** Map of service name to components */
-    private final Map<String, Collection<String>> serviceComponents;
-
-    /** Map of component to service */
-    private final Map<String, String> componentService;
-
-    /** Map of component to dependencies */
-    private final Map<String, Collection<DependencyInfo>> dependencies;
-
-    /** Map of dependency to conditional service */
-    private final Map<DependencyInfo, String> dependencyConditionalServiceMap;
-
-    /**
-     * Map of database component name to configuration property which indicates whether
-     * the database in to be managed or if it is an external non-managed instance.
-     * If the value of the config property starts with 'New', the database is determined
-     * to be managed, otherwise it is non-managed.
-     */
-    private final Map<String, String> dbDependencyInfo;
-
-    /** Map of component to required cardinality */
-    private final Map<String, String> cardinalityRequirements = new HashMap<>();
-
-    //todo: instead of all these maps from component -> * ,
-    //todo: we should use a Component object with all of these attributes
-    private Set<String> masterComponents = new HashSet<>();
-
-    /** Map of component to auto-deploy information */
-    private final Map<String, AutoDeployInfo> componentAutoDeployInfo;
-
-    /** Map of service to config type properties */
-    private final Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations;
-
-    /** Map of service to required type properties */
-    private final Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations;
-
-    /** Map of service to config type properties */
-    private final Map<String, Map<String, ConfigProperty>> stackConfigurations;
-
-    /** Map of service to set of excluded config types */
-    private final Map<String, Set<String>> excludedConfigurationTypes;
-
-    public StackV2(String name,
-                   String version,
-                   String repoVersion,
-                   Map<String, Collection<String>> serviceComponents,
-                   Map<String, Collection<DependencyInfo>> dependencies,
-                   Map<String, String> dbDependencyInfo,
-                   Map<String, AutoDeployInfo> componentAutoDeployInfo,
-                   Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations,
-                   Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations,
-                   Map<String, Map<String, ConfigProperty>> stackConfigurations,
-                   Map<String, Set<String>> excludedConfigurationTypes) {
-        this.name = name;
-        this.version = version;
-        this.repoVersion = repoVersion;
-
-        this.serviceComponents = serviceComponents;
-        this.componentService = new HashMap<>();
-        for (Map.Entry<String, Collection<String>> entry: serviceComponents.entrySet()) {
-            for (String comp: entry.getValue()) {
-                componentService.put(comp, entry.getKey());
-            }
-        }
-
-        this.dependencies = dependencies;
-        this.dependencyConditionalServiceMap = new HashMap<>();
-        for (Map.Entry<String, Collection<DependencyInfo>> entry: dependencies.entrySet()) {
-            for (DependencyInfo di: entry.getValue()) {
-                dependencyConditionalServiceMap.put(di, entry.getKey());
-            }
-        }
-
-        this.dbDependencyInfo = dbDependencyInfo;
-        this.componentAutoDeployInfo = componentAutoDeployInfo;
-        this.serviceConfigurations = serviceConfigurations;
-        this.requiredServiceConfigurations = requiredServiceConfigurations;
-        this.stackConfigurations = stackConfigurations;
-        this.excludedConfigurationTypes = excludedConfigurationTypes;
-    }
-
-    /** @return stack name */
-    public String getName() {
-        return name;
-    }
-
-    /** @return stack version */
-    public String getVersion() {
-        return version;
-    }
-
-    /** @return repo version */
-    public String getRepoVersion() { return repoVersion; }
-
-    Map<DependencyInfo, String> getDependencyConditionalServiceMap() {
-        return dependencyConditionalServiceMap;
-    }
-
-    /** @return collection of all services for the stack */
-    public Collection<String> getServices() {
-        return serviceComponents.keySet();
-    }
-
-    /**
-     * Get components contained in the stack for the specified service.
-     *
-     * @param service  service name
-     * @return collection of component names for the specified service
-     */
-    public Collection<String> getComponents(String service) {
-        return serviceComponents.get(service);
-    }
-
-    /** @return map of service to associated components */
-    public Map<String, Collection<String>> getComponents() {
-        return serviceComponents;
+  /** Stack name */
+  private final String name;
+
+  /** Stack version */
+  private final String version;
+
+  /** Repo version */
+  private final String repoVersion;
+
+  /** Map of service name to components */
+  private final Map<String, Collection<String>> serviceComponents;
+
+  /** Map of component to service */
+  private final Map<String, String> componentService;
+
+  /** Map of component to dependencies */
+  private final Map<String, Collection<DependencyInfo>> dependencies;
+
+  /** Map of dependency to conditional service */
+  private final Map<DependencyInfo, String> dependencyConditionalServiceMap;
+
+  /**
+   * Map of database component name to configuration property which indicates whether
+   * the database in to be managed or if it is an external non-managed instance.
+   * If the value of the config property starts with 'New', the database is determined
+   * to be managed, otherwise it is non-managed.
+   */
+  private final Map<String, String> dbDependencyInfo;
+
+  /** Map of component to required cardinality */
+  private final Map<String, String> cardinalityRequirements = new HashMap<>();
+
+  //todo: instead of all these maps from component -> * ,
+  //todo: we should use a Component object with all of these attributes
+  private Set<String> masterComponents = new HashSet<>();
+
+  /** Map of component to auto-deploy information */
+  private final Map<String, AutoDeployInfo> componentAutoDeployInfo;
+
+  /** Map of service to config type properties */
+  private final Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations;
+
+  /** Map of service to required type properties */
+  private final Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations;
+
+  /** Map of service to config type properties */
+  private final Map<String, Map<String, ConfigProperty>> stackConfigurations;
+
+  /** Map of service to set of excluded config types */
+  private final Map<String, Set<String>> excludedConfigurationTypes;
+
+  public StackV2(String name,
+           String version,
+           String repoVersion,
+           Map<String, Collection<String>> serviceComponents,
+           Map<String, Collection<DependencyInfo>> dependencies,
+           Map<String, String> dbDependencyInfo,
+           Map<String, AutoDeployInfo> componentAutoDeployInfo,
+           Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations,
+           Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations,
+           Map<String, Map<String, ConfigProperty>> stackConfigurations,
+           Map<String, Set<String>> excludedConfigurationTypes) {
+    this.name = name;
+    this.version = version;
+    this.repoVersion = repoVersion;
+
+    this.serviceComponents = serviceComponents;
+    this.componentService = new HashMap<>();
+    for (Map.Entry<String, Collection<String>> entry: serviceComponents.entrySet()) {
+      for (String comp: entry.getValue()) {
+        componentService.put(comp, entry.getKey());
+      }
     }
 
-      /**
-       * Get info for the specified component.
-       *
-       * @param component  component name
-       *
-       * @return component information for the requested component
-       *         or null if the component doesn't exist in the stack
-       */
-      @Deprecated
-      public ComponentInfo getComponentInfo(String component) {
-        ComponentInfo componentInfo = null;
-//        String service = getServiceForComponent(component);
-//        if (service != null) {
-//          try {
-//            componentInfo = controller.getAmbariMetaInfo().getComponent(
-//                getName(), getVersion(), service, component);
-//          } catch (AmbariException e) {
-//            // just return null if component doesn't exist
-//          }
-//        }
-        return componentInfo;
+    this.dependencies = dependencies;
+    this.dependencyConditionalServiceMap = new HashMap<>();
+    for (Map.Entry<String, Collection<DependencyInfo>> entry: dependencies.entrySet()) {
+      for (DependencyInfo di: entry.getValue()) {
+        dependencyConditionalServiceMap.put(di, entry.getKey());
       }
-
-    /**
-     * Get all configuration types, including excluded types for the specified service.
-     *
-     * @param service  service name
-     *
-     * @return collection of all configuration types for the specified service
-     */
-    public Collection<String> getAllConfigurationTypes(String service) {
-        return serviceConfigurations.get(service).keySet();
     }
 
-    /**
-     * Get configuration types for the specified service.
-     * This doesn't include any service excluded types.
-     *
-     * @param service  service name
-     *
-     * @return collection of all configuration types for the specified service
-     */
-    public Collection<String> getConfigurationTypes(String service) {
-        Set<String> serviceTypes = new HashSet<>(serviceConfigurations.get(service).keySet());
-        serviceTypes.removeAll(getExcludedConfigurationTypes(service));
-        return serviceTypes;
-    }
+    this.dbDependencyInfo = dbDependencyInfo;
+    this.componentAutoDeployInfo = componentAutoDeployInfo;
+    this.serviceConfigurations = serviceConfigurations;
+    this.requiredServiceConfigurations = requiredServiceConfigurations;
+    this.stackConfigurations = stackConfigurations;
+    this.excludedConfigurationTypes = excludedConfigurationTypes;
+  }
+
+  /** @return stack name */
+  public String getName() {
+    return name;
+  }
+
+  /** @return stack version */
+  public String getVersion() {
+    return version;
+  }
+
+  public StackId getStackId() {
+    return new StackId(name, version);
+  }
+
+  /** @return repo version */
+  public String getRepoVersion() { return repoVersion; }
+
+  Map<DependencyInfo, String> getDependencyConditionalServiceMap() {
+    return dependencyConditionalServiceMap;
+  }
+
+  /** @return collection of all services for the stack */
+  public Collection<String> getServices() {
+    return serviceComponents.keySet();
+  }
+
+  /**
+   * Get components contained in the stack for the specified service.
+   *
+   * @param service  service name
+   * @return collection of component names for the specified service
+   */
+  public Collection<String> getComponents(String service) {
+    return serviceComponents.get(service);
+  }
+
+  /** @return map of service to associated components */
+  public Map<String, Collection<String>> getComponents() {
+    return serviceComponents;
+  }
 
     /**
-     * Get the set of excluded configuration types for this service.
+     * Get info for the specified component.
      *
-     * @param service service name
+     * @param component  component name
      *
-     * @return Set of names of excluded config types. Will not return null.
+     * @return component information for the requested component
+     *     or null if the component doesn't exist in the stack
      */
-    public Set<String> getExcludedConfigurationTypes(String service) {
-        return excludedConfigurationTypes.containsKey(service) ?
-                excludedConfigurationTypes.get(service) :
-                Collections.emptySet();
+    @Deprecated
+    public ComponentInfo getComponentInfo(String component) {
+    ComponentInfo componentInfo = null;
+//    String service = getServiceForComponent(component);
+//    if (service != null) {
+//      try {
+//      componentInfo = controller.getAmbariMetaInfo().getComponent(
+//        getName(), getVersion(), service, component);
+//      } catch (AmbariException e) {
+//      // just return null if component doesn't exist
+//      }
+//    }
+    return componentInfo;
+    }
+
+  /**
+   * Get all configuration types, including excluded types for the specified service.
+   *
+   * @param service  service name
+   *
+   * @return collection of all configuration types for the specified service
+   */
+  public Collection<String> getAllConfigurationTypes(String service) {
+    return serviceConfigurations.get(service).keySet();
+  }
+
+  /**
+   * Get configuration types for the specified service.
+   * This doesn't include any service excluded types.
+   *
+   * @param service  service name
+   *
+   * @return collection of all configuration types for the specified service
+   */
+  public Collection<String> getConfigurationTypes(String service) {
+    Set<String> serviceTypes = new HashSet<>(serviceConfigurations.get(service).keySet());
+    serviceTypes.removeAll(getExcludedConfigurationTypes(service));
+    return serviceTypes;
+  }
+
+  /**
+   * Get the set of excluded configuration types for this service.
+   *
+   * @param service service name
+   *
+   * @return Set of names of excluded config types. Will not return null.
+   */
+  public Set<String> getExcludedConfigurationTypes(String service) {
+    return excludedConfigurationTypes.containsKey(service) ?
+        excludedConfigurationTypes.get(service) :
+        Collections.emptySet();
+  }
+
+  /**
+   * Get config properties for the specified service and configuration type.
+   *
+   * @param service  service name
+   * @param type   configuration type
+   *
+   * @return map of property names to values for the specified service and configuration type
+   */
+  public Map<String, String> getConfigurationProperties(String service, String type) {
+    Map<String, String> configMap = new HashMap<>();
+    Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
+    if (configProperties != null) {
+      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+        configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
+      }
     }
-
-    /**
-     * Get config properties for the specified service and configuration type.
-     *
-     * @param service  service name
-     * @param type     configuration type
-     *
-     * @return map of property names to values for the specified service and configuration type
-     */
-    public Map<String, String> getConfigurationProperties(String service, String type) {
-        Map<String, String> configMap = new HashMap<>();
-        Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
-        if (configProperties != null) {
-            for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-                configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
-            }
+    return configMap;
+  }
+
+  public Map<String, ConfigProperty> getConfigurationPropertiesWithMetadata(String service, String type) {
+    return serviceConfigurations.get(service).get(type);
+  }
+
+  /**
+   * Get all required config properties for the specified service.
+   *
+   * @param service  service name
+   *
+   * @return collection of all required properties for the given service
+   */
+  public Collection<ConfigProperty> getRequiredConfigurationProperties(String service) {
+    Collection<ConfigProperty> requiredConfigProperties = new HashSet<>();
+    Map<String, Map<String, ConfigProperty>> serviceProperties = requiredServiceConfigurations.get(service);
+    if (serviceProperties != null) {
+      for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : serviceProperties.entrySet()) {
+        requiredConfigProperties.addAll(typePropertiesEntry.getValue().values());
+      }
+    }
+    return requiredConfigProperties;
+  }
+
+  /**
+   * Get required config properties for the specified service which belong to the specified property type.
+   *
+   * @param service     service name
+   * @param propertyType  property type
+   *
+   * @return collection of required properties for the given service and property type
+   */
+  public Collection<ConfigProperty> getRequiredConfigurationProperties(String service, PropertyInfo.PropertyType propertyType) {
+    Collection<ConfigProperty> matchingProperties = new HashSet<>();
+    Map<String, Map<String, ConfigProperty>> requiredProperties = requiredServiceConfigurations.get(service);
+    if (requiredProperties != null) {
+      for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : requiredProperties.entrySet()) {
+        for (ConfigProperty configProperty : typePropertiesEntry.getValue().values()) {
+          if (configProperty.getPropertyTypes().contains(propertyType)) {
+            matchingProperties.add(configProperty);
+          }
         }
-        return configMap;
+      }
     }
-
-    public Map<String, ConfigProperty> getConfigurationPropertiesWithMetadata(String service, String type) {
-        return serviceConfigurations.get(service).get(type);
+    return matchingProperties;
+  }
+
+  public boolean isPasswordProperty(String service, String type, String propertyName) {
+    return (serviceConfigurations.containsKey(service) &&
+        serviceConfigurations.get(service).containsKey(type) &&
+        serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
+        serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
+            contains(PropertyInfo.PropertyType.PASSWORD));
+  }
+
+  //todo
+  public Map<String, String> getStackConfigurationProperties(String type) {
+    Map<String, String> configMap = new HashMap<>();
+    Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
+    if (configProperties != null) {
+      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+        configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
+      }
     }
-
-    /**
-     * Get all required config properties for the specified service.
-     *
-     * @param service  service name
-     *
-     * @return collection of all required properties for the given service
-     */
-    public Collection<ConfigProperty> getRequiredConfigurationProperties(String service) {
-        Collection<ConfigProperty> requiredConfigProperties = new HashSet<>();
-        Map<String, Map<String, ConfigProperty>> serviceProperties = requiredServiceConfigurations.get(service);
-        if (serviceProperties != null) {
-            for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : serviceProperties.entrySet()) {
-                requiredConfigProperties.addAll(typePropertiesEntry.getValue().values());
+    return configMap;
+  }
+
+  public boolean isKerberosPrincipalNameProperty(String service, String type, String propertyName) {
+    return (serviceConfigurations.containsKey(service) &&
+        serviceConfigurations.get(service).containsKey(type) &&
+        serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
+        serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
+            contains(PropertyInfo.PropertyType.KERBEROS_PRINCIPAL));
+  }
+  /**
+   * Get config attributes for the specified service and configuration type.
+   *
+   * @param service  service name
+   * @param type   configuration type
+   *
+   * @return  map of attribute names to map of property names to attribute values
+   *      for the specified service and configuration type
+   */
+  public Map<String, Map<String, String>> getConfigurationAttributes(String service, String type) {
+    Map<String, Map<String, String>> attributesMap = new HashMap<>();
+    Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
+    if (configProperties != null) {
+      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+        String propertyName = configProperty.getKey();
+        Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
+        if (propertyAttributes != null) {
+          for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
+            String attributeName = propertyAttribute.getKey();
+            String attributeValue = propertyAttribute.getValue();
+            if (attributeValue != null) {
+              Map<String, String> attributes = getWithEmptyDefault(attributesMap, attributeName);
+              attributes.put(propertyName, attributeValue);
             }
+          }
         }
-        return requiredConfigProperties;
+      }
     }
-
-    /**
-     * Get required config properties for the specified service which belong to the specified property type.
-     *
-     * @param service       service name
-     * @param propertyType  property type
-     *
-     * @return collection of required properties for the given service and property type
-     */
-    public Collection<ConfigProperty> getRequiredConfigurationProperties(String service, PropertyInfo.PropertyType propertyType) {
-        Collection<ConfigProperty> matchingProperties = new HashSet<>();
-        Map<String, Map<String, ConfigProperty>> requiredProperties = requiredServiceConfigurations.get(service);
-        if (requiredProperties != null) {
-            for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : requiredProperties.entrySet()) {
-                for (ConfigProperty configProperty : typePropertiesEntry.getValue().values()) {
-                    if (configProperty.getPropertyTypes().contains(propertyType)) {
-                        matchingProperties.add(configProperty);
-                    }
-                }
-            }
+    return attributesMap;
+  }
+
+  //todo:
+  public Map<String, Map<String, String>> getStackConfigurationAttributes(String type) {
+    Map<String, Map<String, String>> attributesMap = new HashMap<>();
+    Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
+    if (configProperties != null) {
+      for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
+        String propertyName = configProperty.getKey();
+        Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
+        if (propertyAttributes != null) {
+          for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
+            String attributeName = propertyAttribute.getKey();
+            String attributeValue = propertyAttribute.getValue();
+            Map<String, String> attributes = getWithEmptyDefault(attributesMap, attributeName);
+            attributes.put(propertyName, attributeValue);
+          }
         }
-        return matchingProperties;
+      }
     }
-
-    public boolean isPasswordProperty(String service, String type, String propertyName) {
-        return (serviceConfigurations.containsKey(service) &&
-                serviceConfigurations.get(service).containsKey(type) &&
-                serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
-                serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
-                        contains(PropertyInfo.PropertyType.PASSWORD));
+    return attributesMap;
+  }
+
+  /**
+   * Get the service for the specified component.
+   *
+   * @param component  component name
+   *
+   * @return service name that contains tha specified component
+   */
+  public String getServiceForComponent(String component) {
+    return componentService.get(component);
+  }
+
+  /**
+   * Get the names of the services which contains the specified components.
+   *
+   * @param components collection of components
+   *
+   * @return collection of services which contain the specified components
+   */
+  public Collection<String> getServicesForComponents(Collection<String> components) {
+    Set<String> services = new HashSet<>();
+    for (String component : components) {
+      services.add(getServiceForComponent(component));
+    }
+
+    return services;
+  }
+
+  /**
+   * Obtain the service name which corresponds to the specified configuration.
+   *
+   * @param config  configuration type
+   *
+   * @return name of service which corresponds to the specified configuration type
+   */
+  public String getServiceForConfigType(String config) {
+    for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) {
+      Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue();
+      String serviceName = entry.getKey();
+      if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) {
+        return serviceName;
+      }
     }
-
-    //todo
-    public Map<String, String> getStackConfigurationProperties(String type) {
-        Map<String, String> configMap = new HashMap<>();
-        Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
-        if (configProperties != null) {
-            for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-                configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
-            }
+    throw new IllegalArgumentException(
+        "Specified configuration type is not associated with any service: " + config);
+  }
+
+  /**
+   * Return the dependencies specified for the given component.
+   *
+   * @param component  component to get dependency information for
+   *
+   * @return collection of dependency information for the specified component
+   */
+  //todo: full dependency graph
+  public Collection<DependencyInfo> getDependenciesForComponent(String component) {
+    return dependencies.containsKey(component) ? dependencies.get(component) :
+        Collections.emptySet();
+  }
+
+  /**
+   * Get the service, if any, that a component dependency is conditional on.
+   *
+   * @param dependency  dependency to get conditional service for
+   *
+   * @return conditional service for provided component or null if dependency
+   *     is not conditional on a service
+   */
+  public String getConditionalServiceForDependency(DependencyInfo dependency) {
+    return dependencyConditionalServiceMap.get(dependency);
+  }
+
+  public String getExternalComponentConfig(String component) {
+    return dbDependencyInfo.get(component);
+  }
+
+  /**
+   * Obtain the required cardinality for the specified component.
+   */
+  public Cardinality getCardinality(String component) {
+    return new Cardinality(cardinalityRequirements.get(component));
+  }
+
+  /**
+   * Obtain auto-deploy information for the specified component.
+   */
+  public AutoDeployInfo getAutoDeployInfo(String component) {
+    return componentAutoDeployInfo.get(component);
+  }
+
+  public boolean isMasterComponent(String component) {
+    return masterComponents.contains(component);
+  }
+
+  public Configuration getConfiguration(Collection<String> services) {
+    Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>();
+    Map<String, Map<String, String>> properties = new HashMap<>();
+
+    for (String service : services) {
+      Collection<String> serviceConfigTypes = getConfigurationTypes(service);
+      for (String type : serviceConfigTypes) {
+        Map<String, String> typeProps = getWithEmptyDefault(properties, type);
+        typeProps.putAll(getConfigurationProperties(service, type));
+
+        Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
+        if (!stackTypeAttributes.isEmpty()) {
+          if (! attributes.containsKey(type)) {
+            attributes.put(type, new HashMap<>());
+          }
+          Map<String, Map<String, String>> typeAttributes = attributes.get(type);
+          for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
+            String attributeName = attribute.getKey();
+            Map<String, String> attributeProps = getWithEmptyDefault(typeAttributes, attributeName);
+            attributeProps.putAll(attribute.getValue());
+          }
         }
-        return configMap;
-    }
-
-    public boolean isKerberosPrincipalNameProperty(String service, String type, String propertyName) {
-        return (serviceConfigurations.containsKey(service) &&
-                serviceConfigurations.get(service).containsKey(type) &&
-                serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
-                serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
-                        contains(PropertyInfo.PropertyType.KERBEROS_PRINCIPAL));
+      }
     }
-    /**
-     * Get config attributes for the specified service and configuration type.
-     *
-     * @param service  service name
-     * @param type     configuration type
-     *
-     * @return  map of attribute names to map of property names to attribute values
-     *          for the specified service and configuration type
-     */
-    public Map<String, Map<String, String>> getConfigurationAttributes(String service, String type) {
-        Map<String, Map<String, String>> attributesMap = new HashMap<>();
-        Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
-        if (configProperties != null) {
-            for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-                String propertyName = configProperty.getKey();
-                Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
-                if (propertyAttributes != null) {
-                    for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
-                        String attributeName = propertyAttribute.getKey();
-                        String attributeValue = propertyAttribute.getValue();
-                        if (attributeValue != null) {
-                            Map<String, String> attributes = getWithEmptyDefault(attributesMap, attributeName);
-                            attributes.put(propertyName, attributeValue);
-                        }
-                    }
-                }
-            }
+    return new Configuration(properties, attributes);
+  }
+
+  public Configuration getConfiguration() {
+    Map<String, Map<String, Map<String, String>>> stackAttributes = new HashMap<>();
+    Map<String, Map<String, String>> stackConfigs = new HashMap<>();
+
+    for (String service : getServices()) {
+      for (String type : getAllConfigurationTypes(service)) {
+        Map<String, String> typeProps = getWithEmptyDefault(stackConfigs, type);
+        typeProps.putAll(getConfigurationProperties(service, type));
+
+        Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
+        if (!stackTypeAttributes.isEmpty()) {
+          if (! stackAttributes.containsKey(type)) {
+            stackAttributes.put(type, new HashMap<>());
+          }
+          Map<String, Map<String, String>> typeAttrs = stackAttributes.get(type);
+          for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
+            String attributeName = attribute.getKey();
+            Map<String, String> attributes = getWithEmptyDefault(typeAttrs, attributeName);
+            attributes.putAll(attribute.getValue());
+          }
         }
-        return attributesMap;
+      }
     }
+    return new Configuration(stackConfigs, stackAttributes);
+  }
 
-    //todo:
-    public Map<String, Map<String, String>> getStackConfigurationAttributes(String type) {
-        Map<String, Map<String, String>> attributesMap = new HashMap<>();
-        Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
-        if (configProperties != null) {
-            for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
-                String propertyName = configProperty.getKey();
-                Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
-                if (propertyAttributes != null) {
-                    for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
-                        String attributeName = propertyAttribute.getKey();
-                        String attributeValue = propertyAttribute.getValue();
-                        Map<String, String> attributes = getWithEmptyDefault(attributesMap, attributeName);
-                        attributes.put(propertyName, attributeValue);
-                    }
-                }
-            }
-        }
-        return attributesMap;
+  static <OK, IK, IV> Map<IK, IV> getWithEmptyDefault(Map<OK, Map<IK, IV>> outerMap, OK outerKey) {
+    Map<IK, IV> innerMap = outerMap.get(outerKey);
+    if (null == innerMap) {
+      innerMap = new HashMap<>();
+      outerMap.put(outerKey, innerMap);
     }
+    return innerMap;
+  }
 
-    /**
-     * Get the service for the specified component.
-     *
-     * @param component  component name
-     *
-     * @return service name that contains tha specified component
-     */
-    public String getServiceForComponent(String component) {
-        return componentService.get(component);
-    }
 
-    /**
-     * Get the names of the services which contains the specified components.
-     *
-     * @param components collection of components
-     *
-     * @return collection of services which contain the specified components
-     */
-    public Collection<String> getServicesForComponents(Collection<String> components) {
-        Set<String> services = new HashSet<>();
-        for (String component : components) {
-            services.add(getServiceForComponent(component));
-        }
+  /**
+   * Contains a configuration property's value and attributes.
+   */
+  public static class ConfigProperty {
+    private ValueAttributesInfo propertyValueAttributes = null;
+    private String name;
+    private String value;
+    private Map<String, String> attributes;
+    private Set<PropertyInfo.PropertyType> propertyTypes;
+    private String type;
+    private Set<PropertyDependencyInfo> dependsOnProperties =
+        Collections.emptySet();
 
-        return services;
+    public ConfigProperty(ReadOnlyConfigurationResponse config) {
+      this.name = config.getPropertyName();
+      this.value = config.getPropertyValue();
+      this.attributes = config.getPropertyAttributes();
+      this.propertyTypes = config.getPropertyType();
+      this.type = normalizeType(config.getType());
+      this.dependsOnProperties = config.getDependsOnProperties();
+      this.propertyValueAttributes = config.getPropertyValueAttributes();
     }
 
-    /**
-     * Obtain the service name which corresponds to the specified configuration.
-     *
-     * @param config  configuration type
-     *
-     * @return name of service which corresponds to the specified configuration type
-     */
-    public String getServiceForConfigType(String config) {
-        for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) {
-            Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue();
-            String serviceName = entry.getKey();
-            if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) {
-                return serviceName;
-            }
-        }
-        throw new IllegalArgumentException(
-                "Specified configuration type is not associated with any service: " + config);
+    public ConfigProperty(String type, String name, String value) {
+      this.type = type;
+      this.name = name;
+      this.value = value;
     }
 
-    /**
-     * Return the dependencies specified for the given component.
-     *
-     * @param component  component to get dependency information for
-     *
-     * @return collection of dependency information for the specified component
-     */
-    //todo: full dependency graph
-    public Collection<DependencyInfo> getDependenciesForComponent(String component) {
-        return dependencies.containsKey(component) ? dependencies.get(component) :
-                Collections.emptySet();
+    public String getName() {
+      return name;
     }
 
-    /**
-     * Get the service, if any, that a component dependency is conditional on.
-     *
-     * @param dependency  dependency to get conditional service for
-     *
-     * @return conditional service for provided component or null if dependency
-     *         is not conditional on a service
-     */
-    public String getConditionalServiceForDependency(DependencyInfo dependency) {
-        return dependencyConditionalServiceMap.get(dependency);
+    public String getValue() {
+      return value;
     }
 
-    public String getExternalComponentConfig(String component) {
-        return dbDependencyInfo.get(component);
+    public void setValue(String value) {
+      this.value = value;
     }
 
-    /**
-     * Obtain the required cardinality for the specified component.
-     */
-    public Cardinality getCardinality(String component) {
-        return new Cardinality(cardinalityRequirements.get(component));
+    public String getType() {
+      return type;
     }
 
-    /**
-     * Obtain auto-deploy information for the specified component.
-     */
-    public AutoDeployInfo getAutoDeployInfo(String component) {
-        return componentAutoDeployInfo.get(component);
+    public Set<PropertyInfo.PropertyType> getPropertyTypes() {
+      return propertyTypes;
     }
 
-    public boolean isMasterComponent(String component) {
-        return masterComponents.contains(component);
+    public void setPropertyTypes(Set<PropertyInfo.PropertyType> propertyTypes) {
+      this.propertyTypes = propertyTypes;
     }
 
-    public Configuration getConfiguration(Collection<String> services) {
-        Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>();
-        Map<String, Map<String, String>> properties = new HashMap<>();
-
-        for (String service : services) {
-            Collection<String> serviceConfigTypes = getConfigurationTypes(service);
-            for (String type : serviceConfigTypes) {
-                Map<String, String> typeProps = getWithEmptyDefault(properties, type);
-                typeProps.putAll(getConfigurationProperties(service, type));
-
-                Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
-                if (!stackTypeAttributes.isEmpty()) {
-                    if (! attributes.containsKey(type)) {
-                        attributes.put(type, new HashMap<>());
-                    }
-                    Map<String, Map<String, String>> typeAttributes = attributes.get(type);
-                    for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
-                        String attributeName = attribute.getKey();
-                        Map<String, String> attributeProps = getWithEmptyDefault(typeAttributes, attributeName);
-                        attributeProps.putAll(attribute.getValue());
-                    }
-                }
-            }
-        }
-        return new Configuration(properties, attributes);
+    public Map<String, String> getAttributes() {
+      return attributes;
     }
 
-    public Configuration getConfiguration() {
-        Map<String, Map<String, Map<String, String>>> stackAttributes = new HashMap<>();
-        Map<String, Map<String, String>> stackConfigs = new HashMap<>();
-
-        for (String service : getServices()) {
-            for (String type : getAllConfigurationTypes(service)) {
-                Map<String, String> typeProps = getWithEmptyDefault(stackConfigs, type);
-                typeProps.putAll(getConfigurationProperties(service, type));
-
-                Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
-                if (!stackTypeAttributes.isEmpty()) {
-                    if (! stackAttributes.containsKey(type)) {
-                        stackAttributes.put(type, new HashMap<>());
-                    }
-                    Map<String, Map<String, String>> typeAttrs = stackAttributes.get(type);
-                    for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
-                        String attributeName = attribute.getKey();
-                        Map<String, String> attributes = getWithEmptyDefault(typeAttrs, attributeName);
-                        attributes.putAll(attribute.getValue());
-                    }
-                }
-            }
-        }
-        return new Configuration(stackConfigs, stackAttributes);
+    public void setAttributes(Map<String, String> attributes) {
+      this.attributes = attributes;
     }
 
-    static <OK, IK, IV> Map<IK, IV> getWithEmptyDefault(Map<OK, Map<IK, IV>> outerMap, OK outerKey) {
-        Map<IK, IV> innerMap = outerMap.get(outerKey);
-        if (null == innerMap) {
-            innerMap = new HashMap<>();
-            outerMap.put(outerKey, innerMap);
-        }
-        return innerMap;
+    public Set<PropertyDependencyInfo> getDependsOnProperties() {
+      return this.dependsOnProperties;
     }
 
+    private String normalizeType(String type) {
+      //strip .xml from type
+      if (type.endsWith(".xml")) {
+        type = type.substring(0, type.length() - 4);
+      }
+      return type;
+    }
 
-    /**
-     * Contains a configuration property's value and attributes.
-     */
-    public static class ConfigProperty {
-        private ValueAttributesInfo propertyValueAttributes = null;
-        private String name;
-        private String value;
-        private Map<String, String> attributes;
-        private Set<PropertyInfo.PropertyType> propertyTypes;
-        private String type;
-        private Set<PropertyDependencyInfo> dependsOnProperties =
-                Collections.emptySet();
-
-        public ConfigProperty(ReadOnlyConfigurationResponse config) {
-            this.name = config.getPropertyName();
-            this.value = config.getPropertyValue();
-            this.attributes = config.getPropertyAttributes();
-            this.propertyTypes = config.getPropertyType();
-            this.type = normalizeType(config.getType());
-            this.dependsOnProperties = config.getDependsOnProperties();
-            this.propertyValueAttributes = config.getPropertyValueAttributes();
-        }
-
-        public ConfigProperty(String type, String name, String value) {
-            this.type = type;
-            this.name = name;
-            this.value = value;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-        public String getValue() {
-            return value;
-        }
-
-        public void setValue(String value) {
-            this.value = value;
-        }
-
-        public String getType() {
-            return type;
-        }
-
-        public Set<PropertyInfo.PropertyType> getPropertyTypes() {
-            return propertyTypes;
-        }
-
-        public void setPropertyTypes(Set<PropertyInfo.PropertyType> propertyTypes) {
-            this.propertyTypes = propertyTypes;
-        }
-
-        public Map<String, String> getAttributes() {
-            return attributes;
-        }
-
-        public void setAttributes(Map<String, String> attributes) {
-            this.attributes = attributes;
-        }
-
-        public Set<PropertyDependencyInfo> getDependsOnProperties() {
-            return this.dependsOnProperties;
-        }
-
-        private String normalizeType(String type) {
-            //strip .xml from type
-            if (type.endsWith(".xml")) {
-                type = type.substring(0, type.length() - 4);
-            }
-            return type;
-        }
-
-        public ValueAttributesInfo getPropertyValueAttributes() {
-            return propertyValueAttributes;
-        }
+    public ValueAttributesInfo getPropertyValueAttributes() {
+      return propertyValueAttributes;
     }
+  }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
index 4b7dd32..044e78a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
@@ -19,13 +19,16 @@
 
 package org.apache.ambari.server.topology;
 
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toMap;
+import static java.util.stream.Collectors.toSet;
+
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
-import java.util.stream.Collectors;
 
 import javax.annotation.Nonnull;
 
@@ -33,7 +36,6 @@ import org.apache.ambari.server.controller.StackV2;
 import org.apache.ambari.server.orm.entities.BlueprintEntity;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.StackId;
-import org.apache.commons.lang.StringUtils;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
@@ -46,14 +48,13 @@ public class BlueprintImplV2 implements BlueprintV2 {
   private String name;
   private SecurityConfiguration securityConfiguration;
   private Collection<RepositoryVersion> repositoryVersions;
-  private Collection<ServiceGroup> serviceGroups;
-  private Collection<? extends HostGroupV2> hostGroups;
+  private Map<String, ServiceGroup> serviceGroups;
   private Setting setting;
+  private Configuration configuration;
 
   // Transient fields
   @JsonIgnore
-  private Map<String, HostGroupV2> hostGroupMap = new HashMap<>();
-
+  private Map<String, HostGroupV2Impl> hostGroupMap = new HashMap<>();
 
   @JsonIgnore
   private Map<StackId, StackV2> stacks;
@@ -61,8 +62,12 @@ public class BlueprintImplV2 implements BlueprintV2 {
   @JsonIgnore
   private List<RepositorySetting> repoSettings;
 
+  @JsonIgnore
+  private Map<ServiceId, Service> services = new HashMap<>();
+
   public void setStacks(Map<StackId, StackV2> stacks) {
     this.stacks = stacks;
+    getAllServices().stream().forEach(s -> s.setStackFromBlueprint(this));
   }
 
   @JsonProperty("Blueprints")
@@ -86,13 +91,12 @@ public class BlueprintImplV2 implements BlueprintV2 {
 
   @JsonProperty("service_groups")
   public void setServiceGroups(Collection<ServiceGroup> serviceGroups) {
-    this.serviceGroups = serviceGroups;
+    this.serviceGroups = serviceGroups.stream().collect(toMap( sg -> sg.getName(), sg -> sg ));
   }
 
   @JsonProperty("host_groups")
   public void setHostGroups(Collection<HostGroupV2Impl> hostGroups) {
-    this.hostGroups = hostGroups;
-    this.hostGroupMap = hostGroups.stream().collect(Collectors.toMap(
+    this.hostGroupMap = hostGroups.stream().collect(toMap(
       hg -> hg.getName(),
       hg -> hg
     ));
@@ -114,7 +118,8 @@ public class BlueprintImplV2 implements BlueprintV2 {
   }
 
   @Override
-  public Map<String, HostGroupV2> getHostGroups() {
+  @JsonProperty("host_groups")
+  public Map<String, ? extends HostGroupV2> getHostGroups() {
     return hostGroupMap;
   }
 
@@ -125,18 +130,23 @@ public class BlueprintImplV2 implements BlueprintV2 {
 
   @Override
   public Collection<String> getStackIds() {
-    return repositoryVersions.stream().map(rv -> rv.getStackId()).collect(Collectors.toList());
+    return repositoryVersions.stream().map(rv -> rv.getStackId()).collect(toList());
   }
 
   @Override
   public Collection<ServiceGroup> getServiceGroups() {
-    return serviceGroups;
+    return serviceGroups.values();
+  }
+
+  @Override
+  public ServiceGroup getServiceGroup(String name) {
+    return serviceGroups.get(name);
   }
 
   @Override
   @JsonIgnore
   public Collection<ServiceId> getAllServiceIds() {
-    return hostGroups.stream().flatMap(hg -> hg.getServiceIds().stream()).collect(Collectors.toSet());
+    return getHostGroups().values().stream().flatMap(hg -> hg.getServiceIds().stream()).collect(toSet());
   }
 
   @Override
@@ -146,70 +156,90 @@ public class BlueprintImplV2 implements BlueprintV2 {
       return serviceGroup.getServices();
     } else {
       return serviceGroup.getServices().stream().filter(
-              service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
+              service -> service.getType().equalsIgnoreCase(serviceType)).collect(toList());
     }
   }
 
   @Override
   @JsonIgnore
   public StackV2 getStackById(String stackId) {
-    return null;
+    return stacks.get(new StackId(stackId));
   }
 
   @Override
   @JsonIgnore
   public Collection<Service> getAllServices() {
-    return null;
+    return services.values();
+  }
+
+  @Override
+  @JsonIgnore
+  public Service getService(ServiceId serviceId) {
+    return services.get(serviceId);
   }
 
   @Override
   @JsonIgnore
   public Collection<String> getAllServiceTypes() {
-    return null;
+    return getServiceGroups().stream().flatMap(sg -> sg.getServices().stream()).map(s -> s.getType()).collect(toSet());
   }
 
   @Override
   @JsonIgnore
   public Collection<Service> getServicesByType(String serviceType) {
-    return null;
-//    getAllServices().stream().filter(
-//            service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
+    return serviceGroups.values().stream().flatMap(sg -> sg.getServiceByType(serviceType).stream()).collect(toList());
   }
 
   @Override
   @JsonIgnore
   public Collection<ComponentV2> getComponents(Service service) {
-    return null;
+    return getHostGroupsForService(service.getId()).stream().flatMap(
+      hg -> hg.getComponents().stream()).
+      collect(toList());
   }
 
   @Override
   @JsonIgnore
   public Collection<ComponentV2> getComponentsByType(Service service, String componentType) {
     return getComponents(service).stream().filter(
-            compnoent -> compnoent.getType().equalsIgnoreCase(componentType)).collect(Collectors.toList());
+            compnoent -> compnoent.getType().equalsIgnoreCase(componentType)).collect(toList());
   }
 
   @Override
   @JsonIgnore
   public Collection<ComponentV2> getComponents(ServiceId serviceId) {
-    return getHostGroupsForService(serviceId).stream().flatMap(hg -> hg.getComponents().stream()).collect(Collectors.toSet());
+    return getHostGroupsForService(serviceId).stream().flatMap(hg -> hg.getComponents().stream()).collect(toSet());
   }
 
   @Override
   @JsonIgnore
   public Collection<HostGroupV2> getHostGroupsForService(ServiceId serviceId) {
-    return hostGroups.stream().filter(hg -> !hg.getComponentsByServiceId(serviceId).isEmpty()).collect(Collectors.toList());
+    return getHostGroups().values().stream().filter(hg -> !hg.getComponentsByServiceId(serviceId).isEmpty()).collect(toList());
   }
 
   @Override
   @JsonIgnore
   public Collection<HostGroupV2> getHostGroupsForComponent(ComponentV2 component) {
-    return hostGroups.stream().filter(hg -> hg.getComponents().contains(component)).collect(Collectors.toList());
+    return hostGroupMap.values().stream().filter(hg -> hg.getComponents().contains(component)).collect(toList());
   }
 
   @Override
+  @JsonIgnore
   public Configuration getConfiguration() {
-    return null;
+    if (null == configuration) {
+      configuration = new Configuration(new HashMap<>(), new HashMap<>());
+      getServiceGroups().stream().forEach( sg -> addChildConfiguration(configuration, sg.getConfiguration()) );
+      getHostGroups().values().stream().forEach(
+        hg -> hg.getComponents().stream().forEach(
+          c -> addChildConfiguration(configuration, c.getConfiguration())));
+    }
+    return configuration;
+  }
+
+  private void addChildConfiguration(Configuration parent, Configuration child) {
+    child.setParentConfiguration(parent);
+    parent.getProperties().putAll(child.getProperties());
+    parent.getAttributes().putAll(child.getAttributes());
   }
 
   @Override
@@ -217,86 +247,54 @@ public class BlueprintImplV2 implements BlueprintV2 {
     return this.setting;
   }
 
-
-
   @Nonnull
   @Override
   @JsonIgnore
   public Collection<String> getAllServiceNames() {
-    return getAllServices().stream().map(s -> s.getName()).collect(Collectors.toList());
+    return getAllServices().stream().map(s -> s.getName()).collect(toList());
   }
 
   @Nonnull
   @Override
   public Collection<String> getComponentNames(ServiceId serviceId) {
-    return getComponents(serviceId).stream().map(c -> c.getName()).collect(Collectors.toList());
+    return getComponents(serviceId).stream().map(c -> c.getName()).collect(toList());
   }
 
   @Override
   public String getRecoveryEnabled(ComponentV2 component) {
-    return null;
-  }
-
-  public String getRecoveryEnabled(String serviceName, String componentName) {
-    // If component name was specified in the list of "component_settings",
-    // determine if recovery_enabled is true or false and return it.
-    Optional<String> recoveryEnabled = getSettingValue(Setting.SETTING_NAME_COMPONENT_SETTINGS,
-      Setting.SETTING_NAME_RECOVERY_ENABLED,
-      Optional.of(componentName));
-    if (recoveryEnabled.isPresent()) {
-      return recoveryEnabled.get();
-    }
-
-    // If component name was specified in the list of "component_settings",
-    // determine if recovery_enabled is true or false and return it.
-    recoveryEnabled = getSettingValue(Setting.SETTING_NAME_SERVICE_SETTINGS,
-      Setting.SETTING_NAME_RECOVERY_ENABLED,
-      Optional.of(serviceName));
-    if (recoveryEnabled.isPresent()) {
-      return recoveryEnabled.get();
-    }
-
-    // If service name is not specified, look up the cluster setting.
-    recoveryEnabled = getSettingValue(Setting.SETTING_NAME_RECOVERY_SETTINGS,
-      Setting.SETTING_NAME_RECOVERY_ENABLED,
-      Optional.empty());
-    if (recoveryEnabled.isPresent()) {
-      return recoveryEnabled.get();
-    }
-
-    return null;
-  }
-
-  private Optional<String> getSettingValue(String settingCategory, String settingName, Optional<String> nameFilter) {
-    if (this.setting != null) {
-      Set<HashMap<String, String>> settingValue = this.setting.getSettingValue(settingCategory);
-      for (Map<String, String> setting : settingValue) {
-        String name = setting.get(Setting.SETTING_NAME_NAME);
-        if (!nameFilter.isPresent() || StringUtils.equals(name, nameFilter.get())) {
-          String value = setting.get(settingName);
-          if (!StringUtils.isEmpty(value)) {
-            return Optional.of(value);
-          }
-        }
-      }
-    }
-    return Optional.empty();
-  }
+    Optional<String> value =
+      setting.getSettingValue(Setting.SETTING_NAME_RECOVERY_SETTINGS, Setting.SETTING_NAME_RECOVERY_ENABLED);
+    // TODO: handle service and component level settings
+    return value.orElse(null);
+  }
+
+//  private Optional<String> getSettingValue(String settingCategory, String settingName, Optional<String> nameFilter) {
+//    if (this.setting != null) {
+//      Set<HashMap<String, String>> settingValue = this.setting.getSettingValue(settingCategory);
+//      for (Map<String, String> setting : settingValue) {
+//        String name = setting.get(Setting.SETTING_NAME_NAME);
+//        if (!nameFilter.isPresent() || StringUtils.equals(name, nameFilter.get())) {
+//          String value = setting.get(settingName);
+//          if (!StringUtils.isEmpty(value)) {
+//            return Optional.of(value);
+//          }
+//        }
+//      }
+//    }
+//    return Optional.empty();
+//  }
 
   @Override
   public String getCredentialStoreEnabled(String serviceName) {
-    // Look up the service and return the credential_store_enabled value.
-    Optional<String> credentialStoreEnabled = getSettingValue(Setting.SETTING_NAME_SERVICE_SETTINGS,
-      Setting.SETTING_NAME_CREDENTIAL_STORE_ENABLED,
-      Optional.of(serviceName));
-    return  credentialStoreEnabled.isPresent() ? credentialStoreEnabled.get() : null;
+    // TODO: this is a service level level setting, handle appropriately
+    return null;
   }
 
   @Override
   public boolean shouldSkipFailure() {
-    Optional<String> shouldSkipFailure = getSettingValue(Setting.SETTING_NAME_DEPLOYMENT_SETTINGS,
-      Setting.SETTING_NAME_SKIP_FAILURE,
-      Optional.empty());
+    Optional<String> shouldSkipFailure = setting.getSettingValue(
+      Setting.SETTING_NAME_DEPLOYMENT_SETTINGS,
+      Setting.SETTING_NAME_SKIP_FAILURE);
     return shouldSkipFailure.isPresent() ? shouldSkipFailure.get().equalsIgnoreCase("true") : false;
   }
 
@@ -312,7 +310,7 @@ public class BlueprintImplV2 implements BlueprintV2 {
       return true;
     }
     final Set<String> serviceNames =
-      getAllServices().stream().map(s -> s.getName()).collect(Collectors.toSet());
+      getAllServices().stream().map(s -> s.getName()).collect(toSet());
     return getStacks().stream().anyMatch(
       stack -> {
         String service = stack.getServiceForConfigType(configType);
@@ -321,9 +319,46 @@ public class BlueprintImplV2 implements BlueprintV2 {
     );
   }
 
+  public void postDeserialization() {
+    // Maintain a ServiceId -> Service map
+    this.services = getAllServiceIds().stream().collect(toMap(
+      serviceId -> serviceId,
+      serviceId -> {
+        ServiceGroup sg = getServiceGroup(serviceId.getServiceGroup());
+        Service service = null != sg ? sg.getServiceByName(serviceId.getName()) : null;
+        if (null == service) {
+          throw new IllegalStateException("Cannot find service for service id: " + serviceId);
+        }
+        return service;
+      }
+    ));
+
+    // Set Service -> ServiceGroup references and Service -> Service dependencies
+    getAllServices().stream().forEach( s -> {
+      s.setServiceGroup(serviceGroups.get(s.getServiceGroupId()));
+      Map<ServiceId, Service> dependencies = s.getDependentServiceIds().stream().collect(toMap(
+        serviceId -> serviceId,
+        serviceId -> getService(serviceId)
+      ));
+      s.setDependencyMap(dependencies);
+    });
+
+
+    // Set HostGroup -> Services and Component -> Service references
+    for (HostGroupV2Impl hg: hostGroupMap.values()) {
+      hg.setServiceMap(hg.getServiceIds().stream().collect(toMap(
+        serviceId -> serviceId,
+        serviceId -> this.services.get(serviceId)
+      )));
+      for (ComponentV2 comp: hg.getComponents()) {
+        comp.setService(hg.getService(comp.getServiceId()));
+      }
+    }
+  }
+
   @Override
   public BlueprintEntity toEntity() {
-    throw new UnsupportedOperationException("This is not supported here and will be removed. Pls. use BlueprintConverter");
+    throw new UnsupportedOperationException("This is not supported here and will be removed. Pls. use BlueprintV2Factory");
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
index 29539db..b5d5430 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
@@ -53,7 +53,7 @@ public interface BlueprintV2 {
    * Get the hot groups contained in the blueprint.
    * @return map of host group name to host group
    */
-  Map<String, HostGroupV2> getHostGroups();
+  Map<String, ? extends HostGroupV2> getHostGroups();
 
   /**
    * Get  stacks associated with the blueprint.
@@ -71,6 +71,8 @@ public interface BlueprintV2 {
 
   Collection<ServiceGroup> getServiceGroups();
 
+  ServiceGroup getServiceGroup(String name);
+
   /**
    * Get all of the services represented in the blueprint.
    *
@@ -78,7 +80,7 @@ public interface BlueprintV2 {
    */
   Collection<ServiceId> getAllServiceIds();
 
-  ;Collection<Service> getAllServices();
+  Collection<Service> getAllServices();
 
   /**
    * Get the names of all the services represented in the blueprint.
@@ -104,6 +106,8 @@ public interface BlueprintV2 {
    */
   Collection<Service> getServicesByType(String serviceType);
 
+  Service getService(ServiceId serviceId);
+
   /**
    * Get services by type from a service group.
    * @param serviceGroup

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
index a8c5b4c..3b656e2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
@@ -87,6 +87,7 @@ public class BlueprintV2Factory {
 
   public BlueprintV2 convertFromEntity(BlueprintV2Entity blueprintEntity) throws NoSuchStackException, IOException {
     BlueprintImplV2 blueprintV2 = createObjectMapper().readValue(blueprintEntity.getContent(), BlueprintImplV2.class);
+    blueprintV2.postDeserialization();
     Map<StackId, StackV2> stacks = new HashMap<>();
     for (String stackIdString: blueprintV2.getStackIds()) {
       StackId stackId = new StackId(stackIdString);
@@ -126,6 +127,7 @@ public class BlueprintV2Factory {
     ObjectMapper om = createObjectMapper();
     String json = om.writeValueAsString(properties);
     BlueprintImplV2 blueprint = om.readValue(json, BlueprintImplV2.class);
+    blueprint.postDeserialization();
     Map<String, StackV2> stacks = new HashMap<>();
     for (String stackId: blueprint.getStackIds()) {
       stacks.put(stackId, stackFactory.create(stackId));

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
index e59b1f9..68744d4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
@@ -38,6 +38,9 @@ public class ComponentV2 implements Configurable {
 
   private boolean masterComponent = false;
 
+  @JsonIgnore
+  private Service service;
+
   public ComponentV2() { }
 
 
@@ -69,9 +72,8 @@ public class ComponentV2 implements Configurable {
     return serviceId;
   }
 
-  //TODO
   public Service getService() {
-    return null;
+    return service;
   }
 
   //TODO
@@ -130,4 +132,7 @@ public class ComponentV2 implements Configurable {
     this.masterComponent = stack.isMasterComponent(this.type);
   }
 
+  public void setService(Service service) {
+    this.service = service;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
index 4745f59..8da24bd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
@@ -104,10 +104,12 @@ public interface HostGroupV2 {
   Collection<ServiceId> getServiceIds();
 
   /**
-   * @return collection of service ids associated with the host group components.
+   * @return collection of services associated with the host group components.
    */
   Collection<Service> getServices();
 
+  Service getService(ServiceId serviceId);
+
   /**
    * @return collection of service names associated with the host group components.
    */
@@ -124,11 +126,6 @@ public interface HostGroupV2 {
   Configuration getConfiguration();
 
   /**
-   * List of services
-   */
-  Collection<Service> getServiceConfigs();
-
-  /**
    * Get the cardinality value that was specified for the host group.
    * This is simply meta-data for the stack that a deployer can use
    * and this information is not used by ambari.

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
index ca19df3..2c9d1dd 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
@@ -19,6 +19,7 @@ package org.apache.ambari.server.topology;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 import javax.annotation.Nullable;
@@ -27,9 +28,11 @@ import org.apache.ambari.server.controller.internal.ProvisionAction;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
 import com.google.common.base.Predicates;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Lists;
 
 public class HostGroupV2Impl implements HostGroupV2, Configurable {
@@ -37,10 +40,12 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
   private String name;
   private String blueprintName;
   private List<ComponentV2> components;
-  private List<ServiceId> services;
+  private List<ServiceId> serviceIds;
   private Configuration configuration;
   private String cardinality;
   private boolean containsMasterComponent;
+  @JsonIgnore
+  private Map<ServiceId, Service> serviceMap;
 
   public HostGroupV2Impl() { }
 
@@ -84,8 +89,8 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
   }
 
   @Override
-  public Collection<ComponentV2> getComponents(Service serviceId) {
-    return null;
+  public Collection<ComponentV2> getComponents(Service service) {
+    return getComponentsByServiceId(service.getId());
   }
 
   @Override
@@ -100,29 +105,37 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
 
   @Override
   public Collection<ServiceId> getServiceIds() {
-    return services;
+    return serviceIds;
   }
 
   @Override
   @JsonIgnore
   public Collection<Service> getServices() {
-    return null;
+    return serviceMap.values();
   }
 
   @Override
   @JsonIgnore
-  public Collection<String> getServiceNames() {
-    return services.stream().map(s -> s.getName()).collect(Collectors.toList());
+  public Service getService(ServiceId serviceId) {
+    return serviceMap.get(serviceId);
   }
 
   @Override
-  public Configuration getConfiguration() {
-    return configuration;
+  @JsonIgnore
+  public Collection<String> getServiceNames() {
+    return serviceMap.values().stream().map(s -> s.getName()).collect(Collectors.toList());
+  }
+
+  @JsonIgnore
+  public void setServiceMap(Map<ServiceId, Service> serviceMap) {
+    Preconditions.checkArgument(serviceMap.keySet().equals(ImmutableSet.copyOf(this.serviceIds)),
+      "Maitained list of service ids doesn't match with received service map: %s vs %s", serviceIds, serviceMap.keySet());
+    this.serviceMap = serviceMap;
   }
 
   @Override
-  public Collection<Service> getServiceConfigs() {
-    return null;
+  public Configuration getConfiguration() {
+    return configuration;
   }
 
   @Override
@@ -141,7 +154,7 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
   public void setComponents(List<ComponentV2> components) {
     this.components = components;
     this.containsMasterComponent = components.stream().anyMatch(c -> c.isMasterComponent());
-    this.services = components.stream().map(c -> c.getServiceId()).collect(Collectors.toList());
+    this.serviceIds = components.stream().map(c -> c.getServiceId()).collect(Collectors.toList());
   }
 
   public void setConfiguration(Configuration configuration) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
index 81f235c..46c75c5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
@@ -19,11 +19,17 @@
 package org.apache.ambari.server.topology;
 
 
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.ambari.server.controller.StackV2;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
 
 public class Service implements Configurable {
 
@@ -35,7 +41,16 @@ public class Service implements Configurable {
 
   private Configuration configuration;
 
-  private Set<ServiceId> dependencies;
+  private Set<ServiceId> dependencies = ImmutableSet.of();
+
+  @JsonIgnore
+  private Map<ServiceId, Service> dependencyMap = ImmutableMap.of();
+
+  @JsonIgnore
+  private ServiceGroup serviceGroup;
+
+  @JsonIgnore
+  private StackV2 stack;
 
   /**
    * Gets the name of this service
@@ -50,9 +65,8 @@ public class Service implements Configurable {
     return this.id.getServiceGroup();
   }
 
-  //TODO
   public ServiceGroup getServiceGroup() {
-    return null;
+    return serviceGroup;
   }
 
   public String getType() {
@@ -63,35 +77,36 @@ public class Service implements Configurable {
     return stackId;
   }
 
-  //TODO
   public StackV2 getStack() {
-    return null;
+    return stack;
   }
 
   public Set<ServiceId> getDependentServiceIds() {
     return dependencies;
   }
 
-  //TODO
   public Set<Service> getDependencies() {
-    return null;
+    return ImmutableSet.copyOf(dependencyMap.values());
   }
 
   public Configuration getConfiguration() {
     return configuration;
   }
 
-
   public void setType(String type) {
     this.type = type;
+    if (null == this.getName()) {
+      setName(type);
+    }
   }
 
   public void setName(String name) {
     this.id.setName(name);
   }
 
-  public void setServiceGroup(String serviceGroup) {
-    this.id.setServiceGroup(serviceGroup);
+  public void setServiceGroup(ServiceGroup serviceGroup) {
+    this.serviceGroup = serviceGroup;
+    this.id.setServiceGroup(serviceGroup.getName());
   }
 
   @JsonProperty("stack_id")
@@ -99,6 +114,10 @@ public class Service implements Configurable {
     this.stackId = stackId;
   }
 
+  public void setStackFromBlueprint(BlueprintV2 blueprint) {
+    this.stack = blueprint.getStackById(this.stackId);
+  }
+
   public void setConfiguration(Configuration configuration) {
     this.configuration = configuration;
   }
@@ -107,8 +126,27 @@ public class Service implements Configurable {
     this.dependencies = dependencies;
   }
 
+  /**
+   * Called during post-deserialization
+   * @param dependencyMap
+   */
+  void setDependencyMap(Map<ServiceId, Service> dependencyMap) {
+    Preconditions.checkArgument(dependencyMap.keySet().equals(dependencies),
+      "Received dependency map is not consisted with persisted dependency references: %s vs. %s",
+      dependencyMap.keySet(), dependencies);
+    this.dependencyMap = dependencyMap;
+  }
+
   public ServiceId getId() {
     return id;
   }
 
+  @Override
+  public String toString() {
+    return "Service{" +
+      "type='" + type + '\'' +
+      ", id=" + id +
+      ", stackId='" + stackId + '\'' +
+      '}';
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
index 13967c0..7f38b2c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
@@ -18,17 +18,22 @@
 
 package org.apache.ambari.server.topology;
 
-
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
 import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Multimaps;
 
 public class ServiceGroup {
 
   private String name = null;
 
-  private Collection<Service> services = new ArrayList<>();
+  private Map<String, Service> servicesByName;
+  private ListMultimap<String, Service> servicesByType;
 
   private Configuration configuration = null;
 
@@ -46,7 +51,15 @@ public class ServiceGroup {
   }
 
   public Collection<Service> getServices() {
-    return services;
+    return servicesByName.values();
+  }
+
+  public Service getServiceByName(String name) {
+    return servicesByName.get(name);
+  }
+
+  public List<Service> getServiceByType(String name) {
+    return servicesByType.get(name);
   }
 
   public Configuration getConfiguration() {
@@ -57,14 +70,15 @@ public class ServiceGroup {
     return dependencies;
   }
 
-
   public void setName(String name) {
     this.name = name;
   }
 
   public void setServices(Collection<Service> services) {
-    this.services = services;
-    services.forEach(s -> s.setServiceGroup(this.name));
+    services.forEach(s -> s.setServiceGroup(this));
+    this.servicesByName = services.stream().collect(Collectors.toMap(Service::getName, s -> s));
+    this.servicesByType = Multimaps.index(services, Service::getType);
+    services.forEach(s -> s.setServiceGroup(this));
   }
 
   public void setConfiguration(Configuration configuration) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java
index 669e031..2d81a07 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceId.java
@@ -23,6 +23,8 @@ public class ServiceId {
   private String serviceGroup;
   private String name;
 
+  public ServiceId() { }
+
   public static ServiceId of(String name, String serviceGroup) {
     ServiceId id = new ServiceId();
     id.name = name;
@@ -66,4 +68,12 @@ public class ServiceId {
     result = 31 * result + (name != null ? name.hashCode() : 0);
     return result;
   }
+
+  @Override
+  public String toString() {
+    return "ServiceId{" +
+      "serviceGroup='" + serviceGroup + '\'' +
+      ", name='" + name + '\'' +
+      '}';
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
index 904c784..34542e1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Setting.java
@@ -20,8 +20,14 @@ package org.apache.ambari.server.topology;
 
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
 import java.util.Set;
+import java.util.stream.Collectors;
+
+import com.google.common.base.Preconditions;
 
 public class Setting {
   /**
@@ -95,7 +101,17 @@ public class Setting {
     if (properties.containsKey(settingName)) {
       return properties.get(settingName);
     }
-
     return Collections.emptySet();
   }
+
+  public Optional<String> getSettingValue(String settingCategory, String propertyName) {
+    List<String> values = getSettingValue(settingCategory).stream().
+      flatMap(sv -> sv.entrySet().stream()).
+      filter(entry -> Objects.equals(entry.getKey(), propertyName)).
+      map(entry -> entry.getValue()).
+      collect(Collectors.toList());
+    Preconditions.checkState(values.size() < 2, "Ambigous settings (%s) for category %s, property %s",
+      values.size(), settingCategory, settingCategory);
+    return values.isEmpty() ? Optional.empty() : Optional.of(values.get(0));
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
index 6b98b77..3bcf31b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
@@ -20,6 +20,8 @@ package org.apache.ambari.server.topology.validators;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.ambari.server.controller.StackV2;
+import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.topology.BlueprintImplV2;
 import org.apache.ambari.server.topology.HostGroupV2;
 import org.apache.ambari.server.topology.HostGroupV2Impl;
@@ -32,6 +34,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
 import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
 import com.fasterxml.jackson.databind.module.SimpleModule;
 import com.google.common.base.Charsets;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.io.Resources;
 
 public class BlueprintImplV2Test {
@@ -53,6 +56,14 @@ public class BlueprintImplV2Test {
     mapper.registerModule(module);
     mapper.enable(SerializationFeature.INDENT_OUTPUT);
     BlueprintImplV2 bp = mapper.readValue(BLUEPRINT_V2_JSON, BlueprintImplV2.class);
+    bp.postDeserialization();
+    // -- add stack --
+    StackV2 hdpCore = new StackV2("HDPCORE", "3.0.0", "3.0.0.0-1", new HashMap<>(), new HashMap<>(), new HashMap<>(),
+      new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>());
+    StackV2 analytics = new StackV2("ANALYTICS", "1.0.0", "1.0.0.0-1", new HashMap<>(), new HashMap<>(), new HashMap<>(),
+      new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>());
+    bp.setStacks(ImmutableMap.of(new StackId("HDPCORE", "3.0.0"), hdpCore, new StackId("ANALYTICS", "1.0.0"), analytics));
+    // ---------------
     String bpJson = mapper.writeValueAsString(bp);
     System.out.println(bpJson);
     System.out.println("\n\n====================================================================================\n\n");

http://git-wip-us.apache.org/repos/asf/ambari/blob/acab46dc/ambari-server/src/test/resources/blueprintv2/blueprintv2.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/blueprintv2/blueprintv2.json b/ambari-server/src/test/resources/blueprintv2/blueprintv2.json
index 7884abf..b6b4e8d 100644
--- a/ambari-server/src/test/resources/blueprintv2/blueprintv2.json
+++ b/ambari-server/src/test/resources/blueprintv2/blueprintv2.json
@@ -25,7 +25,7 @@
   ],
   "service_groups": [
     {
-      "name": "Core SG",
+      "name": "CoreSG",
       "dependencies": [],
       "services": [
         {
@@ -88,7 +88,7 @@
           "stack_id": "HDPCORE-3.0.0"
         }
       ],
-      "dependencies": ["Core SG"]
+      "dependencies": ["CoreSG"]
     }
   ],
   "host_groups": [
@@ -100,50 +100,44 @@
         {
           "type": "NAMENODE",
           "service_name": "HDFS",
-          "service_group": "Core SG",
+          "service_group": "CoreSG",
           "configurations": [],
           "provision_action": "INSTALL_AND_START"
         },
         {
           "type": "ZOOKEEPER_SERVER",
           "service_name": "ZK1",
-          "service_group": "Core SG",
+          "service_group": "CoreSG",
           "configurations": []
         },
         {
           "type": "ZOOKEEPER_SERVER",
           "service_name": "ZK2",
-          "service_group": "Core SG",
+          "service_group": "CoreSG",
           "configurations": []
         },
         {
           "type": "RESOURCEMANAGER",
           "service_name": "YARN",
-          "service_group": "Core SG",
+          "service_group": "CoreSG",
           "configurations": []
         },
         {
           "type": "HBASE_MASTER",
           "service_name": "HBASE",
-          "service_group": "Core SG",
-          "configurations": []
-        },
-        {
-          "type": "ZOOKEEPER_SERVER",
-          "service_name": "ZOOKEEPER",
-          "service_group": "Stream SG",
+          "service_group": "CoreSG",
           "configurations": []
         },
         {
           "type": "KAFKA_MASTER",
           "service_name": "KAFKA",
-          "service_group": "Stream SG",
+          "service_group": "StreamSG",
           "configurations": []
         },
         {
           "type": "NIFI_MASTER",
           "service_name": "NIFI",
-          "service_group": "Stream SG",
+          "service_group": "StreamSG",
           "configurations": []
         }
       ]


[06/30] ambari git commit: use V2 objects in TopologyManager

Posted by mr...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
index f50e60f..8feb979 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
@@ -19,36 +19,34 @@
 
 package org.apache.ambari.server.topology;
 
-import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_AND_START;
-import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.controller.RequestStatusResponse;
+import org.apache.ambari.server.controller.internal.ConfigurationContext;
 import org.apache.ambari.server.controller.internal.ProvisionAction;
 import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.*;
+
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_AND_START;
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
+
 /**
  * Represents a cluster topology.
  * Topology includes the the associated blueprint, cluster configuration and hostgroup -> host mapping.
  */
 public class ClusterTopologyImpl implements ClusterTopology {
 
+  private final static Logger LOG = LoggerFactory.getLogger(ClusterTopologyImpl.class);
+
   private Long clusterId;
 
   //todo: currently topology is only associated with a single bp
   //todo: this will need to change to allow usage of multiple bp's for the same cluster
   //todo: for example: provision using bp1 and scale using bp2
-  private Blueprint blueprint;
-  private Configuration configuration;
+  private BlueprintV2 blueprint;
+  private Collection<Service> serviceConfigs;
   private ConfigRecommendationStrategy configRecommendationStrategy;
   private ProvisionAction provisionAction = ProvisionAction.INSTALL_AND_START;
   private Map<String, AdvisedConfiguration> advisedConfigurations = new HashMap<>();
@@ -56,16 +54,13 @@ public class ClusterTopologyImpl implements ClusterTopology {
   private final AmbariContext ambariContext;
   private final String defaultPassword;
 
-  private final static Logger LOG = LoggerFactory.getLogger(ClusterTopologyImpl.class);
-
-
   //todo: will need to convert all usages of hostgroup name to use fully qualified name (BP/HG)
   //todo: for now, restrict scaling to the same BP
   public ClusterTopologyImpl(AmbariContext ambariContext, TopologyRequest topologyRequest) throws InvalidTopologyException {
     this.clusterId = topologyRequest.getClusterId();
     // provision cluster currently requires that all hostgroups have same BP so it is ok to use root level BP here
     this.blueprint = topologyRequest.getBlueprint();
-    this.configuration = topologyRequest.getConfiguration();
+    this.serviceConfigs = topologyRequest.getServiceConfigs();
     if (topologyRequest instanceof ProvisionClusterRequest) {
       this.defaultPassword = ((ProvisionClusterRequest) topologyRequest).getDefaultPassword();
     } else {
@@ -95,13 +90,18 @@ public class ClusterTopologyImpl implements ClusterTopology {
   }
 
   @Override
-  public Blueprint getBlueprint() {
+  public BlueprintV2 getBlueprint() {
     return blueprint;
   }
 
   @Override
+  @Deprecated
   public Configuration getConfiguration() {
-    return configuration;
+    return null;
+  }
+
+  public Collection<Service> getServiceConfigs() {
+    return serviceConfigs;
   }
 
   @Override
@@ -113,7 +113,7 @@ public class ClusterTopologyImpl implements ClusterTopology {
   @Override
   public Collection<String> getHostGroupsForComponent(String component) {
     Collection<String> resultGroups = new ArrayList<>();
-    for (HostGroup group : getBlueprint().getHostGroups().values() ) {
+    for (HostGroupV2 group : getBlueprint().getHostGroups().values() ) {
       if (group.getComponentNames().contains(component)) {
         resultGroups.add(group.getName());
       }
@@ -178,49 +178,48 @@ public class ClusterTopologyImpl implements ClusterTopology {
   }
 
   @Override
-  public boolean isNameNodeHAEnabled() {
-    return isNameNodeHAEnabled(configuration.getFullProperties());
-  }
-
-  public static boolean isNameNodeHAEnabled(Map<String, Map<String, String>> configurationProperties) {
-    return configurationProperties.containsKey("hdfs-site") &&
-           (configurationProperties.get("hdfs-site").containsKey("dfs.nameservices") ||
-            configurationProperties.get("hdfs-site").containsKey("dfs.internal.nameservices"));
-  }
-
-  @Override
-  public boolean isYarnResourceManagerHAEnabled() {
-    return isYarnResourceManagerHAEnabled(configuration.getFullProperties());
+  public boolean isNameNodeHAEnabled(ConfigurationContext configurationContext) {
+    return configurationContext.isNameNodeHAEnabled();
   }
 
   /**
    * Static convenience function to determine if Yarn ResourceManager HA is enabled
-   * @param configProperties configuration properties for this cluster
+   * @param configurationContext configuration context
    * @return true if Yarn ResourceManager HA is enabled
    *         false if Yarn ResourceManager HA is not enabled
    */
-  static boolean isYarnResourceManagerHAEnabled(Map<String, Map<String, String>> configProperties) {
-    return configProperties.containsKey("yarn-site") && configProperties.get("yarn-site").containsKey("yarn.resourcemanager.ha.enabled")
-      && configProperties.get("yarn-site").get("yarn.resourcemanager.ha.enabled").equals("true");
+  @Override
+  public boolean isYarnResourceManagerHAEnabled(ConfigurationContext configurationContext) {
+    return configurationContext.isYarnResourceManagerHAEnabled();
   }
 
   private void validateTopology()
       throws InvalidTopologyException {
 
-    if(isNameNodeHAEnabled()){
+    Collection<Service> hdfsServices = getBlueprint().getServicesByType("HDFS");
+    for (Service hdfsService : hdfsServices) {
+      ConfigurationContext configContext = new ConfigurationContext(hdfsService.getStack(), hdfsService.getConfiguration());
+      if(isNameNodeHAEnabled(configContext)) {
+
         Collection<String> nnHosts = getHostAssignmentsForComponent("NAMENODE");
         if (nnHosts.size() != 2) {
-            throw new InvalidTopologyException("NAMENODE HA requires exactly 2 hosts running NAMENODE but there are: " +
-                nnHosts.size() + " Hosts: " + nnHosts);
+          throw new InvalidTopologyException("NAMENODE HA requires exactly 2 hosts running NAMENODE but there are: " +
+            nnHosts.size() + " Hosts: " + nnHosts);
         }
-        Map<String, String> hadoopEnvConfig = configuration.getFullProperties().get("hadoop-env");
+
+        Map<String, String> hadoopEnvConfig = hdfsService.getConfiguration().getProperties().get("hadoop-env");
         if(hadoopEnvConfig != null && !hadoopEnvConfig.isEmpty() && hadoopEnvConfig.containsKey("dfs_ha_initial_namenode_active") && hadoopEnvConfig.containsKey("dfs_ha_initial_namenode_standby")) {
-           if((!HostGroup.HOSTGROUP_REGEX.matcher(hadoopEnvConfig.get("dfs_ha_initial_namenode_active")).matches() && !nnHosts.contains(hadoopEnvConfig.get("dfs_ha_initial_namenode_active")))
-             || (!HostGroup.HOSTGROUP_REGEX.matcher(hadoopEnvConfig.get("dfs_ha_initial_namenode_standby")).matches() && !nnHosts.contains(hadoopEnvConfig.get("dfs_ha_initial_namenode_standby")))){
-              throw new IllegalArgumentException("NAMENODE HA hosts mapped incorrectly for properties 'dfs_ha_initial_namenode_active' and 'dfs_ha_initial_namenode_standby'. Expected hosts are: " + nnHosts);
-        }
+          if((!HostGroup.HOSTGROUP_REGEX.matcher(hadoopEnvConfig.get("dfs_ha_initial_namenode_active")).matches() && !nnHosts.contains(hadoopEnvConfig.get("dfs_ha_initial_namenode_active")))
+            || (!HostGroup.HOSTGROUP_REGEX.matcher(hadoopEnvConfig.get("dfs_ha_initial_namenode_standby")).matches() && !nnHosts.contains(hadoopEnvConfig.get("dfs_ha_initial_namenode_standby")))){
+            throw new IllegalArgumentException("NAMENODE HA hosts mapped incorrectly for properties 'dfs_ha_initial_namenode_active' and 'dfs_ha_initial_namenode_standby'. Expected hosts are: " + nnHosts);
+          }
         }
+
+      }
+
     }
+
+
   }
 
   @Override
@@ -232,7 +231,7 @@ public class ClusterTopologyImpl implements ClusterTopology {
   public RequestStatusResponse installHost(String hostName, boolean skipInstallTaskCreate, boolean skipFailure) {
     try {
       String hostGroupName = getHostGroupForHost(hostName);
-      HostGroup hostGroup = this.blueprint.getHostGroup(hostGroupName);
+      HostGroupV2 hostGroup = this.blueprint.getHostGroup(hostGroupName);
 
       Collection<String> skipInstallForComponents = new ArrayList<>();
       if (skipInstallTaskCreate) {
@@ -257,7 +256,7 @@ public class ClusterTopologyImpl implements ClusterTopology {
   public RequestStatusResponse startHost(String hostName, boolean skipFailure) {
     try {
       String hostGroupName = getHostGroupForHost(hostName);
-      HostGroup hostGroup = this.blueprint.getHostGroup(hostGroupName);
+      HostGroupV2 hostGroup = this.blueprint.getHostGroup(hostGroupName);
 
       // get the set of components that are marked as INSTALL_ONLY
       // for this hostgroup
@@ -321,7 +320,7 @@ public class ClusterTopologyImpl implements ClusterTopology {
       String hostGroupName = requestedHostGroupInfo.getHostGroupName();
 
       //todo: doesn't support using a different blueprint for update (scaling)
-      HostGroup baseHostGroup = getBlueprint().getHostGroup(hostGroupName);
+      HostGroupV2 baseHostGroup = getBlueprint().getHostGroup(hostGroupName);
 
       if (baseHostGroup == null) {
         throw new IllegalArgumentException("Invalid host_group specified: " + hostGroupName +

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
index 175fe99..d7c08f4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
@@ -23,6 +23,8 @@ import org.apache.ambari.server.controller.internal.ProvisionAction;
 
 public class ComponentV2 {
 
+  private final String type;
+
   private final String name;
 
   private final Service service;
@@ -31,12 +33,17 @@ public class ComponentV2 {
 
   private final Configuration configuration;
 
+  public ComponentV2(String type, Service service) {
+    this(type, type, service, null, null);
+  }
+
 
-  public ComponentV2(String name, Service service) {
-    this(name, service, null, null);
+  public ComponentV2(String type, String name, Service service) {
+    this(type, name, service, null, null);
   }
 
-  public ComponentV2(String name, Service service, ProvisionAction provisionAction, Configuration configuration) {
+  public ComponentV2(String type, String name, Service service, ProvisionAction provisionAction, Configuration configuration) {
+    this.type = type;
     this.name = name;
     this.service = service;
     this.provisionAction = provisionAction;
@@ -52,6 +59,10 @@ public class ComponentV2 {
     return this.name;
   }
 
+  public String getType() {
+    return type;
+  }
+
   /**
    * Gets the provision action associated with this component.
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
index 4648412..4db3a92 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
@@ -18,17 +18,17 @@
 
 package org.apache.ambari.server.topology;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.api.predicate.PredicateCompiler;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
 /**
  * Host Group information specific to a cluster instance.
  */
@@ -57,14 +57,14 @@ public class HostGroupInfo {
   private final Map<String, String> hostRackInfo = new HashMap<>();
 
   /**
-   * explicitly specified host count
+   * List of services
    */
-  private int requested_count = 0;
+  protected Collection<Service> serviceConfigs;
 
   /**
-   * host group scoped configuration
+   * explicitly specified host count
    */
-  Configuration configuration;
+  private int requested_count = 0;
 
   /**
    * explicitly specified host predicate string
@@ -110,6 +110,10 @@ public class HostGroupInfo {
     }
   }
 
+  public Collection<Service> getServiceConfigs() {
+    return serviceConfigs;
+  }
+
   /**
    * Get the requested host count.
    * This is either the user specified value or
@@ -166,7 +170,7 @@ public class HostGroupInfo {
    * @param configuration configuration instance
    */
   public void setConfiguration(Configuration configuration) {
-    this.configuration = configuration;
+
   }
 
   /**
@@ -175,8 +179,9 @@ public class HostGroupInfo {
    * @return associated host group scoped configuration or null if no configuration
    *         is specified for the host group
    */
+  @Deprecated
   public Configuration getConfiguration() {
-    return configuration;
+    return null;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
index df26b68..fd0f966 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
@@ -110,9 +110,15 @@ public interface HostGroupV2 {
    *
    * @return host group configuration
    */
+  @Deprecated
   Configuration getConfiguration();
 
   /**
+   * List of services
+   */
+  Collection<Service> getServiceConfigs();
+
+  /**
    * Get the cardinality value that was specified for the host group.
    * This is simply meta-data for the stack that a deployer can use
    * and this information is not used by ambari.

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
index 7045912..d8390c6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
@@ -18,22 +18,12 @@
 
 package org.apache.ambari.server.topology;
 
-import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_AND_START;
-import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
-import static org.apache.ambari.server.controller.internal.ProvisionAction.START_ONLY;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.api.predicate.PredicateCompiler;
 import org.apache.ambari.server.controller.internal.HostResourceProvider;
 import org.apache.ambari.server.controller.internal.ResourceImpl;
-import org.apache.ambari.server.controller.internal.Stack;
+import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
@@ -41,14 +31,14 @@ import org.apache.ambari.server.orm.entities.TopologyHostRequestEntity;
 import org.apache.ambari.server.orm.entities.TopologyHostTaskEntity;
 import org.apache.ambari.server.orm.entities.TopologyLogicalTaskEntity;
 import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.topology.tasks.InstallHostTask;
-import org.apache.ambari.server.topology.tasks.PersistHostResourcesTask;
-import org.apache.ambari.server.topology.tasks.RegisterWithConfigGroupTask;
-import org.apache.ambari.server.topology.tasks.StartHostTask;
-import org.apache.ambari.server.topology.tasks.TopologyTask;
+import org.apache.ambari.server.topology.tasks.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.*;
+
+import static org.apache.ambari.server.controller.internal.ProvisionAction.*;
+
 
 
 /**
@@ -60,7 +50,7 @@ public class HostRequest implements Comparable<HostRequest> {
 
   private long requestId;
   private String blueprint;
-  private HostGroup hostGroup;
+  private HostGroupV2 hostGroup;
   private String hostgroupName;
   private Predicate predicate;
   private String hostname = null;
@@ -84,7 +74,7 @@ public class HostRequest implements Comparable<HostRequest> {
   private static PredicateCompiler predicateCompiler = new PredicateCompiler();
 
   public HostRequest(long requestId, long id, long clusterId, String hostname, String blueprintName,
-                     HostGroup hostGroup, Predicate predicate, ClusterTopology topology, boolean skipFailure) {
+                     HostGroupV2 hostGroup, Predicate predicate, ClusterTopology topology, boolean skipFailure) {
     this.requestId = requestId;
     this.id = id;
     this.clusterId = clusterId;
@@ -164,7 +154,7 @@ public class HostRequest implements Comparable<HostRequest> {
     return blueprint;
   }
 
-  public HostGroup getHostGroup() {
+  public HostGroupV2 getHostGroup() {
     return hostGroup;
   }
 
@@ -206,13 +196,13 @@ public class HostRequest implements Comparable<HostRequest> {
     }
 
     // lower level logical component level tasks which get mapped to physical tasks
-    HostGroup hostGroup = getHostGroup();
+    HostGroupV2 hostGroup = getHostGroup();
     Collection<String> startOnlyComponents = hostGroup.getComponentNames(START_ONLY);
     Collection<String> installOnlyComponents = hostGroup.getComponentNames(INSTALL_ONLY);
     Collection<String> installAndStartComponents = hostGroup.getComponentNames(INSTALL_AND_START);
 
-    for (String component : hostGroup.getComponentNames()) {
-      if (component == null || component.equals("AMBARI_SERVER")) {
+    for (ComponentV2 component : hostGroup.getComponents()) {
+      if (component == null || component.getType().equals("AMBARI_SERVER")) {
         LOG.info("Skipping component {} when creating request\n", component);
         continue;
       }
@@ -222,31 +212,31 @@ public class HostRequest implements Comparable<HostRequest> {
           "PENDING HOST ASSIGNMENT : HOSTGROUP=" + getHostgroupName();
 
       AmbariContext context = topology.getAmbariContext();
-      Stack stack = hostGroup.getStack();
+      StackV2 stack = component.getService().getStack();
 
       // Skip INSTALL task in case server component is marked as START_ONLY, or the cluster provision_action is
       // START_ONLY, unless component is marked with INSTALL_ONLY or INSTALL_AND_START.
-      if (startOnlyComponents.contains(component) || (skipInstallTaskCreate &&
-        !installOnlyComponents.contains(component) && !installAndStartComponents.contains(component))
-          && stack != null && !stack.getComponentInfo(component).isClient()) {
-        LOG.info("Skipping create of INSTALL task for {} on {}.", component, hostName);
+      if (startOnlyComponents.contains(component.getName()) || (skipInstallTaskCreate &&
+        !installOnlyComponents.contains(component.getName()) && !installAndStartComponents.contains(component.getName()))
+          && stack != null && !stack.getComponentInfo(component.getType()).isClient()) {
+        LOG.info("Skipping create of INSTALL task for {} on {}.", component.getName(), hostName);
       } else {
         HostRoleCommand logicalInstallTask = context.createAmbariTask(
-          getRequestId(), id, component, hostName, AmbariContext.TaskType.INSTALL, skipFailure);
+          getRequestId(), id, component.getName(), hostName, AmbariContext.TaskType.INSTALL, skipFailure);
         logicalTasks.put(logicalInstallTask.getTaskId(), logicalInstallTask);
-        logicalTaskMap.get(installTask).put(component, logicalInstallTask.getTaskId());
+        logicalTaskMap.get(installTask).put(component.getName(), logicalInstallTask.getTaskId());
       }
 
       // Skip START task if component is a client, or ir marked as INSTALL_ONLY or cluster provision_action is
       // INSTALL_ONLY
-      if (installOnlyComponents.contains(component) || skipStartTaskCreate ||
-        (stack != null && stack.getComponentInfo(component).isClient())) {
-        LOG.info("Skipping create of START task for {} on {}.", component, hostName);
+      if (installOnlyComponents.contains(component.getName()) || skipStartTaskCreate ||
+        (stack != null && stack.getComponentInfo(component.getType()).isClient())) {
+        LOG.info("Skipping create of START task for {} on {}.", component.getName(), hostName);
       } else {
         HostRoleCommand logicalStartTask = context.createAmbariTask(
-            getRequestId(), id, component, hostName, AmbariContext.TaskType.START, skipFailure);
+            getRequestId(), id, component.getName(), hostName, AmbariContext.TaskType.START, skipFailure);
         logicalTasks.put(logicalStartTask.getTaskId(), logicalStartTask);
-        logicalTaskMap.get(startTask).put(component, logicalStartTask.getTaskId());
+        logicalTaskMap.get(startTask).put(component.getName(), logicalStartTask.getTaskId());
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
index b63bbad..1049b90 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
@@ -18,18 +18,7 @@
 
 package org.apache.ambari.server.topology;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicLong;
-
+import com.google.common.collect.Iterables;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
@@ -39,17 +28,14 @@ import org.apache.ambari.server.controller.AmbariServer;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.ShortTaskStatus;
 import org.apache.ambari.server.orm.dao.HostRoleCommandStatusSummaryDTO;
-import org.apache.ambari.server.orm.entities.StageEntity;
-import org.apache.ambari.server.orm.entities.TopologyHostGroupEntity;
-import org.apache.ambari.server.orm.entities.TopologyHostInfoEntity;
-import org.apache.ambari.server.orm.entities.TopologyHostRequestEntity;
-import org.apache.ambari.server.orm.entities.TopologyLogicalRequestEntity;
+import org.apache.ambari.server.orm.entities.*;
 import org.apache.ambari.server.state.Host;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.Iterables;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicLong;
 
 
 /**
@@ -222,7 +208,7 @@ public class LogicalRequest extends Request {
 
     //todo: synchronization
     for (HostRequest hostRequest : allHostRequests) {
-      HostGroup hostGroup = hostRequest.getHostGroup();
+      HostGroupV2 hostGroup = hostRequest.getHostGroup();
       for (String host : topology.getHostGroupInfo().get(hostGroup.getName()).getHostNames()) {
         Collection<String> hostComponents = hostComponentMap.get(host);
         if (hostComponents == null) {
@@ -407,7 +393,7 @@ public class LogicalRequest extends Request {
 
   private void createHostRequests(TopologyRequest request, ClusterTopology topology) {
     Map<String, HostGroupInfo> hostGroupInfoMap = request.getHostGroupInfo();
-    Blueprint blueprint = topology.getBlueprint();
+    BlueprintV2 blueprint = topology.getBlueprint();
     boolean skipFailure = topology.getBlueprint().shouldSkipFailure();
     for (HostGroupInfo hostGroupInfo : hostGroupInfoMap.values()) {
       String groupName = hostGroupInfo.getHostGroupName();

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
index 12af131..dfeb99b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
@@ -18,43 +18,23 @@
 
 package org.apache.ambari.server.topology;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.inject.Singleton;
-
+import com.google.gson.Gson;
+import com.google.inject.Inject;
+import com.google.inject.persist.Transactional;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.controller.internal.BaseClusterRequest;
-import org.apache.ambari.server.orm.dao.HostDAO;
-import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
-import org.apache.ambari.server.orm.dao.TopologyHostGroupDAO;
-import org.apache.ambari.server.orm.dao.TopologyHostInfoDAO;
-import org.apache.ambari.server.orm.dao.TopologyHostRequestDAO;
-import org.apache.ambari.server.orm.dao.TopologyLogicalRequestDAO;
-import org.apache.ambari.server.orm.dao.TopologyLogicalTaskDAO;
-import org.apache.ambari.server.orm.dao.TopologyRequestDAO;
-import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
-import org.apache.ambari.server.orm.entities.TopologyHostGroupEntity;
-import org.apache.ambari.server.orm.entities.TopologyHostInfoEntity;
-import org.apache.ambari.server.orm.entities.TopologyHostRequestEntity;
-import org.apache.ambari.server.orm.entities.TopologyHostTaskEntity;
-import org.apache.ambari.server.orm.entities.TopologyLogicalRequestEntity;
-import org.apache.ambari.server.orm.entities.TopologyLogicalTaskEntity;
-import org.apache.ambari.server.orm.entities.TopologyRequestEntity;
+import org.apache.ambari.server.orm.dao.*;
+import org.apache.ambari.server.orm.entities.*;
 import org.apache.ambari.server.stack.NoSuchStackException;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.topology.tasks.TopologyTask;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.gson.Gson;
-import com.google.inject.Inject;
-import com.google.inject.persist.Transactional;
+import javax.inject.Singleton;
+import java.util.*;
 
 /**
  * Implementation which uses Ambari Database DAO and Entity objects for persistence
@@ -378,8 +358,8 @@ public class PersistedStateImpl implements PersistedState {
     private final Long clusterId;
     private final Type type;
     private final String description;
-    private final Blueprint blueprint;
-    private final Configuration configuration;
+    private final BlueprintV2 blueprint;
+    private final Collection<Service> services;
     private final Map<String, HostGroupInfo> hostGroupInfoMap = new HashMap<>();
 
     public ReplayedTopologyRequest(TopologyRequestEntity entity, BlueprintFactory blueprintFactory) {
@@ -392,8 +372,11 @@ public class PersistedStateImpl implements PersistedState {
       } catch (NoSuchStackException e) {
         throw new RuntimeException("Unable to load blueprint while replaying topology request: " + e, e);
       }
-      configuration = createConfiguration(entity.getClusterProperties(), entity.getClusterAttributes());
-      configuration.setParentConfiguration(blueprint.getConfiguration());
+      //TODO load services, merge servie configs from Cluster template with service configs from Blueprint
+      services = new ArrayList<>();
+      //configuration = createConfiguration(entity.getClusterProperties(), entity.getClusterAttributes());
+      //configuration.setParentConfiguration(blueprint.getConfiguration());
+
 
       parseHostGroupInfo(entity);
     }
@@ -409,13 +392,19 @@ public class PersistedStateImpl implements PersistedState {
     }
 
     @Override
-    public Blueprint getBlueprint() {
+    public BlueprintV2 getBlueprint() {
       return blueprint;
     }
 
     @Override
+    @Deprecated
     public Configuration getConfiguration() {
-      return configuration;
+      return null;
+    }
+
+    @Override
+    public Collection<Service> getServiceConfigs() {
+      return services;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
index 62acdfd..f897f7b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
@@ -19,9 +19,9 @@
 package org.apache.ambari.server.topology;
 
 
-import java.util.Set;
+import org.apache.ambari.server.controller.internal.StackV2;
 
-import org.apache.ambari.server.controller.internal.Stack;
+import java.util.Set;
 
 public class Service {
 
@@ -29,14 +29,16 @@ public class Service {
 
   private final String name;
 
-  private final Stack stack;
+  private final StackV2 stack;
 
   private final Configuration configuration;
 
+  private final ServiceGroup serviceGroup;
+
   private final Set<Service> dependentServices;
 
-  public Service(String type, Stack stack) {
-    this(type, null, stack, null, null);
+  public Service(String type, StackV2 stack, ServiceGroup serviceGroup) {
+    this(type, type, stack, serviceGroup,  null, null);
   }
 
   /**
@@ -46,7 +48,7 @@ public class Service {
    * @param stack
    * @param configuration
    */
-  public Service(String type, String name, Stack stack, Configuration configuration, Set<Service> dependentServices) {
+  public Service(String type, String name, StackV2 stack, ServiceGroup serviceGroup, Configuration configuration, Set<Service> dependentServices) {
     this.type = type;
     if (name == null) {
       this.name = type;
@@ -54,6 +56,7 @@ public class Service {
       this.name = name;
     }
     this.stack = stack;
+    this.serviceGroup = serviceGroup;
     this.configuration = configuration;
     this.dependentServices = dependentServices;
   }
@@ -71,11 +74,19 @@ public class Service {
     return type;
   }
 
-  public Stack getStack() {
+  public StackV2 getStack() {
     return stack;
   }
 
   public Configuration getConfiguration() {
     return configuration;
   }
+
+  public ServiceGroup getServiceGroup() {
+    return serviceGroup;
+  }
+
+  public Set<Service> getDependentServices() {
+    return dependentServices;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
index 8e66f02..4b59293 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ServiceGroup.java
@@ -64,4 +64,5 @@ public class ServiceGroup {
   public Set<ServiceGroup> getDependencies() {
     return dependencies;
   }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
index d07dec0..cfd3501 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
@@ -18,22 +18,10 @@
 
 package org.apache.ambari.server.topology;
 
-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.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-
+import com.google.common.eventbus.Subscribe;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.persist.Transactional;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
@@ -42,21 +30,9 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.AmbariServer;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.ShortTaskStatus;
-import org.apache.ambari.server.controller.internal.ArtifactResourceProvider;
-import org.apache.ambari.server.controller.internal.BaseClusterRequest;
-import org.apache.ambari.server.controller.internal.CalculatedStatus;
-import org.apache.ambari.server.controller.internal.CredentialResourceProvider;
-import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
-import org.apache.ambari.server.controller.internal.RequestImpl;
-import org.apache.ambari.server.controller.internal.ScaleClusterRequest;
-import org.apache.ambari.server.controller.internal.Stack;
-import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
-import org.apache.ambari.server.controller.spi.RequestStatus;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
-import org.apache.ambari.server.controller.spi.ResourceProvider;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.controller.internal.*;
+import org.apache.ambari.server.controller.spi.*;
 import org.apache.ambari.server.events.AmbariEvent;
 import org.apache.ambari.server.events.ClusterConfigFinishedEvent;
 import org.apache.ambari.server.events.HostsRemovedEvent;
@@ -79,10 +55,8 @@ import org.apache.ambari.server.utils.RetryHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.eventbus.Subscribe;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.persist.Transactional;
+import java.util.*;
+import java.util.concurrent.*;
 
 /**
  * Manages all cluster provisioning actions on the cluster topology.
@@ -274,7 +248,6 @@ public class TopologyManager {
 
     final ClusterTopology topology = new ClusterTopologyImpl(ambariContext, request);
     final String clusterName = request.getClusterName();
-    final Stack stack = topology.getBlueprint().getStack();
     final String repoVersion = request.getRepositoryVersion();
     final Long repoVersionID = request.getRepositoryVersionId();
 
@@ -291,7 +264,7 @@ public class TopologyManager {
       addKerberosClient(topology);
 
       // refresh default stack config after adding KERBEROS_CLIENT component to topology
-      topology.getBlueprint().getConfiguration().setParentConfiguration(stack.getConfiguration(topology.getBlueprint().getServices()));
+      //topology.getBlueprint().getConfiguration().setParentConfiguration(stack.getConfiguration(topology.getBlueprint().getAllServices()));
 
       credential = request.getCredentialsMap().get(KDC_ADMIN_CREDENTIAL);
       if (credential == null) {
@@ -301,9 +274,8 @@ public class TopologyManager {
 
     topologyValidatorService.validateTopologyConfiguration(topology);
 
-
     // create resources
-    ambariContext.createAmbariResources(topology, clusterName, securityType, repoVersion, repoVersionID);
+    ambariContext.createAmbariResources(topology, clusterName, securityType);
 
     if (securityConfiguration != null && securityConfiguration.getDescriptor() != null) {
       submitKerberosDescriptorAsArtifact(clusterName, securityConfiguration.getDescriptor());
@@ -345,8 +317,11 @@ public class TopologyManager {
 
     //todo: this should be invoked as part of a generic lifecycle event which could possibly
     //todo: be tied to cluster state
-
+    //TODO add all stack or remove concrete stack version
+    Collection<StackV2> stackList = topology.getBlueprint().getStacks();
+    StackV2 stack = stackList.iterator().next();
     ambariContext.persistInstallStateForUI(clusterName, stack.getName(), stack.getVersion());
+
     clusterProvisionWithBlueprintCreateRequests.put(clusterId, logicalRequest);
     return getRequestStatus(logicalRequest.getRequestId());
   }
@@ -1101,9 +1076,10 @@ public class TopologyManager {
    * @param topology  cluster topology
    */
   private void addKerberosClient(ClusterTopology topology) {
-    for (HostGroup group : topology.getBlueprint().getHostGroups().values()) {
-      group.addComponent("KERBEROS_CLIENT");
-    }
+    //TODO lookup KERBEROS_CLIENT
+//    for (HostGroupV2 group : topology.getBlueprint().getHostGroups().values()) {
+//      group.addComponent("KERBEROS_CLIENT");
+//    }
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyRequest.java
index bd5630b..632473a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyRequest.java
@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.topology;
 
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -52,16 +53,23 @@ public interface TopologyRequest {
    *
    * @return associated blueprint instance
    */
-  Blueprint getBlueprint();
+  BlueprintV2 getBlueprint();
 
   /**
    * Get the cluster scoped configuration for the request.
    *
    * @return cluster scoped configuration
    */
+  @Deprecated
   Configuration getConfiguration();
 
   /**
+   * Returns services.
+   * @return
+   */
+  Collection<Service> getServiceConfigs();
+
+  /**
    * Get host group info.
    *
    * @return map of host group name to group info

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java
index 990aee7..f8ad78e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java
@@ -17,20 +17,17 @@
  */
 package org.apache.ambari.server.topology.tasks;
 
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+import org.apache.ambari.server.topology.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
-import org.apache.ambari.server.topology.ClusterTopology;
-import org.apache.ambari.server.topology.HostGroup;
-import org.apache.ambari.server.topology.HostRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
-
 public class PersistHostResourcesTask extends TopologyHostTask  {
 
   private final static Logger LOG = LoggerFactory.getLogger(PersistHostResourcesTask.class);
@@ -49,10 +46,10 @@ public class PersistHostResourcesTask extends TopologyHostTask  {
   public void runTask() {
     LOG.info("HostRequest: Executing RESOURCE_CREATION task for host: {}", hostRequest.getHostName());
 
-    HostGroup group = hostRequest.getHostGroup();
-    Map<String, Collection<String>> serviceComponents = new HashMap<>();
-    for (String service : group.getServices()) {
-      serviceComponents.put(service, new HashSet<>(group.getComponents(service)));
+    HostGroupV2 group = hostRequest.getHostGroup();
+    Map<Service, Collection<ComponentV2>> serviceComponents = new HashMap<>();
+    for (Service service : group.getServices()) {
+      serviceComponents.put(service, new HashSet(group.getComponents(service)));
     }
     clusterTopology.getAmbariContext().createAmbariHostResources(hostRequest.getClusterId(),
       hostRequest.getHostName(), serviceComponents);

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
index 0170186..4895c40 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
@@ -13,15 +13,16 @@
  */
 package org.apache.ambari.server.topology.validators;
 
-import java.util.HashSet;
-import java.util.Set;
-
 import org.apache.ambari.server.topology.ClusterTopology;
 import org.apache.ambari.server.topology.InvalidTopologyException;
+import org.apache.ambari.server.topology.Service;
 import org.apache.ambari.server.topology.TopologyValidator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * Validates configuration types related to services specified in the blueprint.
  * If the cluster creation template contains configuration types that are not related to services in the blueprint the
@@ -44,8 +45,8 @@ public class ClusterConfigTypeValidator implements TopologyValidator {
 
     // collecting all config types for services in the blueprint (from the related stack)
     Set<String> stackServiceConfigTypes = new HashSet<>();
-    for (String serviceName : topology.getBlueprint().getServices()) {
-      stackServiceConfigTypes.addAll(topology.getBlueprint().getStack().getConfigurationTypes(serviceName));
+    for (Service service : topology.getBlueprint().getAllServices()) {
+      stackServiceConfigTypes.addAll(service.getStack().getConfigurationTypes(service.getType()));
     }
 
     // identifying invalid config types

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/HiveServiceValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/HiveServiceValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/HiveServiceValidator.java
index 80b2593..3f8b517 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/HiveServiceValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/HiveServiceValidator.java
@@ -14,13 +14,12 @@
 
 package org.apache.ambari.server.topology.validators;
 
-import org.apache.ambari.server.topology.ClusterTopology;
-import org.apache.ambari.server.topology.Configuration;
-import org.apache.ambari.server.topology.InvalidTopologyException;
-import org.apache.ambari.server.topology.TopologyValidator;
+import org.apache.ambari.server.topology.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.Collection;
+
 /**
  * Validates hive service related setup before provisioning the cluster.
  */
@@ -37,34 +36,41 @@ public class HiveServiceValidator implements TopologyValidator {
   @Override
   public void validate(ClusterTopology topology) throws InvalidTopologyException {
 
+    Collection<Service> services = topology.getBlueprint().getServicesByType(HIVE_SERVICE);
     // there is no hive configured in the blueprint, nothing to do (does the validator apply?)
-    if (!topology.getBlueprint().getServices().contains(HIVE_SERVICE)) {
+    if (services.isEmpty()) {
       LOGGER.info(" [{}] service is not listed in the blueprint, skipping hive service validation.", HIVE_SERVICE);
       return;
     }
 
-    Configuration clusterConfiguration = topology.getConfiguration();
+    for (Service service : services) {
 
-    // hive database settings are missing (this should never be the case, defaults come from the stack def.)
-    if (!clusterConfiguration.getAllConfigTypes().contains(HIVE_ENV)) {
-      String errorMessage = String.format(" [ %s ] config type is missing from the service [ %s ]. HIVE service validation failed.", HIVE_ENV, HIVE_SERVICE);
-      LOGGER.error(errorMessage);
-      throw new InvalidTopologyException(errorMessage);
-    }
+      Configuration serviceConfiguration = service.getConfiguration();
 
-    // hive database has custom configuration, skipping validation
-    if (!HIVE_DB_DEFAULT.equals(clusterConfiguration.getPropertyValue(HIVE_ENV, HIVE_DB_PROPERTY))) {
-      LOGGER.info("Custom hive database settings detected. HIVE service validation succeeded.");
-      return;
-    }
+      // hive database settings are missing (this should never be the case, defaults come from the stack def.)
+      if (!serviceConfiguration.getAllConfigTypes().contains(HIVE_ENV)) {
+        String errorMessage = String.format(" [ %s ] config type is missing from the service [ %s ]. HIVE service validation failed.", HIVE_ENV, HIVE_SERVICE);
+        LOGGER.error(errorMessage);
+        throw new InvalidTopologyException(errorMessage);
+      }
 
-    // hive database settings need the mysql-server component in the blueprint
-    if (!topology.getBlueprint().getComponents(HIVE_SERVICE).contains(MYSQL_SERVER_COMPONENT)) {
-      String errorMessage = String.format("Component [%s] must explicitly be set in the blueprint when hive database " +
+      // hive database has custom configuration, skipping validation
+      if (!HIVE_DB_DEFAULT.equals(serviceConfiguration.getPropertyValue(HIVE_ENV, HIVE_DB_PROPERTY))) {
+        LOGGER.info("Custom hive database settings detected. HIVE service validation succeeded.");
+        return;
+      }
+
+      Collection<ComponentV2> mySqlComponents = topology.getBlueprint().getComponentsByType(service, MYSQL_SERVER_COMPONENT);
+
+      // hive database settings need the mysql-server component in the blueprint
+      if (mySqlComponents.isEmpty()) {
+        String errorMessage = String.format("Component [%s] must explicitly be set in the blueprint when hive database " +
         "is configured with the current settings. HIVE service validation failed.", MYSQL_SERVER_COMPONENT);
-      LOGGER.error(errorMessage);
-      throw new InvalidTopologyException(errorMessage);
+        LOGGER.error(errorMessage);
+        throw new InvalidTopologyException(errorMessage);
+      }
     }
+
   }
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
index 4022fcb..4d37a02 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
@@ -14,23 +14,14 @@
 
 package org.apache.ambari.server.topology.validators;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.TreeSet;
-
-import org.apache.ambari.server.controller.internal.Stack;
+import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.state.PropertyInfo;
-import org.apache.ambari.server.topology.Blueprint;
-import org.apache.ambari.server.topology.ClusterTopology;
-import org.apache.ambari.server.topology.HostGroup;
-import org.apache.ambari.server.topology.InvalidTopologyException;
-import org.apache.ambari.server.topology.TopologyValidator;
+import org.apache.ambari.server.topology.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.*;
+
 
 /**
  * Validates the configuration by checking the existence of required properties for the services listed in the blueprint.
@@ -52,14 +43,11 @@ public class RequiredConfigPropertiesValidator implements TopologyValidator {
   @Override
   public void validate(ClusterTopology topology) throws InvalidTopologyException {
 
-    // collect required properties
-    Map<String, Map<String, Collection<String>>> requiredPropertiesByService = getRequiredPropertiesByService(topology.getBlueprint());
-
     // find missing properties in the cluster configuration
     Map<String, Collection<String>> missingProperties = new TreeMap<>();
     Map<String, Map<String, String>> topologyConfiguration = new HashMap<>(topology.getConfiguration().getFullProperties(1));
 
-    for (HostGroup hostGroup : topology.getBlueprint().getHostGroups().values()) {
+    for (HostGroupV2 hostGroup : topology.getBlueprint().getHostGroups().values()) {
       LOGGER.debug("Processing hostgroup configurations for hostgroup: {}", hostGroup.getName());
 
       // copy of all configurations available in the topology hgConfig -> topologyConfig -> bpConfig
@@ -73,21 +61,21 @@ public class RequiredConfigPropertiesValidator implements TopologyValidator {
         }
       }
 
-      for (String hostGroupService : hostGroup.getServices()) {
+      for (Service hostGroupService : hostGroup.getServices()) {
 
-        if (!requiredPropertiesByService.containsKey(hostGroupService)) {
+        // collect required properties
+        Map<String, Collection<String>> requiredPropertiesForService = getRequiredPropertiesForService(hostGroupService);
+        if (requiredPropertiesForService.isEmpty()) {
           // there are no required properties for the service
           LOGGER.debug("There are no required properties found for hostgroup/service: [{}/{}]", hostGroup.getName(), hostGroupService);
           continue;
         }
 
-        Map<String, Collection<String>> requiredPropertiesByType = requiredPropertiesByService.get(hostGroupService);
-
-        for (String configType : requiredPropertiesByType.keySet()) {
+        for (String configType : requiredPropertiesForService.keySet()) {
 
           // We need a copy not to modify the original
           Collection<String> requiredPropertiesForType = new HashSet(
-              requiredPropertiesByType.get(configType));
+            requiredPropertiesForService.get(configType));
 
           if (!operationalConfigurations.containsKey(configType)) {
             // all required configuration is missing for the config type
@@ -116,60 +104,48 @@ public class RequiredConfigPropertiesValidator implements TopologyValidator {
 
 
   /**
-   * Collects required properties for services in the blueprint. Configuration properties are returned by configuration type.
-   * service -> configType -> properties
-   *
-   * @param blueprint the blueprint from the cluster topology
+   * Collects required properties for a specified services in the blueprint. Configuration properties are returned
+   * by configuration type. configType -> properties
+   * @param service the blueprint from the cluster topology
    * @return a map with configuration types mapped to collections of required property names
    */
 
-  private Map<String, Map<String, Collection<String>>> getRequiredPropertiesByService(Blueprint blueprint) {
+  private Map<String, Collection<String>> getRequiredPropertiesForService(Service service) {
 
-    Map<String, Map<String, Collection<String>>> requiredPropertiesForServiceByType = new HashMap<>();
+    LOGGER.debug("Collecting required properties for the service: {}", service.getName());
 
-    for (String bpService : blueprint.getServices()) {
-      LOGGER.debug("Collecting required properties for the service: {}", bpService);
+    Collection<StackV2.ConfigProperty> requiredConfigsForService = service.getStack().
+      getRequiredConfigurationProperties(service.getType());
+    Map<String, Collection<String>> requiredPropertiesByConfigType = new HashMap<>();
 
-      Collection<Stack.ConfigProperty> requiredConfigsForService = blueprint.getStack().getRequiredConfigurationProperties(bpService);
-      Map<String, Collection<String>> requiredPropertiesByConfigType = new HashMap<>();
-
-      for (Stack.ConfigProperty configProperty : requiredConfigsForService) {
-
-        if (configProperty.getPropertyTypes() != null && configProperty.getPropertyTypes().contains(PropertyInfo.PropertyType.PASSWORD)) {
-          LOGGER.debug("Skipping required property validation for password type: {}", configProperty.getName());
-          // skip password types
-          continue;
-        }
+    for (StackV2.ConfigProperty configProperty : requiredConfigsForService) {
 
-        // add / get  service related required propeByType map
-        if (requiredPropertiesForServiceByType.containsKey(bpService)) {
-          requiredPropertiesByConfigType = requiredPropertiesForServiceByType.get(bpService);
-        } else {
-          LOGGER.debug("Adding required properties entry for service: {}", bpService);
-          requiredPropertiesForServiceByType.put(bpService, requiredPropertiesByConfigType);
-        }
-
-        // add collection of required properties
-        Collection<String> requiredPropsForType = new HashSet<>();
-        if (requiredPropertiesByConfigType.containsKey(configProperty.getType())) {
-          requiredPropsForType = requiredPropertiesByConfigType.get(configProperty.getType());
-        } else {
-          LOGGER.debug("Adding required properties entry for configuration type: {}", configProperty.getType());
-          requiredPropertiesByConfigType.put(configProperty.getType(), requiredPropsForType);
-        }
+      if (configProperty.getPropertyTypes() != null && configProperty.getPropertyTypes().contains(PropertyInfo.PropertyType.PASSWORD)) {
+        LOGGER.debug("Skipping required property validation for password type: {}", configProperty.getName());
+        // skip password types
+        continue;
+      }
 
-        requiredPropsForType.add(configProperty.getName());
-        LOGGER.debug("Added required property for service; {}, configuration type: {}, property: {}", bpService,
-          configProperty.getType(), configProperty.getName());
+      // add collection of required properties
+      Collection<String> requiredPropsForType = new HashSet<>();
+      if (requiredPropertiesByConfigType.containsKey(configProperty.getType())) {
+        requiredPropsForType = requiredPropertiesByConfigType.get(configProperty.getType());
+      } else {
+        LOGGER.debug("Adding required properties entry for configuration type: {}", configProperty.getType());
+        requiredPropertiesByConfigType.put(configProperty.getType(), requiredPropsForType);
       }
+
+      requiredPropsForType.add(configProperty.getName());
+      LOGGER.debug("Added required property for service; {}, configuration type: {}, property: {}", service.getName(),
+        configProperty.getType(), configProperty.getName());
     }
 
-    LOGGER.info("Identified required properties for blueprint services: {}", requiredPropertiesForServiceByType);
-    return requiredPropertiesForServiceByType;
+    return requiredPropertiesByConfigType;
 
   }
 
-  private Map<String, Collection<String>> addTomissingProperties(Map<String, Collection<String>> missingProperties, String hostGroup, Collection<String> values) {
+  private Map<String, Collection<String>> addTomissingProperties(Map<String, Collection<String>> missingProperties,
+                                                                 String hostGroup, Collection<String> values) {
     Map<String, Collection<String>> missing;
 
     if (missingProperties == null) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
index 5b4ecc1..9a2b846 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
@@ -14,20 +14,15 @@ package org.apache.ambari.server.topology.validators;
  * limitations under the License.
  */
 
+import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.topology.*;
+
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
-import org.apache.ambari.server.controller.internal.Stack;
-import org.apache.ambari.server.state.PropertyInfo;
-import org.apache.ambari.server.topology.Blueprint;
-import org.apache.ambari.server.topology.ClusterTopology;
-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.TopologyValidator;
-
 /**
  * Validates that all required passwords are provided.
  */
@@ -80,23 +75,22 @@ public class RequiredPasswordValidator implements TopologyValidator {
           groupEntry.getValue().getConfiguration().getFullProperties(3);
 
       Collection<String> processedServices = new HashSet<>();
-      Blueprint blueprint = topology.getBlueprint();
-      Stack stack = blueprint.getStack();
+      BlueprintV2 blueprint = topology.getBlueprint();
 
-      HostGroup hostGroup = blueprint.getHostGroup(hostGroupName);
-      for (String component : hostGroup.getComponentNames()) {
+      HostGroupV2 hostGroup = blueprint.getHostGroup(hostGroupName);
+      for (ComponentV2 component : hostGroup.getComponents()) {
         //for now, AMBARI is not recognized as a service in Stacks
-        if (component.equals("AMBARI_SERVER")) {
+        if (component.getType().equals("AMBARI_SERVER")) {
           continue;
         }
 
-        String serviceName = stack.getServiceForComponent(component);
-        if (processedServices.add(serviceName)) {
+        Service service = component.getService();
+        if (processedServices.add(service.getName())) {
           //todo: do I need to subtract excluded configs?
-          Collection<Stack.ConfigProperty> requiredProperties =
-              stack.getRequiredConfigurationProperties(serviceName, PropertyInfo.PropertyType.PASSWORD);
+          Collection<StackV2.ConfigProperty> requiredProperties =
+          service.getStack().getRequiredConfigurationProperties(service.getType(), PropertyInfo.PropertyType.PASSWORD);
 
-          for (Stack.ConfigProperty property : requiredProperties) {
+          for (StackV2.ConfigProperty property : requiredProperties) {
             String category = property.getType();
             String name = property.getName();
             if (! propertyExists(topology, groupProperties, category, name)) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidator.java
index f028a31..55660e3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidator.java
@@ -14,15 +14,16 @@
 
 package org.apache.ambari.server.topology.validators;
 
-import java.util.HashSet;
-import java.util.Set;
-
 import org.apache.ambari.server.topology.ClusterTopology;
 import org.apache.ambari.server.topology.InvalidTopologyException;
+import org.apache.ambari.server.topology.Service;
 import org.apache.ambari.server.topology.TopologyValidator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * Validates whether incoming config types (form the blueprint or the cluster creation template) are valid.
  * A configuration type is considered valid if the stack based on which the cluster is to be created contains such a
@@ -36,25 +37,27 @@ public class StackConfigTypeValidator implements TopologyValidator {
 
   @Override
   public void validate(ClusterTopology topology) throws InvalidTopologyException {
+    for (Service service : topology.getServiceConfigs()) {
+      // get the config types form the request
+      Set<String> incomingConfigTypes = new HashSet<>(service.getConfiguration().getAllConfigTypes());
 
-    // get the config types form the request
-    Set<String> incomingConfigTypes = new HashSet<>(topology.getConfiguration().getAllConfigTypes());
+      if (incomingConfigTypes.isEmpty()) {
+        LOGGER.debug("No config types to be checked.");
+        return;
+      }
 
-    if (incomingConfigTypes.isEmpty()) {
-      LOGGER.debug("No config types to be checked.");
-      return;
-    }
+      Set<String> stackConfigTypes = new HashSet<>(service.getStack().getConfiguration().getAllConfigTypes());
 
-    Set<String> stackConfigTypes = new HashSet<>(topology.getBlueprint().getStack().getConfiguration().getAllConfigTypes());
+      // remove all "valid" config types from the incoming set
+      incomingConfigTypes.removeAll(stackConfigTypes);
 
-    // remove all "valid" config types from the incoming set
-    incomingConfigTypes.removeAll(stackConfigTypes);
+      if (!incomingConfigTypes.isEmpty()) {
+        // there are config types in the request that are not in the stack
+        String message = String.format("The following config types are not defined in the stack: %s ", incomingConfigTypes);
+        LOGGER.error(message);
+        throw new InvalidTopologyException(message);
+      }
 
-    if (!incomingConfigTypes.isEmpty()) {
-      // there are config types in the request that are not in the stack
-      String message = String.format("The following config types are not defined in the stack: %s ", incomingConfigTypes);
-      LOGGER.error(message);
-      throw new InvalidTopologyException(message);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
index e75ffa4..50bdec6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
@@ -17,18 +17,17 @@
  */
 package org.apache.ambari.server.topology.validators;
 
-import static org.apache.ambari.server.controller.internal.UnitUpdater.PropertyValue;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.ambari.server.controller.internal.Stack;
+import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.controller.internal.UnitUpdater.PropertyUnit;
 import org.apache.ambari.server.topology.ClusterTopology;
-import org.apache.ambari.server.topology.HostGroupInfo;
 import org.apache.ambari.server.topology.InvalidTopologyException;
 import org.apache.ambari.server.topology.TopologyValidator;
 
+import java.util.Map;
+import java.util.Set;
+
+import static org.apache.ambari.server.controller.internal.UnitUpdater.PropertyValue;
+
 /**
  * I validate the unit of properties by checking if it matches to the stack defined unit.
  * Properties with different unit than the stack defined unit are rejected.
@@ -42,33 +41,32 @@ public class UnitValidator implements TopologyValidator {
 
   @Override
   public void validate(ClusterTopology topology) throws InvalidTopologyException {
-    Stack stack = topology.getBlueprint().getStack();
-    validateConfig(topology.getConfiguration().getFullProperties(), stack);
-    for (HostGroupInfo hostGroup : topology.getHostGroupInfo().values()) {
-      validateConfig(hostGroup.getConfiguration().getFullProperties(), stack);
-    }
+    topology.getServiceConfigs().forEach(service -> {
+      validateConfig(service.getConfiguration().getFullProperties(), service.getStack());
+      topology.getHostGroupInfo().values().forEach(hostGroup ->
+        validateConfig(hostGroup.getConfiguration().getFullProperties(), service.getStack()));
+    });
+
   }
 
-  private void validateConfig(Map<String, Map<String, String>> configuration, Stack stack) {
-    for (Map.Entry<String, Map<String, String>> each : configuration.entrySet()) {
-      validateConfigType(each.getKey(), each.getValue(), stack);
-    }
+  private void validateConfig(Map<String, Map<String, String>> configuration, StackV2 stack) {
+    configuration.entrySet().forEach(each ->
+      validateConfigType(each.getKey(), each.getValue(), stack)
+    );
   }
 
-  private void validateConfigType(String configType, Map<String, String> config, Stack stack) {
-    for (String propertyName : config.keySet()) {
-      validateProperty(configType, config, propertyName, stack);
-    }
+  private void validateConfigType(String configType, Map<String, String> config, StackV2 stack) {
+    config.keySet().forEach(propertyName -> validateProperty(configType, config, propertyName, stack));
   }
 
-  private void validateProperty(String configType, Map<String, String> config, String propertyName, Stack stack) {
+  private void validateProperty(String configType, Map<String, String> config, String propertyName, StackV2 stack) {
     relevantProps.stream()
       .filter(each -> each.hasTypeAndName(configType, propertyName))
       .findFirst()
       .ifPresent(relevantProperty -> checkUnit(config, stack, relevantProperty));
   }
 
-  private void checkUnit(Map<String, String> configToBeValidated, Stack stack, UnitValidatedProperty prop) {
+  private void checkUnit(Map<String, String> configToBeValidated, StackV2 stack, UnitValidatedProperty prop) {
     PropertyUnit stackUnit = PropertyUnit.of(stack, prop);
     PropertyValue value = PropertyValue.of(prop.getPropertyName(), configToBeValidated.get(prop.getPropertyName()));
     if (value.hasAnyUnit() && !value.hasUnit(stackUnit)) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/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 8c44632..bbd0fea 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
@@ -322,7 +322,7 @@ public class AmbariMetaInfoTest {
   }
 
   /**
-   * Method: Map<String, ServiceInfo> getServices(String stackName, String
+   * Method: Map<String, ServiceInfo> getServiceConfigs(String stackName, String
    * version, String serviceName)
    * @throws AmbariException
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/test/java/org/apache/ambari/server/api/services/RootServiceServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/RootServiceServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/RootServiceServiceTest.java
index cbf2036..490d2da 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/RootServiceServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/RootServiceServiceTest.java
@@ -40,7 +40,7 @@ public class RootServiceServiceTest extends BaseServiceTest {
   public List<ServiceTestInvocation> getTestInvocations() throws Exception {
     List<ServiceTestInvocation> listInvocations = new ArrayList<>();
     
-    //getServices
+    //getServiceConfigs
     RootServiceService service = new TestRootServiceService(null, null, null);
     Method m = service.getClass().getMethod("getRootServices", String.class, HttpHeaders.class, UriInfo.class);
     Object[] args = new Object[] {null, getHttpHeaders(), getUriInfo()};

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/test/java/org/apache/ambari/server/api/services/ServiceServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/ServiceServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/ServiceServiceTest.java
index a51d710..a5bb5e7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/ServiceServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/ServiceServiceTest.java
@@ -45,7 +45,7 @@ public class ServiceServiceTest extends BaseServiceTest {
     Object[] args = new Object[] {null, getHttpHeaders(), getUriInfo(), "serviceName"};
     listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
 
-    //getServices
+    //getServiceConfigs
     service = new TestServiceService("clusterName", null);
     m = service.getClass().getMethod("getServices", String.class, HttpHeaders.class, UriInfo.class);
     args = new Object[] {null, getHttpHeaders(), getUriInfo()};

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/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 bf2b84d..44b46f4 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
@@ -8961,7 +8961,7 @@ public class AmbariManagementControllerTest {
     expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(maintHelper);
     expect(injector.getInstance(KerberosHelper.class)).andReturn(createStrictMock(KerberosHelper.class));
 
-    // getServices
+    // getServiceConfigs
     expect(clusters.getCluster("cluster1")).andReturn(cluster);
     expect(cluster.getService("service1")).andReturn(service);
 
@@ -9005,7 +9005,7 @@ public class AmbariManagementControllerTest {
     expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(maintHelper);
     expect(injector.getInstance(KerberosHelper.class)).andReturn(createStrictMock(KerberosHelper.class));
 
-    // getServices
+    // getServiceConfigs
     expect(clusters.getCluster("cluster1")).andReturn(cluster);
     expect(cluster.getService("service1")).andThrow(new ServiceNotFoundException("custer1", "service1"));
 
@@ -9064,7 +9064,7 @@ public class AmbariManagementControllerTest {
     expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(maintHelper);
     expect(injector.getInstance(KerberosHelper.class)).andReturn(createStrictMock(KerberosHelper.class));
 
-    // getServices
+    // getServiceConfigs
     expect(clusters.getCluster("cluster1")).andReturn(cluster).times(4);
     expect(cluster.getService("service1")).andReturn(service1);
     expect(cluster.getService("service2")).andThrow(new ServiceNotFoundException("cluster1", "service2"));

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
index 4b09c6d..c9e3ce9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
@@ -599,7 +599,7 @@ public class ClusterTest {
     // TODO write unit tests for
     // public void addService(Service service) throws AmbariException;
     // public Service getService(String serviceName) throws AmbariException;
-    // public Map<String, Service> getServices();
+    // public Map<String, Service> getServiceConfigs();
 
     RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(c1);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintImplTest.java
index 6ac74a3..bb33edd 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/BlueprintImplTest.java
@@ -459,7 +459,7 @@ public class BlueprintImplTest {
 //    expect(request.getProperties()).andReturn(setProperties);
 //    expect(request.getRequestInfoProperties()).andReturn(Collections.<String, String>emptyMap());
 //    expect(dao.findByName(BLUEPRINT_NAME)).andReturn(null);
-//    expect(metaInfo.getServices("test-stack-name", "test-stack-version")).andReturn(services).anyTimes();
+//    expect(metaInfo.getServiceConfigs("test-stack-name", "test-stack-version")).andReturn(services).anyTimes();
 //    expect(metaInfo.getComponentsByService("test-stack-name", "test-stack-version", "test-service")).
 //        andReturn(serviceComponents).anyTimes();
 //    expect(metaInfo.getComponentToService("test-stack-name", "test-stack-version", "component1")).
@@ -570,7 +570,7 @@ public class BlueprintImplTest {
 //    expect(request.getProperties()).andReturn(setProperties);
 //    expect(request.getRequestInfoProperties()).andReturn(Collections.<String, String>emptyMap());
 //    expect(dao.findByName(BLUEPRINT_NAME)).andReturn(null);
-//    expect(metaInfo.getServices("test-stack-name", "test-stack-version")).andReturn(services).anyTimes();
+//    expect(metaInfo.getServiceConfigs("test-stack-name", "test-stack-version")).andReturn(services).anyTimes();
 //    expect(metaInfo.getComponentsByService("test-stack-name", "test-stack-version", "test-service")).
 //        andReturn(serviceComponents).anyTimes();
 //    expect(metaInfo.getComponentToService("test-stack-name", "test-stack-version", "component1")).
@@ -689,7 +689,7 @@ public class BlueprintImplTest {
 //    expect(request.getProperties()).andReturn(setProperties);
 //    expect(request.getRequestInfoProperties()).andReturn(Collections.<String, String>emptyMap());
 //    expect(dao.findByName(BLUEPRINT_NAME)).andReturn(null);
-//    expect(metaInfo.getServices("test-stack-name", "test-stack-version")).andReturn(services).anyTimes();
+//    expect(metaInfo.getServiceConfigs("test-stack-name", "test-stack-version")).andReturn(services).anyTimes();
 //    expect(metaInfo.getComponentsByService("test-stack-name", "test-stack-version", "test-service")).
 //        andReturn(serviceComponents).anyTimes();
 //    expect(metaInfo.getComponentToService("test-stack-name", "test-stack-version", "component1")).
@@ -797,7 +797,7 @@ public class BlueprintImplTest {
 //    expect(request.getProperties()).andReturn(setProperties);
 //    expect(request.getRequestInfoProperties()).andReturn(Collections.<String, String>emptyMap());
 //    expect(dao.findByName(BLUEPRINT_NAME)).andReturn(null);
-//    expect(metaInfo.getServices("test-stack-name", "test-stack-version")).andReturn(services).anyTimes();
+//    expect(metaInfo.getServiceConfigs("test-stack-name", "test-stack-version")).andReturn(services).anyTimes();
 //    expect(metaInfo.getComponentsByService("test-stack-name", "test-stack-version", "test-service")).
 //        andReturn(serviceComponents).anyTimes();
 //    expect(metaInfo.getComponentToService("test-stack-name", "test-stack-version", "component1")).
@@ -865,7 +865,7 @@ public class BlueprintImplTest {
 //    expect(request.getProperties()).andReturn(setProperties);
 //    expect(request.getRequestInfoProperties()).andReturn(Collections.<String, String>emptyMap());
 //    expect(dao.findByName(BLUEPRINT_NAME)).andReturn(null);
-//    expect(metaInfo.getServices("test-stack-name", "test-stack-version")).andReturn(services).anyTimes();
+//    expect(metaInfo.getServiceConfigs("test-stack-name", "test-stack-version")).andReturn(services).anyTimes();
 //    expect(metaInfo.getComponentsByService("test-stack-name", "test-stack-version", "test-service")).
 //        andReturn(serviceComponents).anyTimes();
 //    expect(metaInfo.getComponentToService("test-stack-name", "test-stack-version", "component1")).

http://git-wip-us.apache.org/repos/asf/ambari/blob/65d44cd5/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
index e51ce5f..87d6363 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
@@ -18,23 +18,16 @@
 
 package org.apache.ambari.server.topology;
 
-import static org.easymock.EasyMock.expect;
-import static org.powermock.api.easymock.PowerMock.createNiceMock;
-import static org.powermock.api.easymock.PowerMock.replay;
-import static org.powermock.api.easymock.PowerMock.reset;
-import static org.powermock.api.easymock.PowerMock.verify;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
+import org.apache.ambari.server.controller.internal.Stack;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.*;
+
+import static org.easymock.EasyMock.expect;
+import static org.powermock.api.easymock.PowerMock.*;
+
 /**
  * Unit tests for ClusterTopologyImpl.
  */
@@ -44,13 +37,14 @@ public class ClusterTopologyImplTest {
   private static final String CLUSTER_NAME = "cluster_name";
   private static final long CLUSTER_ID = 1L;
   private static final String predicate = "Hosts/host_name=foo";
-  private static final Blueprint blueprint = createNiceMock(Blueprint.class);
-  private static final HostGroup group1 = createNiceMock(HostGroup.class);
-  private static final HostGroup group2 = createNiceMock(HostGroup.class);
-  private static final HostGroup group3 = createNiceMock(HostGroup.class);
-  private static final HostGroup group4 = createNiceMock(HostGroup.class);
+  private static final BlueprintV2 blueprint = createNiceMock(BlueprintV2.class);
+  private static final HostGroupV2 group1 = createNiceMock(HostGroupV2.class);
+  private static final HostGroupV2 group2 = createNiceMock(HostGroupV2.class);
+  private static final HostGroupV2 group3 = createNiceMock(HostGroupV2.class);
+  private static final HostGroupV2 group4 = createNiceMock(HostGroupV2.class);
+  private static final Stack stack = createNiceMock(Stack.class);
   private final Map<String, HostGroupInfo> hostGroupInfoMap = new HashMap<>();
-  private final Map<String, HostGroup> hostGroupMap = new HashMap<>();
+  private final Map<String, HostGroupV2> hostGroupMap = new HashMap<>();
 
   private Configuration configuration;
   private Configuration bpconfiguration;
@@ -101,20 +95,20 @@ public class ClusterTopologyImplTest {
     hostGroupMap.put("group3", group3);
     hostGroupMap.put("group4", group4);
 
-    Set<Component> group1Components = new HashSet<>();
-    group1Components.add(new Component("component1"));
-    group1Components.add(new Component("component2"));
+    Set<ComponentV2> group1Components = new HashSet<>();
+    group1Components.add(new ComponentV2("component1", new Service("service1", stack)));
+    group1Components.add(new ComponentV2("component2", new Service("service1", stack)));
 
     Set<String> group1ComponentNames = new HashSet<>();
     group1ComponentNames.add("component1");
     group1ComponentNames.add("component2");
 
-    Set<Component> group2Components = new HashSet<>();
-    group2Components.add(new Component("component3"));
-    Set<Component> group3Components = new HashSet<>();
-    group3Components.add(new Component("component4"));
-    Set<Component> group4Components = new HashSet<>();
-    group4Components.add(new Component("component5"));
+    Set<ComponentV2> group2Components = new HashSet<>();
+    group2Components.add(new ComponentV2("component3", new Service("service1", stack)));
+    Set<ComponentV2> group3Components = new HashSet<>();
+    group3Components.add(new ComponentV2("component4", new Service("service2", stack)));
+    Set<ComponentV2> group4Components = new HashSet<>();
+    group4Components.add(new ComponentV2("component5", new Service("service2", stack)));
 
     expect(blueprint.getHostGroups()).andReturn(hostGroupMap).anyTimes();
     expect(blueprint.getHostGroup("group1")).andReturn(group1).anyTimes();
@@ -143,7 +137,6 @@ public class ClusterTopologyImplTest {
     verify(blueprint, group1, group2, group3, group4);
     reset(blueprint, group1, group2, group3, group4);
 
-
     hostGroupInfoMap.clear();
     hostGroupMap.clear();
   }
@@ -241,7 +234,7 @@ public class ClusterTopologyImplTest {
     }
 
     @Override
-    public Blueprint getBlueprint() {
+    public BlueprintV2 getBlueprint() {
       return blueprint;
     }
 
@@ -251,6 +244,11 @@ public class ClusterTopologyImplTest {
     }
 
     @Override
+    public Collection<Service> getServiceConfigs() {
+      return null;
+    }
+
+    @Override
     public Map<String, HostGroupInfo> getHostGroupInfo() {
       return hostGroupInfoMap;
     }


[03/30] ambari git commit: AMBARI-22209. HdpCoreMpack: Quick Links should show NN web UI links.(vbrodetskyi)

Posted by mr...@apache.org.
AMBARI-22209. HdpCoreMpack: Quick Links should show NN web UI links.(vbrodetskyi)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: cbaa88d2bdcc3ee3c3f043098f2b7a98f3563746
Parents: 8d8c1a5
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Thu Oct 12 23:48:20 2017 +0300
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Thu Oct 12 23:48:20 2017 +0300

----------------------------------------------------------------------
 .../apache/ambari/server/state/ServiceInfo.java | 28 +++++++++++++++++---
 1 file changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/cbaa88d2/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 1cad4df..0e6e3c3 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
@@ -468,9 +468,11 @@ public class ServiceInfo implements Validable, Cloneable {
     clone.serviceOsSpecifics =  serviceOsSpecifics;
     clone.configDir = configDir;
     clone.themesDir = themesDir;
-    clone.setThemes(themes);
+    clone.setThemes(getThemes());
+    clone.setThemesMap(themesMap);
     clone.setQuickLinksConfigurationsDir(quickLinksConfigurationsDir);
-    clone.setQuickLinksConfigurations(quickLinksConfigurations);
+    clone.setQuickLinksConfigurations(getQuickLinksConfigurations());
+    clone.setQuickLinksConfigurationsMap(quickLinksConfigurationsMap);
     clone.setCommandScript(commandScript);
     clone.setRequiredServices(requiredServices);
     return clone;
@@ -1029,8 +1031,17 @@ public class ServiceInfo implements Validable, Cloneable {
     this.themesDir = themesDir;
   }
 
+  /*
+  * This method will return data from themesMap if themes are not available.
+  * ThemesMap contain merged themes from all previous stacks.
+  * TODO we should think and fix it for HDP 3.0 because there we don't need merged data.
+  * */
   public List<ThemeInfo> getThemes() {
-    return themes;
+    List<ThemeInfo> themeList = themes;
+    if (themes == null & themesMap != null) {
+      themeList = new ArrayList<>(themesMap.values());
+    }
+    return themeList;
   }
 
   public void setThemes(List<ThemeInfo> themes) {
@@ -1063,8 +1074,17 @@ public class ServiceInfo implements Validable, Cloneable {
     this.quickLinksConfigurationsDir = quickLinksConfigurationsDir;
   }
 
+  /*
+  * This method will return data from quickLinksConfigurationsMap if quickLinksConfigurations are not available.
+  * quickLinksConfigurationsMap contain merged quickLinksConfigurations from all previous stacks.
+  * TODO we should think and fix it for HDP 3.0 because there we don't need merged data.
+  * */
   public List<QuickLinksConfigurationInfo> getQuickLinksConfigurations() {
-    return quickLinksConfigurations;
+    List<QuickLinksConfigurationInfo> quickLinksConigurationList = quickLinksConfigurations;
+    if (quickLinksConfigurations == null && quickLinksConfigurationsMap != null) {
+      quickLinksConigurationList = new ArrayList<>(quickLinksConfigurationsMap.values());
+    }
+    return quickLinksConigurationList;
   }
 
   public void setQuickLinksConfigurations(List<QuickLinksConfigurationInfo> quickLinksConfigurations) {


[29/30] ambari git commit: AMBARI-22325 Fix compile issue (benyoka)

Posted by mr...@apache.org.
AMBARI-22325 Fix compile issue (benyoka)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 259036f9c2ae5e35566feca16f3f0c0ace4d8ed9
Parents: 93a6dbf
Author: Balazs Bence Sari <be...@apache.org>
Authored: Fri Oct 27 18:03:24 2017 +0200
Committer: Balazs Bence Sari <be...@apache.org>
Committed: Fri Oct 27 18:03:24 2017 +0200

----------------------------------------------------------------------
 .../apache/ambari/server/orm/dao/BlueprintV2DAO.java    | 12 ------------
 1 file changed, 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/259036f9/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java
index 8a21dc1..267ae05 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java
@@ -25,7 +25,6 @@ import javax.persistence.TypedQuery;
 
 import org.apache.ambari.server.orm.RequiresSession;
 import org.apache.ambari.server.orm.entities.BlueprintV2Entity;
-import org.apache.ambari.server.orm.entities.StackEntity;
 
 import com.google.inject.Inject;
 import com.google.inject.Provider;
@@ -79,7 +78,6 @@ public class BlueprintV2DAO {
    */
   @Transactional
   public void refresh(BlueprintV2Entity blueprintEntity) {
-    ensureStackIdSet(blueprintEntity);
     entityManagerProvider.get().refresh(blueprintEntity);
   }
 
@@ -90,7 +88,6 @@ public class BlueprintV2DAO {
    */
   @Transactional
   public void create(BlueprintV2Entity blueprintEntity) {
-    ensureStackIdSet(blueprintEntity);
     entityManagerProvider.get().persist(blueprintEntity);
   }
 
@@ -102,7 +99,6 @@ public class BlueprintV2DAO {
    */
   @Transactional
   public BlueprintV2Entity merge(BlueprintV2Entity blueprintEntity) {
-    ensureStackIdSet(blueprintEntity);
     return entityManagerProvider.get().merge(blueprintEntity);
   }
 
@@ -113,7 +109,6 @@ public class BlueprintV2DAO {
    */
   @Transactional
   public void remove(BlueprintV2Entity blueprintEntity) {
-    ensureStackIdSet(blueprintEntity);
     entityManagerProvider.get().remove(merge(blueprintEntity));
   }
 
@@ -126,11 +121,4 @@ public class BlueprintV2DAO {
     entityManagerProvider.get().remove(findByName(blueprint_name));
   }
 
-  private void ensureStackIdSet(BlueprintV2Entity entity) {
-    StackEntity stack = entity.getStack();
-    if (stack != null && stack.getStackId() == null) {
-      entity.setStack(stackDAO.find(stack.getStackName(), stack.getStackVersion()));
-    }
-  }
-
 }


[22/30] ambari git commit: AMBARI-22253. Add TopologyConfigurationsEntity (magyari_sandor)

Posted by mr...@apache.org.
AMBARI-22253. Add TopologyConfigurationsEntity (magyari_sandor)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 4b963392342c521f376218c761696989fa78344f
Parents: acab46d
Author: Sandor Magyari <sm...@hortonworks.com>
Authored: Tue Oct 24 20:51:54 2017 +0200
Committer: Sandor Magyari <sm...@hortonworks.com>
Committed: Tue Oct 24 22:20:11 2017 +0200

----------------------------------------------------------------------
 .../internal/ProvisionClusterRequest.java       |   7 +
 .../orm/entities/HostGroupComponentEntity.java  |   9 +-
 .../entities/HostGroupComponentEntityPK.java    |  36 +++++
 .../entities/TopologyConfigurationsEntity.java  | 148 +++++++++++++++++++
 .../orm/entities/TopologyRequestEntity.java     |  40 ++---
 .../ambari/server/topology/BlueprintImplV2.java |   5 +
 .../ambari/server/topology/BlueprintV2.java     |  12 ++
 .../server/topology/BlueprintV2Factory.java     |   5 +-
 .../topology/ClusterConfigurationRequest.java   |   3 +-
 .../server/topology/ClusterTopologyImpl.java    |  12 +-
 .../server/topology/PersistedStateImpl.java     |  35 ++++-
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  15 ++
 .../src/main/resources/META-INF/persistence.xml |   1 +
 13 files changed, 285 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
index bfa46d8..0e1753b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
@@ -91,6 +91,11 @@ public class ProvisionClusterRequest extends BaseClusterRequest {
   public static final String CONFIGURATIONS_PROPERTY = "configurations";
 
   /**
+   * services property name
+   */
+  public static final String SERVICES_PROPERTY = "services";
+
+  /**
    * default password property name
    */
   public static final String DEFAULT_PASSWORD_PROPERTY = "default_password";
@@ -184,6 +189,8 @@ public class ProvisionClusterRequest extends BaseClusterRequest {
 
     this.securityConfiguration = securityConfiguration;
 
+    //TODO parse service configs and mereg with BP service configs
+//    Collection<Map<String, String>> services = properties.get(SERVICES_PROPERTY);
 //    Configuration configuration = configurationFactory.getConfiguration(
 //      (Collection<Map<String, String>>) properties.get(CONFIGURATIONS_PROPERTY));
 //    configuration.setParentConfiguration(blueprint.getConfiguration());

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntity.java
index 186180b..bd34d29 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntity.java
@@ -52,14 +52,13 @@ public class HostGroupComponentEntity {
   private String serviceName;
 
   @Id
-  @Column(name = "instance_name", nullable = true, insertable = true, updatable = false)
-  private String name;
-
-
-  @Id
   @Column(name = "type", nullable = false, insertable = true, updatable = false)
   private String type;
 
+  @Id
+  @Column(name = "instance_name", nullable = true, insertable = true, updatable = false)
+  private String name;
+
   @Column(name = "provision_action", nullable = true, insertable = true, updatable = false)
   private String provisionAction;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntityPK.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntityPK.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntityPK.java
index 0898133..812f0d6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntityPK.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostGroupComponentEntityPK.java
@@ -38,6 +38,18 @@ public class HostGroupComponentEntityPK {
   @Column(name = "name", nullable = false, insertable = true, updatable = false, length = 100)
   private String name;
 
+  @Id
+  @Column(name = "service_group", nullable = true, insertable = true, updatable = false)
+  private String serviceGroup;
+
+  @Id
+  @Column(name = "service_name", nullable = true, insertable = true, updatable = false)
+  private String serviceName;
+
+  @Id
+  @Column(name = "type", nullable = false, insertable = true, updatable = false)
+  private String type;
+
   /**
    * Get the name of the associated host group.
    *
@@ -92,6 +104,30 @@ public class HostGroupComponentEntityPK {
     this.name = name;
   }
 
+  public String getServiceGroup() {
+    return serviceGroup;
+  }
+
+  public void setServiceGroup(String serviceGroup) {
+    this.serviceGroup = serviceGroup;
+  }
+
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+
+  public String getType() {
+    return type;
+  }
+
+  public void setType(String type) {
+    this.type = type;
+  }
+
   @Override
   public boolean equals(Object o) {
     if (this == o) return true;

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyConfigurationsEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyConfigurationsEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyConfigurationsEntity.java
new file mode 100644
index 0000000..a29db99
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyConfigurationsEntity.java
@@ -0,0 +1,148 @@
+/*
+ * 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.orm.entities;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.Lob;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+
+
+@Entity
+@Table(name = "topology_configurations")
+@TableGenerator(name = "topology_configurations_id_generator", table = "ambari_sequences",
+        pkColumnName = "sequence_name", valueColumnName = "sequence_value",
+        pkColumnValue = "topology_configurations_id_seq", initialValue = 0)
+public class TopologyConfigurationsEntity {
+
+  @Id
+  @GeneratedValue(strategy = GenerationType.TABLE, generator = "topology_configurations_id_generator")
+  private Long id;
+
+  @OneToOne
+  @JoinColumn(name = "request_id", referencedColumnName = "id", nullable = false)
+  private TopologyRequestEntity topologyRequestEntity;
+
+  @Column(name = "service_group_name", length = 100, nullable = false)
+  private String serviceGroupName;
+
+  @Column(name = "service_name", length = 100, nullable = false)
+  private String serviceName;
+
+  @Column(name = "component_name", length = 100, nullable = true)
+  private String componentName;
+
+  @Column(name = "host_group_name", length = 100, nullable = true)
+  private String hostGroupName;
+
+  @Column(name = "cluster_properties")
+  @Basic(fetch = FetchType.LAZY)
+  @Lob
+  private String configProperties;
+
+  @Column(name = "cluster_attributes")
+  @Basic(fetch = FetchType.LAZY)
+  @Lob
+  private String configAttributes;
+
+  public Long getId() {
+    return id;
+  }
+
+  public void setId(Long id) {
+    this.id = id;
+  }
+
+  public TopologyRequestEntity getTopologyRequestEntity() {
+    return topologyRequestEntity;
+  }
+
+  public void setTopologyRequestEntity(TopologyRequestEntity topologyRequestEntity) {
+    this.topologyRequestEntity = topologyRequestEntity;
+  }
+
+  public String getServiceGroupName() {
+    return serviceGroupName;
+  }
+
+  public void setServiceGroupName(String serviceGroupName) {
+    this.serviceGroupName = serviceGroupName;
+  }
+
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+
+  public String getComponentName() {
+    return componentName;
+  }
+
+  public void setComponentName(String componentName) {
+    this.componentName = componentName;
+  }
+
+  public String getHostGroupName() {
+    return hostGroupName;
+  }
+
+  public void setHostGroupName(String hostGroupName) {
+    this.hostGroupName = hostGroupName;
+  }
+
+  public String getConfigProperties() {
+    return configProperties;
+  }
+
+  public void setConfigProperties(String configProperties) {
+    this.configProperties = configProperties;
+  }
+
+  public String getConfigAttributes() {
+    return configAttributes;
+  }
+
+  public void setConfigAttributes(String configAttributes) {
+    this.configAttributes = configAttributes;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+    TopologyConfigurationsEntity that = (TopologyConfigurationsEntity) o;
+    if (!id.equals(that.id)) return false;
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return id.hashCode();
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyRequestEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyRequestEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyRequestEntity.java
index d281838..4b431f1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyRequestEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyRequestEntity.java
@@ -19,17 +19,14 @@ package org.apache.ambari.server.orm.entities;
 
 import java.util.Collection;
 
-import javax.persistence.Basic;
 import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.EnumType;
 import javax.persistence.Enumerated;
-import javax.persistence.FetchType;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
-import javax.persistence.Lob;
 import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
 import javax.persistence.OneToMany;
@@ -62,16 +59,6 @@ public class TopologyRequestEntity {
   @Column(name = "bp_name", length = 100, nullable = false)
   private String blueprintName;
 
-  @Column(name = "cluster_properties")
-  @Basic(fetch = FetchType.LAZY)
-  @Lob
-  private String clusterProperties;
-
-  @Column(name = "cluster_attributes")
-  @Basic(fetch = FetchType.LAZY)
-  @Lob
-  private String clusterAttributes;
-
   @Column(name = "description", length = 1024, nullable = false)
   private String description;
 
@@ -81,6 +68,9 @@ public class TopologyRequestEntity {
   @OneToOne(mappedBy = "topologyRequestEntity", cascade = CascadeType.ALL)
   private TopologyLogicalRequestEntity topologyLogicalRequestEntity;
 
+  @OneToMany(mappedBy = "topologyRequestEntity", cascade = CascadeType.ALL)
+  private Collection<TopologyConfigurationsEntity> topologyConfigurationsEntities;
+
   @Column(name = "provision_action", length = 255, nullable = true)
   @Enumerated(EnumType.STRING)
   private ProvisionAction provisionAction;
@@ -117,22 +107,6 @@ public class TopologyRequestEntity {
     this.blueprintName = blueprintName;
   }
 
-  public String getClusterProperties() {
-    return clusterProperties;
-  }
-
-  public void setClusterProperties(String clusterProperties) {
-    this.clusterProperties = clusterProperties;
-  }
-
-  public String getClusterAttributes() {
-    return clusterAttributes;
-  }
-
-  public void setClusterAttributes(String clusterAttributes) {
-    this.clusterAttributes = clusterAttributes;
-  }
-
   public String getDescription() {
     return description;
   }
@@ -157,6 +131,14 @@ public class TopologyRequestEntity {
     this.topologyLogicalRequestEntity = topologyLogicalRequestEntity;
   }
 
+  public Collection<TopologyConfigurationsEntity> getTopologyConfigurationsEntities() {
+    return topologyConfigurationsEntities;
+  }
+
+  public void setTopologyConfigurationsEntities(Collection<TopologyConfigurationsEntity> topologyConfigurationsEntity) {
+    this.topologyConfigurationsEntities = topologyConfigurationsEntity;
+  }
+
   public ProvisionAction getProvisionAction() {
     return provisionAction;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
index 044e78a..356a72e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
@@ -150,6 +150,11 @@ public class BlueprintImplV2 implements BlueprintV2 {
   }
 
   @Override
+  public Service getServiceById(ServiceId serviceId) {
+    return null;
+  }
+
+  @Override
   @JsonIgnore
   public Collection<Service> getServicesFromServiceGroup(ServiceGroup serviceGroup, String serviceType) {
     if (serviceType == null) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
index b5d5430..3925c4f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
@@ -80,6 +80,18 @@ public interface BlueprintV2 {
    */
   Collection<ServiceId> getAllServiceIds();
 
+  /**
+   * Get service by Id
+   * @param serviceId
+   * @return
+   */
+  Service getServiceById(ServiceId serviceId);
+
+  /**
+   * Get all of the services represented in the blueprint.
+   *
+   * @return collection of all represented service names
+   */
   Collection<Service> getAllServices();
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
index 3b656e2..ddb7cf8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
@@ -73,8 +73,11 @@ public class BlueprintV2Factory {
   private static StackDAO stackDao;
   private ConfigurationFactory configFactory = new ConfigurationFactory();
 
-  private final StackV2Factory stackFactory;
+  private StackV2Factory stackFactory;
 
+  protected BlueprintV2Factory() {
+
+  }
   protected BlueprintV2Factory(StackV2Factory stackFactory) {
     this.stackFactory = stackFactory;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
index b3ce044..379a69c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
@@ -78,7 +78,8 @@ public class ClusterConfigurationRequest {
     BlueprintV2 blueprint = clusterTopology.getBlueprint();
     // set initial configuration (not topology resolved)
     //TODO set up proper ConfigurationContext
-    ConfigurationContext configurationContext = new ConfigurationContext(blueprint.getStacks().iterator().next(), blueprint.getConfiguration());
+    ConfigurationContext configurationContext = new ConfigurationContext(blueprint.getStacks().iterator().next(), clusterTopology
+            .getConfiguration());
     this.configurationProcessor = new BlueprintConfigurationProcessor(clusterTopology, configurationContext);
     this.stackAdvisorBlueprintProcessor = stackAdvisorBlueprintProcessor;
     removeOrphanConfigTypes();

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
index 4ef5d4c..db3f29b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
@@ -51,6 +51,7 @@ public class ClusterTopologyImpl implements ClusterTopology {
   //todo: this will need to change to allow usage of multiple bp's for the same cluster
   //todo: for example: provision using bp1 and scale using bp2
   private BlueprintV2 blueprint;
+  private Configuration configuration;
   private Collection<Service> serviceConfigs;
   private ConfigRecommendationStrategy configRecommendationStrategy;
   private ProvisionAction provisionAction = ProvisionAction.INSTALL_AND_START;
@@ -74,6 +75,15 @@ public class ClusterTopologyImpl implements ClusterTopology {
 
     registerHostGroupInfo(topologyRequest.getHostGroupInfo());
 
+    // merge service configs into global cluster configs
+    Map<String, Map<String, String>> properties = new HashMap<>();
+    Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>();
+    serviceConfigs.forEach(service -> {
+      properties.putAll(service.getConfiguration().getProperties());
+      attributes.putAll(service.getConfiguration().getAttributes());
+    });
+    configuration = new Configuration(properties, attributes);
+
     // todo extract validation to specialized service
     validateTopology();
     this.ambariContext = ambariContext;
@@ -102,7 +112,7 @@ public class ClusterTopologyImpl implements ClusterTopology {
   @Override
   @Deprecated
   public Configuration getConfiguration() {
-    return null;
+    return configuration;
   }
 
   public Collection<Service> getServiceConfigs() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
index a9a132b..b18915c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
@@ -40,6 +40,7 @@ import org.apache.ambari.server.orm.dao.TopologyLogicalRequestDAO;
 import org.apache.ambari.server.orm.dao.TopologyLogicalTaskDAO;
 import org.apache.ambari.server.orm.dao.TopologyRequestDAO;
 import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
+import org.apache.ambari.server.orm.entities.TopologyConfigurationsEntity;
 import org.apache.ambari.server.orm.entities.TopologyHostGroupEntity;
 import org.apache.ambari.server.orm.entities.TopologyHostInfoEntity;
 import org.apache.ambari.server.orm.entities.TopologyHostRequestEntity;
@@ -255,9 +256,18 @@ public class PersistedStateImpl implements PersistedState {
       entity.setBlueprintName(request.getBlueprint().getName());
     }
 
-    entity.setClusterAttributes(attributesAsString(request.getConfiguration().getAttributes()));
+    Collection<TopologyConfigurationsEntity> serviceConfigurations = new ArrayList<>();
+    request.getServiceConfigs().forEach(service -> {
+      TopologyConfigurationsEntity topologyConfigurationsEntity = new TopologyConfigurationsEntity();
+      topologyConfigurationsEntity.setServiceGroupName(service.getServiceGroup().getName());
+      topologyConfigurationsEntity.setServiceName(service.getName());
+      topologyConfigurationsEntity.setConfigProperties(propertiesAsString(service.getConfiguration().getProperties()));
+      topologyConfigurationsEntity.setConfigAttributes(attributesAsString(service.getConfiguration().getAttributes()));
+      serviceConfigurations.add(topologyConfigurationsEntity);
+    });
+    entity.setTopologyConfigurationsEntities(serviceConfigurations);
+
     entity.setClusterId(request.getClusterId());
-    entity.setClusterProperties(propertiesAsString(request.getConfiguration().getProperties()));
     entity.setDescription(request.getDescription());
 
     if (request.getProvisionAction() != null) {
@@ -397,11 +407,24 @@ public class PersistedStateImpl implements PersistedState {
       } catch (NoSuchStackException e) {
         throw new RuntimeException("Unable to load blueprint while replaying topology request: " + e, e);
       }
-      //TODO load services, merge servie configs from Cluster template with service configs from Blueprint
+      // load Service configurations from db, set Blueprint service config as parent for each
       services = new ArrayList<>();
-      //configuration = createConfiguration(entity.getClusterProperties(), entity.getClusterAttributes());
-      //configuration.setParentConfiguration(blueprint.getConfiguration());
-
+      entity.getTopologyConfigurationsEntities().stream().filter(topologyConfigurationsEntity -> (
+        topologyConfigurationsEntity.getComponentName() == null
+                && topologyConfigurationsEntity.getHostGroupName() == null))
+              .forEach(topologyConfigurationsEntity -> {
+
+        ServiceId serviceId = ServiceId.of(topologyConfigurationsEntity.getServiceGroupName(),
+                topologyConfigurationsEntity.getServiceName());
+        Service service = blueprint.getServiceById(serviceId);
+        Configuration configuration = createConfiguration(topologyConfigurationsEntity.getConfigProperties(),
+                topologyConfigurationsEntity.getConfigAttributes());
+        configuration.setParentConfiguration(service.getConfiguration());
+
+        service.setConfiguration(configuration);
+        services.add(service);
+
+      });
 
       parseHostGroupInfo(entity);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index f48bcd6..482f5e8 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -538,6 +538,9 @@ CREATE TABLE hostgroup_component (
   blueprint_name VARCHAR(255) NOT NULL,
   hostgroup_name VARCHAR(255) NOT NULL,
   name VARCHAR(255) NOT NULL,
+  service_group VARCHAR(255) NOT NULL,
+  service_name VARCHAR(255) NOT NULL,
+  type VARCHAR(255) NOT NULL,
   provision_action VARCHAR(255),
   CONSTRAINT PK_hostgroup_component PRIMARY KEY (blueprint_name, hostgroup_name, name),
   CONSTRAINT FK_hgc_blueprint_name FOREIGN KEY (blueprint_name, hostgroup_name) REFERENCES hostgroup (blueprint_name, name));
@@ -755,6 +758,18 @@ CREATE TABLE topology_request (
   CONSTRAINT PK_topology_request PRIMARY KEY (id),
   CONSTRAINT FK_topology_request_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id));
 
+CREATE TABLE topology_configurations (
+  id BIGINT NOT NULL,
+  request_id BIGINT NOT NULL,
+  service_group_name VARCHAR(100) NOT NULL,
+  service_name VARCHAR(100) NOT NULL,
+  component_name VARCHAR(100),
+  host_group_name VARCHAR(100),
+  cluster_properties TEXT,
+  cluster_attributes TEXT,
+  CONSTRAINT PK_topology_configurations PRIMARY KEY (id),
+  CONSTRAINT FK_hostgroup_req_id FOREIGN KEY (request_id) REFERENCES topology_request(id));
+
 CREATE TABLE topology_hostgroup (
   id BIGINT NOT NULL,
   name VARCHAR(255) NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b963392/ambari-server/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/META-INF/persistence.xml b/ambari-server/src/main/resources/META-INF/persistence.xml
index 20c95f9..5f56f09 100644
--- a/ambari-server/src/main/resources/META-INF/persistence.xml
+++ b/ambari-server/src/main/resources/META-INF/persistence.xml
@@ -87,6 +87,7 @@
     <class>org.apache.ambari.server.orm.entities.WidgetLayoutEntity</class>
     <class>org.apache.ambari.server.orm.entities.WidgetLayoutUserWidgetEntity</class>
     <class>org.apache.ambari.server.orm.entities.TopologyRequestEntity</class>
+    <class>org.apache.ambari.server.orm.entities.TopologyConfigurationsEntity</class>
     <class>org.apache.ambari.server.orm.entities.TopologyLogicalRequestEntity</class>
     <class>org.apache.ambari.server.orm.entities.TopologyHostRequestEntity</class>
     <class>org.apache.ambari.server.orm.entities.TopologyHostGroupEntity</class>


[10/30] ambari git commit: AMBARI-22253. Modify TopologyManager to create service groups (magyari_sandor)

Posted by mr...@apache.org.
AMBARI-22253. Modify TopologyManager to create service groups (magyari_sandor)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 58c833946d8be370af2beb4735f8e21beea1359e
Parents: 65d44cd
Author: Sandor Magyari <sm...@hortonworks.com>
Authored: Tue Oct 17 15:09:05 2017 +0200
Committer: Sandor Magyari <sm...@hortonworks.com>
Committed: Tue Oct 17 15:43:40 2017 +0200

----------------------------------------------------------------------
 .../query/render/ClusterBlueprintRenderer.java  | 45 +++++++++++--
 .../StackAdvisorBlueprintProcessor.java         | 27 +++++---
 .../controller/internal/BaseClusterRequest.java | 17 ++++-
 .../BlueprintConfigurationProcessor.java        | 22 ++++--
 .../internal/ConfigurationContext.java          |  4 +-
 .../internal/ExportBlueprintRequest.java        | 25 +++++--
 .../internal/ProvisionClusterRequest.java       | 22 ++++--
 .../internal/ScaleClusterRequest.java           |  8 +--
 .../server/controller/internal/StackV2.java     | 11 ++-
 .../server/controller/internal/UnitUpdater.java |  6 +-
 .../ambari/server/topology/AmbariContext.java   | 71 ++++++++++++++++----
 .../server/topology/BlueprintFactory.java       | 10 ++-
 .../ambari/server/topology/BlueprintImplV2.java |  6 +-
 .../ambari/server/topology/BlueprintV2.java     |  6 +-
 .../server/topology/BlueprintValidatorImpl.java | 10 +--
 .../topology/ClusterConfigurationRequest.java   | 21 ++++--
 .../ambari/server/topology/ClusterTopology.java |  6 +-
 .../server/topology/ClusterTopologyImpl.java    | 15 +++--
 .../ambari/server/topology/HostGroupInfo.java   | 10 +--
 .../ambari/server/topology/HostRequest.java     | 20 ++++--
 .../ambari/server/topology/LogicalRequest.java  | 22 ++++--
 .../server/topology/PersistedStateImpl.java     | 34 ++++++++--
 .../apache/ambari/server/topology/Service.java  |  4 +-
 .../ambari/server/topology/TopologyManager.java | 42 +++++++++---
 .../tasks/PersistHostResourcesTask.java         | 17 +++--
 .../validators/ClusterConfigTypeValidator.java  |  6 +-
 .../validators/HiveServiceValidator.java        | 11 ++-
 .../RequiredConfigPropertiesValidator.java      | 15 ++++-
 .../validators/RequiredPasswordValidator.java   | 15 +++--
 .../validators/StackConfigTypeValidator.java    |  6 +-
 .../topology/validators/UnitValidator.java      | 10 +--
 .../topology/ClusterTopologyImplTest.java       | 18 +++--
 32 files changed, 414 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/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 4f71255..7171fc7 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,24 +18,57 @@
 
 package org.apache.ambari.server.api.query.render;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.query.QueryInfo;
 import org.apache.ambari.server.api.services.Request;
-import org.apache.ambari.server.api.services.*;
+import org.apache.ambari.server.api.services.Result;
+import org.apache.ambari.server.api.services.ResultImpl;
+import org.apache.ambari.server.api.services.ResultPostProcessor;
+import org.apache.ambari.server.api.services.ResultPostProcessorImpl;
 import org.apache.ambari.server.api.util.TreeNode;
 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.*;
-import org.apache.ambari.server.controller.spi.*;
+import org.apache.ambari.server.controller.internal.ArtifactResourceProvider;
+import org.apache.ambari.server.controller.internal.BlueprintConfigurationProcessor;
+import org.apache.ambari.server.controller.internal.BlueprintResourceProvider;
+import org.apache.ambari.server.controller.internal.ConfigurationContext;
+import org.apache.ambari.server.controller.internal.ExportBlueprintRequest;
+import org.apache.ambari.server.controller.internal.RequestImpl;
+import org.apache.ambari.server.controller.internal.ResourceImpl;
+import org.apache.ambari.server.controller.spi.ClusterController;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.state.SecurityType;
-import org.apache.ambari.server.topology.*;
+import org.apache.ambari.server.topology.AmbariContext;
+import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.ClusterTopologyImpl;
+import org.apache.ambari.server.topology.ComponentV2;
+import org.apache.ambari.server.topology.Configuration;
+import org.apache.ambari.server.topology.HostGroupInfo;
+import org.apache.ambari.server.topology.HostGroupV2;
+import org.apache.ambari.server.topology.InvalidTopologyException;
+import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
+import org.apache.ambari.server.topology.SecurityConfigurationFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
-
 /**
  * Renderer which renders a cluster resource as a blueprint.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
index 441f71d..ba35cce 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
@@ -18,23 +18,34 @@
 
 package org.apache.ambari.server.api.services.stackadvisor;
 
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.inject.Singleton;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest.StackAdvisorRequestType;
 import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse;
 import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse.BlueprintConfigurations;
 import org.apache.ambari.server.controller.internal.ConfigurationTopologyException;
 import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.state.ValueAttributesInfo;
-import org.apache.ambari.server.topology.*;
+import org.apache.ambari.server.topology.AdvisedConfiguration;
+import org.apache.ambari.server.topology.BlueprintV2;
+import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.ConfigRecommendationStrategy;
+import org.apache.ambari.server.topology.HostGroupInfo;
+import org.apache.ambari.server.topology.HostGroupV2;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.inject.Singleton;
 
 /**
  * Generate advised configurations for blueprint cluster provisioning by the stack advisor.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
index c3858ba..e3e0aa2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
@@ -18,15 +18,26 @@
 
 package org.apache.ambari.server.controller.internal;
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.api.predicate.QueryLexer;
 import org.apache.ambari.server.api.predicate.Token;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
-import org.apache.ambari.server.topology.*;
-
-import java.util.*;
+import org.apache.ambari.server.topology.BlueprintFactory;
+import org.apache.ambari.server.topology.BlueprintV2;
+import org.apache.ambari.server.topology.Configuration;
+import org.apache.ambari.server.topology.HostGroupInfo;
+import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
+import org.apache.ambari.server.topology.SecurityConfiguration;
+import org.apache.ambari.server.topology.Service;
+import org.apache.ambari.server.topology.TopologyRequest;
 
 /**
  * Provides common cluster request functionality.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
index 4c51762..8c4a5eb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
@@ -37,19 +37,29 @@ import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Sets;
-
 import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.state.*;
-import org.apache.ambari.server.topology.*;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.state.PropertyDependencyInfo;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.ValueAttributesInfo;
+import org.apache.ambari.server.topology.AdvisedConfiguration;
+import org.apache.ambari.server.topology.BlueprintV2;
+import org.apache.ambari.server.topology.Cardinality;
+import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.ConfigRecommendationStrategy;
+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.Service;
 import org.apache.ambari.server.topology.validators.UnitValidatedProperty;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Sets;
+
 /**
  * Updates configuration properties based on cluster topology.  This is done when exporting
  * a blueprint and when a cluster is provisioned via a blueprint.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
index 983bb9f..a313f5e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
@@ -18,10 +18,10 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import org.apache.ambari.server.topology.Configuration;
-
 import java.util.Map;
 
+import org.apache.ambari.server.topology.Configuration;
+
 /**
  * Provides a context for configuration.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java
index 800e2ff..565369b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java
@@ -19,6 +19,17 @@
 
 package org.apache.ambari.server.controller.internal;
 
+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.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.util.TreeNode;
 import org.apache.ambari.server.controller.AmbariManagementController;
@@ -27,14 +38,18 @@ 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.topology.*;
+import org.apache.ambari.server.topology.BlueprintV2;
+import org.apache.ambari.server.topology.Component;
+import org.apache.ambari.server.topology.Configuration;
+import org.apache.ambari.server.topology.HostGroup;
+import org.apache.ambari.server.topology.HostGroupImpl;
+import org.apache.ambari.server.topology.HostGroupInfo;
+import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
+import org.apache.ambari.server.topology.Service;
+import org.apache.ambari.server.topology.TopologyRequest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.*;
-
 /**
  * Request to export a blueprint from an existing cluster.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
index 6d72b21..75ec9ba 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
@@ -17,19 +17,31 @@
  */
 package org.apache.ambari.server.controller.internal;
 
-import com.google.common.base.Enums;
-import com.google.common.base.Optional;
-import com.google.common.base.Strings;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.security.encryption.CredentialStoreType;
 import org.apache.ambari.server.stack.NoSuchStackException;
 import org.apache.ambari.server.state.quicklinksprofile.QuickLinksProfileBuilder;
 import org.apache.ambari.server.state.quicklinksprofile.QuickLinksProfileEvaluationException;
-import org.apache.ambari.server.topology.*;
+import org.apache.ambari.server.topology.ConfigRecommendationStrategy;
+import org.apache.ambari.server.topology.ConfigurationFactory;
+import org.apache.ambari.server.topology.Credential;
+import org.apache.ambari.server.topology.HostGroupInfo;
+import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
+import org.apache.ambari.server.topology.NoSuchBlueprintException;
+import org.apache.ambari.server.topology.SecurityConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
+import com.google.common.base.Enums;
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
 
 /**
  * Request for provisioning a cluster.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
index 314fb26..c5cc061b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
@@ -19,6 +19,10 @@
 
 package org.apache.ambari.server.controller.internal;
 
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.stack.NoSuchStackException;
 import org.apache.ambari.server.topology.BlueprintV2;
@@ -28,10 +32,6 @@ import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * A request for a scaling an existing cluster.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
index c5a6064..fb5d02c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
@@ -26,16 +26,21 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.controller.*;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.ReadOnlyConfigurationResponse;
+import org.apache.ambari.server.controller.StackConfigurationRequest;
+import org.apache.ambari.server.controller.StackLevelConfigurationRequest;
+import org.apache.ambari.server.controller.StackServiceComponentRequest;
+import org.apache.ambari.server.controller.StackServiceComponentResponse;
+import org.apache.ambari.server.controller.StackServiceRequest;
+import org.apache.ambari.server.controller.StackServiceResponse;
 import org.apache.ambari.server.orm.entities.StackEntity;
-
 import org.apache.ambari.server.state.AutoDeployInfo;
 import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.DependencyInfo;
 import org.apache.ambari.server.state.PropertyDependencyInfo;
 import org.apache.ambari.server.state.PropertyInfo;
 import org.apache.ambari.server.state.ValueAttributesInfo;
-
 import org.apache.ambari.server.topology.Cardinality;
 import org.apache.ambari.server.topology.Configuration;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
index 37725b1..a566625 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
@@ -17,15 +17,15 @@
  */
 package org.apache.ambari.server.controller.internal;
 
-import org.apache.ambari.server.topology.ClusterTopology;
-import org.apache.ambari.server.topology.validators.UnitValidatedProperty;
+import static org.apache.commons.lang.StringUtils.isBlank;
 
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Optional;
 
-import static org.apache.commons.lang.StringUtils.isBlank;
+import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.validators.UnitValidatedProperty;
 
 /**
  * I append the stack defined unit to the original property value.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
index 3a65662..0434728 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
@@ -18,16 +18,52 @@
 
 package org.apache.ambari.server.topology;
 
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-import com.google.common.util.concurrent.Striped;
-import com.google.inject.Provider;
-import org.apache.ambari.server.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.Lock;
+
+import javax.annotation.Nullable;
+import javax.inject.Inject;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.ClusterNotFoundException;
+import org.apache.ambari.server.DuplicateResourceException;
+import org.apache.ambari.server.Role;
+import org.apache.ambari.server.RoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleCommandFactory;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
-import org.apache.ambari.server.controller.*;
-import org.apache.ambari.server.controller.internal.*;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.AmbariServer;
+import org.apache.ambari.server.controller.ClusterRequest;
+import org.apache.ambari.server.controller.ConfigGroupRequest;
+import org.apache.ambari.server.controller.ConfigurationRequest;
+import org.apache.ambari.server.controller.RequestStatusResponse;
+import org.apache.ambari.server.controller.ServiceComponentHostRequest;
+import org.apache.ambari.server.controller.ServiceComponentRequest;
+import org.apache.ambari.server.controller.ServiceGroupRequest;
+import org.apache.ambari.server.controller.ServiceRequest;
+import org.apache.ambari.server.controller.internal.AbstractResourceProvider;
+import org.apache.ambari.server.controller.internal.ComponentResourceProvider;
+import org.apache.ambari.server.controller.internal.ConfigGroupResourceProvider;
+import org.apache.ambari.server.controller.internal.HostComponentResourceProvider;
+import org.apache.ambari.server.controller.internal.HostResourceProvider;
+import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
+import org.apache.ambari.server.controller.internal.RequestImpl;
+import org.apache.ambari.server.controller.internal.ServiceGroupResourceProvider;
+import org.apache.ambari.server.controller.internal.ServiceResourceProvider;
+import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.controller.internal.VersionDefinitionResourceProvider;
 import org.apache.ambari.server.controller.predicate.EqualsPredicate;
 import org.apache.ambari.server.controller.spi.ClusterController;
 import org.apache.ambari.server.controller.spi.Predicate;
@@ -36,18 +72,25 @@ import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.entities.RepositoryVersionEntity;
 import org.apache.ambari.server.security.authorization.AuthorizationException;
-import org.apache.ambari.server.state.*;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.ConfigFactory;
+import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.RepositoryType;
+import org.apache.ambari.server.state.SecurityType;
+import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.configgroup.ConfigGroup;
 import org.apache.ambari.server.utils.RetryHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.annotation.Nullable;
-import javax.inject.Inject;
-import java.util.*;
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.locks.Lock;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.Striped;
+import com.google.inject.Provider;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
index c8860f6..fc419cb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
@@ -19,7 +19,13 @@
 
 package org.apache.ambari.server.topology;
 
-import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ObjectNotFoundException;
 import org.apache.ambari.server.controller.AmbariManagementController;
@@ -31,7 +37,7 @@ import org.apache.ambari.server.orm.dao.BlueprintDAO;
 import org.apache.ambari.server.orm.entities.BlueprintEntity;
 import org.apache.ambari.server.stack.NoSuchStackException;
 
-import java.util.*;
+import com.google.inject.Inject;
 
 /**
  * Create a Blueprint instance.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
index 79456e5..26dc41d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
@@ -19,14 +19,14 @@
 
 package org.apache.ambari.server.topology;
 
-import org.apache.ambari.server.controller.internal.StackV2;
-import org.apache.ambari.server.orm.entities.BlueprintEntity;
-
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.orm.entities.BlueprintEntity;
+
 /**
  * Blueprint implementation.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
index 3c71e41..10fa2fa 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
@@ -18,13 +18,13 @@
 
 package org.apache.ambari.server.topology;
 
-import org.apache.ambari.server.controller.internal.StackV2;
-import org.apache.ambari.server.orm.entities.BlueprintEntity;
-
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.orm.entities.BlueprintEntity;
+
 
 /**
  * Blueprint representation.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
index 0244d7b..b207071 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintValidatorImpl.java
@@ -18,6 +18,11 @@
 
 package org.apache.ambari.server.topology;
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
 import org.apache.ambari.server.controller.internal.Stack;
 import org.apache.ambari.server.state.AutoDeployInfo;
 import org.apache.ambari.server.state.DependencyConditionInfo;
@@ -27,11 +32,6 @@ import org.apache.ambari.server.utils.VersionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
 /**
  * Default blueprint validator.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
index 48f8fec..6b86ba5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
@@ -18,11 +18,26 @@
 
 package org.apache.ambari.server.topology;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorBlueprintProcessor;
 import org.apache.ambari.server.controller.ClusterRequest;
 import org.apache.ambari.server.controller.ConfigurationRequest;
-import org.apache.ambari.server.controller.internal.*;
+import org.apache.ambari.server.controller.internal.BlueprintConfigurationProcessor;
+import org.apache.ambari.server.controller.internal.ClusterResourceProvider;
+import org.apache.ambari.server.controller.internal.ConfigurationContext;
+import org.apache.ambari.server.controller.internal.ConfigurationTopologyException;
+import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.serveraction.kerberos.KerberosInvalidConfigurationException;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.SecurityType;
@@ -32,10 +47,6 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 /**
  * Responsible for cluster configuration.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
index f0d6e59..289f053 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopology.java
@@ -18,13 +18,13 @@
 
 package org.apache.ambari.server.topology;
 
+import java.util.Collection;
+import java.util.Map;
+
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.internal.ConfigurationContext;
 import org.apache.ambari.server.controller.internal.ProvisionAction;
 
-import java.util.Collection;
-import java.util.Map;
-
 /**
  * Represents a full cluster topology including all instance information as well as the associated
  * blueprint which provides all abstract topology information.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
index 8feb979..4ef5d4c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterTopologyImpl.java
@@ -19,6 +19,16 @@
 
 package org.apache.ambari.server.topology;
 
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_AND_START;
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.internal.ConfigurationContext;
@@ -27,11 +37,6 @@ import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
-
-import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_AND_START;
-import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
-
 /**
  * Represents a cluster topology.
  * Topology includes the the associated blueprint, cluster configuration and hostgroup -> host mapping.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
index 4db3a92..7cbdd98 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
@@ -18,17 +18,17 @@
 
 package org.apache.ambari.server.topology;
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.api.predicate.PredicateCompiler;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
 /**
  * Host Group information specific to a cluster instance.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
index d8390c6..3243359 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
@@ -18,6 +18,16 @@
 
 package org.apache.ambari.server.topology;
 
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_AND_START;
+import static org.apache.ambari.server.controller.internal.ProvisionAction.INSTALL_ONLY;
+import static org.apache.ambari.server.controller.internal.ProvisionAction.START_ONLY;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.api.predicate.PredicateCompiler;
@@ -31,14 +41,14 @@ import org.apache.ambari.server.orm.entities.TopologyHostRequestEntity;
 import org.apache.ambari.server.orm.entities.TopologyHostTaskEntity;
 import org.apache.ambari.server.orm.entities.TopologyLogicalTaskEntity;
 import org.apache.ambari.server.state.Host;
-import org.apache.ambari.server.topology.tasks.*;
+import org.apache.ambari.server.topology.tasks.InstallHostTask;
+import org.apache.ambari.server.topology.tasks.PersistHostResourcesTask;
+import org.apache.ambari.server.topology.tasks.RegisterWithConfigGroupTask;
+import org.apache.ambari.server.topology.tasks.StartHostTask;
+import org.apache.ambari.server.topology.tasks.TopologyTask;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
-
-import static org.apache.ambari.server.controller.internal.ProvisionAction.*;
-
 
 
 /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
index 1049b90..fc6101d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/LogicalRequest.java
@@ -18,7 +18,18 @@
 
 package org.apache.ambari.server.topology;
 
-import com.google.common.collect.Iterables;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
@@ -28,14 +39,17 @@ import org.apache.ambari.server.controller.AmbariServer;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.ShortTaskStatus;
 import org.apache.ambari.server.orm.dao.HostRoleCommandStatusSummaryDTO;
-import org.apache.ambari.server.orm.entities.*;
+import org.apache.ambari.server.orm.entities.StageEntity;
+import org.apache.ambari.server.orm.entities.TopologyHostGroupEntity;
+import org.apache.ambari.server.orm.entities.TopologyHostInfoEntity;
+import org.apache.ambari.server.orm.entities.TopologyHostRequestEntity;
+import org.apache.ambari.server.orm.entities.TopologyLogicalRequestEntity;
 import org.apache.ambari.server.state.Host;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
-import java.util.concurrent.atomic.AtomicLong;
+import com.google.common.collect.Iterables;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
index dfeb99b..8b51fab 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
@@ -18,23 +18,43 @@
 
 package org.apache.ambari.server.topology;
 
-import com.google.gson.Gson;
-import com.google.inject.Inject;
-import com.google.inject.persist.Transactional;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Singleton;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.controller.internal.BaseClusterRequest;
-import org.apache.ambari.server.orm.dao.*;
-import org.apache.ambari.server.orm.entities.*;
+import org.apache.ambari.server.orm.dao.HostDAO;
+import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
+import org.apache.ambari.server.orm.dao.TopologyHostGroupDAO;
+import org.apache.ambari.server.orm.dao.TopologyHostInfoDAO;
+import org.apache.ambari.server.orm.dao.TopologyHostRequestDAO;
+import org.apache.ambari.server.orm.dao.TopologyLogicalRequestDAO;
+import org.apache.ambari.server.orm.dao.TopologyLogicalTaskDAO;
+import org.apache.ambari.server.orm.dao.TopologyRequestDAO;
+import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
+import org.apache.ambari.server.orm.entities.TopologyHostGroupEntity;
+import org.apache.ambari.server.orm.entities.TopologyHostInfoEntity;
+import org.apache.ambari.server.orm.entities.TopologyHostRequestEntity;
+import org.apache.ambari.server.orm.entities.TopologyHostTaskEntity;
+import org.apache.ambari.server.orm.entities.TopologyLogicalRequestEntity;
+import org.apache.ambari.server.orm.entities.TopologyLogicalTaskEntity;
+import org.apache.ambari.server.orm.entities.TopologyRequestEntity;
 import org.apache.ambari.server.stack.NoSuchStackException;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.topology.tasks.TopologyTask;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.inject.Singleton;
-import java.util.*;
+import com.google.gson.Gson;
+import com.google.inject.Inject;
+import com.google.inject.persist.Transactional;
 
 /**
  * Implementation which uses Ambari Database DAO and Entity objects for persistence

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
index f897f7b..1505107 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
@@ -19,10 +19,10 @@
 package org.apache.ambari.server.topology;
 
 
-import org.apache.ambari.server.controller.internal.StackV2;
-
 import java.util.Set;
 
+import org.apache.ambari.server.controller.internal.StackV2;
+
 public class Service {
 
   private final String type;

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
index cfd3501..7691619 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
@@ -18,10 +18,22 @@
 
 package org.apache.ambari.server.topology;
 
-import com.google.common.eventbus.Subscribe;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.persist.Transactional;
+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.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
@@ -30,9 +42,21 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.AmbariServer;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.ShortTaskStatus;
+import org.apache.ambari.server.controller.internal.ArtifactResourceProvider;
+import org.apache.ambari.server.controller.internal.BaseClusterRequest;
+import org.apache.ambari.server.controller.internal.CalculatedStatus;
+import org.apache.ambari.server.controller.internal.CredentialResourceProvider;
+import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
+import org.apache.ambari.server.controller.internal.RequestImpl;
+import org.apache.ambari.server.controller.internal.ScaleClusterRequest;
 import org.apache.ambari.server.controller.internal.StackV2;
-import org.apache.ambari.server.controller.internal.*;
-import org.apache.ambari.server.controller.spi.*;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.events.AmbariEvent;
 import org.apache.ambari.server.events.ClusterConfigFinishedEvent;
 import org.apache.ambari.server.events.HostsRemovedEvent;
@@ -55,8 +79,10 @@ import org.apache.ambari.server.utils.RetryHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
-import java.util.concurrent.*;
+import com.google.common.eventbus.Subscribe;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.persist.Transactional;
 
 /**
  * Manages all cluster provisioning actions on the cluster topology.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java
index f8ad78e..00eb706 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java
@@ -17,17 +17,22 @@
  */
 package org.apache.ambari.server.topology.tasks;
 
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
-import org.apache.ambari.server.topology.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
+import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.ComponentV2;
+import org.apache.ambari.server.topology.HostGroupV2;
+import org.apache.ambari.server.topology.HostRequest;
+import org.apache.ambari.server.topology.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+
 public class PersistHostResourcesTask extends TopologyHostTask  {
 
   private final static Logger LOG = LoggerFactory.getLogger(PersistHostResourcesTask.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
index 4895c40..94a1a5c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
@@ -13,6 +13,9 @@
  */
 package org.apache.ambari.server.topology.validators;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.ambari.server.topology.ClusterTopology;
 import org.apache.ambari.server.topology.InvalidTopologyException;
 import org.apache.ambari.server.topology.Service;
@@ -20,9 +23,6 @@ import org.apache.ambari.server.topology.TopologyValidator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * Validates configuration types related to services specified in the blueprint.
  * If the cluster creation template contains configuration types that are not related to services in the blueprint the

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/HiveServiceValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/HiveServiceValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/HiveServiceValidator.java
index 3f8b517..80b6560 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/HiveServiceValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/HiveServiceValidator.java
@@ -14,12 +14,17 @@
 
 package org.apache.ambari.server.topology.validators;
 
-import org.apache.ambari.server.topology.*;
+import java.util.Collection;
+
+import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.ComponentV2;
+import org.apache.ambari.server.topology.Configuration;
+import org.apache.ambari.server.topology.InvalidTopologyException;
+import org.apache.ambari.server.topology.Service;
+import org.apache.ambari.server.topology.TopologyValidator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Collection;
-
 /**
  * Validates hive service related setup before provisioning the cluster.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
index 4d37a02..05c063c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
@@ -14,14 +14,23 @@
 
 package org.apache.ambari.server.topology.validators;
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
 import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.state.PropertyInfo;
-import org.apache.ambari.server.topology.*;
+import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.HostGroupV2;
+import org.apache.ambari.server.topology.InvalidTopologyException;
+import org.apache.ambari.server.topology.Service;
+import org.apache.ambari.server.topology.TopologyValidator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.*;
-
 
 /**
  * Validates the configuration by checking the existence of required properties for the services listed in the blueprint.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
index 9a2b846..41dee07 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
@@ -14,15 +14,22 @@ package org.apache.ambari.server.topology.validators;
  * limitations under the License.
  */
 
-import org.apache.ambari.server.controller.internal.StackV2;
-import org.apache.ambari.server.state.PropertyInfo;
-import org.apache.ambari.server.topology.*;
-
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
+import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.topology.BlueprintV2;
+import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.ComponentV2;
+import org.apache.ambari.server.topology.HostGroupInfo;
+import org.apache.ambari.server.topology.HostGroupV2;
+import org.apache.ambari.server.topology.InvalidTopologyException;
+import org.apache.ambari.server.topology.Service;
+import org.apache.ambari.server.topology.TopologyValidator;
+
 /**
  * Validates that all required passwords are provided.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidator.java
index 55660e3..2adda10 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/StackConfigTypeValidator.java
@@ -14,6 +14,9 @@
 
 package org.apache.ambari.server.topology.validators;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.ambari.server.topology.ClusterTopology;
 import org.apache.ambari.server.topology.InvalidTopologyException;
 import org.apache.ambari.server.topology.Service;
@@ -21,9 +24,6 @@ import org.apache.ambari.server.topology.TopologyValidator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * Validates whether incoming config types (form the blueprint or the cluster creation template) are valid.
  * A configuration type is considered valid if the stack based on which the cluster is to be created contains such a

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
index 50bdec6..8c8475a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
@@ -17,17 +17,17 @@
  */
 package org.apache.ambari.server.topology.validators;
 
+import static org.apache.ambari.server.controller.internal.UnitUpdater.PropertyValue;
+
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.controller.internal.StackV2;
 import org.apache.ambari.server.controller.internal.UnitUpdater.PropertyUnit;
 import org.apache.ambari.server.topology.ClusterTopology;
 import org.apache.ambari.server.topology.InvalidTopologyException;
 import org.apache.ambari.server.topology.TopologyValidator;
 
-import java.util.Map;
-import java.util.Set;
-
-import static org.apache.ambari.server.controller.internal.UnitUpdater.PropertyValue;
-
 /**
  * I validate the unit of properties by checking if it matches to the stack defined unit.
  * Properties with different unit than the stack defined unit are rejected.

http://git-wip-us.apache.org/repos/asf/ambari/blob/58c83394/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
index 87d6363..a8674b3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/ClusterTopologyImplTest.java
@@ -18,16 +18,24 @@
 
 package org.apache.ambari.server.topology;
 
+import static org.easymock.EasyMock.expect;
+import static org.powermock.api.easymock.PowerMock.createNiceMock;
+import static org.powermock.api.easymock.PowerMock.replay;
+import static org.powermock.api.easymock.PowerMock.reset;
+import static org.powermock.api.easymock.PowerMock.verify;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.controller.internal.Stack;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.*;
-
-import static org.easymock.EasyMock.expect;
-import static org.powermock.api.easymock.PowerMock.*;
-
 /**
  * Unit tests for ClusterTopologyImpl.
  */


[14/30] ambari git commit: Create first unit test for Blueprint v2 data model (benyoka)

Posted by mr...@apache.org.
Create first unit test for Blueprint v2 data model (benyoka)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 37b1e6e5132823d71b3cfe91ca4c270bd11a2013
Parents: f82497d
Author: Balazs Bence Sari <be...@apache.org>
Authored: Wed Oct 18 18:29:56 2017 +0200
Committer: Sandor Magyari <sm...@hortonworks.com>
Committed: Thu Oct 19 14:30:23 2017 +0200

----------------------------------------------------------------------
 .../ambari/server/topology/BlueprintImplV2.java |  29 ----
 .../validators/BlueprintImplV2Test.java         |  45 +++++-
 .../test/resources/blueprintv2/blueprintv2.json | 152 +++++++++++++++++++
 3 files changed, 196 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/37b1e6e5/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
index 827fa39..b2119e6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
@@ -19,7 +19,6 @@
 
 package org.apache.ambari.server.topology;
 
-import java.io.File;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -38,11 +37,6 @@ import org.apache.commons.lang.StringUtils;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.core.Version;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
-import com.fasterxml.jackson.databind.module.SimpleModule;
 
 /**
  * Blueprint implementation.
@@ -336,27 +330,4 @@ public class BlueprintImplV2 implements BlueprintV2 {
     public Blueprints() { }
   }
 
-  public static void main(String[] args) throws Exception {
-    ObjectMapper mapper = new ObjectMapper();
-    SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
-    SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
-    resolver.addMapping(HostGroupV2.class, HostGroupV2Impl.class);
-    module.setAbstractTypes(resolver);
-    mapper.registerModule(module);
-    mapper.enable(SerializationFeature.INDENT_OUTPUT);
-    BlueprintImplV2 bp = mapper.readValue(new File("/Users/bsari/develop/blueprints/blueprintv2.json"), BlueprintImplV2.class);
-    String bpJson = mapper.writeValueAsString(bp);
-    System.out.println(bpJson);
-    System.out.println("\n\n====================================================================================\n\n");
-    Map<String, Object> map = mapper.readValue(new File("/Users/bsari/develop/blueprints/blueprintv2.json"), HashMap.class);
-    System.out.println(map);
-    System.out.println("\n\n====================================================================================\n\n");
-    String bpJson2 = mapper.writeValueAsString(map);
-    System.out.println(bpJson2);
-    System.out.println("\n\n====================================================================================\n\n");
-    BlueprintImplV2 bp2 = mapper.readValue(bpJson2, BlueprintImplV2.class);
-    System.out.println(bp2);
-  }
-
-
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/37b1e6e5/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
index dbe269a..5a676bc 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/validators/BlueprintImplV2Test.java
@@ -1,9 +1,52 @@
 package org.apache.ambari.server.topology.validators;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.ambari.server.topology.BlueprintImplV2;
+import org.apache.ambari.server.topology.HostGroupV2;
+import org.apache.ambari.server.topology.HostGroupV2Impl;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.Version;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.google.common.base.Charsets;
+import com.google.common.io.Resources;
+
 public class BlueprintImplV2Test {
 
-  private static final String BLUEPRINT_LOCATION = "";
+  static String BLUEPRINT_V2_JSON;
 
+  @BeforeClass
+  public static void setUpClass() throws Exception {
+    BLUEPRINT_V2_JSON = Resources.toString(Resources.getResource("blueprintv2/blueprintv2.json"), Charsets.UTF_8);
+  }
 
+  @Test
+  public void testSerialization() throws Exception {
+    ObjectMapper mapper = new ObjectMapper();
+    SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
+    SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
+    resolver.addMapping(HostGroupV2.class, HostGroupV2Impl.class);
+    module.setAbstractTypes(resolver);
+    mapper.registerModule(module);
+    mapper.enable(SerializationFeature.INDENT_OUTPUT);
+    BlueprintImplV2 bp = mapper.readValue(BLUEPRINT_V2_JSON, BlueprintImplV2.class);
+    String bpJson = mapper.writeValueAsString(bp);
+    System.out.println(bpJson);
+    System.out.println("\n\n====================================================================================\n\n");
+    Map<String, Object> map = mapper.readValue(BLUEPRINT_V2_JSON, HashMap.class);
+    System.out.println(map);
+    System.out.println("\n\n====================================================================================\n\n");
+    String bpJson2 = mapper.writeValueAsString(map);
+    System.out.println(bpJson2);
+    System.out.println("\n\n====================================================================================\n\n");
+    BlueprintImplV2 bp2 = mapper.readValue(bpJson2, BlueprintImplV2.class);
+    System.out.println(bp2);
+  }
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/37b1e6e5/ambari-server/src/test/resources/blueprintv2/blueprintv2.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/blueprintv2/blueprintv2.json b/ambari-server/src/test/resources/blueprintv2/blueprintv2.json
new file mode 100644
index 0000000..7884abf
--- /dev/null
+++ b/ambari-server/src/test/resources/blueprintv2/blueprintv2.json
@@ -0,0 +1,152 @@
+{
+  "Blueprints": {
+    "blueprint_name": "blueprint-def",
+    "security": {
+      "type": "NONE"
+    }
+  },
+  "cluster-settings": {
+    "deployment_settings": [
+      {"skip_failure":"true"}
+    ],
+    "recovery_settings":[
+      {"recovery_enabled":"true"}
+    ]
+  },
+  "repository_versions": [
+    {
+      "stack_id": "HDPCORE-3.0.0",
+      "repository_version": "3.0.0.0-1"
+    },
+    {
+      "stack_id": "ANALYTICS-1.0.0",
+      "repository_version": "1.0.0.0-12"
+    }
+  ],
+  "service_groups": [
+    {
+      "name": "Core SG",
+      "dependencies": [],
+      "services": [
+        {
+          "type": "ZOOKEEPER",
+          "name": "ZK1",
+          "stack_id": "HDPCORE-3.0.0",
+          "configurations": [
+            {
+              "zoo.cfg" : {
+                "properties" : {
+                  "dataDir" : "/zookeeper1"
+                }
+              }
+            }
+          ]
+        },
+        {
+          "type": "ZOOKEEPER",
+          "name": "ZK2",
+          "stack_id": "HDPCORE-3.0.0",
+          "configurations": [
+            {
+              "zoo.cfg" : {
+                "properties" : {
+                  "dataDir" : "/zookeeper2"
+                }
+              }
+            }
+          ]
+        },
+        {
+          "type": "HDFS",
+          "stack_id": "HDPCORE-3.0.0"
+        },
+        {
+          "type": "YARN",
+          "stack_id": "HDPCORE-3.0.0"
+        },
+        {
+          "type": "HBASE",
+          "stack_id": "HDPCORE-3.0.0"
+        }
+      ]
+    },
+    {
+      "name": "StreamSG",
+      "services": [
+        {
+          "type": "KAFKA",
+          "stack_id": "HDPCORE-3.0.0",
+          "dependencies": [
+            {
+              "service_group" : "CoreSG",
+              "service_name" : "ZK2"
+            }
+          ]
+        },
+        {
+          "type": "NIFI",
+          "stack_id": "HDPCORE-3.0.0"
+        }
+      ],
+      "dependencies": ["Core SG"]
+    }
+  ],
+  "host_groups": [
+    {
+      "cardinality": "1",
+      "name": "host_group_1",
+      "configurations": [],
+      "components": [
+        {
+          "type": "NAMENODE",
+          "service_name": "HDFS",
+          "service_group": "Core SG",
+          "configurations": [],
+          "provision_action": "INSTALL_AND_START"
+        },
+        {
+          "type": "ZOOKEEPER_SERVER",
+          "service_name": "ZK1",
+          "service_group": "Core SG",
+          "configurations": []
+        },
+        {
+          "type": "ZOOKEEPER_SERVER",
+          "service_name": "ZK2",
+          "service_group": "Core SG",
+          "configurations": []
+        },
+        {
+          "type": "RESOURCEMANAGER",
+          "service_name": "YARN",
+          "service_group": "Core SG",
+          "configurations": []
+        },
+        {
+          "type": "HBASE_MASTER",
+          "service_name": "HBASE",
+          "service_group": "Core SG",
+          "configurations": []
+        },
+        {
+          "type": "ZOOKEEPER_SERVER",
+          "service_name": "ZOOKEEPER",
+          "service_group": "Stream SG",
+          "configurations": []
+        },
+        {
+          "type": "KAFKA_MASTER",
+          "service_name": "KAFKA",
+          "service_group": "Stream SG",
+          "configurations": []
+        },
+        {
+          "type": "NIFI_MASTER",
+          "service_name": "NIFI",
+          "service_group": "Stream SG",
+          "configurations": []
+        }
+      ]
+    }
+  ]
+}


[04/30] ambari git commit: AMBARI-22227 : Unit tests for Registry (mradhakrishnan)

Posted by mr...@apache.org.
AMBARI-22227 : Unit tests for Registry (mradhakrishnan)


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

Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: a5d0f0c34f210644e8a854e20c20a962e5d7d70d
Parents: cbaa88d
Author: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Authored: Thu Oct 12 17:21:39 2017 -0700
Committer: Madhuvanthi Radhakrishnan <mr...@hortonworks.com>
Committed: Thu Oct 12 17:22:32 2017 -0700

----------------------------------------------------------------------
 ...tryRecommendationResourceDefinitionTest.java | 37 ++++++++
 .../RegistryResourceDefinitionTest.java         | 62 +++++++++++++
 ...egistryValidationResourceDefinitionTest.java | 37 ++++++++
 .../api/services/RegistryServiceTest.java       | 94 ++++++++++++++++++++
 .../server/controller/RegistryRequestTest.java  | 37 ++++++++
 5 files changed, 267 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a5d0f0c3/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryRecommendationResourceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryRecommendationResourceDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryRecommendationResourceDefinitionTest.java
new file mode 100644
index 0000000..335126c
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryRecommendationResourceDefinitionTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.api.resources;
+
+import static junit.framework.Assert.assertEquals;
+
+import org.junit.Test;
+
+
+
+/**
+ * Test Class for RegistryRecommendationResourceDefinition
+ */
+public class RegistryRecommendationResourceDefinitionTest {
+
+  @Test
+  public void testDefinitionNames() {
+    ResourceDefinition def = new RegistryRecommendationResourceDefinition();
+    assertEquals("recommendation", def.getSingularName());
+    assertEquals("recommendations", def.getPluralName());
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/a5d0f0c3/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryResourceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryResourceDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryResourceDefinitionTest.java
new file mode 100644
index 0000000..145b09d
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryResourceDefinitionTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.api.resources;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.apache.ambari.server.controller.spi.Resource;
+
+import org.junit.Test;
+
+/**
+ * Test class for RegistryResourceDefinition
+ */
+public class RegistryResourceDefinitionTest {
+  @Test
+  public void testDefinitionNames() {
+    ResourceDefinition def = new RegistryResourceDefinition();
+    assertEquals("registry", def.getSingularName());
+    assertEquals("registries", def.getPluralName());
+  }
+
+  @Test
+  public void testGetSubResourceDefinitions() {
+    ResourceDefinition resource = new RegistryResourceDefinition();
+    Set<SubResourceDefinition> subResources = resource.getSubResourceDefinitions();
+
+    assertEquals(2, subResources.size());
+    assertTrue(includesType(subResources, Resource.Type.RegistryScenario));
+    assertTrue(includesType(subResources, Resource.Type.RegistryMpack));
+
+  }
+
+  private boolean includesType(Set<SubResourceDefinition> resources, Resource.Type type) {
+    for (SubResourceDefinition subResource : resources) {
+      if (subResource.getType() == type) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/a5d0f0c3/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryValidationResourceDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryValidationResourceDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryValidationResourceDefinitionTest.java
new file mode 100644
index 0000000..322a827
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/RegistryValidationResourceDefinitionTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.api.resources;
+
+import static junit.framework.Assert.assertEquals;
+
+import org.junit.Test;
+
+
+
+
+/**
+ * Test class for RegistryValidationResourceDefinition
+ */
+public class RegistryValidationResourceDefinitionTest {
+  @Test
+  public void testDefinitionNames() {
+    ResourceDefinition def = new RegistryValidationResourceDefinition();
+    assertEquals("validation", def.getSingularName());
+    assertEquals("validations", def.getPluralName());
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/a5d0f0c3/ambari-server/src/test/java/org/apache/ambari/server/api/services/RegistryServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/RegistryServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/RegistryServiceTest.java
new file mode 100644
index 0000000..41bfedf
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/RegistryServiceTest.java
@@ -0,0 +1,94 @@
+/**
+ * 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.api.services;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.api.services.parsers.RequestBodyParser;
+import org.apache.ambari.server.api.services.registry.RegistryService;
+import org.apache.ambari.server.api.services.serializers.ResultSerializer;
+
+import org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Unit tests for RegistryService
+ */
+public class RegistryServiceTest extends BaseServiceTest{
+  @Override
+  public List<BaseServiceTest.ServiceTestInvocation> getTestInvocations() throws Exception {
+    List<BaseServiceTest.ServiceTestInvocation> listInvocations = new ArrayList<>();
+
+    // getRegistries
+    RegistryService service = new TestRegistryService("null");
+    Method m = service.getClass().getMethod("getRegistries", String.class, HttpHeaders.class, UriInfo.class);
+    Object[] args = new Object[]{null, getHttpHeaders(), getUriInfo()};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getRegistry
+    service = new TestRegistryService("1");
+    m = service.getClass().getMethod("getRegistry", String.class, HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[]{null, getHttpHeaders(), getUriInfo(), ""};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    //createRegistry
+    service = new TestRegistryService(null);
+    m = service.getClass().getMethod("createRegistries", String.class, HttpHeaders.class, UriInfo.class);
+    args = new Object[]{"body", getHttpHeaders(), getUriInfo()};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.POST, service, m, args, "body"));
+
+    return listInvocations;
+  }
+  private class TestRegistryService extends RegistryService {
+
+    private String r_registryId;
+
+    private TestRegistryService(String registryId) {
+      super();
+      r_registryId = registryId;
+    }
+
+    @Override
+    protected ResourceInstance createResource(Resource.Type type, Map<Resource.Type, String> mapIds) {
+      return getTestResource();
+    }
+
+
+    RequestFactory getRequestFactory() {
+      return getTestRequestFactory();
+    }
+
+    @Override
+    protected RequestBodyParser getBodyParser() {
+      return getTestBodyParser();
+    }
+
+    @Override
+    protected ResultSerializer getResultSerializer() {
+      return getTestResultSerializer();
+    }
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/a5d0f0c3/ambari-server/src/test/java/org/apache/ambari/server/controller/RegistryRequestTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/RegistryRequestTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/RegistryRequestTest.java
new file mode 100644
index 0000000..c61cafb
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/RegistryRequestTest.java
@@ -0,0 +1,37 @@
+/**
+ * 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 org.apache.ambari.server.registry.RegistryType;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Unit tests for RegistryRequest
+ */
+public class RegistryRequestTest {
+  @Test
+  public void testBasicGetAndSet() {
+    RegistryRequest registryRequest =
+            new RegistryRequest((Long) 1L, "hwx", RegistryType.JSON, "abc.tar.gz");
+    Assert.assertEquals((Long) 1L, registryRequest.getRegistryId());
+    Assert.assertEquals("abc.tar.gz", registryRequest.getRegistryUri());
+    Assert.assertEquals("hwx", registryRequest.getRegistryName());
+    Assert.assertEquals(RegistryType.JSON, registryRequest.getRegistryType());
+  }
+}