You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ad...@apache.org on 2017/12/18 14:25:28 UTC
[4/4] ambari git commit: AMBARI-22660. Fix unit tests failing due to
ServiceGroup issues (adoroszlai)
AMBARI-22660. Fix unit tests failing due to ServiceGroup issues (adoroszlai)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4e575a59
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4e575a59
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4e575a59
Branch: refs/heads/branch-feature-AMBARI-14714
Commit: 4e575a59acd1861f7b3be10acd439ffc0410f443
Parents: 57051fa
Author: Doroszlai, Attila <ad...@hortonworks.com>
Authored: Mon Dec 18 15:15:21 2017 +0100
Committer: Doroszlai, Attila <ad...@hortonworks.com>
Committed: Mon Dec 18 15:15:32 2017 +0100
----------------------------------------------------------------------
.../server/api/services/AmbariMetaInfo.java | 6 +-
.../AmbariManagementControllerImpl.java | 31 +-
.../controller/ServiceComponentHostRequest.java | 33 +-
.../ambari/server/orm/dao/ServiceGroupDAO.java | 15 +
.../orm/entities/HostComponentStateEntity.java | 2 +-
.../server/orm/entities/ServiceGroupEntity.java | 8 +-
.../server/state/cluster/ClusterImpl.java | 3 +-
.../AmbariCustomCommandExecutionHelperTest.java | 92 +-
.../AmbariManagementControllerImplTest.java | 4 +-
.../AmbariManagementControllerTest.java | 2538 ++++++++----------
.../BackgroundCustomCommandExecutionTest.java | 74 +-
...hYarnCapacitySchedulerReleaseConfigTest.java | 83 +-
.../internal/AbstractResourceProviderTest.java | 55 -
.../internal/ComponentResourceProviderTest.java | 50 +-
.../HostComponentResourceProviderTest.java | 27 +-
.../internal/JMXHostProviderTest.java | 182 +-
.../ServiceGroupResourceProviderTest.java | 45 +
.../internal/ServiceResourceProviderTest.java | 5 +-
.../LoggingSearchPropertyProviderTest.java | 10 +-
.../apache/ambari/server/events/EventsTest.java | 35 +-
.../HostVersionOutOfSyncListenerTest.java | 17 +-
.../apache/ambari/server/orm/OrmTestHelper.java | 15 +-
.../server/orm/dao/AlertDispatchDAOTest.java | 76 +-
.../ComponentVersionCheckActionTest.java | 43 +-
.../upgrades/ConfigureActionTest.java | 21 +-
.../upgrades/CreateAndConfigureActionTest.java | 37 +-
.../upgrades/UpgradeActionTest.java | 67 +-
.../server/state/ServiceComponentTest.java | 6 +-
.../state/alerts/AlertEventPublisherTest.java | 33 +-
.../state/alerts/InitialAlertEventTest.java | 31 +-
.../state/cluster/ClusterDeadlockTest.java | 34 +-
.../server/state/cluster/ClusterTest.java | 170 +-
.../state/cluster/ClustersDeadlockTest.java | 64 +-
.../svccomphost/ServiceComponentHostTest.java | 30 +-
.../server/testing/DBInconsistencyTests.java | 4 -
35 files changed, 1738 insertions(+), 2208 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e575a59/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 25cfaf8..007ec32 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
@@ -97,6 +97,7 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@@ -846,7 +847,8 @@ public class AmbariMetaInfo {
*/
public Set<PropertyInfo> getStackSettings(String stackName, String version)
throws AmbariException {
- return new HashSet<>(getStack(stackName, version).getStackSettings());
+ Collection<PropertyInfo> stackSettings = getStack(stackName, version).getStackSettings();
+ return stackSettings != null ? ImmutableSet.copyOf(stackSettings) : ImmutableSet.of();
}
/*
@@ -856,7 +858,7 @@ public class AmbariMetaInfo {
public Map<String, String> getStackSettingsNameValueMap(StackId stackId)
throws AmbariException {
Set<PropertyInfo> stackSettings = getStackSettings(stackId.getStackName(), stackId.getStackVersion());
- if (stackSettings != null) {
+ if (stackSettings != null && !stackSettings.isEmpty()) {
return stackSettings.stream().collect(
Collectors.toMap(PropertyInfo::getName, PropertyInfo::getValue));
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e575a59/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 1bf5299..41d1bf2 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
@@ -621,7 +621,11 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
if (StringUtils.isEmpty(request.getServiceName())) {
- request.setServiceName(findService(cluster, request.getComponentName()));
+ try {
+ request.setServiceName(findService(cluster, request.getComponentName()));
+ } catch (ServiceNotFoundException e) {
+ // handled below
+ }
// TODO : What if request.getServiceGroupName() is null ? Get it from service instead.
}
@@ -898,14 +902,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
// If the config type is for a service, then allow a user with SERVICE_MODIFY_CONFIGS to
// update, else ensure the user has CLUSTER_MODIFY_CONFIGS
- Long service = null;
-
- try {
- service = cluster.getServiceForConfigTypes(Collections.singleton(configType));
- } catch (IllegalArgumentException e) {
- // Ignore this since we may have hit a config type that spans multiple services. This may
- // happen in unit test cases but should not happen with later versions of stacks.
- }
+ Service service = cluster.getServiceByConfigType(configType);
// Get the changes so that the user's intention can be determined. For example, maybe
// the user wants to change the run-as user for a service or maybe the the cluster-wide
@@ -1012,13 +1009,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
StackId stackId = null;
if (null != service) {
- try {
- Service svc = cluster.getService(service);
- stackId = svc.getDesiredStackId();
- } catch (AmbariException ambariException) {
- LOG.warn("Adding configurations for {} even though its parent service {} is not installed",
- configType, service);
- }
+ stackId = service.getDesiredStackId();
}
if (null == stackId) {
@@ -1266,13 +1257,19 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
// !!! FIXME the assumption that a component is unique across all stacks is a ticking
// time bomb. Blueprints are making this assumption.
- String serviceName = findService(cluster, request.getComponentName());
+ String serviceName = "";
+ try {
+ serviceName = findService(cluster, request.getComponentName());
+ } catch (ServiceNotFoundException e) {
+ // handled below
+ }
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);
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e575a59/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
index 2554c25..0824d53 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostRequest.java
@@ -19,6 +19,7 @@
package org.apache.ambari.server.controller;
+import java.util.Objects;
public class ServiceComponentHostRequest {
@@ -41,7 +42,6 @@ public class ServiceComponentHostRequest {
String componentName,
String hostname,
String desiredState) {
- super();
this.clusterName = clusterName;
this.serviceGroupName = serviceGroupName;
this.serviceName = serviceName;
@@ -188,4 +188,35 @@ public class ServiceComponentHostRequest {
public String getPublicHostname() { return publicHostname; }
public void setPublicHostname(String publicHostname) { this.publicHostname = publicHostname; }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
+ }
+
+ ServiceComponentHostRequest other = (ServiceComponentHostRequest) obj;
+
+ return Objects.equals(clusterName, other.clusterName) &&
+ Objects.equals(serviceGroupName, other.serviceGroupName) &&
+ Objects.equals(serviceName, other.serviceName) &&
+ Objects.equals(componentName, other.componentName) &&
+ Objects.equals(hostname, other.hostname) &&
+ Objects.equals(publicHostname, other.publicHostname) &&
+ Objects.equals(desiredState, other.desiredState) &&
+ Objects.equals(state, other.state) &&
+ Objects.equals(desiredStackId, other.desiredStackId) &&
+ Objects.equals(staleConfig, other.staleConfig) &&
+ Objects.equals(adminState, other.adminState) &&
+ Objects.equals(maintenanceState, other.maintenanceState);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(clusterName, serviceGroupName, serviceName, componentName, hostname, publicHostname,
+ desiredState, state, desiredStackId, staleConfig, adminState, maintenanceState);
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e575a59/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceGroupDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceGroupDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceGroupDAO.java
index 97659f7..9a338c1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceGroupDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceGroupDAO.java
@@ -36,6 +36,7 @@ import com.google.inject.persist.Transactional;
@Singleton
public class ServiceGroupDAO {
+ public static final String SERVICE_GROUP_BY_CLUSTER_ID_AND_SERVICE_GROUP_NAME = "serviceGroupByClusterIdAndServiceGroupName";
@Inject
Provider<EntityManager> entityManagerProvider;
@Inject
@@ -61,6 +62,20 @@ public class ServiceGroupDAO {
}
@RequiresSession
+ public ServiceGroupEntity find(Long clusterId, String serviceGroupName) {
+ TypedQuery<ServiceGroupEntity> query = entityManagerProvider.get()
+ .createNamedQuery(SERVICE_GROUP_BY_CLUSTER_ID_AND_SERVICE_GROUP_NAME, ServiceGroupEntity.class);
+ query.setParameter("clusterId", clusterId);
+ query.setParameter("serviceGroupName", serviceGroupName);
+
+ try {
+ return query.getSingleResult();
+ } catch (NoResultException ignored) {
+ return null;
+ }
+ }
+
+ @RequiresSession
public ServiceGroupDependencyEntity findDependencyByClustersAndServiceGroupsIds(Long serviceGroupClusterId, Long serviceGroupId,
Long dependentServiceGroupClusterId, Long dependenctServiceGroupId) {
TypedQuery<ServiceGroupDependencyEntity> query = entityManagerProvider.get()
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e575a59/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java
index 8994384..f56df9d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java
@@ -72,7 +72,7 @@ import com.google.common.base.Objects;
name = "HostComponentStateEntity.findByServiceAndComponentAndNotVersion",
query = "SELECT hcs from HostComponentStateEntity hcs WHERE hcs.clusterId=:clusterId " +
"AND hcs.serviceGroupId=:serviceGroupId AND hcs.serviceId=:serviceId " +
- "AND hcs.componentName=:componentName AND hcs.hostEntity.hostName=:hostName " +
+ "AND hcs.componentName=:componentName " +
"AND hcs.version != :version"),
@NamedQuery(
name = "HostComponentStateEntity.findByIndex",
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e575a59/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceGroupEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceGroupEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceGroupEntity.java
index fedaee8..7d03e44 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceGroupEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceGroupEntity.java
@@ -34,6 +34,8 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
+import org.apache.ambari.server.orm.dao.ServiceGroupDAO;
+
@IdClass(ServiceGroupEntityPK.class)
@Table(name = "servicegroups")
@@ -42,7 +44,11 @@ import javax.persistence.TableGenerator;
"SELECT serviceGroup " +
"FROM ServiceGroupEntity serviceGroup " +
"JOIN serviceGroup.clusterEntity cluster " +
- "WHERE serviceGroup.serviceGroupId=:serviceGroupId AND cluster.clusterId=:clusterId")
+ "WHERE serviceGroup.serviceGroupId=:serviceGroupId AND cluster.clusterId=:clusterId"),
+ @NamedQuery(name = ServiceGroupDAO.SERVICE_GROUP_BY_CLUSTER_ID_AND_SERVICE_GROUP_NAME, query =
+ "SELECT serviceGroup " +
+ "FROM ServiceGroupEntity serviceGroup " +
+ "WHERE serviceGroup.serviceGroupName = :serviceGroupName AND serviceGroup.clusterId = :clusterId")
})
@Entity
@TableGenerator(name = "service_group_id_generator",
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e575a59/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index bdda9a7..9d76845 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
@@ -1730,7 +1730,7 @@ public class ClusterImpl implements Cluster {
@Override
public void deleteAllServiceGroups() throws AmbariException {
-
+ // FIXME implement
}
@Override
@@ -1885,6 +1885,7 @@ public class ClusterImpl implements Cluster {
try {
refresh();
deleteAllServices();
+ deleteAllServiceGroups();
refresh(); // update one-to-many clusterServiceEntities
removeEntities();
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e575a59/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
index aff6d74..a3eb3c1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelperTest.java
@@ -43,6 +43,7 @@ import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.controller.internal.ComponentResourceProviderTest;
import org.apache.ambari.server.controller.internal.RequestOperationLevel;
import org.apache.ambari.server.controller.internal.RequestResourceFilter;
+import org.apache.ambari.server.controller.internal.ServiceGroupResourceProviderTest;
import org.apache.ambari.server.controller.internal.ServiceResourceProviderTest;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.metadata.ActionMetadata;
@@ -642,29 +643,32 @@ public class AmbariCustomCommandExecutionHelperTest {
ServiceGroup serviceGroup = cluster.addServiceGroup("CORE");
Assert.assertNotNull(cluster);
- createService(clusterName, "YARN", repositoryVersion, serviceGroup.getServiceGroupName(), stackId);
- createService(clusterName, "GANGLIA", repositoryVersion, serviceGroup.getServiceGroupName(), stackId);
- createService(clusterName, "ZOOKEEPER", repositoryVersion, serviceGroup.getServiceGroupName(), stackId);
- createService(clusterName, "FLUME", repositoryVersion, serviceGroup.getServiceGroupName(), stackId);
+ String serviceGroupName = "CORE";
+ ServiceGroupResourceProviderTest.createServiceGroup(ambariManagementController, clusterName, serviceGroupName);
- createServiceComponent(clusterName, "YARN", "RESOURCEMANAGER", State.INIT, serviceGroup.getServiceGroupName());
- createServiceComponent(clusterName, "YARN", "NODEMANAGER", State.INIT, serviceGroup.getServiceGroupName());
- createServiceComponent(clusterName, "GANGLIA", "GANGLIA_SERVER", State.INIT, serviceGroup.getServiceGroupName());
- createServiceComponent(clusterName, "GANGLIA", "GANGLIA_MONITOR", State.INIT, serviceGroup.getServiceGroupName());
- createServiceComponent(clusterName, "ZOOKEEPER", "ZOOKEEPER_CLIENT", State.INIT, serviceGroup.getServiceGroupName());
+ createService(clusterName, serviceGroupName, "YARN", repositoryVersion);
+ createService(clusterName, serviceGroupName, "GANGLIA", repositoryVersion);
+ createService(clusterName, serviceGroupName, "ZOOKEEPER", repositoryVersion);
+ createService(clusterName, serviceGroupName, "FLUME", repositoryVersion);
+
+ createServiceComponent(clusterName, serviceGroupName, "YARN", "RESOURCEMANAGER", State.INIT);
+ createServiceComponent(clusterName, serviceGroupName, "YARN", "NODEMANAGER", State.INIT);
+ createServiceComponent(clusterName, serviceGroupName, "GANGLIA", "GANGLIA_SERVER", State.INIT);
+ createServiceComponent(clusterName, serviceGroupName, "GANGLIA", "GANGLIA_MONITOR", State.INIT);
+ createServiceComponent(clusterName, serviceGroupName, "ZOOKEEPER", "ZOOKEEPER_CLIENT", State.INIT);
// this component should be not installed on any host
- createServiceComponent(clusterName, "FLUME", "FLUME_HANDLER", State.INIT, serviceGroup.getServiceGroupName());
+ createServiceComponent(clusterName, serviceGroupName, "FLUME", "FLUME_HANDLER", State.INIT);
- createServiceComponentHost(clusterName, "YARN", "RESOURCEMANAGER", hostC6401, null, serviceGroup.getServiceGroupName());
- createServiceComponentHost(clusterName, "YARN", "NODEMANAGER", hostC6401, null, serviceGroup.getServiceGroupName());
- createServiceComponentHost(clusterName, "GANGLIA", "GANGLIA_SERVER", hostC6401, State.INIT, serviceGroup.getServiceGroupName());
- createServiceComponentHost(clusterName, "GANGLIA", "GANGLIA_MONITOR", hostC6401, State.INIT, serviceGroup.getServiceGroupName());
- createServiceComponentHost(clusterName, "ZOOKEEPER", "ZOOKEEPER_CLIENT", hostC6401, State.INIT, serviceGroup.getServiceGroupName());
+ createServiceComponentHost(clusterName, serviceGroupName, "YARN", "RESOURCEMANAGER", hostC6401, null);
+ createServiceComponentHost(clusterName, serviceGroupName, "YARN", "NODEMANAGER", hostC6401, null);
+ createServiceComponentHost(clusterName, serviceGroupName, "GANGLIA", "GANGLIA_SERVER", hostC6401, State.INIT);
+ createServiceComponentHost(clusterName, serviceGroupName, "GANGLIA", "GANGLIA_MONITOR", hostC6401, State.INIT);
+ createServiceComponentHost(clusterName, serviceGroupName, "ZOOKEEPER", "ZOOKEEPER_CLIENT", hostC6401, State.INIT);
- createServiceComponentHost(clusterName, "YARN", "NODEMANAGER", hostC6402, null, serviceGroup.getServiceGroupName());
- createServiceComponentHost(clusterName, "GANGLIA", "GANGLIA_MONITOR", hostC6402, State.INIT, serviceGroup.getServiceGroupName());
- createServiceComponentHost(clusterName, "ZOOKEEPER", "ZOOKEEPER_CLIENT", hostC6402, State.INIT, serviceGroup.getServiceGroupName());
+ createServiceComponentHost(clusterName, serviceGroupName, "YARN", "NODEMANAGER", hostC6402, null);
+ createServiceComponentHost(clusterName, serviceGroupName, "GANGLIA", "GANGLIA_MONITOR", hostC6402, State.INIT);
+ createServiceComponentHost(clusterName, serviceGroupName, "ZOOKEEPER", "ZOOKEEPER_CLIENT", hostC6402, State.INIT);
}
private void addHost(String hostname, String clusterName) throws AmbariException {
clusters.addHost(hostname);
@@ -688,48 +692,26 @@ public class AmbariCustomCommandExecutionHelperTest {
ambariManagementController.createCluster(r);
}
- private void createService(String clusterName, String serviceName,
- RepositoryVersionEntity repositoryVersion, String serviceGroupName, StackId stackId) throws AmbariException, AuthorizationException {
-
-
- ServiceRequest r1 = new ServiceRequest(clusterName, serviceGroupName, serviceName,
- repositoryVersion.getId(), null, stackId);
-
- Set<ServiceRequest> requests = new HashSet<>();
- requests.add(r1);
-
+ private void createService(
+ String clusterName, String serviceGroupName, String serviceName, RepositoryVersionEntity repositoryVersion
+ ) throws AmbariException, AuthorizationException {
+ ServiceRequest request = new ServiceRequest(clusterName, serviceGroupName, serviceName, serviceName, repositoryVersion.getId(), null, null, null);
ServiceResourceProviderTest.createServices(ambariManagementController,
- injector.getInstance(RepositoryVersionDAO.class), requests);
+ injector.getInstance(RepositoryVersionDAO.class), Collections.singleton(request));
}
- private void createServiceComponent(String clusterName,
- String serviceName, String componentName, State desiredState, String serviceGroupName)
- throws AmbariException, AuthorizationException {
- String dStateStr = null;
- if (desiredState != null) {
- dStateStr = desiredState.toString();
- }
- ServiceComponentRequest r = new ServiceComponentRequest(clusterName, serviceGroupName,
- serviceName, componentName, dStateStr);
- Set<ServiceComponentRequest> requests =
- new HashSet<>();
- requests.add(r);
- ComponentResourceProviderTest.createComponents(ambariManagementController, requests);
+ private void createServiceComponent(
+ String clusterName, String serviceGroupName, String serviceName, String componentName, State desiredState
+ ) throws AmbariException, AuthorizationException {
+ ServiceComponentRequest r = new ServiceComponentRequest(clusterName, serviceGroupName, serviceName, componentName, desiredState != null ? desiredState.name() : null);
+ ComponentResourceProviderTest.createComponents(ambariManagementController, Collections.singleton(r));
}
- private void createServiceComponentHost(String clusterName, String serviceName, String componentName, String hostname,
- State desiredState, String serviceGroupName)
- throws AmbariException, AuthorizationException {
- String dStateStr = null;
- if (desiredState != null) {
- dStateStr = desiredState.toString();
- }
- ServiceComponentHostRequest r = new ServiceComponentHostRequest(clusterName, serviceGroupName,
- serviceName, componentName, hostname, dStateStr);
- Set<ServiceComponentHostRequest> requests =
- new HashSet<>();
- requests.add(r);
- ambariManagementController.createHostComponents(requests);
+ private void createServiceComponentHost(
+ String clusterName, String serviceGroupName, String serviceName, String componentName, String hostname, State desiredState
+ ) throws AmbariException, AuthorizationException {
+ ServiceComponentHostRequest r = new ServiceComponentHostRequest(clusterName, serviceGroupName, serviceName, componentName, hostname, desiredState != null ? desiredState.name() : null);
+ ambariManagementController.createHostComponents(Collections.singleton(r));
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e575a59/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
index 14ab8cf..fde1c5e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
@@ -386,7 +386,7 @@ public class AmbariManagementControllerImplTest {
expect(service.getServiceType()).andReturn("service");
expect(service.getServiceComponent("component")).andThrow(
- new ServiceComponentNotFoundException("cluster", "service", "component", "", ""));
+ new ServiceComponentNotFoundException("cluster", "service", "service", "CORE", "component"));
expect(service.getDesiredStackId()).andReturn(stackId);
expect(stackId.getStackName()).andReturn("stack");
expect(stackId.getStackVersion()).andReturn("1.0");
@@ -1588,7 +1588,7 @@ public class AmbariManagementControllerImplTest {
expect(cluster.getService("service2")).andReturn(service2);
expect(cluster.getServiceByComponentName("component2")).andReturn(service2).anyTimes();
expect(service2.getServiceComponent("component2")).
- andThrow(new ServiceComponentNotFoundException("cluster1", "service2", "component2", "", ""));
+ andThrow(new ServiceComponentNotFoundException("cluster1", "service2", "service2", "CORE", "component2"));
// expect(ambariMetaInfo.getComponentToService("stackName", "stackVersion", "component3")).andReturn("service1");
expect(cluster.getService("service1")).andReturn(service);