AMBARI-21824. MultiEverything : Make services as sub-resource of ServiceGroups 
and use Servicegroup while doing Creation, Update and retrieval of 
HostComponents and ServiceComponents.


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

Branch: refs/heads/branch-feature-AMBARI-14714
Commit: f3520c09e0dfb1f3f82d881d1a9c0df23fe549d8
Parents: 289c31f
Author: Swapan Shridhar <sshrid...@hortonworks.com>
Authored: Mon Aug 28 19:49:11 2017 -0700
Committer: Swapan Shridhar <sshrid...@hortonworks.com>
Committed: Tue Aug 29 11:44:03 2017 -0700

----------------------------------------------------------------------
 .../ServiceComponentNotFoundException.java      |   4 +-
 .../ambari/server/ServiceNotFoundException.java |  10 +-
 .../ambari/server/StateRecoveryManager.java     |   2 +-
 .../ambari/server/agent/HeartbeatMonitor.java   |   8 +-
 .../ambari/server/agent/HeartbeatProcessor.java |   5 +-
 .../ambari/server/agent/StatusCommand.java      |   9 +
 .../resources/ClusterResourceDefinition.java    |   1 -
 .../resources/ComponentResourceDefinition.java  |   8 +-
 .../ServiceGroupResourceDefinition.java         |   6 +-
 .../server/api/services/AmbariMetaInfo.java     |  12 +-
 .../server/api/services/ClusterService.java     |   4 +-
 .../server/api/services/ComponentService.java   |  68 ++---
 .../api/services/ServiceGroupService.java       |  14 ++
 .../server/api/services/ServiceService.java     | 235 ++++++++---------
 .../checks/ComponentsInstallationCheck.java     |   2 +-
 .../checks/DatabaseConsistencyCheckHelper.java  |   6 +-
 .../checks/SecondaryNamenodeDeletedCheck.java   |   4 +-
 .../ambari/server/checks/ServicesUpCheck.java   |   2 +-
 .../controller/AmbariManagementController.java  |  12 +-
 .../AmbariManagementControllerImpl.java         |  86 ++++---
 .../server/controller/ClusterResponse.java      |   2 +-
 .../server/controller/ControllerModule.java     |   3 +-
 .../controller/ServiceComponentHostRequest.java |  82 +++---
 .../ServiceComponentHostResponse.java           | 122 ++++++++-
 .../controller/ServiceComponentRequest.java     |  56 +++--
 .../controller/ServiceComponentResponse.java    |  93 ++++++-
 .../server/controller/ServiceRequest.java       | 117 ++++-----
 .../server/controller/ServiceResponse.java      |  94 +++++--
 .../internal/AbstractProviderModule.java        |   2 +-
 .../internal/ClientConfigResourceProvider.java  |   5 +-
 .../internal/ComponentResourceProvider.java     | 162 ++++++++----
 .../internal/HostComponentResourceProvider.java | 192 ++++++++------
 .../internal/HostResourceProvider.java          |   1 +
 .../controller/internal/HostStatusHelper.java   |  10 +-
 .../internal/ServiceResourceProvider.java       | 250 ++++++++++++-------
 .../logging/LoggingSearchPropertyProvider.java  |   2 +-
 .../controller/utilities/DatabaseChecker.java   |  47 ++--
 .../state/DefaultServiceCalculatedState.java    |   2 +-
 .../state/FlumeServiceCalculatedState.java      |   5 +-
 .../state/HBaseServiceCalculatedState.java      |   2 +-
 .../state/HDFSServiceCalculatedState.java       |   2 +-
 .../state/HiveServiceCalculatedState.java       |   2 +-
 .../state/OozieServiceCalculatedState.java      |   3 +-
 .../state/YARNServiceCalculatedState.java       |   2 +-
 .../events/ServiceComponentInstalledEvent.java  |  13 +-
 .../ServiceComponentUninstalledEvent.java       |  11 +-
 .../ambari/server/events/ServiceEvent.java      |  26 +-
 .../server/events/ServiceInstalledEvent.java    |  10 +-
 .../server/events/ServiceRemovedEvent.java      |   8 +-
 .../upgrade/HostVersionOutOfSyncListener.java   |  18 +-
 .../server/orm/dao/ClusterServiceDAO.java       |  11 +-
 .../orm/dao/HostComponentDesiredStateDAO.java   |  24 +-
 .../server/orm/dao/HostComponentStateDAO.java   |  71 +++---
 .../dao/ServiceComponentDesiredStateDAO.java    |  33 ++-
 .../ambari/server/orm/dao/ServiceGroupDAO.java  |   8 +-
 .../orm/entities/ClusterServiceEntity.java      |  82 +++++-
 .../orm/entities/ClusterServiceEntityPK.java    |  32 ++-
 .../HostComponentDesiredStateEntity.java        |  62 +++--
 .../orm/entities/HostComponentStateEntity.java  |  78 ++++--
 .../ServiceComponentDesiredStateEntity.java     |  89 ++++---
 .../entities/ServiceComponentVersionEntity.java |  12 +-
 .../orm/entities/ServiceDesiredStateEntity.java |  86 ++++---
 .../entities/ServiceDesiredStateEntityPK.java   |  34 ++-
 .../server/orm/entities/ServiceGroupEntity.java |   4 +-
 .../server/orm/models/HostComponentSummary.java |  29 ++-
 .../org/apache/ambari/server/state/Cluster.java |  32 +--
 .../org/apache/ambari/server/state/Service.java |  12 +-
 .../ambari/server/state/ServiceComponent.java   |   8 +-
 .../server/state/ServiceComponentHost.java      |  24 +-
 .../server/state/ServiceComponentImpl.java      |  46 +++-
 .../ambari/server/state/ServiceFactory.java     |  16 +-
 .../apache/ambari/server/state/ServiceImpl.java | 131 +++++++---
 .../apache/ambari/server/state/StackInfo.java   |   4 +-
 .../server/state/cluster/ClusterImpl.java       |  52 +++-
 .../ambari/server/state/host/HostImpl.java      |   6 +-
 .../state/repository/VersionDefinitionXml.java  |   2 +-
 .../svccomphost/ServiceComponentHostImpl.java   |  67 ++++-
 .../ServiceComponentHostSummary.java            |   7 +-
 .../ambari/server/topology/AmbariContext.java   |   5 +-
 .../main/resources/Ambari-DDL-Derby-CREATE.sql  |  37 +--
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |  36 +--
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |  34 ++-
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  36 +--
 .../resources/Ambari-DDL-SQLAnywhere-CREATE.sql |  34 ++-
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |  36 +--
 .../src/main/resources/key_properties.json      |   2 +
 .../src/main/resources/properties.json          |   6 +
 .../server/upgrade/UpgradeCatalogHelper.java    |  12 +-
 ambari-web/app/app.js                           |   6 +
 .../app/controllers/global/update_controller.js |   3 +-
 .../main/admin/kerberos/step3_controller.js     |   2 +-
 .../controllers/main/service/add_controller.js  |   2 +-
 .../app/controllers/wizard/step8_controller.js  |  22 +-
 .../app/controllers/wizard/step9_controller.js  |   2 +-
 ambari-web/app/mappers/service_mapper.js        |  12 +-
 .../app/mappers/service_metrics_mapper.js       |  34 +--
 .../app/mixins/common/configs/configs_saver.js  |   2 +-
 .../wizard/wizardProgressPageController.js      |   4 +-
 ambari-web/app/utils/ajax/ajax.js               | 125 +++++-----
 99 files changed, 2205 insertions(+), 1151 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentNotFoundException.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentNotFoundException.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentNotFoundException.java
index 8f25cb1..698f2ab 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentNotFoundException.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/ServiceComponentNotFoundException.java
@@ -23,9 +23,11 @@ public class ServiceComponentNotFoundException
     extends ObjectNotFoundException {
 
   public ServiceComponentNotFoundException (String clusterName,
-      String serviceName, String serviceComponentName) {
+      String serviceName, String serviceDisplayName, String serviceGroupName, 
String serviceComponentName) {
     super("ServiceComponent not found"
         + ", clusterName=" + clusterName
+        + ", serviceDisplayName=" + serviceDisplayName
+        + ", serviceGroupName=" + serviceGroupName
         + ", serviceName=" + serviceName
         + ", serviceComponentName=" + serviceComponentName);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/ServiceNotFoundException.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/ServiceNotFoundException.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/ServiceNotFoundException.java
index 6b18c09..24cd7ae 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/ServiceNotFoundException.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/ServiceNotFoundException.java
@@ -21,9 +21,15 @@ package org.apache.ambari.server;
 @SuppressWarnings("serial")
 public class ServiceNotFoundException extends ObjectNotFoundException {
 
-  public ServiceNotFoundException(String clusterName, String serviceName) {
+  public ServiceNotFoundException(String clusterName, String 
serviceDisplayName) {
     super("Service not found"
         + ", clusterName=" + clusterName
-        + ", serviceName=" + serviceName);
+        + ", serviceDisplayName=" + serviceDisplayName);
+  }
+
+  public ServiceNotFoundException(String clusterName, Long serviceId) {
+    super("Service not found"
+      + ", clusterName=" + clusterName
+      + ", serviceId=" + serviceId);
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/StateRecoveryManager.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/StateRecoveryManager.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/StateRecoveryManager.java
index 03990a2..94a6e08 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/StateRecoveryManager.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/StateRecoveryManager.java
@@ -72,7 +72,7 @@ public class StateRecoveryManager {
         String msg = String.format(
             "Recovered state of cluster %s of component %s/%s for version %s 
from %s to %s",
             component.getClusterId(),
-            component.getServiceName(),
+            component.getServiceId(),
             component.getComponentName(),
             component.getDesiredRepositoryVersion().getDisplayName(),
             RepositoryVersionState.INSTALLING,

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
index d83a5d1..a5b4d08 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
@@ -162,7 +162,7 @@ public class HeartbeatMonitor implements Runnable {
         // mark all components that are not clients with unknown status
         for (Cluster cluster : 
clusters.getClustersForHost(hostObj.getHostName())) {
           for (ServiceComponentHost sch : 
cluster.getServiceComponentHosts(hostObj.getHostName())) {
-            Service s = cluster.getService(sch.getServiceName());
+            Service s = cluster.getService(sch.getServiceDisplayName());
             ServiceComponent sc = 
s.getServiceComponent(sch.getServiceComponentName());
             if (!sc.isClientComponent() &&
               !sch.getState().equals(State.INIT) &&
@@ -237,15 +237,16 @@ public class HeartbeatMonitor implements Runnable {
   private StatusCommand createStatusCommand(String hostname, Cluster cluster,
       ServiceComponentHost sch, Map<String, DesiredConfig> desiredConfigs) 
throws AmbariException {
     String serviceName = sch.getServiceName();
+    String serviceDisplayName = sch.getServiceDisplayName();
     String componentName = sch.getServiceComponentName();
 
     StackId stackId = sch.getDesiredStackId();
 
     ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(),
-        stackId.getStackVersion(), serviceName);
+        stackId.getStackVersion(), serviceDisplayName);
     ComponentInfo componentInfo = ambariMetaInfo.getComponent(
             stackId.getStackName(), stackId.getStackVersion(),
-            serviceName, componentName);
+            serviceDisplayName, componentName);
     StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(),
         stackId.getStackVersion());
 
@@ -306,6 +307,7 @@ public class HeartbeatMonitor implements Runnable {
     StatusCommand statusCmd = new StatusCommand();
     statusCmd.setClusterName(cluster.getClusterName());
     statusCmd.setServiceName(serviceName);
+    statusCmd.setServiceDisplayName(serviceDisplayName);
     statusCmd.setComponentName(componentName);
     statusCmd.setConfigurations(configurations);
     statusCmd.setConfigurationAttributes(configurationAttributes);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java
index 2690008..e99b0e0 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java
@@ -306,7 +306,7 @@ public class HeartbeatProcessor extends AbstractService{
 
           ComponentInfo componentInfo =
               ambariMetaInfo.getComponent(stackId.getStackName(),
-                  stackId.getStackVersion(), scHost.getServiceName(),
+                  stackId.getStackVersion(), scHost.getServiceDisplayName(),
                   scHost.getServiceComponentName());
 
           String status = scHost.getState().name();
@@ -509,7 +509,8 @@ public class HeartbeatProcessor extends AbstractService{
                         "RESTART".equals(report.getCustomCommand()))))
                 && null != report.getConfigurationTags()
                 && !report.getConfigurationTags().isEmpty()) {
-              LOG.info("Updating applied config on service " + 
scHost.getServiceName() +
+              LOG.info("Updating applied config on serviceDisplayName " + 
scHost.getServiceDisplayName() +
+                  ", serviceName " + scHost.getServiceName() +
                   ", component " + scHost.getServiceComponentName() + ", host 
" + scHost.getHostName());
               scHost.updateActualConfigs(report.getConfigurationTags());
               scHost.setRestartRequired(false);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java
index e8c0b05..d778999 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/agent/StatusCommand.java
@@ -39,6 +39,9 @@ public class StatusCommand extends AgentCommand {
   @SerializedName("serviceName")
   private String serviceName;
 
+  @SerializedName("serviceDisplayName")
+  private String serviceDisplayName;
+
   @SerializedName("componentName")
   private String componentName;
 
@@ -117,6 +120,12 @@ public class StatusCommand extends AgentCommand {
     this.serviceName = serviceName;
   }
 
+  public String getServiceDisplayName() { return serviceDisplayName; }
+
+  public void setServiceDisplayName(String serviceDisplayName) {
+    this.serviceDisplayName = serviceDisplayName;
+  }
+
   public String getComponentName() {
     return componentName;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
index 24c2810..8b4a546 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ClusterResourceDefinition.java
@@ -61,7 +61,6 @@ public class ClusterResourceDefinition extends 
BaseResourceDefinition {
   @Override
   public Set<SubResourceDefinition> getSubResourceDefinitions() {
     Set<SubResourceDefinition> setChildren = new HashSet<>();
-    setChildren.add(new SubResourceDefinition(Resource.Type.Service));
     setChildren.add(new SubResourceDefinition(Resource.Type.ServiceGroup));
     setChildren.add(new SubResourceDefinition(Resource.Type.Host));
     setChildren.add(new SubResourceDefinition(Resource.Type.Configuration));

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ComponentResourceDefinition.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ComponentResourceDefinition.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ComponentResourceDefinition.java
index 2a98a9c..b88c985 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ComponentResourceDefinition.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ComponentResourceDefinition.java
@@ -75,14 +75,16 @@ public class ComponentResourceDefinition extends 
BaseResourceDefinition {
     public void process(Request request, TreeNode<Resource> resultNode, String 
href) {
       TreeNode<Resource> parent = resultNode.getParent();
 
-      if (parent.getParent() != null && 
parent.getParent().getObject().getType() == Resource.Type.HostComponent) {
+      if (parent.getParent() != null && parent.getParent().getObject() != null
+              && parent.getParent().getObject().getType() == 
Resource.Type.HostComponent) {
         Resource r = resultNode.getObject();
         Schema schema = 
ClusterControllerHelper.getClusterController().getSchema(r.getType());
+        Object serviceGroupId = 
r.getPropertyValue(schema.getKeyPropertyId(Resource.Type.ServiceGroup));
         Object serviceId = 
r.getPropertyValue(schema.getKeyPropertyId(Resource.Type.Service));
         Object componentId = 
r.getPropertyValue(schema.getKeyPropertyId(r.getType()));
 
         href = href.substring(0, href.indexOf("/hosts/") + 1) +
-            "services/" + serviceId + "/components/" + componentId;
+                "servicegroups/" + serviceGroupId + "/services/" + serviceId + 
"/components/" + componentId;
 
         resultNode.setProperty("href", href);
       } else {
@@ -90,4 +92,4 @@ public class ComponentResourceDefinition extends 
BaseResourceDefinition {
       }
     }
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ServiceGroupResourceDefinition.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ServiceGroupResourceDefinition.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ServiceGroupResourceDefinition.java
index f686851..13bdd7b 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ServiceGroupResourceDefinition.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ServiceGroupResourceDefinition.java
@@ -18,6 +18,9 @@
 
 package org.apache.ambari.server.api.resources;
 
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.ambari.server.controller.spi.Resource;
 
 /**
@@ -27,7 +30,6 @@ public class ServiceGroupResourceDefinition extends 
BaseResourceDefinition {
 
   /**
    * Constructor.
-   *
    */
   public ServiceGroupResourceDefinition() {
     super(Resource.Type.ServiceGroup);
@@ -43,12 +45,10 @@ public class ServiceGroupResourceDefinition extends 
BaseResourceDefinition {
     return "servicegroup";
   }
 
-  /* TODO: To be called when Services become sub-resource of ServiceGroup.
   @Override
   public Set<SubResourceDefinition> getSubResourceDefinitions() {
     Set<SubResourceDefinition> subs = new HashSet<SubResourceDefinition>();
     subs.add(new SubResourceDefinition(Resource.Type.Service));
     return subs;
   }
-  */
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/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 80bd58d..56aabce 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
@@ -339,15 +339,15 @@ public class AmbariMetaInfo {
     return service.getComponents();
   }
 
-  public ComponentInfo getComponent(String stackName, String version, String 
serviceName,
+  public ComponentInfo getComponent(String stackName, String version, String 
serviceDisplayName,
                                     String componentName) throws 
AmbariException {
 
-    ComponentInfo component = getService(stackName, version, 
serviceName).getComponentByName(componentName);
+    ComponentInfo component = getService(stackName, version, 
serviceDisplayName).getComponentByName(componentName);
 
     if (component == null) {
       throw new StackAccessException("stackName=" + stackName
           + ", stackVersion=" + version
-          + ", serviceName=" + serviceName
+          + ", serviceDisplayName=" + serviceDisplayName
           + ", componentName=" + componentName);
     }
     return component;
@@ -586,12 +586,12 @@ public class AmbariMetaInfo {
     return getService(stackId.getStackName(), stackId.getStackVersion(), 
service.getName());
   }
 
-  public ServiceInfo getService(String stackName, String version, String 
serviceName) throws AmbariException {
-    ServiceInfo service = getStack(stackName, version).getService(serviceName);
+  public ServiceInfo getService(String stackName, String version, String 
serviceDisplayName) throws AmbariException {
+    ServiceInfo service = getStack(stackName, 
version).getService(serviceDisplayName);
 
     if (service == null) {
       throw new StackAccessException("stackName=" + stackName + ", 
stackVersion=" +
-                                     version + ", serviceName=" + serviceName);
+                                     version + ", serviceDisplayName=" + 
serviceDisplayName);
     }
 
     return service;

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
index c38489d..92f50f4 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
@@ -506,7 +506,7 @@ public class ClusterService extends BaseService {
    */
   @Path("{clusterName}/services")
   public ServiceService getServiceHandler(@Context javax.ws.rs.core.Request 
request, @ApiParam @PathParam("clusterName") String clusterName) {
-    return new ServiceService(clusterName);
+    return new ServiceService(clusterName, null);
   }
 
   /**
@@ -586,7 +586,7 @@ public class ClusterService extends BaseService {
    */
   @Path("{clusterName}/components")
   public ComponentService getComponentHandler(@Context 
javax.ws.rs.core.Request request, @PathParam("clusterName") String clusterName) 
{
-    return new ComponentService(clusterName, null);
+    return new ComponentService(clusterName, null, null);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/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 b489a15..dfe117e 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
@@ -55,23 +55,30 @@ public class ComponentService extends BaseService {
   private String m_clusterName;
 
   /**
-   * Parent service id.
+   * Parent service group name.
    */
-  private String m_serviceName;
+  private String m_serviceGroupName;
+
+  /**
+   * Parent service display name.
+   */
+  private String m_serviceDisplayName;
 
   /**
    * Constructor.
    *
-   * @param clusterName cluster id
-   * @param serviceName service id
+   * @param clusterName           cluster name
+   * @param serviceGroupName      servicegroup name
+   * @param serviceDisplayName    service display name
    */
-  public ComponentService(String clusterName, String serviceName) {
+  public ComponentService(String clusterName, String serviceGroupName, String 
serviceDisplayName) {
     m_clusterName = clusterName;
-    m_serviceName = serviceName;
+    m_serviceGroupName = serviceGroupName;
+    m_serviceDisplayName = serviceDisplayName;
   }
 
   /**
-   * Handles GET: 
/clusters/{clusterID}/services/{serviceID}/components/{componentID}
+   * Handles GET: 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/components/{componentName}
    * Get a specific component.
    *
    * @param headers       http headers
@@ -88,12 +95,11 @@ public class ComponentService extends BaseService {
       return createClientConfigResource(body, headers, ui, componentName);
     }
 
-    return handleRequest(headers, body, ui, Request.Type.GET,
-        createComponentResource(m_clusterName, m_serviceName, componentName));
+    return handleRequest(headers, body, ui, Request.Type.GET, 
createComponentResource(componentName));
   }
 
   /**
-   * Handles GET: /clusters/{clusterID}/services/{serviceID}/components
+   * Handles GET: 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/components
    * Get all components for a service.
    *
    * @param headers http headers
@@ -109,11 +115,11 @@ public class ComponentService extends BaseService {
       return createClientConfigResource(body, headers, ui, null);
     }
     return handleRequest(headers, body, ui, Request.Type.GET,
-        createComponentResource(m_clusterName, m_serviceName, null));
+        createComponentResource(null));
   }
 
   /**
-   * Handles: POST /clusters/{clusterID}/services/{serviceID}/components
+   * Handles: POST 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/components
    * Create components by specifying an array of components in the http body.
    * This is used to create multiple components in a single request.
    *
@@ -128,11 +134,11 @@ public class ComponentService extends BaseService {
   public Response createComponents(String body, @Context HttpHeaders headers, 
@Context UriInfo ui) {
 
     return handleRequest(headers, body, ui, Request.Type.POST,
-        createComponentResource(m_clusterName, m_serviceName, null));
+        createComponentResource(null));
   }
 
   /**
-   * Handles: POST 
/clusters/{clusterID}/services/{serviceID}/components/{componentID}
+   * Handles: POST 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/components/{componentID}
    * Create a specific component.
    *
    * @param body          http body
@@ -149,11 +155,11 @@ public class ComponentService extends BaseService {
                                 @PathParam("componentName") String 
componentName) {
 
     return handleRequest(headers, body, ui, Request.Type.POST,
-        createComponentResource(m_clusterName, m_serviceName, componentName));
+        createComponentResource(componentName));
   }
 
   /**
-   * Handles: PUT 
/clusters/{clusterID}/services/{serviceID}/components/{componentID}
+   * Handles: PUT 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/components/{componentID}
    * Update a specific component.
    *
    * @param body          http body
@@ -169,12 +175,11 @@ public class ComponentService extends BaseService {
   public Response updateComponent(String body, @Context HttpHeaders headers, 
@Context UriInfo ui,
                                 @PathParam("componentName") String 
componentName) {
 
-    return handleRequest(headers, body, ui, Request.Type.PUT, 
createComponentResource(
-        m_clusterName, m_serviceName, componentName));
+    return handleRequest(headers, body, ui, Request.Type.PUT, 
createComponentResource(componentName));
   }
 
   /**
-   * Handles: PUT /clusters/{clusterID}/services/{serviceID}/components
+   * Handles: PUT 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/components
    * Update multiple components.
    *
    * @param body          http body
@@ -187,12 +192,11 @@ public class ComponentService extends BaseService {
   @Produces("text/plain")
   public Response updateComponents(String body, @Context HttpHeaders headers, 
@Context UriInfo ui) {
 
-    return handleRequest(headers, body, ui, Request.Type.PUT, 
createComponentResource(
-        m_clusterName, m_serviceName, null));
+    return handleRequest(headers, body, ui, Request.Type.PUT, 
createComponentResource(null));
   }
 
   /**
-   * Handles: DELETE 
/clusters/{clusterID}/services/{serviceID}/components/{componentID}
+   * Handles: DELETE 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/components/{componentID}
    * Delete a specific component.
    *
    * @param headers     http headers
@@ -206,24 +210,22 @@ public class ComponentService extends BaseService {
   public Response deleteComponent(@Context HttpHeaders headers, @Context 
UriInfo ui,
                                 @PathParam("componentName") String 
componentName) {
 
-    return handleRequest(headers, null, ui, Request.Type.DELETE, 
createComponentResource(
-        m_clusterName, m_serviceName, componentName));
+    return handleRequest(headers, null, ui, Request.Type.DELETE, 
createComponentResource(componentName));
   }
 
   /**
    * Create a component resource instance.
    *
    *
-   * @param clusterName   cluster name
-   * @param serviceName   service name
    * @param componentName component name
    *
    * @return a component resource instance
    */
-  ResourceInstance createComponentResource(String clusterName, String 
serviceName, String componentName) {
-    Map<Resource.Type,String> mapIds = new HashMap<>();
-    mapIds.put(Resource.Type.Cluster, clusterName);
-    mapIds.put(Resource.Type.Service, serviceName);
+  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_serviceDisplayName == null? null : 
m_serviceDisplayName.toString());
     mapIds.put(Resource.Type.Component, componentName);
 
     return createResource(Resource.Type.Component, mapIds);
@@ -233,15 +235,15 @@ public class ComponentService extends BaseService {
                                       String componentName) {
     Map<Resource.Type,String> mapIds = new HashMap<>();
     mapIds.put(Resource.Type.Cluster, m_clusterName);
-    mapIds.put(Resource.Type.Service, m_serviceName);
+    mapIds.put(Resource.Type.Service, m_serviceDisplayName);
     mapIds.put(Resource.Type.Component, componentName);
     String filePrefixName;
 
     if (StringUtils.isEmpty(componentName)) {
-      if (StringUtils.isEmpty(m_serviceName)) {
+      if (StringUtils.isEmpty(m_serviceDisplayName)) {
         filePrefixName = m_clusterName + "(" + 
Resource.InternalType.Cluster.toString().toUpperCase()+")";
       } else {
-        filePrefixName = m_serviceName + "(" + 
Resource.InternalType.Service.toString().toUpperCase()+")";
+        filePrefixName = m_serviceDisplayName + "(" + 
Resource.InternalType.Service.toString().toUpperCase()+")";
       }
     } else {
       filePrefixName = componentName;

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceGroupService.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceGroupService.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceGroupService.java
index aa1270a..1e2eaf4 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceGroupService.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ServiceGroupService.java
@@ -265,6 +265,20 @@ public class ServiceGroupService extends BaseService {
   }
 
   /**
+   * Get the services sub-resource
+   *
+   * @param request           the request
+   * @param serviceGroupName  service group Name
+   *
+   * @return the services service
+   */
+  @Path("{serviceGroupName}/services")
+  // TODO: find a way to handle this with Swagger (refactor or custom 
annotation?)
+  public ServiceService getServiceHandler(@Context javax.ws.rs.core.Request 
request, @PathParam("serviceGroupName") String serviceGroupName) {
+    return new ServiceService(m_clusterName, serviceGroupName);
+  }
+
+  /**
    * Create a service resource instance.
    *
    * @param clusterName  cluster Name

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/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 6ab2704..7a5e9ab 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
@@ -61,26 +61,33 @@ public class ServiceService extends BaseService {
    */
   private String m_clusterName;
 
+  /*
+   * Parent service group name.
+   */
+  private String m_serviceGroupName;
+
   /**
    * Constructor.
    *
-   * @param clusterName cluster id
+   * @param clusterName       cluster name
+   * @param serviceGroupName  servicegroup name
    */
-  public ServiceService(String clusterName) {
+  public ServiceService(String clusterName, String serviceGroupName) {
     m_clusterName = clusterName;
+    m_serviceGroupName = serviceGroupName;
   }
 
   /**
-   * Handles URL: /clusters/{clusterID}/services/{serviceID}
+   * Handles URL: 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}
    * Get a specific service.
    *
-   * @param headers     http headers
-   * @param ui          uri info
-   * @param serviceName service id
+   * @param headers             http headers
+   * @param ui                  uri info
+   * @param serviceDisplayName  service display name
    * @return service resource representation
    */
   @GET
-  @Path("{serviceName}")
+  @Path("{serviceDisplayName}")
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Get the details of a service",
       nickname = "ServiceService#getService",
@@ -97,14 +104,14 @@ public class ServiceService extends BaseService {
       @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = 
MSG_SERVER_ERROR)
   })
   public Response getService(String body, @Context HttpHeaders headers, 
@Context UriInfo ui,
-                             @ApiParam @PathParam("serviceName") String 
serviceName) {
+                             @ApiParam @PathParam("serviceDisplayName") String 
serviceDisplayName) {
 
     return handleRequest(headers, body, ui, Request.Type.GET,
-        createServiceResource(m_clusterName, serviceName));
+        createServiceResource(m_clusterName, m_serviceGroupName, 
serviceDisplayName));
   }
 
   /**
-   * Handles URL: /clusters/{clusterId}/services
+   * Handles URL: 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services
    * Get all services for a cluster.
    *
    * @param headers http headers
@@ -136,21 +143,21 @@ public class ServiceService extends BaseService {
   })
   public Response getServices(String body, @Context HttpHeaders headers, 
@Context UriInfo ui) {
     return handleRequest(headers, body, ui, Request.Type.GET,
-        createServiceResource(m_clusterName, null));
+        createServiceResource(m_clusterName, m_serviceGroupName, null));
   }
 
   /**
-   * Handles: POST /clusters/{clusterId}/services/{serviceId}
+   * Handles: POST 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}
    * Create a specific service.
    *
-   * @param body        http body
-   * @param headers     http headers
-   * @param ui          uri info
-   * @param serviceName service id
+   * @param body                http body
+   * @param headers             http headers
+   * @param ui                  uri info
+   * @param serviceDisplayName  service display name
    * @return information regarding the created service
    */
   @POST
-  @Path("{serviceName}")
+  @Path("{serviceDisplayName}")
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Creates a service",
       nickname = "ServiceService#createServices"
@@ -169,13 +176,13 @@ public class ServiceService extends BaseService {
       @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = 
MSG_SERVER_ERROR),
   })
   public Response createService(String body, @Context HttpHeaders headers, 
@Context UriInfo ui,
-                                @ApiParam @PathParam("serviceName") String 
serviceName) {
+                                @ApiParam @PathParam("serviceDisplayName") 
String serviceDisplayName) {
     return handleRequest(headers, body, ui, Request.Type.POST,
-        createServiceResource(m_clusterName, serviceName));
+        createServiceResource(m_clusterName, m_serviceGroupName, 
serviceDisplayName));
   }
 
   /**
-   * Handles: POST /clusters/{clusterId}/services
+   * Handles: POST 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services
    * Create multiple services.
    *
    * @param body        http body
@@ -204,21 +211,21 @@ public class ServiceService extends BaseService {
   public Response createServices(String body, @Context HttpHeaders headers, 
@Context UriInfo ui) {
 
     return handleRequest(headers, body, ui, Request.Type.POST,
-        createServiceResource(m_clusterName, null));
+        createServiceResource(m_clusterName, m_serviceGroupName, null));
   }
 
   /**
-   * Handles: PUT /clusters/{clusterId}/services/{serviceId}
+   * Handles: PUT 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}
    * Update a specific service.
    *
-   * @param body        http body
-   * @param headers     http headers
-   * @param ui          uri info
-   * @param serviceName service id
+   * @param body                http body
+   * @param headers             http headers
+   * @param ui                  uri info
+   * @param serviceDisplayName service display name
    * @return information regarding the updated service
    */
   @PUT
-  @Path("{serviceName}")
+  @Path("{serviceDisplayName}")
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Updates a service",
       nickname = "ServiceService#updateService"
@@ -236,12 +243,12 @@ public class ServiceService extends BaseService {
       @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = 
MSG_SERVER_ERROR),
   })
   public Response updateService(String body, @Context HttpHeaders headers, 
@Context UriInfo ui,
-                                @ApiParam @PathParam("serviceName") String 
serviceName) {
-    return handleRequest(headers, body, ui, Request.Type.PUT, 
createServiceResource(m_clusterName, serviceName));
+                                @ApiParam @PathParam("serviceDisplayName") 
String serviceDisplayName) {
+    return handleRequest(headers, body, ui, Request.Type.PUT, 
createServiceResource(m_clusterName, m_serviceGroupName, serviceDisplayName));
   }
 
   /**
-   * Handles: PUT /clusters/{clusterId}/services
+   * Handles: PUT 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services
    * Update multiple services.
    *
    * @param body        http body
@@ -268,20 +275,20 @@ public class ServiceService extends BaseService {
   })
   public Response updateServices(String body, @Context HttpHeaders headers, 
@Context UriInfo ui) {
 
-    return handleRequest(headers, body, ui, Request.Type.PUT, 
createServiceResource(m_clusterName, null));
+    return handleRequest(headers, body, ui, Request.Type.PUT, 
createServiceResource(m_clusterName, m_serviceGroupName, null));
   }
 
   /**
-   * Handles: DELETE /clusters/{clusterId}/services/{serviceId}
+   * Handles: DELETE 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}
    * Delete a specific service.
    *
-   * @param headers     http headers
-   * @param ui          uri info
-   * @param serviceName service id
+   * @param headers             http headers
+   * @param ui                  uri info
+   * @param serviceDisplayName  service display name
    * @return information regarding the deleted service
    */
   @DELETE
-  @Path("{serviceName}")
+  @Path("{serviceDisplayName}")
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Deletes a service",
       nickname = "ServiceService#deleteService"
@@ -294,47 +301,47 @@ public class ServiceService extends BaseService {
       @ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = 
MSG_SERVER_ERROR),
   })
   public Response deleteService(@Context HttpHeaders headers, @Context UriInfo 
ui,
-                                @ApiParam(required = true) 
@PathParam("serviceName") String serviceName) {
-    return handleRequest(headers, null, ui, Request.Type.DELETE, 
createServiceResource(m_clusterName, serviceName));
+                                @ApiParam(required = true) 
@PathParam("serviceDisplayName") String serviceDisplayName) {
+    return handleRequest(headers, null, ui, Request.Type.DELETE, 
createServiceResource(m_clusterName, m_serviceGroupName, serviceDisplayName));
   }
 
   /**
    * Get the components sub-resource.
    *
-   * @param serviceName service id
+   * @param serviceDisplayName service display name
    * @return the components service
    */
-  @Path("{serviceName}/components")
+  @Path("{serviceDisplayName}/components")
   // TODO: find a way to handle this with Swagger (refactor or custom 
annotation?)
-  public ComponentService getComponentHandler(@PathParam("serviceName") String 
serviceName) {
+  public ComponentService getComponentHandler(@PathParam("serviceDisplayName") 
String serviceDisplayName) {
 
-    return new ComponentService(m_clusterName, serviceName);
+    return new ComponentService(m_clusterName, m_serviceGroupName, 
serviceDisplayName);
   }
 
   /**
    * Gets the alerts sub-resource.
    */
-  @Path("{serviceName}/alerts")
+  @Path("{serviceDisplayName}/alerts")
   // TODO: find a way to handle this with Swagger (refactor or custom 
annotation?)
   public AlertService getAlertHandler(
-      @PathParam("serviceName") String serviceName) {
-    return new AlertService(m_clusterName, serviceName, null);
+      @PathParam("serviceDisplayName") String serviceDisplayName) {
+    return new AlertService(m_clusterName, serviceDisplayName, null);
   }
 
   /**
-   * Handles: POST 
/clusters/{clusterId}/services/{serviceId}/artifacts/{artifactName}
+   * Handles: POST 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/artifacts/{artifactName}
    * Create a service artifact instance.
    *
-   * @param body          http body
-   * @param headers       http headers
-   * @param ui            uri info
-   * @param serviceName   service name
+   * @param body                http body
+   * @param headers             http headers
+   * @param ui                  uri info
+   * @param serviceDisplayName  service display name
    * @param artifactName  artifact name
    *
    * @return information regarding the created artifact
    */
   @POST
-  @Path("{serviceName}/artifacts/{artifactName}")
+  @Path("{serviceDisplayName}/artifacts/{artifactName}")
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Creates a service artifact",
       nickname = "ServiceService#createArtifact"
@@ -355,26 +362,26 @@ public class ServiceService extends BaseService {
   public Response createArtifact(String body,
                                  @Context HttpHeaders headers,
                                  @Context UriInfo ui,
-                                 @ApiParam @PathParam("serviceName") String 
serviceName,
+                                 @ApiParam @PathParam("serviceDisplayName") 
String serviceDisplayName,
                                  @ApiParam @PathParam("artifactName") String 
artifactName) {
 
     return handleRequest(headers, body, ui, Request.Type.POST,
-        createArtifactResource(m_clusterName, serviceName, artifactName));
+        createArtifactResource(m_clusterName, m_serviceGroupName, 
serviceDisplayName, artifactName));
   }
 
   /**
-   * Handles: GET /clusters/{clusterId}/services/{serviceId}/artifacts
+   * Handles: GET 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/artifacts
    * Get all service artifacts.
    *
-   * @param body          http body
-   * @param headers       http headers
-   * @param ui            uri info
-   * @param serviceName   service name
+   * @param body                    http body
+   * @param headers                 http headers
+   * @param ui                      uri info
+   * @param serviceDisplayName      service display name
    *
    * @return artifact collection resource representation
    */
   @GET
-  @Path("{serviceName}/artifacts")
+  @Path("{serviceDisplayName}/artifacts")
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Get all service artifacts",
       nickname = "ServiceService#getArtifacts",
@@ -399,26 +406,26 @@ public class ServiceService extends BaseService {
   public Response getArtifacts(String body,
                               @Context HttpHeaders headers,
                               @Context UriInfo ui,
-                              @PathParam("serviceName") String serviceName) {
+                              @PathParam("serviceDisplayName") String 
serviceDisplayName) {
 
     return handleRequest(headers, body, ui, Request.Type.GET,
-        createArtifactResource(m_clusterName, serviceName, null));
+        createArtifactResource(m_clusterName, m_serviceGroupName, 
serviceDisplayName, null));
   }
 
   /**
-   * Handles: GET 
/clusters/{clusterId}/services/{serviceId}/artifacts/{artifactName}
+   * Handles: GET 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/artifacts/{artifactName}
    * Gat a service artifact instance.
    *
-   * @param body          http body
-   * @param headers       http headers
-   * @param ui            uri info
-   * @param serviceName   service name
+   * @param body                    http body
+   * @param headers                 http headers
+   * @param ui                      uri info
+   * @param serviceDisplayName      service display name
    * @param artifactName  artifact name
    *
    * @return artifact instance resource representation
    */
   @GET
-  @Path("{serviceName}/artifacts/{artifactName}")
+  @Path("{serviceDisplayName}/artifacts/{artifactName}")
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Get the details of a service artifact",
       nickname = "ServiceService#getArtifact",
@@ -443,24 +450,24 @@ public class ServiceService extends BaseService {
   public Response getArtifact(String body,
                                  @Context HttpHeaders headers,
                                  @Context UriInfo ui,
-                                 @ApiParam @PathParam("serviceName") String 
serviceName,
+                                 @ApiParam @PathParam("serviceDisplayName") 
String serviceDisplayName,
                                  @ApiParam @PathParam("artifactName") String 
artifactName) {
     return handleRequest(headers, body, ui, Request.Type.GET,
-        createArtifactResource(m_clusterName, serviceName, artifactName));
+        createArtifactResource(m_clusterName, m_serviceGroupName, 
serviceDisplayName, artifactName));
   }
 
   /**
-   * Handles: PUT /clusters/{clusterID}/services/{serviceName}/artifacts
+   * Handles: PUT 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/artifacts
    * Update all artifacts matching the provided predicate.
    *
-   * @param headers      http headers
-   * @param ui           uri info
-   * @param serviceName  service name
+   * @param headers             http headers
+   * @param ui                  uri info
+   * @param serviceDisplayName  service display name
    *
    * @return information regarding the updated artifacts
    */
   @PUT
-  @Path("{serviceName}/artifacts")
+  @Path("{serviceDisplayName}/artifacts")
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Updates multiple artifacts",
       nickname = "ServiceService#updateArtifacts"
@@ -480,25 +487,25 @@ public class ServiceService extends BaseService {
   public Response updateArtifacts(String body,
                                   @Context HttpHeaders headers,
                                   @Context UriInfo ui,
-                                  @ApiParam @PathParam("serviceName") String 
serviceName) {
+                                  @ApiParam @PathParam("serviceDisplayName") 
String serviceDisplayName) {
 
     return handleRequest(headers, body, ui, Request.Type.PUT,
-        createArtifactResource(m_clusterName, serviceName, null));
+        createArtifactResource(m_clusterName, m_serviceGroupName, 
serviceDisplayName, null));
   }
 
   /**
-   * Handles: PUT 
/clusters/{clusterID}/services/{serviceName}/artifacts/{artifactName}
+   * Handles: PUT 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/artifacts/{artifactName}
    * Update a specific artifact.
    *
-   * @param headers       http headers
-   * @param ui            uri info
-   * @param serviceName   service name
-   * @param artifactName  artifact name
+   * @param headers                 http headers
+   * @param ui                      uri info
+   * @param serviceDisplayName      service display name
+   * @param artifactName            artifact name
    *
    * @return information regarding the updated artifact
    */
   @PUT
-  @Path("{serviceName}/artifacts/{artifactName}")
+  @Path("{serviceDisplayName}/artifacts/{artifactName}")
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Updates a single artifact",
       nickname = "ServiceService#updateArtifact"
@@ -518,25 +525,25 @@ public class ServiceService extends BaseService {
   public Response updateArtifact(String body,
                                  @Context HttpHeaders headers,
                                  @Context UriInfo ui,
-                                 @ApiParam(required = true) 
@PathParam("serviceName") String serviceName,
+                                 @ApiParam(required = true) 
@PathParam("serviceDisplayName") String serviceDisplayName,
                                  @ApiParam(required = true) 
@PathParam("artifactName") String artifactName) {
 
     return handleRequest(headers, body, ui, Request.Type.PUT,
-        createArtifactResource(m_clusterName, serviceName, artifactName));
+        createArtifactResource(m_clusterName, m_serviceGroupName, 
serviceDisplayName, artifactName));
   }
 
   /**
-   * Handles: DELETE /clusters/{clusterID}/services/{serviceName}/artifacts
+   * Handles: DELETE 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/artifacts
    * Delete all artifacts matching the provided predicate.
    *
-   * @param headers      http headers
-   * @param ui           uri info
-   * @param serviceName  service name
+   * @param headers             http headers
+   * @param ui                  uri info
+   * @param serviceDisplayName  service display name
    *
    * @return information regarding the deleted artifacts
    */
   @DELETE
-  @Path("{serviceName}/artifacts")
+  @Path("{serviceDisplayName}/artifacts")
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Deletes all artifacts of a service that match the 
provided predicate",
     nickname = "ServiceService#deleteArtifacts"
@@ -551,25 +558,25 @@ public class ServiceService extends BaseService {
   public Response deleteArtifacts(String body,
                                   @Context HttpHeaders headers,
                                   @Context UriInfo ui,
-                                  @ApiParam(required = true) 
@PathParam("serviceName") String serviceName) {
+                                  @ApiParam(required = true) 
@PathParam("serviceDisplayName") String serviceDisplayName) {
 
     return handleRequest(headers, body, ui, Request.Type.DELETE,
-        createArtifactResource(m_clusterName, serviceName, null));
+        createArtifactResource(m_clusterName, m_serviceGroupName, 
serviceDisplayName, null));
   }
 
   /**
-   * Handles: DELETE 
/clusters/{clusterID}/services/{serviceName}/artifacts/{artifactName}
+   * Handles: DELETE 
/clusters/{clusterName}/servicegroups/{serviceGroupName}/services/{serviceDisplayName}/artifacts/{artifactName}
    * Delete a specific artifact.
    *
-   * @param headers       http headers
-   * @param ui            uri info
-   * @param serviceName   service name
-   * @param artifactName  artifact name
+   * @param headers                 http headers
+   * @param ui                      uri info
+   * @param serviceDisplayName      service display name
+   * @param artifactName            artifact name
    *
    * @return information regarding the deleted artifact
    */
   @DELETE
-  @Path("{serviceName}/artifacts/{artifactName}")
+  @Path("{serviceDisplayName}/artifacts/{artifactName}")
   @Produces(MediaType.TEXT_PLAIN)
   @ApiOperation(value = "Deletes a single service artifact",
       nickname = "ServiceService#deleteArtifact"
@@ -584,11 +591,11 @@ public class ServiceService extends BaseService {
   public Response deleteArtifact(String body,
                                  @Context HttpHeaders headers,
                                  @Context UriInfo ui,
-                                 @ApiParam(required = true) 
@PathParam("serviceName") String serviceName,
+                                 @ApiParam(required = true) 
@PathParam("serviceDisplayName") String serviceDisplayName,
                                  @ApiParam(required = true) 
@PathParam("artifactName") String artifactName) {
 
     return handleRequest(headers, body, ui, Request.Type.DELETE,
-        createArtifactResource(m_clusterName, serviceName, artifactName));
+        createArtifactResource(m_clusterName, m_serviceGroupName, 
serviceDisplayName, artifactName));
   }
 
   /**
@@ -596,32 +603,33 @@ public class ServiceService extends BaseService {
    *
    * @param request
    *          the request
-   * @param serviceName
-   *          the service name
+   * @param serviceDisplayName
+   *          the service display name
    *
    * @return the alert history service
    */
-  @Path("{serviceName}/alert_history")
+  @Path("{serviceDisplayName}/alert_history")
   // TODO: find a way to handle this with Swagger (refactor or custom 
annotation?)
   public AlertHistoryService getAlertHistoryService(
       @Context javax.ws.rs.core.Request request,
-      @PathParam("serviceName") String serviceName) {
+      @PathParam("serviceDisplayName") String serviceDisplayName) {
 
-    return new AlertHistoryService(m_clusterName, serviceName, null);
+    return new AlertHistoryService(m_clusterName, serviceDisplayName, null);
   }
 
   /**
    * Create a service resource instance.
    *
-   * @param clusterName  cluster name
-   * @param serviceName  service name
+   * @param clusterName         cluster name
+   * @param serviceDisplayName  service display name
    *
    * @return a service resource instance
    */
-  ResourceInstance createServiceResource(String clusterName, String 
serviceName) {
+  ResourceInstance createServiceResource(String clusterName, String 
serviceGroupName, String serviceDisplayName) {
     Map<Resource.Type,String> mapIds = new HashMap<>();
     mapIds.put(Resource.Type.Cluster, clusterName);
-    mapIds.put(Resource.Type.Service, serviceName);
+    mapIds.put(Resource.Type.ServiceGroup, serviceGroupName);
+    mapIds.put(Resource.Type.Service, serviceDisplayName);
 
     return createResource(Resource.Type.Service, mapIds);
   }
@@ -629,16 +637,17 @@ public class ServiceService extends BaseService {
   /**
    * Create an artifact resource instance.
    *
-   * @param clusterName   cluster name
-   * @param serviceName   service name
-   * @param artifactName  artifact name
+   * @param clusterName           cluster name
+   * @param serviceDisplayName    service display name
+   * @param artifactName          artifact name
    *
    * @return an artifact resource instance
    */
-  ResourceInstance createArtifactResource(String clusterName, String 
serviceName, String artifactName) {
+  ResourceInstance createArtifactResource(String clusterName, String 
serviceGroupName, String serviceDisplayName, String artifactName) {
     Map<Resource.Type,String> mapIds = new HashMap<>();
     mapIds.put(Resource.Type.Cluster, clusterName);
-    mapIds.put(Resource.Type.Service, serviceName);
+    mapIds.put(Resource.Type.ServiceGroup, serviceGroupName);
+    mapIds.put(Resource.Type.Service, serviceDisplayName);
     mapIds.put(Resource.Type.Artifact, artifactName);
 
     return createResource(Resource.Type.Artifact, mapIds);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/checks/ComponentsInstallationCheck.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/ComponentsInstallationCheck.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/ComponentsInstallationCheck.java
index 988fc78..b6c8133 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/ComponentsInstallationCheck.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/ComponentsInstallationCheck.java
@@ -75,7 +75,7 @@ public class ComponentsInstallationCheck extends 
AbstractCheckDescriptor {
           ServiceComponent serviceComponent = component.getValue();
           if (serviceComponent.isVersionAdvertised()) {
             List<HostComponentSummary> hostComponentSummaries = 
HostComponentSummary.getHostComponentSummaries(
-                service.getName(), serviceComponent.getName());
+              service.getClusterId(), service.getServiceGroupId(), 
service.getServiceId(), serviceComponent.getName());
 
             for (HostComponentSummary hcs : hostComponentSummaries) {
               // Skip host if it is in maintenance mode

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
index b440c93..5120a27 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
@@ -702,7 +702,7 @@ public class DatabaseConsistencyCheckHelper {
       for (Iterator<HostComponentDesiredStateEntity> desiredStateIterator = 
missedHostComponentDesiredStates.iterator(); desiredStateIterator.hasNext();) {
         HostComponentDesiredStateEntity hostComponentDesiredStateEntity = 
desiredStateIterator.next();
         if 
(hostComponentStateEntity.getComponentName().equals(hostComponentDesiredStateEntity.getComponentName())
 &&
-            
hostComponentStateEntity.getServiceName().equals(hostComponentDesiredStateEntity.getServiceName())
 &&
+          
hostComponentStateEntity.getServiceId().equals(hostComponentDesiredStateEntity.getServiceId())
 &&
             
hostComponentStateEntity.getHostId().equals(hostComponentDesiredStateEntity.getHostId())){
           desiredStateIterator.remove();
           stateIterator.remove();
@@ -717,7 +717,7 @@ public class DatabaseConsistencyCheckHelper {
       HostComponentStateEntity stateEntity = new HostComponentStateEntity();
       stateEntity.setClusterId(hostComponentDesiredStateEntity.getClusterId());
       
stateEntity.setComponentName(hostComponentDesiredStateEntity.getComponentName());
-      
stateEntity.setServiceName(hostComponentDesiredStateEntity.getServiceName());
+      stateEntity.setServiceId(hostComponentDesiredStateEntity.getServiceId());
       stateEntity.setVersion(State.UNKNOWN.toString());
       
stateEntity.setHostEntity(hostComponentDesiredStateEntity.getHostEntity());
       stateEntity.setCurrentState(State.UNKNOWN);
@@ -733,7 +733,7 @@ public class DatabaseConsistencyCheckHelper {
       HostComponentDesiredStateEntity stateEntity = new 
HostComponentDesiredStateEntity();
       stateEntity.setClusterId(missedHostComponentState.getClusterId());
       
stateEntity.setComponentName(missedHostComponentState.getComponentName());
-      stateEntity.setServiceName(missedHostComponentState.getServiceName());
+      stateEntity.setServiceId(missedHostComponentState.getServiceId());
       stateEntity.setHostEntity(missedHostComponentState.getHostEntity());
       stateEntity.setDesiredState(State.UNKNOWN);
       
stateEntity.setServiceComponentDesiredStateEntity(missedHostComponentState.getServiceComponentDesiredStateEntity());

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
index 543df26..3cea69d 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/checks/SecondaryNamenodeDeletedCheck.java
@@ -29,6 +29,7 @@ import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
 import org.apache.ambari.server.orm.entities.HostComponentStateEntity;
 import org.apache.ambari.server.stack.MasterHostResolver;
 import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
@@ -93,7 +94,8 @@ public class SecondaryNamenodeDeletedCheck extends 
AbstractCheckDescriptor {
     if (hosts.isEmpty()) {
       List<HostComponentStateEntity> allHostComponents = 
hostComponentStateDao.findAll();
       for(HostComponentStateEntity hc : allHostComponents) {
-        if (hc.getServiceName().equalsIgnoreCase(HDFS_SERVICE_NAME) && 
hc.getComponentName().equalsIgnoreCase(SECONDARY_NAMENODE)) {
+        Service s = cluster.getService(hc.getServiceId());
+        if (s.getName().equalsIgnoreCase(HDFS_SERVICE_NAME) && 
hc.getComponentName().equalsIgnoreCase(SECONDARY_NAMENODE)) {
           hosts.add(hc.getHostName());
         }
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/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 6b03249..bf8e88b 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
@@ -121,7 +121,7 @@ public class ServicesUpCheck extends 
AbstractCheckDescriptor {
         // Generally, if it advertises a version => in the upgrade pack.
         // So it can be in the Upgrade Pack but not advertise a version.
         List<HostComponentSummary> hostComponentSummaries = 
HostComponentSummary.getHostComponentSummaries(
-            service.getName(), serviceComponent.getName());
+          service.getClusterId(), service.getServiceGroupId(), 
service.getServiceId(), serviceComponent.getName());
 
         // not installed, nothing to do
         if (hostComponentSummaries.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/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 663d857..12c1d34 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
@@ -62,6 +62,7 @@ import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
 import org.apache.ambari.server.state.ServiceComponentFactory;
 import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.ServiceFactory;
 import org.apache.ambari.server.state.ServiceGroupFactory;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.ServiceOsSpecific;
@@ -105,7 +106,7 @@ public interface AmbariManagementController {
    *
    * @throws AmbariException thrown if the host component cannot be created
    */
-  void createHostComponents(
+  Set<ServiceComponentHostResponse> createHostComponents(
       Set<ServiceComponentHostRequest> requests) throws AmbariException, 
AuthorizationException;
 
   /**
@@ -543,7 +544,7 @@ public interface AmbariManagementController {
    *
    * @throws  AmbariException if service name is null or empty
    */
-  String findServiceName(Cluster cluster, String componentName) throws 
AmbariException;
+  String findService(Cluster cluster, String componentName) throws 
AmbariException;
 
   /**
    * Get the clusters for this management controller.
@@ -567,6 +568,13 @@ public interface AmbariManagementController {
   AmbariMetaInfo getAmbariMetaInfo();
 
   /**
+   * Get the service factory for this management controller.
+   *
+   * @return the service factory
+   */
+  ServiceFactory getServiceFactory();
+
+  /**
    * Get the service groups factory for this management controller.
    *
    * @return the service factory

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/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 ca84826..cff1dc1 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
@@ -182,6 +182,7 @@ import 
org.apache.ambari.server.state.ServiceComponentFactory;
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.ServiceComponentHostEvent;
 import org.apache.ambari.server.state.ServiceComponentHostFactory;
+import org.apache.ambari.server.state.ServiceFactory;
 import org.apache.ambari.server.state.ServiceGroupFactory;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.ServiceOsSpecific;
@@ -270,6 +271,8 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
   @Inject
   private ServiceGroupFactory serviceGroupFactory;
   @Inject
+  private ServiceFactory serviceFactory;
+  @Inject
   private ServiceComponentFactory serviceComponentFactory;
   @Inject
   private ServiceComponentHostFactory serviceComponentHostFactory;
@@ -574,18 +577,18 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
   }
 
   @Override
-  public synchronized void 
createHostComponents(Set<ServiceComponentHostRequest> requests)
+  public synchronized Set<ServiceComponentHostResponse> 
createHostComponents(Set<ServiceComponentHostRequest> requests)
       throws AmbariException, AuthorizationException {
 
     if (requests.isEmpty()) {
       LOG.warn("Received an empty requests set");
-      return;
+      return null;
     }
 
     // do all validation checks
-    Map<String, Map<String, Map<String, Set<String>>>> hostComponentNames =
-        new HashMap<>();
+    Map<String, Map<String, Map<String, Set<String>>>> hostComponentNames = 
new HashMap<>();
     Set<String> duplicates = new HashSet<>();
+    Set<ServiceComponentHostResponse> createdSvcHostCmpnt = null;
     for (ServiceComponentHostRequest request : requests) {
       validateServiceComponentHostRequest(request);
 
@@ -602,13 +605,14 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
         throw new AuthorizationException("The authenticated user is not 
authorized to install service components on to hosts");
       }
 
-      if (StringUtils.isEmpty(request.getServiceName())) {
-        request.setServiceName(findServiceName(cluster, 
request.getComponentName()));
+      if (StringUtils.isEmpty(request.getServiceDisplayName())) {
+        request.setServiceDisplayName(findService(cluster, 
request.getComponentName()));
+        // TODO : What if request.getServiceGroupName() is null ? Get it from 
service instead.
       }
 
       if (LOG.isDebugEnabled()) {
-        LOG.debug("Received a createHostComponent request, clusterName={}, 
serviceName={}, componentName={}, hostname={}, request={}",
-          request.getClusterName(), request.getServiceName(), 
request.getComponentName(), request.getHostname(), request);
+        LOG.debug("Received a createHostComponent request, clusterName={}, 
serviceGroupName={}, serviceName={}, componentName={}, hostname={}, request={}",
+          request.getClusterName(), request.getServiceGroupName(), 
request.getServiceDisplayName(), request.getComponentName(), 
request.getHostname(), request);
       }
 
       if (!hostComponentNames.containsKey(request.getClusterName())) {
@@ -616,19 +620,19 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
             new HashMap<String, Map<String,Set<String>>>());
       }
       if (!hostComponentNames.get(request.getClusterName())
-          .containsKey(request.getServiceName())) {
+          .containsKey(request.getServiceDisplayName())) {
         hostComponentNames.get(request.getClusterName()).put(
-            request.getServiceName(), new HashMap<String, Set<String>>());
+            request.getServiceDisplayName(), new HashMap<String, 
Set<String>>());
       }
       if (!hostComponentNames.get(request.getClusterName())
-          .get(request.getServiceName())
+          .get(request.getServiceDisplayName())
           .containsKey(request.getComponentName())) {
         hostComponentNames.get(request.getClusterName())
-            .get(request.getServiceName()).put(request.getComponentName(),
+            
.get(request.getServiceDisplayName()).put(request.getComponentName(),
                 new HashSet<String>());
       }
       if (hostComponentNames.get(request.getClusterName())
-          .get(request.getServiceName())
+          .get(request.getServiceDisplayName())
           .get(request.getComponentName())
           .contains(request.getHostname())) {
         duplicates.add("[clusterName=" + request.getClusterName() + ", 
hostName=" + request.getHostname() +
@@ -636,7 +640,7 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
         continue;
       }
       hostComponentNames.get(request.getClusterName())
-          .get(request.getServiceName()).get(request.getComponentName())
+          .get(request.getServiceDisplayName()).get(request.getComponentName())
           .add(request.getHostname());
 
       if (request.getDesiredState() != null
@@ -652,10 +656,10 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
 
       Service s;
       try {
-        s = cluster.getService(request.getServiceName());
+        s = cluster.getService(request.getServiceDisplayName());
       } catch (ServiceNotFoundException e) {
         throw new IllegalArgumentException(
-            "The service[" + request.getServiceName() + "] associated with the 
component[" +
+            "The service[" + request.getServiceDisplayName() + "] associated 
with the component[" +
             request.getComponentName() + "] doesn't exist for the cluster[" + 
request.getClusterName() + "]");
       }
       ServiceComponent sc = s.getServiceComponent(
@@ -692,8 +696,7 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
             "clusterName=" + request.getClusterName() + ", hostName=" + 
request.getHostname());
       }
       try {
-        ServiceComponentHost sch = sc.getServiceComponentHost(
-            request.getHostname());
+        ServiceComponentHost sch = 
sc.getServiceComponentHost(request.getHostname());
         if (sch != null) {
           duplicates.add("[clusterName=" + request.getClusterName() + ", 
hostName=" + request.getHostname() +
               ", componentName=" +request.getComponentName() +']');
@@ -731,16 +734,16 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
     // set restartRequired flag for  monitoring services
     setMonitoringServicesRestartRequired(requests);
     // now doing actual work
-    persistServiceComponentHosts(requests);
+    return persistServiceComponentHosts(requests);
   }
 
-  void persistServiceComponentHosts(Set<ServiceComponentHostRequest> requests)
+  Set<ServiceComponentHostResponse> 
persistServiceComponentHosts(Set<ServiceComponentHostRequest> requests)
     throws AmbariException {
     Multimap<Cluster, ServiceComponentHost> schMap = 
ArrayListMultimap.create();
 
     for (ServiceComponentHostRequest request : requests) {
       Cluster cluster = clusters.getCluster(request.getClusterName());
-      Service s = cluster.getService(request.getServiceName());
+      Service s = cluster.getService(request.getServiceDisplayName());
       ServiceComponent sc = s.getServiceComponent(
           request.getComponentName());
 
@@ -755,10 +758,11 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
 
       schMap.put(cluster, sch);
     }
-
+    Set<ServiceComponentHostResponse> createdSvcHostCmpnt = null;
     for (Cluster cluster : schMap.keySet()) {
-      cluster.addServiceComponentHosts(schMap.get(cluster));
+      createdSvcHostCmpnt = 
cluster.addServiceComponentHosts(schMap.get(cluster));
     }
+    return createdSvcHostCmpnt;
   }
 
   private void setMonitoringServicesRestartRequired(
@@ -1232,24 +1236,24 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
     }
 
     if (request.getComponentName() != null) {
-      if (StringUtils.isBlank(request.getServiceName())) {
+      if (StringUtils.isBlank(request.getServiceDisplayName())) {
 
         // !!! FIXME the assumption that a component is unique across all 
stacks is a ticking
         // time bomb.  Blueprints are making this assumption.
-        String serviceName = findServiceName(cluster, 
request.getComponentName());
+        String serviceName = findService(cluster, request.getComponentName());
 
         if (StringUtils.isBlank(serviceName)) {
           LOG.error("Unable to find service for component {}", 
request.getComponentName());
           throw new ServiceComponentHostNotFoundException(
               cluster.getClusterName(), null, request.getComponentName(), 
request.getHostname());
         }
-        request.setServiceName(serviceName);
+        request.setServiceDisplayName(serviceName);
       }
     }
 
     Set<Service> services = new HashSet<>();
-    if (request.getServiceName() != null && 
!request.getServiceName().isEmpty()) {
-      services.add(cluster.getService(request.getServiceName()));
+    if (request.getServiceDisplayName() != null && 
!request.getServiceDisplayName().isEmpty()) {
+      services.add(cluster.getService(request.getServiceDisplayName()));
     } else {
       services.addAll(cluster.getServices().values());
     }
@@ -1359,7 +1363,7 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
 
             response.add(r);
           } catch (ServiceComponentHostNotFoundException e) {
-            if (request.getServiceName() == null || request.getComponentName() 
== null) {
+            if (request.getServiceDisplayName() == null || 
request.getComponentName() == null) {
               // Ignore the exception if either the service name or component 
name are not specified.
               // This is an artifact of how we get host_components and can 
happen in the case where
               // we get all host_components for a host, for example.
@@ -1371,7 +1375,7 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
               // condition.
               LOG.debug("ServiceComponentHost not found ", e);
               throw new 
ServiceComponentHostNotFoundException(cluster.getClusterName(),
-                  request.getServiceName(), request.getComponentName(), 
request.getHostname());
+                  request.getServiceDisplayName(), request.getComponentName(), 
request.getHostname());
             }
           }
         } else {
@@ -3528,14 +3532,14 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
   }
 
   private void 
checkIfHostComponentsInDeleteFriendlyState(ServiceComponentHostRequest request, 
Cluster cluster) throws AmbariException {
-    Service service = cluster.getService(request.getServiceName());
+    Service service = cluster.getService(request.getServiceDisplayName());
     ServiceComponent component = 
service.getServiceComponent(request.getComponentName());
     ServiceComponentHost componentHost = 
component.getServiceComponentHost(request.getHostname());
 
     if (!componentHost.canBeRemoved()) {
       throw new AmbariException("Host Component cannot be removed"
               + ", clusterName=" + request.getClusterName()
-              + ", serviceName=" + request.getServiceName()
+              + ", serviceDisplayName=" + request.getServiceDisplayName()
               + ", componentName=" + request.getComponentName()
               + ", hostname=" + request.getHostname()
               + ", request=" + request);
@@ -3552,8 +3556,8 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
   }
 
   @Override
-  public String findServiceName(Cluster cluster, String componentName) throws 
AmbariException {
-    return cluster.getServiceByComponentName(componentName).getName();
+  public String findService(Cluster cluster, String componentName) throws 
AmbariException {
+    return 
cluster.getServiceByComponentName(componentName).getServiceDisplayName();
   }
 
   /**
@@ -3655,7 +3659,8 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
 
         for (ServiceComponentHost sch : 
cluster.getServiceComponentHosts(request.getHostname())) {
           ServiceComponentHostRequest schr = new 
ServiceComponentHostRequest(request.getClusterName(),
-              sch.getServiceName(), sch.getServiceComponentName(), 
sch.getHostName(), null);
+                  request.getServiceGroupName(), sch.getServiceName(), 
sch.getServiceComponentName(),
+                  sch.getHostName(), null);
           expanded.add(schr);
         }
       }
@@ -3673,18 +3678,18 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
 
       Cluster cluster = clusters.getCluster(request.getClusterName());
 
-      if (StringUtils.isEmpty(request.getServiceName())) {
-        request.setServiceName(findServiceName(cluster, 
request.getComponentName()));
+      if (StringUtils.isEmpty(request.getServiceDisplayName())) {
+        request.setServiceDisplayName(findService(cluster, 
request.getComponentName()));
       }
 
       LOG.info("Received a hostComponent DELETE request"
         + ", clusterName=" + request.getClusterName()
-        + ", serviceName=" + request.getServiceName()
+        + ", serviceDisplayName=" + request.getServiceDisplayName()
         + ", componentName=" + request.getComponentName()
         + ", hostname=" + request.getHostname()
         + ", request=" + request);
 
-      Service service = cluster.getService(request.getServiceName());
+      Service service = cluster.getService(request.getServiceDisplayName());
       ServiceComponent component = 
service.getServiceComponent(request.getComponentName());
       ServiceComponentHost componentHost = 
component.getServiceComponentHost(request.getHostname());
 
@@ -5128,6 +5133,9 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
   }
 
   @Override
+  public ServiceFactory getServiceFactory() { return serviceFactory; }
+
+  @Override
   public ServiceComponentFactory getServiceComponentFactory() {
     return serviceComponentFactory;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/ambari-server/src/main/java/org/apache/ambari/server/controller/ClusterResponse.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/ClusterResponse.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ClusterResponse.java
index 3f75971..576bf12 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/ClusterResponse.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ClusterResponse.java
@@ -74,7 +74,7 @@ public class ClusterResponse {
    * @return the clusterId
    */
   @ApiModelProperty(name = ClusterResourceProvider.CLUSTER_ID)
-  public long getClusterId() {
+  public Long getClusterId() {
     return clusterId;
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/f3520c09/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 e09f433..68c4450 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
@@ -386,8 +386,7 @@ public class ControllerModule extends AbstractModule {
     
bindConstant().annotatedWith(Names.named(HostRoleCommandDAO.HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_MINUTES)).
         to(configuration.getHostRoleCommandStatusSummaryCacheExpiryDuration());
 
-    bind(AmbariManagementController.class).to(
-        AmbariManagementControllerImpl.class);
+    
bind(AmbariManagementController.class).to(AmbariManagementControllerImpl.class);
     
bind(AbstractRootServiceResponseFactory.class).to(RootServiceResponseFactory.class);
     bind(ExecutionScheduler.class).to(ExecutionSchedulerImpl.class);
     bind(DBAccessor.class).to(DBAccessorImpl.class);

Reply via email to