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/16 17:40:17 UTC

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

Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-14714 cbaa88d2b -> b0ff5da46


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
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());
+  }
+}


[2/2] 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
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",