This is an automated email from the ASF dual-hosted git repository. jgolieb pushed a commit to branch branch-feature-AMBARI-14714-mpack-advisor in repository https://gitbox.apache.org/repos/asf/ambari.git
commit 84f080036f01c8a2014e9232eeef524415f26662 Author: Doroszlai, Attila <[email protected]> AuthorDate: Wed May 30 00:30:19 2018 +0200 AMBARI-23746. Cannot query services with same name --- .../controller/AmbariManagementControllerImpl.java | 8 ++--- .../internal/ComponentResourceProvider.java | 2 +- .../ServiceDependencyResourceProvider.java | 17 ++++------ .../internal/ServiceResourceProvider.java | 11 +++---- .../ambari/server/state/cluster/ClusterImpl.java | 38 +++++++++------------- .../internal/ComponentResourceProviderTest.java | 13 +++++--- .../ServiceDependencyResourceProviderTest.java | 2 +- .../internal/ServiceResourceProviderTest.java | 31 ++++++++---------- 8 files changed, 56 insertions(+), 66 deletions(-) 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 24b95e6..a036408 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 @@ -761,7 +761,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle for (ServiceComponentHostRequest request : requests) { Cluster cluster = clusters.getCluster(request.getClusterName()); - Service s = cluster.getService(request.getServiceName()); + Service s = cluster.getService(request.getServiceGroupName(), request.getServiceName()); ServiceComponent sc = s.getServiceComponent( request.getComponentName()); serviceComponentNames.computeIfAbsent(sc.getClusterId(), c -> new HashMap<>()) @@ -1325,7 +1325,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle List<Service> services; if (!Strings.isNullOrEmpty(request.getServiceName())) { - services = ImmutableList.of(cluster.getService(request.getServiceName())); + services = ImmutableList.of(cluster.getService(request.getServiceGroupName(), request.getServiceName())); } else if (!Strings.isNullOrEmpty(request.getServiceGroupName())) { services = ImmutableList.copyOf(cluster.getServicesByServiceGroup(request.getServiceGroupName())); } else { @@ -3300,7 +3300,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle } private boolean hostComponentAlreadyExists(Cluster cluster, ServiceComponentHost sch) throws AmbariException { - Service service = cluster.getService(sch.getServiceName()); + Service service = cluster.getService(sch.getServiceGroupName(), sch.getServiceName()); if (service != null) { ServiceComponent serviceComponent = service.getServiceComponent(sch.getServiceComponentName()); if (serviceComponent != null) { @@ -3319,7 +3319,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle private boolean skipInstallTaskForComponent(Map<String, String> requestProperties, Cluster cluster, ServiceComponentHost sch) throws AmbariException { boolean isClientComponent = false; - Service service = cluster.getService(sch.getServiceName()); + Service service = cluster.getService(sch.getServiceGroupName(), sch.getServiceName()); if (service != null) { ServiceComponent serviceComponent = service.getServiceComponent(sch.getServiceComponentName()); if (serviceComponent != null) { diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java index c59e51d..64afd34 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java @@ -659,7 +659,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide } componentNames.get(clusterName).get(serviceName).add(componentName); - Service s = cluster.getService(serviceName); + Service s = cluster.getService(serviceGroupName, serviceName); ServiceComponent sc = s.getServiceComponent(componentName); State newState = getValidDesiredState(request); diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceDependencyResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceDependencyResourceProvider.java index 3cb7d18..3b8c64a 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceDependencyResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceDependencyResourceProvider.java @@ -20,11 +20,13 @@ package org.apache.ambari.server.controller.internal; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import org.apache.ambari.server.AmbariException; @@ -414,20 +416,15 @@ public class ServiceDependencyResourceProvider extends AbstractControllerResourc Set<ServiceDependencyResponse> responses = new HashSet<>(); if (request.getServiceName() != null) { - Collection<Service> services = cluster.getServices().values(); - Service currentService = null; + Collection<Service> services = cluster.getServicesById().values(); for (Service service : services) { - if (service.getServiceGroupId() == serviceGroup.getServiceGroupId() && + if (Objects.equals(service.getServiceGroupId(), serviceGroup.getServiceGroupId()) && service.getName().equals(request.getServiceName())) { - currentService = service; - break; + return new HashSet<>(service.getServiceDependencyResponses()); } } - - responses.addAll(currentService.getServiceDependencyResponses()); - return responses; } - return responses; + return Collections.emptySet(); } @@ -509,7 +506,7 @@ public class ServiceDependencyResourceProvider extends AbstractControllerResourc //throws service group not found exception ServiceGroup serviceGroup = cluster.getServiceGroup(serviceGroupName); //throws service not found exception - Service service = cluster.getService(serviceName); + Service service = cluster.getService(serviceGroupName, serviceName); Cluster dependencyCluster = cluster; if (StringUtils.isNotEmpty(dependentClusterName)) { diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java index 98eff23..8931d8a 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java @@ -545,7 +545,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider Set<ServiceResponse> response = new HashSet<>(); if (request.getServiceName() != null) { - Service s = cluster.getService(request.getServiceName()); + Service s = cluster.getService(request.getServiceGroupName(), request.getServiceName()); response.add(s.convertToResponse()); return response; } @@ -947,9 +947,8 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider throw new AuthorizationException("The user is not authorized to delete services"); } - Service service = clusters.getCluster( - serviceRequest.getClusterName()).getService( - serviceRequest.getServiceName()); + Service service = clusters.getCluster(serviceRequest.getClusterName()) + .getService(serviceRequest.getServiceGroupName(), serviceRequest.getServiceName()); // // Run through the list of service component hosts. If all host components are in removable state, @@ -1114,8 +1113,8 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider throw new ParentObjectNotFoundException("Attempted to add a service to a cluster which doesn't exist", e); } try { - Service s = cluster.getService(serviceName); - if (s != null && (s.getServiceGroupName().equals(serviceGroupName))) { + Service s = cluster.getService(serviceGroupName, serviceName); + if (s != null) { // throw error later for dup duplicates.add(serviceID); continue; 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 598abe3..6c5678f 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 @@ -159,6 +159,7 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Functions; import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.ListMultimap; @@ -439,9 +440,8 @@ public class ClusterImpl implements Cluster { * We need this for live status checks. */ private void loadServiceHostComponents() { - for (Entry<String, Service> serviceKV : services.entrySet()) { + for (Service service : servicesById.values()) { /* get all the service component hosts **/ - Service service = serviceKV.getValue(); if (!serviceComponentHosts.containsKey(service.getName())) { serviceComponentHosts.put(service.getName(), new ConcurrentHashMap<>()); } @@ -486,11 +486,9 @@ public class ClusterImpl implements Cluster { ServiceGroupEntity serviceGroupEntity = serviceEntity.getClusterServiceGroupEntity(); StackId stackId = new StackId(serviceGroupEntity.getStack()); try { - if (ambariMetaInfo.getService(stackId.getStackName(), - stackId.getStackVersion(), serviceEntity.getServiceType()) != null) { + if (ambariMetaInfo.getService(stackId.getStackName(), stackId.getStackVersion(), serviceEntity.getServiceType()) != null) { Service service = serviceFactory.createExisting(this, getServiceGroup(serviceEntity.getServiceGroupId()), serviceEntity); services.put(serviceEntity.getServiceName(), service); - stackId = getService(serviceEntity.getServiceName()).getStackId(); servicesById.put(serviceEntity.getServiceId(), service); } @@ -705,7 +703,7 @@ public class ClusterImpl implements Cluster { Set<ServiceComponentHostResponse> createdSvcHostCmpnt = new HashSet<>(); Cluster cluster = null; for (ServiceComponentHost serviceComponentHost : serviceComponentHosts) { - Service service = getService(serviceComponentHost.getServiceName()); + Service service = getService(serviceComponentHost.getServiceGroupName(), serviceComponentHost.getServiceName()); cluster = service.getCluster(); ServiceComponent serviceComponent = service.getServiceComponent(serviceComponentHost.getServiceComponentName()); serviceComponent.addServiceComponentHost(serviceComponentHost); @@ -931,13 +929,13 @@ public class ClusterImpl implements Cluster { clusterGlobalLock.writeLock().lock(); try { if (LOG.isDebugEnabled()) { - LOG.debug("Adding a new Service, clusterName={}, clusterId={}, serviceName={} serviceType={}", - getClusterName(), getClusterId(), service.getName(), service.getServiceType()); + LOG.debug("Adding a new Service, clusterName={}, clusterId={} serviceGroup={} serviceName={} serviceType={}", + getClusterName(), getClusterId(), service.getServiceGroupName(), service.getName(), service.getServiceType()); } //TODO get rid of services map services.put(service.getName(), service); - servicesById.put(service.getServiceId(), service); + try { loadServiceConfigTypes(service); } catch (AmbariException e) { @@ -1210,7 +1208,7 @@ public class ClusterImpl implements Cluster { @Override public Service getServiceByComponentName(String componentName) throws AmbariException { - for (Service service : services.values()) { + for (Service service : servicesById.values()) { for (ServiceComponent component : service.getServiceComponents().values()) { if (component.getName().equals(componentName)) { return service; @@ -1223,7 +1221,7 @@ public class ClusterImpl implements Cluster { @Override public Service getServiceByComponentId(Long componentId) throws AmbariException { - for (Service service : services.values()) { + for (Service service : servicesById.values()) { for (ServiceComponent component : service.getServiceComponents().values()) { if (component.getId().equals(componentId)) { return service; @@ -1241,7 +1239,7 @@ public class ClusterImpl implements Cluster { @Override public String getComponentName(Long componentId) throws AmbariException { - for (Service service : services.values()) { + for (Service service : servicesById.values()) { for (ServiceComponent component : service.getServiceComponents().values()) { if (component.getId().equals(componentId)) { return component.getName(); @@ -1255,7 +1253,7 @@ public class ClusterImpl implements Cluster { @Override public String getComponentType(Long componentId) throws AmbariException { - for (Service service : services.values()) { + for (Service service : servicesById.values()) { for (ServiceComponent component : service.getServiceComponents().values()) { if (component.getId().equals(componentId)) { return component.getType(); @@ -1268,7 +1266,7 @@ public class ClusterImpl implements Cluster { @Override public Long getComponentId(String componentName) throws AmbariException { - for (Service service : services.values()) { + for (Service service : servicesById.values()) { for (ServiceComponent component : service.getServiceComponents().values()) { if (component.getName().equals(componentName)) { return component.getId(); @@ -1654,7 +1652,7 @@ public class ClusterImpl implements Cluster { getClusterId()).append(", desiredStackVersion=").append( desiredStackVersion.getStackId()).append(", services=[ "); boolean first = true; - for (Service s : services.values()) { + for (Service s : servicesById.values()) { if (!first) { sb.append(" , "); } @@ -1686,7 +1684,7 @@ public class ClusterImpl implements Cluster { try { LOG.info("Deleting all services for cluster" + ", clusterName=" + getClusterName()); - for (Service service : services.values()) { + for (Service service : servicesById.values()) { if (!service.canBeRemoved()) { throw new AmbariException( "Found non removable service when trying to" @@ -1696,7 +1694,7 @@ public class ClusterImpl implements Cluster { } DeleteHostComponentStatusMetaData deleteMetaData = new DeleteHostComponentStatusMetaData(); - for (Service service : services.values()) { + for (Service service : ImmutableList.copyOf(servicesById.values())) { deleteService(service, deleteMetaData); topologyDeleteFormer.processDeleteMetaDataException(deleteMetaData); } @@ -1887,7 +1885,7 @@ public class ClusterImpl implements Cluster { clusterGlobalLock.readLock().lock(); try { boolean safeToRemove = true; - for (Service service : services.values()) { + for (Service service : servicesById.values()) { if (!service.canBeRemoved()) { safeToRemove = false; LOG.warn("Found non removable service" + ", clusterName=" @@ -2207,10 +2205,6 @@ public class ClusterImpl implements Cluster { return getServiceOrNull(resultingServiceIds.get(0)); } - private boolean isServiceInstalled(String serviceName) { - return services.get(serviceName) != null; - } - @Override public ServiceConfigVersionResponse setServiceConfigVersion(Long serviceId, Long version, String user, String note) throws AmbariException { if (null == user) { diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java index b49ae01..c4dc2fe 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java @@ -401,6 +401,8 @@ public class ComponentResourceProviderTest { expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes(); expect(cluster.getService("Service100")).andReturn(service).anyTimes(); + String serviceGroupName = "CORE"; + expect(cluster.getService(serviceGroupName, "Service100")).andReturn(service).anyTimes(); expect(service.getName()).andReturn("Service100").anyTimes(); expect(service.getServiceType()).andReturn("Service100").anyTimes(); expect(service.getServiceComponent("Component101")).andReturn(serviceComponent1).anyTimes(); @@ -427,13 +429,13 @@ public class ComponentResourceProviderTest { expect(component3Info.getCategory()).andReturn(null); expect(serviceComponent1.convertToResponse()).andReturn( - new ServiceComponentResponse(100L, "Cluster100", 1L, "", 1L, "Service100", "", 1L, "Component101", "Component101", stackId, "", serviceComponentStateCountMap, + new ServiceComponentResponse(100L, "Cluster100", 1L, serviceGroupName, 1L, "Service100", "", 1L, "Component101", "Component101", stackId, "", serviceComponentStateCountMap, false /* recovery not enabled */, "Component101 Client", null)); expect(serviceComponent2.convertToResponse()).andReturn( - new ServiceComponentResponse(100L, "Cluster100", 1L, "", 1L, "Service100", "", 2L, "Component102", "Component102",stackId, "", serviceComponentStateCountMap, + new ServiceComponentResponse(100L, "Cluster100", 1L, serviceGroupName, 1L, "Service100", "", 2L, "Component102", "Component102",stackId, "", serviceComponentStateCountMap, false /* recovery not enabled */, "Component102 Client", null)); expect(serviceComponent3.convertToResponse()).andReturn( - new ServiceComponentResponse(100L, "Cluster100", 1L, "", 1L, "Service100", "", 3L, "Component103", "Component103", stackId, "", serviceComponentStateCountMap, + new ServiceComponentResponse(100L, "Cluster100", 1L, serviceGroupName, 1L, "Service100", "", 3L, "Component103", "Component103", stackId, "", serviceComponentStateCountMap, false /* recovery not enabled */, "Component103 Client", null)); expect(serviceComponent1.getDesiredState()).andReturn(State.INSTALLED).anyTimes(); expect(serviceComponent2.getDesiredState()).andReturn(State.INSTALLED).anyTimes(); @@ -737,7 +739,8 @@ public class ComponentResourceProviderTest { expect(cluster.getServices()).andReturn(Collections.singletonMap("Service100", service)).anyTimes(); expect(cluster.getClusterId()).andReturn(2L).anyTimes(); - expect(cluster.getService("Service100")).andReturn(service).anyTimes(); + String serviceGroupName = "CORE"; + expect(cluster.getService(serviceGroupName, "Service100")).andReturn(service).anyTimes(); expect(service.getName()).andReturn("Service100").anyTimes(); expect(service.getServiceType()).andReturn("Service100").anyTimes(); expect(service.getServiceComponent("Component101")).andReturn(serviceComponent1).anyTimes(); @@ -754,7 +757,7 @@ public class ComponentResourceProviderTest { expect(component1Info.getCategory()).andReturn(null); expect(serviceComponent1.convertToResponse()).andReturn( - new ServiceComponentResponse(100L, "Cluster100", 1L, "", 1L, "Service100", "", 1L, "Component101", "Component101", stackId, "", serviceComponentStateCountMap, + new ServiceComponentResponse(100L, "Cluster100", 1L, serviceGroupName, 1L, "Service100", "", 1L, "Component101", "Component101", stackId, "", serviceComponentStateCountMap, false /* recovery not enabled */, "Component101 Client", null)); expect(serviceComponent1.getDesiredState()).andReturn(State.INSTALLED).anyTimes(); diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceDependencyResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceDependencyResourceProviderTest.java index 46b572a..4767f9b 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceDependencyResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceDependencyResourceProviderTest.java @@ -241,7 +241,7 @@ public class ServiceDependencyResourceProviderTest { mapRequestProps, runSmokeTests, reconfigureClients, maintenanceStateHelper); Assert.assertEquals(State.INSTALLED, - clusters.getCluster(clusterName).getService(serviceName) + clusters.getCluster(clusterName).getService(serviceGroupName, serviceName) .getDesiredState()); if (resp != null) { diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java index e82ab51..1a344c6 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java @@ -143,11 +143,12 @@ public class ServiceResourceProviderTest { expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes(); expect(cluster.getServicesById()).andReturn(Collections.emptyMap()).anyTimes(); - expect(cluster.getService("Service100")).andReturn(null); + String serviceGroupName = "SERVICE_GROUP"; + expect(cluster.getService(serviceGroupName, "Service100")).andReturn(null); expect(cluster.getDesiredStackVersion()).andReturn(stackId).anyTimes(); expect(cluster.getClusterId()).andReturn(2L).anyTimes(); - expect(cluster.getServiceGroup("SERVICE_GROUP")).andReturn(serviceGroup); + expect(cluster.getServiceGroup(serviceGroupName)).andReturn(serviceGroup); expect(cluster.getServiceGroup(1L)).andReturn(serviceGroup); expect(serviceGroup.getStackId()).andReturn(stackId).anyTimes(); expect(service.getServiceGroupId()).andReturn(1L).anyTimes(); @@ -174,7 +175,7 @@ public class ServiceResourceProviderTest { // add properties to the request map properties.put(ServiceResourceProvider.SERVICE_CLUSTER_NAME_PROPERTY_ID, "Cluster100"); properties.put(ServiceResourceProvider.SERVICE_SERVICE_NAME_PROPERTY_ID, "Service100"); - properties.put(ServiceResourceProvider.SERVICE_SERVICE_GROUP_NAME_PROPERTY_ID, "SERVICE_GROUP"); + properties.put(ServiceResourceProvider.SERVICE_SERVICE_GROUP_NAME_PROPERTY_ID, serviceGroupName); properties.put(ServiceResourceProvider.SERVICE_SERVICE_STATE_PROPERTY_ID, "INIT"); propertySet.add(properties); @@ -206,7 +207,7 @@ public class ServiceResourceProviderTest { expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes(); expect(clusters.getCluster(clusterName)).andReturn(cluster).anyTimes(); - expect(cluster.getService(anyString())).andReturn(null); + expect(cluster.getService(anyString(), anyString())).andReturn(null); expect(cluster.getClusterId()).andReturn(2L).anyTimes(); Set<Map<String, Object>> propertySet = new HashSet<>(); @@ -262,7 +263,7 @@ public class ServiceResourceProviderTest { expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes(); expect(clusters.getCluster(clusterName)).andReturn(cluster).anyTimes(); - expect(cluster.getService(anyString())).andReturn(null); + expect(cluster.getService(stackId.getStackName(), serviceName)).andReturn(null); expect(cluster.getClusterId()).andReturn(2L).anyTimes(); ServiceGroup serviceGroup = createNiceMock(ServiceGroup.class); @@ -346,7 +347,6 @@ public class ServiceResourceProviderTest { Map<Long, Service> servicesById = ImmutableMap.of(1L, service0, 2L, service1, 3L, service2, 4L, service3, 5L, service4); expect(cluster.getServicesById()).andReturn(servicesById).anyTimes(); expect(cluster.getServices()).andReturn(allResponseMap).anyTimes(); - expect(cluster.getService("Service102")).andReturn(service2).anyTimes(); expect(cluster.getService(null, "Service102")).andReturn(service2).anyTimes(); expect(service0.convertToResponse()).andReturn(serviceResponse0).anyTimes(); @@ -465,7 +465,7 @@ public class ServiceResourceProviderTest { expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes(); expect(cluster.getServices()).andReturn(allResponseMap).anyTimes(); - expect(cluster.getService("KERBEROS")).andReturn(service0); + expect(cluster.getService(null, "KERBEROS")).andReturn(service0); expect(service0.convertToResponse()).andReturn(serviceResponse0).anyTimes(); @@ -533,7 +533,7 @@ public class ServiceResourceProviderTest { expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes(); expect(cluster.getServices()).andReturn(allResponseMap).anyTimes(); - expect(cluster.getService("KERBEROS")).andReturn(service0); + expect(cluster.getService(null, "KERBEROS")).andReturn(service0); expect(service0.convertToResponse()).andReturn(serviceResponse0).anyTimes(); @@ -600,7 +600,7 @@ public class ServiceResourceProviderTest { expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes(); expect(cluster.getServices()).andReturn(allResponseMap).anyTimes(); - expect(cluster.getService("KERBEROS")).andReturn(service0); + expect(cluster.getService(null, "KERBEROS")).andReturn(service0); expect(service0.convertToResponse()).andReturn(serviceResponse0).anyTimes(); @@ -669,7 +669,7 @@ public class ServiceResourceProviderTest { expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes(); expect(cluster.getServices()).andReturn(allResponseMap).anyTimes(); - expect(cluster.getService("KERBEROS")).andReturn(service0); + expect(cluster.getService(null, "KERBEROS")).andReturn(service0); expect(service0.convertToResponse()).andReturn(serviceResponse0).anyTimes(); @@ -754,7 +754,6 @@ public class ServiceResourceProviderTest { expect(cluster.getClusterId()).andReturn(2L).anyTimes(); expect(cluster.getServicesById()).andReturn(ImmutableMap.of(1L, service0)).anyTimes(); - expect(cluster.getService("Service102")).andReturn(service0).anyTimes(); expect(cluster.getService(null, "Service102")).andReturn(service0).anyTimes(); expect(service0.getDesiredState()).andReturn(State.INSTALLED).anyTimes(); @@ -876,7 +875,6 @@ public class ServiceResourceProviderTest { expect(managementController2.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes(); expect(cluster.getClusterId()).andReturn(2L).anyTimes(); - expect(cluster.getService("Service102")).andReturn(service0).anyTimes(); expect(cluster.getService(null, "Service102")).andReturn(service0).anyTimes(); expect(stackId.getStackId()).andReturn("HDP-2.5").anyTimes(); @@ -999,8 +997,7 @@ public class ServiceResourceProviderTest { expect(managementController.getClusters()).andReturn(clusters).anyTimes(); expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes(); expect(cluster.getClusterId()).andReturn(2L).anyTimes(); - expect(cluster.getService(serviceName)).andReturn(service).anyTimes(); - expect(cluster.getService("SERVICE_GROUP", serviceName)).andReturn(service).anyTimes(); + expect(cluster.getService(null, serviceName)).andReturn(service).anyTimes(); expect(service.getDesiredState()).andReturn(State.INSTALLED).anyTimes(); expect(service.getName()).andReturn(serviceName).anyTimes(); expect(service.getServiceComponents()).andReturn(new HashMap<>()); @@ -1053,7 +1050,7 @@ public class ServiceResourceProviderTest { expect(managementController.getClusters()).andReturn(clusters).anyTimes(); expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes(); expect(cluster.getClusterId()).andReturn(2L).anyTimes(); - expect(cluster.getService(serviceName)).andReturn(service).anyTimes(); + expect(cluster.getService(null, serviceName)).andReturn(service).anyTimes(); expect(service.getDesiredState()).andReturn(State.STARTED).anyTimes(); expect(service.getName()).andReturn(serviceName).anyTimes(); expect(service.getServiceComponents()).andReturn(new HashMap<>()); @@ -1108,7 +1105,7 @@ public class ServiceResourceProviderTest { // set expectations expect(managementController.getClusters()).andReturn(clusters).anyTimes(); expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes(); - expect(cluster.getService(serviceName)).andReturn(service).anyTimes(); + expect(cluster.getService(null, serviceName)).andReturn(service).anyTimes(); expect(service.getDesiredState()).andReturn(State.INSTALLED).anyTimes(); expect(service.getName()).andReturn(serviceName).anyTimes(); expect(service.getServiceComponents()).andReturn(scMap); @@ -1197,7 +1194,7 @@ public class ServiceResourceProviderTest { // set expectations expect(managementController.getClusters()).andReturn(clusters).anyTimes(); expect(clusters.getCluster(clusterName)).andReturn(cluster).anyTimes(); - expect(cluster.getService(serviceName)).andReturn(service).anyTimes(); + expect(cluster.getService(null, serviceName)).andReturn(service).anyTimes(); expect(service.getDesiredState()).andReturn(State.STARTED).anyTimes(); // Service is in a non-removable state expect(service.getName()).andReturn(serviceName).anyTimes(); expect(service.getServiceComponents()).andReturn(scMap).anyTimes(); -- To stop receiving notification emails like this one, please contact [email protected].
