You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2017/11/03 12:37:55 UTC
[2/2] ambari git commit: AMBARI-22309 Update db schema to use
service_id instead of service_name (configs part) (dsen)
AMBARI-22309 Update db schema to use service_id instead of service_name (configs part) (dsen)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/527c4a2d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/527c4a2d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/527c4a2d
Branch: refs/heads/branch-feature-AMBARI-14714
Commit: 527c4a2d74e7f03b44d9412bd418c73a6f155032
Parents: 72bac1f
Author: Dmytro Sen <ds...@apache.org>
Authored: Fri Nov 3 14:35:10 2017 +0200
Committer: Dmytro Sen <ds...@apache.org>
Committed: Fri Nov 3 14:35:10 2017 +0200
----------------------------------------------------------------------
.../checks/ServiceCheckValidityCheck.java | 2 +-
.../AmbariManagementControllerImpl.java | 16 +-
.../server/controller/ConfigGroupRequest.java | 12 +-
.../controller/ServiceConfigVersionRequest.java | 14 +-
.../ServiceConfigVersionResponse.java | 24 ++
.../internal/ClusterResourceProvider.java | 6 +
.../internal/ConfigGroupResourceProvider.java | 48 ++--
.../ServiceConfigVersionResourceProvider.java | 7 +-
.../server/orm/cache/HostConfigMapping.java | 7 +-
.../server/orm/cache/HostConfigMappingImpl.java | 30 ++-
.../server/orm/dao/HostConfigMappingDAO.java | 8 +-
.../ambari/server/orm/dao/ServiceConfigDAO.java | 46 ++--
.../orm/entities/ClusterServiceEntity.java | 6 +
.../server/orm/entities/ConfigGroupEntity.java | 41 ++-
.../orm/entities/HostConfigMappingEntity.java | 59 +++-
.../orm/entities/ServiceConfigEntity.java | 66 ++++-
.../serveraction/upgrades/ConfigureAction.java | 2 +-
.../upgrades/FinalizeUpgradeAction.java | 4 +-
.../upgrades/PreconfigureKerberosAction.java | 2 +-
.../org/apache/ambari/server/state/Cluster.java | 35 +--
.../ambari/server/state/ConfigHelper.java | 4 +-
.../ambari/server/state/DesiredConfig.java | 51 +++-
.../apache/ambari/server/state/ServiceImpl.java | 13 +-
.../ambari/server/state/UpgradeHelper.java | 7 +-
.../server/state/cluster/ClusterImpl.java | 268 +++++++++++--------
.../server/state/configgroup/ConfigGroup.java | 11 +-
.../state/configgroup/ConfigGroupFactory.java | 3 +-
.../state/configgroup/ConfigGroupImpl.java | 67 +++--
.../ambari/server/state/host/HostImpl.java | 3 +-
.../ambari/server/topology/AmbariContext.java | 2 +-
.../apache/ambari/server/topology/Service.java | 7 +
.../server/upgrade/AbstractUpgradeCatalog.java | 2 +-
.../main/resources/Ambari-DDL-Derby-CREATE.sql | 66 ++---
.../main/resources/Ambari-DDL-MySQL-CREATE.sql | 66 ++---
.../main/resources/Ambari-DDL-Oracle-CREATE.sql | 67 ++---
.../resources/Ambari-DDL-Postgres-CREATE.sql | 66 ++---
.../resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 66 ++---
.../resources/Ambari-DDL-SQLServer-CREATE.sql | 66 ++---
.../checks/ServiceCheckValidityCheckTest.java | 27 +-
39 files changed, 829 insertions(+), 468 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/checks/ServiceCheckValidityCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServiceCheckValidityCheck.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServiceCheckValidityCheck.java
index a4c2430..2582c71 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/ServiceCheckValidityCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/ServiceCheckValidityCheck.java
@@ -106,7 +106,7 @@ public class ServiceCheckValidityCheck extends AbstractCheckDescriptor {
LOG.info(String.format("%s in %s version %s does not have customizable configurations. Skip checking service configuration history.", service.getName(), stackId.getStackName(), stackId.getStackVersion()));
} else {
LOG.info(String.format("%s in %s version %s has customizable configurations. Check service configuration history.", service.getName(), stackId.getStackName(), stackId.getStackVersion()));
- ServiceConfigEntity lastServiceConfig = serviceConfigDAO.getLastServiceConfig(clusterId, service.getName());
+ ServiceConfigEntity lastServiceConfig = serviceConfigDAO.getLastServiceConfig(clusterId, service.getServiceId());
lastServiceConfigUpdates.put(service.getName(), lastServiceConfig.getCreateTimestamp());
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/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 370f735..7f5c051 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
@@ -883,7 +883,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
- String service = null;
+ Long service = null;
try {
service = cluster.getServiceForConfigTypes(Collections.singleton(configType));
@@ -897,7 +897,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
// recovery mode setting.
Map<String, String[]> propertyChanges = getPropertyChanges(cluster, request);
- if(StringUtils.isEmpty(service)) {
+ if(service == null) {
// If the configuration is not attached to a specific service, it is a cluster-wide configuration
// type. For example, cluster-env.
@@ -1961,6 +1961,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
ServiceConfigVersionRequest serviceConfigVersionRequest = request.getServiceConfigVersionRequest();
+ //TODO add serviceGroupName validation when the UI is updated to use them
if (StringUtils.isEmpty(serviceConfigVersionRequest.getServiceName()) ||
null == serviceConfigVersionRequest.getVersion()) {
String msg = "Service name and version should be specified in service config version";
@@ -1968,7 +1969,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
throw new IllegalArgumentException(msg);
}
- serviceConfigVersionResponse = cluster.setServiceConfigVersion(serviceConfigVersionRequest.getServiceName(),
+ serviceConfigVersionResponse = cluster.setServiceConfigVersion(
+ cluster.getService(serviceConfigVersionRequest.getServiceGroupName(), serviceConfigVersionRequest.getServiceName()).getServiceId(),
serviceConfigVersionRequest.getVersion(), getAuthName(),
serviceConfigVersionRequest.getNote());
}
@@ -3985,7 +3987,13 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
List<ServiceConfigVersionResponse> serviceConfigVersionResponses = new ArrayList<>();
if (Boolean.TRUE.equals(request.getIsCurrent()) && serviceName != null) {
- serviceConfigVersionResponses.addAll(cluster.getActiveServiceConfigVersionResponse(serviceName));
+ //TODO add serviceGroupName validation when the UI is updated to use them
+ try {
+ Long serviceId = cluster.getService(request.getServiceGroupName(), request.getServiceName()).getServiceId();
+ serviceConfigVersionResponses.addAll(cluster.getActiveServiceConfigVersionResponse(serviceId));
+ } catch (ServiceNotFoundException e) {
+ LOG.warn("Service {} not found on cluster {}", serviceName, cluster.getClusterName());
+ }
} else {
serviceConfigVersionResponses.addAll(cluster.getServiceConfigVersions());
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigGroupRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigGroupRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigGroupRequest.java
index babdf10..fb8d2c9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigGroupRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigGroupRequest.java
@@ -28,18 +28,20 @@ public class ConfigGroupRequest {
private String groupName;
private String tag;
private String serviceName;
+ private String serviceGroupName;
private String description;
private String serviceConfigVersionNote;
private Set<String> hosts;
private Map<String, Config> configs;
public ConfigGroupRequest(Long id, String clusterName, String groupName,
- String tag, String serviceName, String description,
+ String tag, String serviceGroupName, String serviceName, String description,
Set<String> hosts, Map<String, Config> configs) {
this.id = id;
this.clusterName = clusterName;
this.groupName = groupName;
this.tag = tag;
+ this.serviceGroupName = serviceGroupName;
this.serviceName = serviceName;
this.description = description;
this.hosts = hosts;
@@ -117,4 +119,12 @@ public class ConfigGroupRequest {
public void setServiceConfigVersionNote(String serviceConfigVersionNote) {
this.serviceConfigVersionNote = serviceConfigVersionNote;
}
+
+ public String getServiceGroupName() {
+ return serviceGroupName;
+ }
+
+ public void setServiceGroupName(String serviceGroupName) {
+ this.serviceGroupName = serviceGroupName;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionRequest.java
index c47a5e0..29a7a42 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionRequest.java
@@ -21,6 +21,7 @@ package org.apache.ambari.server.controller;
public class ServiceConfigVersionRequest {
private String clusterName;
private String serviceName;
+ private String serviceGroupName;
private Long version;
private Long createTime;
private Long applyTime;
@@ -31,8 +32,9 @@ public class ServiceConfigVersionRequest {
public ServiceConfigVersionRequest() {
}
- public ServiceConfigVersionRequest(String clusterName, String serviceName, Long version, Long createTime, Long applyTime, String userName, Boolean isCurrent) {
+ public ServiceConfigVersionRequest(String clusterName, String serviceGroupName, String serviceName, Long version, Long createTime, Long applyTime, String userName, Boolean isCurrent) {
this.clusterName = clusterName;
+ this.serviceGroupName = serviceGroupName;
this.serviceName = serviceName;
this.version = version;
this.createTime = createTime;
@@ -105,10 +107,20 @@ public class ServiceConfigVersionRequest {
this.isCurrent = isCurrent;
}
+ public String getServiceGroupName() {
+ return serviceGroupName;
+ }
+
+ public void setServiceGroupName(String serviceGroupName) {
+ this.serviceGroupName = serviceGroupName;
+ }
+
+
@Override
public String toString() {
return "ServiceConfigVersionRequest{" +
"clusterName='" + clusterName + '\'' +
+ ", serviceGroupName='" + serviceGroupName + '\'' +
", serviceName='" + serviceName + '\'' +
", version=" + version +
", createTime=" + createTime +
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
index 275d703..0d5b99e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
@@ -54,6 +54,15 @@ public class ServiceConfigVersionResponse {
@JsonProperty("service_name")
private final String serviceName;
+ @JsonProperty("service_id")
+ private final Long serviceId;
+
+ @JsonProperty("service_group_name")
+ private final String serviceGroupName;
+
+ @JsonProperty("service_group_id")
+ private final Long serviceGroupId;
+
@JsonProperty("service_config_version")
private final Long version;
@@ -106,6 +115,9 @@ public class ServiceConfigVersionResponse {
clusterName = clusterEntity.getClusterName();
serviceName = serviceConfigEntity.getServiceName();
+ serviceId = serviceConfigEntity.getServiceId();
+ serviceGroupName = serviceConfigEntity.getServiceGroupName();
+ serviceGroupId = serviceConfigEntity.getServiceGroupId();
version = serviceConfigEntity.getVersion();
userName = serviceConfigEntity.getUser();
createTime = serviceConfigEntity.getCreateTimestamp();
@@ -234,5 +246,17 @@ public class ServiceConfigVersionResponse {
.append(hosts)
.toHashCode();
}
+
+ public String getServiceGroupName() {
+ return serviceGroupName;
+ }
+
+ public Long getServiceId() {
+ return serviceId;
+ }
+
+ public Long getServiceGroupId() {
+ return serviceGroupId;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
index ed80291..61e0f99 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java
@@ -328,8 +328,14 @@ public class ClusterResourceProvider extends AbstractControllerResourceProvider
for (Collection<ServiceConfigVersionResponse> scvCollection : serviceConfigVersions.values()) {
for (ServiceConfigVersionResponse serviceConfigVersionResponse : scvCollection) {
Resource resource = new ResourceImpl(Resource.Type.ServiceConfigVersion);
+ resource.setProperty(ServiceConfigVersionResourceProvider.SERVICE_CONFIG_VERSION_SERVICE_GROUP_NAME_PROPERTY_ID,
+ serviceConfigVersionResponse.getServiceGroupName());
+ resource.setProperty(ServiceConfigVersionResourceProvider.SERVICE_CONFIG_VERSION_SERVICE_GROUP_ID_PROPERTY_ID,
+ serviceConfigVersionResponse.getServiceGroupId());
resource.setProperty(ServiceConfigVersionResourceProvider.SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID,
serviceConfigVersionResponse.getServiceName());
+ resource.setProperty(ServiceConfigVersionResourceProvider.SERVICE_CONFIG_VERSION_SERVICE_ID_PROPERTY_ID,
+ serviceConfigVersionResponse.getServiceId());
resource.setProperty(ServiceConfigVersionResourceProvider.SERVICE_CONFIG_VERSION_PROPERTY_ID,
serviceConfigVersionResponse.getVersion());
resource.setProperty(ServiceConfigVersionResourceProvider.SERVICE_CONFIG_VERSION_NOTE_PROPERTY_ID,
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
index 737bfa4..332b1d2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
@@ -60,6 +60,7 @@ import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.Config;
import org.apache.ambari.server.state.ConfigFactory;
import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.configgroup.ConfigGroup;
import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
import org.apache.commons.collections.MapUtils;
@@ -85,6 +86,8 @@ public class ConfigGroupResourceProvider extends
.getPropertyId("ConfigGroup", "group_name");
protected static final String CONFIGGROUP_TAG_PROPERTY_ID = PropertyHelper
.getPropertyId("ConfigGroup", "tag");
+ protected static final String CONFIGGROUP_SERVICEGROUPNAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("ConfigGroup", "service_group_name");
protected static final String CONFIGGROUP_SERVICENAME_PROPERTY_ID = PropertyHelper
.getPropertyId("ConfigGroup", "service_name");
protected static final String CONFIGGROUP_DESC_PROPERTY_ID = PropertyHelper
@@ -475,7 +478,7 @@ public class ConfigGroupResourceProvider extends
throw new ConfigGroupNotFoundException(cluster.getClusterName(), request.getId().toString());
}
- if (StringUtils.isEmpty(configGroup.getServiceName())) {
+ if (configGroup.getServiceId() == null) {
if (!AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, cluster.getResourceId(),
RoleAuthorization.CLUSTER_MANAGE_CONFIG_GROUPS)) {
throw new AuthorizationException("The authenticated user is not authorized to delete config groups");
@@ -564,18 +567,20 @@ public class ConfigGroupResourceProvider extends
}
verifyHostList(cluster, hosts, request);
-
- String serviceName = request.getServiceName();
- if (serviceName == null && !MapUtils.isEmpty(request.getConfigs())) {
+ Service service = cluster.getService(request.getServiceGroupName(), request.getServiceName());
+ Long serviceId = service.getServiceId();
+ Long serviceGroupId = service.getServiceGroupId();
+ if (serviceId == null && !MapUtils.isEmpty(request.getConfigs())) {
try {
- serviceName = cluster.getServiceForConfigTypes(request.getConfigs().keySet());
+ serviceId = cluster.getServiceForConfigTypes(request.getConfigs().keySet());
+ serviceGroupId = cluster.getService(serviceId).getServiceGroupId();
} 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.
}
}
- if (StringUtils.isEmpty(serviceName)) {
+ if (serviceId == null) {
if (!AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, cluster.getResourceId(),
RoleAuthorization.CLUSTER_MANAGE_CONFIG_GROUPS)) {
throw new AuthorizationException("The authenticated user is not authorized to create config groups");
@@ -592,14 +597,14 @@ public class ConfigGroupResourceProvider extends
verifyConfigs(request.getConfigs(), cluster.getClusterName());
- ConfigGroup configGroup = configGroupFactory.createNew(cluster, serviceName,
+ ConfigGroup configGroup = configGroupFactory.createNew(cluster, serviceGroupId, serviceId,
request.getGroupName(),
request.getTag(), request.getDescription(),
request.getConfigs(), hosts);
cluster.addConfigGroup(configGroup);
- if (serviceName != null) {
- cluster.createServiceConfigVersion(serviceName, getManagementController().getAuthName(),
+ if (serviceGroupId != null && serviceId != null) {
+ cluster.createServiceConfigVersion(serviceId, getManagementController().getAuthName(),
request.getServiceConfigVersionNote(), configGroup);
} else {
LOG.warn("Could not determine service name for config group {}, service config version not created",
@@ -648,10 +653,10 @@ public class ConfigGroupResourceProvider extends
+ ", groupId = " + request.getId());
}
- String serviceName = configGroup.getServiceName();
- String requestServiceName = cluster.getServiceForConfigTypes(request.getConfigs().keySet());
+ Long serviceId = configGroup.getServiceId();
+ Long requestServiceId = cluster.getServiceForConfigTypes(request.getConfigs().keySet());
- if (StringUtils.isEmpty(serviceName) && StringUtils.isEmpty(requestServiceName)) {
+ if (serviceId == null && requestServiceId == null) {
if (!AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, cluster.getResourceId(),
RoleAuthorization.CLUSTER_MANAGE_CONFIG_GROUPS)) {
throw new AuthorizationException("The authenticated user is not authorized to update config groups");
@@ -663,20 +668,20 @@ public class ConfigGroupResourceProvider extends
}
}
- if (serviceName != null && requestServiceName != null && !StringUtils.equals(serviceName, requestServiceName)) {
+ if (serviceId != null && requestServiceId != null && !serviceId.equals(requestServiceId)) {
throw new IllegalArgumentException("Config group " + configGroup.getId() +
- " is mapped to service " + serviceName + ", " +
- "but request contain configs from service " + requestServiceName);
- } else if (serviceName == null && requestServiceName != null) {
- configGroup.setServiceName(requestServiceName);
- serviceName = requestServiceName;
+ " is mapped to service " + serviceId + ", " +
+ "but request contain configs from service " + requestServiceId);
+ } else if (serviceId == null && requestServiceId != null) {
+ configGroup.setServiceId(requestServiceId);
+ serviceId = requestServiceId;
}
int numHosts = (null != configGroup.getHosts()) ? configGroup.getHosts().size() : 0;
configLogger.info("(configchange) Updating configuration group host membership or config value. cluster: '{}', changed by: '{}', " +
"service_name: '{}', config group: '{}', tag: '{}', num hosts in config group: '{}', note: '{}'",
cluster.getClusterName(), getManagementController().getAuthName(),
- serviceName, request.getGroupName(), request.getTag(), numHosts, request.getServiceConfigVersionNote());
+ serviceId, request.getGroupName(), request.getTag(), numHosts, request.getServiceConfigVersionNote());
if (!request.getConfigs().isEmpty()) {
List<String> affectedConfigTypeList = new ArrayList(request.getConfigs().keySet());
@@ -718,8 +723,8 @@ public class ConfigGroupResourceProvider extends
configGroup.setDescription(request.getDescription());
configGroup.setTag(request.getTag());
- if (serviceName != null) {
- cluster.createServiceConfigVersion(serviceName, getManagementController().getAuthName(),
+ if (serviceId != null) {
+ cluster.createServiceConfigVersion(serviceId, getManagementController().getAuthName(),
request.getServiceConfigVersionNote(), configGroup);
ConfigGroupResponse configGroupResponse = new ConfigGroupResponse(configGroup.getId(), cluster.getClusterName(), configGroup.getName(),
@@ -754,6 +759,7 @@ public class ConfigGroupResourceProvider extends
(String) properties.get(CONFIGGROUP_CLUSTER_NAME_PROPERTY_ID),
(String) properties.get(CONFIGGROUP_NAME_PROPERTY_ID),
(String) properties.get(CONFIGGROUP_TAG_PROPERTY_ID),
+ (String) properties.get(CONFIGGROUP_SERVICEGROUPNAME_PROPERTY_ID),
(String) properties.get(CONFIGGROUP_SERVICENAME_PROPERTY_ID),
(String) properties.get(CONFIGGROUP_DESC_PROPERTY_ID),
null,
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
index e7dbbc0..cbc08eb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
@@ -52,7 +52,10 @@ public class ServiceConfigVersionResourceProvider extends
public static final String SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(null, "cluster_name");
public static final String SERVICE_CONFIG_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(null, "service_config_version");
+ public static final String SERVICE_CONFIG_VERSION_SERVICE_GROUP_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(null, "service_group_name");
+ public static final String SERVICE_CONFIG_VERSION_SERVICE_GROUP_ID_PROPERTY_ID = PropertyHelper.getPropertyId(null, "service_group_id");
public static final String SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(null, "service_name");
+ public static final String SERVICE_CONFIG_VERSION_SERVICE_ID_PROPERTY_ID = PropertyHelper.getPropertyId(null, "service_id");
public static final String SERVICE_CONFIG_VERSION_CREATE_TIME_PROPERTY_ID = PropertyHelper.getPropertyId(null, "createtime");
public static final String SERVICE_CONFIG_VERSION_USER_PROPERTY_ID = PropertyHelper.getPropertyId(null, "user");
public static final String SERVICE_CONFIG_VERSION_NOTE_PROPERTY_ID = PropertyHelper.getPropertyId(null, "service_config_version_note");
@@ -194,6 +197,7 @@ public class ServiceConfigVersionResourceProvider extends
for (String propertyId : propertyIds) {
if (!propertyId.equals("cluster_name") && !propertyId.equals("service_config_version") &&
+ !propertyId.equals("service_group_name")&&
!propertyId.equals("service_name") && !propertyId.equals("createtime") &&
!propertyId.equals("appliedtime") && !propertyId.equals("user") &&
!propertyId.equals("service_config_version_note") &&
@@ -214,13 +218,14 @@ public class ServiceConfigVersionResourceProvider extends
private ServiceConfigVersionRequest createRequest(Map<String, Object> properties) {
String clusterName = (String) properties.get(SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID);
+ String serviceGroupName = (String) properties.get(SERVICE_CONFIG_VERSION_SERVICE_GROUP_NAME_PROPERTY_ID);
String serviceName = (String) properties.get(SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID);
String user = (String) properties.get(SERVICE_CONFIG_VERSION_USER_PROPERTY_ID);
Boolean isCurrent = Boolean.valueOf((String) properties.get(SERVICE_CONFIG_VERSION_IS_CURRENT_PROPERTY_ID));
Object versionObject = properties.get(SERVICE_CONFIG_VERSION_PROPERTY_ID);
Long version = versionObject == null ? null : Long.valueOf(versionObject.toString());
- return new ServiceConfigVersionRequest(clusterName, serviceName, version, null, null, user, isCurrent);
+ return new ServiceConfigVersionRequest(clusterName, serviceGroupName, serviceName, version, null, null, user, isCurrent);
}
private List<Map<String, Object>> convertToSubResources(final String clusterName, List<ConfigurationResponse> configs) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/orm/cache/HostConfigMapping.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/cache/HostConfigMapping.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/cache/HostConfigMapping.java
index 8f6c9b7..9ead794 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/cache/HostConfigMapping.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/cache/HostConfigMapping.java
@@ -34,8 +34,11 @@ public interface HostConfigMapping {
String getVersion();
void setVersion(String version);
- String getServiceName();
- void setServiceName(String serviceName);
+ Long getServiceId();
+ void setServiceId(Long serviceId);
+
+ Long getServiceGroupId();
+ void setServiceGroupId(Long serviceGroupId);
String getUser();
void setUser(String user);
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/orm/cache/HostConfigMappingImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/cache/HostConfigMappingImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/cache/HostConfigMappingImpl.java
index 5da7f95..f28841f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/cache/HostConfigMappingImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/cache/HostConfigMappingImpl.java
@@ -26,7 +26,8 @@ public class HostConfigMappingImpl implements HostConfigMapping {
private String type;
private Long createTimestamp;
private String version;
- private String serviceName;
+ private Long serviceId;
+ private Long serviceGroupId;
private String user;
private Integer selected;
@@ -38,7 +39,8 @@ public class HostConfigMappingImpl implements HostConfigMapping {
setType(entry.getType());
setCreateTimestamp(entry.getCreateTimestamp());
setVersion(entry.getVersion());
- setServiceName(entry.getServiceName());
+ setServiceGroupId(entry.getServiceGroupId());
+ setServiceId(entry.getServiceId());
setUser(entry.getUser());
setSelected(entry.getSelected());
}
@@ -105,15 +107,27 @@ public class HostConfigMappingImpl implements HostConfigMapping {
throw new RuntimeException("Version couldn't be null");
this.version = version;
}
- public String getServiceName() {
- return serviceName;
+
+ @Override
+ public Long getServiceId() {
+ return serviceId;
}
-
+
@Override
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
+ public void setServiceId(Long serviceId) {
+ this.serviceId = serviceId;
}
-
+
+ @Override
+ public Long getServiceGroupId() {
+ return serviceGroupId;
+ }
+
+ @Override
+ public void setServiceGroupId(Long serviceGroupId) {
+ this.serviceGroupId = serviceGroupId;
+ }
+
@Override
public String getUser() {
return user;
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostConfigMappingDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostConfigMappingDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostConfigMappingDAO.java
index 5e43473..b80e0e7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostConfigMappingDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostConfigMappingDAO.java
@@ -351,7 +351,8 @@ public class HostConfigMappingDAO {
hostConfigMappingEntity.setCreateTimestamp(hostConfigMapping.getCreateTimestamp());
hostConfigMappingEntity.setHostId(hostEntity.getHostId());
hostConfigMappingEntity.setSelected(hostConfigMapping.getSelected());
- hostConfigMappingEntity.setServiceName(hostConfigMapping.getServiceName());
+ hostConfigMappingEntity.setServiceGroupId(hostConfigMapping.getServiceGroupId());
+ hostConfigMappingEntity.setServiceId(hostConfigMapping.getServiceId());
hostConfigMappingEntity.setType(hostConfigMapping.getType());
hostConfigMappingEntity.setUser(hostConfigMapping.getUser());
hostConfigMappingEntity.setVersion(hostConfigMapping.getVersion());
@@ -362,11 +363,12 @@ public class HostConfigMappingDAO {
public HostConfigMapping buildHostConfigMapping(
HostConfigMappingEntity hostConfigMappingEntity) {
HostConfigMapping hostConfigMapping = new HostConfigMappingImpl();
-
+
hostConfigMapping.setClusterId(hostConfigMappingEntity.getClusterId());
hostConfigMapping.setCreateTimestamp(hostConfigMappingEntity.getCreateTimestamp());
hostConfigMapping.setHostId(hostConfigMappingEntity.getHostId());
- hostConfigMapping.setServiceName(hostConfigMappingEntity.getServiceName());
+ hostConfigMapping.setServiceGroupId(hostConfigMappingEntity.getServiceGroupId());
+ hostConfigMapping.setServiceId(hostConfigMappingEntity.getServiceId());
hostConfigMapping.setType(hostConfigMappingEntity.getType());
hostConfigMapping.setUser(hostConfigMappingEntity.getUser());
hostConfigMapping.setSelected(hostConfigMappingEntity.isSelected());
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
index 6bfad54..d00ff67 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
@@ -59,19 +59,19 @@ public class ServiceConfigDAO {
}
@RequiresSession
- public ServiceConfigEntity findByServiceAndVersion(String serviceName, Long version) {
+ public ServiceConfigEntity findByServiceAndVersion(Long serviceId, Long version) {
TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().
createQuery("SELECT scv FROM ServiceConfigEntity scv " +
- "WHERE scv.serviceName=?1 AND scv.version=?2", ServiceConfigEntity.class);
- return daoUtils.selectOne(query, serviceName, version);
+ "WHERE scv.serviceId=?1 AND scv.version=?2", ServiceConfigEntity.class);
+ return daoUtils.selectOne(query, serviceId, version);
}
@RequiresSession
- public List<ServiceConfigEntity> findByService(Long clusterId, String serviceName) {
+ public List<ServiceConfigEntity> findByService(Long clusterId, Long serviceId) {
TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().
createQuery("SELECT scv FROM ServiceConfigEntity scv " +
- "WHERE scv.clusterId=?1 AND scv.serviceName=?2", ServiceConfigEntity.class);
- return daoUtils.selectList(query, clusterId, serviceName);
+ "WHERE scv.clusterId=?1 AND scv.serviceId=?2", ServiceConfigEntity.class);
+ return daoUtils.selectList(query, clusterId, serviceId);
}
@RequiresSession
@@ -128,18 +128,18 @@ public class ServiceConfigDAO {
* Gets the latest service config versions of all config groups for a service
* @param clusterId
* the cluster (not {@code null}).
- * @param serviceName
- * Name of the service whose latest service config versions needs to be retrieved .
+ * @param serviceId
+ * ID of the service whose latest service config versions needs to be retrieved .
* @return all service configurations for the cluster and service.
*/
@RequiresSession
- public List<ServiceConfigEntity> getLastServiceConfigsForService(Long clusterId, String serviceName) {
+ public List<ServiceConfigEntity> getLastServiceConfigsForService(Long clusterId, Long serviceId) {
TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().createNamedQuery(
"ServiceConfigEntity.findLatestServiceConfigsByService",
ServiceConfigEntity.class);
query.setParameter("clusterId", clusterId);
- query.setParameter("serviceName", serviceName);
+ query.setParameter("serviceId", serviceId);
return daoUtils.selectList(query);
}
@@ -157,7 +157,7 @@ public class ServiceConfigDAO {
*/
@RequiresSession
public List<ServiceConfigEntity> getServiceConfigsForServiceAndStack(Long clusterId,
- StackId stackId, String serviceName) {
+ StackId stackId, Long serviceId) {
StackEntity stackEntity = stackDAO.find(stackId.getStackName(),
stackId.getStackVersion());
@@ -168,7 +168,7 @@ public class ServiceConfigDAO {
query.setParameter("clusterId", clusterId);
query.setParameter("stack", stackEntity);
- query.setParameter("serviceName", serviceName);
+ query.setParameter("serviceId", serviceId);
return daoUtils.selectList(query);
}
@@ -200,24 +200,24 @@ public class ServiceConfigDAO {
}
@RequiresSession
- public ServiceConfigEntity getLastServiceConfig(Long clusterId, String serviceName) {
+ public ServiceConfigEntity getLastServiceConfig(Long clusterId, Long serviceId) {
TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().
createQuery("SELECT scv FROM ServiceConfigEntity scv " +
- "WHERE scv.clusterId = ?1 AND scv.serviceName = ?2 " +
+ "WHERE scv.clusterId = ?1 AND scv.serviceId = ?2 " +
"ORDER BY scv.createTimestamp DESC",
ServiceConfigEntity.class);
- return daoUtils.selectOne(query, clusterId, serviceName);
+ return daoUtils.selectOne(query, clusterId, serviceId);
}
@RequiresSession
- public ServiceConfigEntity findMaxVersion(Long clusterId, String serviceName) {
+ public ServiceConfigEntity findMaxVersion(Long clusterId, Long serviceId) {
TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().createQuery("SELECT scv FROM ServiceConfigEntity scv " +
- "WHERE scv.clusterId=?1 AND scv.serviceName=?2 AND scv.version = (" +
+ "WHERE scv.clusterId=?1 AND scv.serviceId=?2 AND scv.version = (" +
"SELECT max(scv2.version) FROM ServiceConfigEntity scv2 " +
- "WHERE scv2.clusterId=?1 AND scv2.serviceName=?2)", ServiceConfigEntity.class);
+ "WHERE scv2.clusterId=?1 AND scv2.serviceId=?2)", ServiceConfigEntity.class);
- return daoUtils.selectSingle(query, clusterId, serviceName);
+ return daoUtils.selectSingle(query, clusterId, serviceId);
}
/**
@@ -250,17 +250,17 @@ public class ServiceConfigDAO {
*
* @param clusterId
* the cluster that the service is a part of.
- * @param serviceName
- * the name of the service (not {@code null}).
+ * @param serviceId
+ * the ID of the service (not {@code null}).
* @return the maximum version value + 1
*/
@RequiresSession
- public Long findNextServiceConfigVersion(long clusterId, String serviceName) {
+ public Long findNextServiceConfigVersion(long clusterId, Long serviceId) {
TypedQuery<Number> query = entityManagerProvider.get().createNamedQuery(
"ServiceConfigEntity.findNextServiceConfigVersion", Number.class);
query.setParameter("clusterId", clusterId);
- query.setParameter("serviceName", serviceName);
+ query.setParameter("serviceId", serviceId);
return daoUtils.selectSingle(query).longValue();
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java
index b6c60be..976bb67 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java
@@ -235,4 +235,10 @@ public class ClusterServiceEntity {
this.serviceComponentDesiredStateEntities = serviceComponentDesiredStateEntities;
}
+ public String getServiceGroupName() {
+ if (serviceGroupEntity != null) {
+ return serviceGroupEntity.getServiceGroupName();
+ }
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ConfigGroupEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ConfigGroupEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ConfigGroupEntity.java
index 065a073..225b2cc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ConfigGroupEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ConfigGroupEntity.java
@@ -26,6 +26,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
@@ -73,8 +74,20 @@ public class ConfigGroupEntity {
@Column(name = "create_timestamp", nullable=false, insertable=true, updatable=false)
private long timestamp;
- @Column(name = "service_name")
- private String serviceName;
+ @Column(name = "service_id", nullable = false, insertable = false, updatable = false)
+ private Long serviceId;
+
+ @Column(name = "service_group_id", nullable = false, insertable = false, updatable = false)
+ private Long serviceGroupId;
+
+ @ManyToOne
+ @JoinColumns(
+ {
+ @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false, insertable = false, updatable = false),
+ @JoinColumn(name = "service_group_id", referencedColumnName = "service_group_id", nullable = false),
+ @JoinColumn(name = "service_id", referencedColumnName = "id", nullable = false)
+ })
+ private ClusterServiceEntity clusterServiceEntity;
@ManyToOne
@JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false)
@@ -182,11 +195,27 @@ public class ConfigGroupEntity {
return result;
}
- public String getServiceName() {
- return serviceName;
+ public Long getServiceId() {
+ return serviceId;
+ }
+
+ public void setServiceId(Long serviceId) {
+ this.serviceId = serviceId;
+ }
+
+ public Long getServiceGroupId() {
+ return serviceGroupId;
+ }
+
+ public void setServiceGroupId(Long serviceGroupId) {
+ this.serviceGroupId = serviceGroupId;
+ }
+
+ public ClusterServiceEntity getClusterServiceEntity() {
+ return clusterServiceEntity;
}
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
+ public void setClusterServiceEntity(ClusterServiceEntity clusterServiceEntity) {
+ this.clusterServiceEntity = clusterServiceEntity;
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java
index eea4a40..76708f9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostConfigMappingEntity.java
@@ -21,6 +21,9 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
@@ -40,7 +43,7 @@ import javax.persistence.Table;
public class HostConfigMappingEntity {
@Id
- @Column(name = "cluster_id", insertable = true, updatable = false, nullable = false)
+ @Column(name = "cluster_id", insertable = false, updatable = false, nullable = false)
private Long clusterId;
@Id
@@ -58,8 +61,20 @@ public class HostConfigMappingEntity {
@Column(name = "version_tag", insertable = true, updatable = false, nullable = false)
private String versionTag;
- @Column(name = "service_name", insertable = true, updatable = true)
- private String serviceName;
+ @Column(name = "service_id", insertable = false, updatable = false, nullable = false)
+ private Long serviceId;
+
+ @Column(name = "service_group_id", insertable = false, updatable = false, nullable = false)
+ private Long serviceGroupId;
+
+ @ManyToOne
+ @JoinColumns(
+ {
+ @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false),
+ @JoinColumn(name = "service_group_id", referencedColumnName = "service_group_id", nullable = false),
+ @JoinColumn(name = "service_id", referencedColumnName = "id", nullable = false)
+ })
+ private ClusterServiceEntity clusterServiceEntity;
@Column(name = "selected", insertable = true, updatable = true, nullable = false)
private int selected = 0;
@@ -115,14 +130,6 @@ public class HostConfigMappingEntity {
this.selected = selected;
}
- public String getServiceName() {
- return serviceName;
- }
-
- public void setServiceName(String name) {
- serviceName = name;
- }
-
/**
* @return the user
*/
@@ -149,7 +156,8 @@ public class HostConfigMappingEntity {
if (createTimestamp != null ? !createTimestamp.equals(that.createTimestamp) : that.createTimestamp != null)
return false;
if (hostId != null ? !hostId.equals(that.hostId) : that.hostId != null) return false;
- if (serviceName != null ? !serviceName.equals(that.serviceName) : that.serviceName != null) return false;
+ if (serviceGroupId != null ? !serviceGroupId.equals(that.serviceGroupId) : that.serviceGroupId != null) return false;
+ if (serviceId != null ? !serviceId.equals(that.serviceId) : that.serviceId != null) return false;
if (type != null ? !type.equals(that.type) : that.type != null) return false;
if (user != null ? !user.equals(that.user) : that.user != null) return false;
if (versionTag != null ? !versionTag.equals(that.versionTag) : that.versionTag != null) return false;
@@ -164,9 +172,34 @@ public class HostConfigMappingEntity {
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (createTimestamp != null ? createTimestamp.hashCode() : 0);
result = 31 * result + (versionTag != null ? versionTag.hashCode() : 0);
- result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0);
+ result = 31 * result + (serviceGroupId != null ? serviceGroupId.hashCode() : 0);
+ result = 31 * result + (serviceId != null ? serviceId.hashCode() : 0);
result = 31 * result + selected;
result = 31 * result + (user != null ? user.hashCode() : 0);
return result;
}
+
+ public Long getServiceId() {
+ return serviceId;
+ }
+
+ public void setServiceId(Long serviceId) {
+ this.serviceId = serviceId;
+ }
+
+ public Long getServiceGroupId() {
+ return serviceGroupId;
+ }
+
+ public void setServiceGroupId(Long serviceGroupId) {
+ this.serviceGroupId = serviceGroupId;
+ }
+
+ public ClusterServiceEntity getClusterServiceEntity() {
+ return clusterServiceEntity;
+ }
+
+ public void setClusterServiceEntity(ClusterServiceEntity clusterServiceEntity) {
+ this.clusterServiceEntity = clusterServiceEntity;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
index b1409ed..7cd7e98 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
@@ -29,6 +29,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
@@ -51,19 +52,19 @@ import javax.persistence.TableGenerator;
query = "SELECT serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId=:clusterId ORDER BY serviceConfig.version DESC"),
@NamedQuery(
name = "ServiceConfigEntity.findNextServiceConfigVersion",
- query = "SELECT COALESCE(MAX(serviceConfig.version), 0) + 1 AS nextVersion FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.serviceName=:serviceName AND serviceConfig.clusterId=:clusterId"),
+ query = "SELECT COALESCE(MAX(serviceConfig.version), 0) + 1 AS nextVersion FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.serviceId=:serviceId AND serviceConfig.clusterId=:clusterId"),
@NamedQuery(
name = "ServiceConfigEntity.findServiceConfigsByStack",
- query = "SELECT serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId=:clusterId AND serviceConfig.stack=:stack AND serviceConfig.serviceName=:serviceName"),
+ query = "SELECT serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId=:clusterId AND serviceConfig.stack=:stack AND serviceConfig.serviceId=:serviceId"),
@NamedQuery(
name = "ServiceConfigEntity.findLatestServiceConfigsByStack",
- query = "SELECT serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId = :clusterId AND (serviceConfig.groupId = null OR serviceConfig.groupId IN (SELECT cg.groupId from ConfigGroupEntity cg)) AND serviceConfig.version = (SELECT MAX(serviceConfig2.version) FROM ServiceConfigEntity serviceConfig2 WHERE serviceConfig2.clusterId= :clusterId AND serviceConfig2.stack = :stack AND serviceConfig2.serviceName = serviceConfig.serviceName)"),
+ query = "SELECT serviceConfig FROM ServiceConfigEntity serviceConfig WHERE serviceConfig.clusterId = :clusterId AND (serviceConfig.groupId = null OR serviceConfig.groupId IN (SELECT cg.groupId from ConfigGroupEntity cg)) AND serviceConfig.version = (SELECT MAX(serviceConfig2.version) FROM ServiceConfigEntity serviceConfig2 WHERE serviceConfig2.clusterId= :clusterId AND serviceConfig2.stack = :stack AND serviceConfig2.serviceId = serviceConfig.serviceId)"),
@NamedQuery(
name = "ServiceConfigEntity.findLatestServiceConfigsByService",
- query = "SELECT scv FROM ServiceConfigEntity scv WHERE scv.clusterId = :clusterId AND scv.serviceName = :serviceName AND (scv.groupId = null OR scv.groupId IN (SELECT cg.groupId from ConfigGroupEntity cg)) AND scv.version = (SELECT MAX(scv2.version) FROM ServiceConfigEntity scv2 WHERE (scv2.serviceName = :serviceName AND scv2.clusterId = :clusterId) AND (scv2.groupId = scv.groupId OR (scv2.groupId IS NULL AND scv.groupId IS NULL)))"),
+ query = "SELECT scv FROM ServiceConfigEntity scv WHERE scv.clusterId = :clusterId AND scv.serviceId = :serviceId AND (scv.groupId = null OR scv.groupId IN (SELECT cg.groupId from ConfigGroupEntity cg)) AND scv.version = (SELECT MAX(scv2.version) FROM ServiceConfigEntity scv2 WHERE (scv2.serviceId = :serviceId AND scv2.clusterId = :clusterId) AND (scv2.groupId = scv.groupId OR (scv2.groupId IS NULL AND scv.groupId IS NULL)))"),
@NamedQuery(
name = "ServiceConfigEntity.findLatestServiceConfigsByCluster",
- query = "SELECT scv FROM ServiceConfigEntity scv WHERE scv.clusterId = :clusterId AND scv.serviceConfigId IN (SELECT MAX(scv1.serviceConfigId) FROM ServiceConfigEntity scv1 WHERE (scv1.clusterId = :clusterId) AND (scv1.groupId IS NULL) GROUP BY scv1.serviceName)") })
+ query = "SELECT scv FROM ServiceConfigEntity scv WHERE scv.clusterId = :clusterId AND scv.serviceConfigId IN (SELECT MAX(scv1.serviceConfigId) FROM ServiceConfigEntity scv1 WHERE (scv1.clusterId = :clusterId) AND (scv1.groupId IS NULL) GROUP BY scv1.serviceId)") })
public class ServiceConfigEntity {
@Id
@Column(name = "service_config_id")
@@ -75,8 +76,21 @@ public class ServiceConfigEntity {
private Long clusterId;
@Basic
- @Column(name = "service_name", nullable = false)
- private String serviceName;
+ @Column(name = "service_id", nullable = false, insertable = false, updatable = false)
+ private Long serviceId;
+
+ @Basic
+ @Column(name = "service_group_id", nullable = false, insertable = false, updatable = false)
+ private Long serviceGroupId;
+
+ @ManyToOne
+ @JoinColumns(
+ {
+ @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false, insertable = false, updatable = false),
+ @JoinColumn(name = "service_group_id", referencedColumnName = "service_group_id", nullable = false),
+ @JoinColumn(name = "service_id", referencedColumnName = "id", nullable = false)
+ })
+ private ClusterServiceEntity clusterServiceEntity;
@Basic
@Column(name = "group_id", nullable = true)
@@ -135,12 +149,12 @@ public class ServiceConfigEntity {
this.serviceConfigId = serviceConfigId;
}
- public String getServiceName() {
- return serviceName;
+ public Long getServiceId() {
+ return serviceId;
}
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
+ public void setServiceId(Long serviceId) {
+ this.serviceId = serviceId;
}
public Long getVersion() {
@@ -275,4 +289,34 @@ public class ServiceConfigEntity {
}
return true;
}
+
+ public Long getServiceGroupId() {
+ return serviceGroupId;
+ }
+
+ public void setServiceGroupId(Long serviceGroupId) {
+ this.serviceGroupId = serviceGroupId;
+ }
+
+ public ClusterServiceEntity getClusterServiceEntity() {
+ return clusterServiceEntity;
+ }
+
+ public void setClusterServiceEntity(ClusterServiceEntity clusterServiceEntity) {
+ this.clusterServiceEntity = clusterServiceEntity;
+ }
+
+ public String getServiceGroupName() {
+ if (clusterServiceEntity != null) {
+ return clusterServiceEntity.getServiceGroupName();
+ }
+ return null;
+ }
+
+ public String getServiceName() {
+ if (clusterServiceEntity != null) {
+ return clusterServiceEntity.getServiceName();
+ }
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
index f15a507..6bb248e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/ConfigureAction.java
@@ -181,7 +181,7 @@ public class ConfigureAction extends AbstractUpgradeServerAction {
// such as hdfs-site or hbase-env
String configType = commandParameters.get(ConfigureTask.PARAMETER_CONFIG_TYPE);
- String serviceName = cluster.getServiceByConfigType(configType);
+ String serviceName = cluster.getServiceByConfigType(configType).getName();
// !!! we couldn't get the service based on its config type, so try the associated
if (StringUtils.isBlank(serviceName)) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
index f0ae0c8..7380cba 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/FinalizeUpgradeAction.java
@@ -325,8 +325,8 @@ public class FinalizeUpgradeAction extends AbstractUpgradeServerAction {
outSB.append(
String.format("Removing %s configurations for %s", sourceStackId,
serviceName)).append(System.lineSeparator());
-
- cluster.removeConfigurations(sourceStackId, serviceName);
+ //TODO pass serviceGroupName
+ cluster.removeConfigurations(sourceStackId, cluster.getService(null, serviceName).getServiceId());
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/PreconfigureKerberosAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/PreconfigureKerberosAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/PreconfigureKerberosAction.java
index 5af7c6b..02cb70a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/PreconfigureKerberosAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/upgrades/PreconfigureKerberosAction.java
@@ -462,7 +462,7 @@ public class PreconfigureKerberosAction extends AbstractUpgradeServerAction {
for (Map.Entry<String, Map<String, String>> entry : kerberosConfigurations.entrySet()) {
String configType = entry.getKey();
- String service = cluster.getServiceByConfigType(configType);
+ String service = cluster.getServiceByConfigType(configType).getName();
Set<String> allowedProperties = propertyFilter.get(configType);
// Update properties for services that are installed and not filtered out
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
index 2193c3a..27d37e3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
@@ -98,6 +98,7 @@ public interface Cluster {
ServiceGroup addServiceGroupDependency(String serviceGroupName, String dependencyServiceGroupName) throws AmbariException;
+ //TODO remove when UI starts using service groups
/**
* Get a service
*
@@ -106,6 +107,8 @@ public interface Cluster {
*/
Service getService(String serviceName) throws AmbariException;
+ Service getService(String serviceGroupName, String serviceName) throws AmbariException;
+
Service getService(Long serviceId) throws AmbariException;
/**
@@ -383,7 +386,7 @@ public interface Cluster {
* @return <code>true</code> if the config was added, or <code>false</code>
* if the config is already set as the current
*/
- ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs);
+ ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs) throws AmbariException;
/**
* Adds and sets a DESIRED configuration to be applied to a cluster. There
@@ -395,24 +398,24 @@ public interface Cluster {
* @return <code>true</code> if the config was added, or <code>false</code>
* if the config is already set as the current
*/
- ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs, String serviceConfigVersionNote);
+ ServiceConfigVersionResponse addDesiredConfig(String user, Set<Config> configs, String serviceConfigVersionNote) throws AmbariException;
- ServiceConfigVersionResponse createServiceConfigVersion(String serviceName, String user, String note,
- ConfigGroup configGroup);
+ ServiceConfigVersionResponse createServiceConfigVersion(Long serviceId, String user, String note,
+ ConfigGroup configGroup) throws AmbariException;
- String getServiceForConfigTypes(Collection<String> configTypes);
+ Long getServiceForConfigTypes(Collection<String> configTypes);
/**
* Apply specified service config version (rollback)
*
- * @param serviceName service name
+ * @param serviceId service Id
* @param version service config version
* @param user the user making the change for audit purposes
* @param note
* @return service config version created
* @throws AmbariException
*/
- ServiceConfigVersionResponse setServiceConfigVersion(String serviceName, Long version, String user, String note) throws AmbariException;
+ ServiceConfigVersionResponse setServiceConfigVersion(Long serviceId, Long version, String user, String note) throws AmbariException;
/**
* Get currently active service config versions for stack services
@@ -424,10 +427,10 @@ public interface Cluster {
/**
* Get active service config version responses for all config groups of a service
*
- * @param serviceName service name
+ * @param serviceId service ID
* @return
*/
- List<ServiceConfigVersionResponse> getActiveServiceConfigVersionResponse(String serviceName);
+ List<ServiceConfigVersionResponse> getActiveServiceConfigVersionResponse(Long serviceId);
/**
* Get service config version history
@@ -670,18 +673,18 @@ public interface Cluster {
*
* @param stackId the stack to use when finding the latest configurations (not
* {@code null}).
- * @param serviceName the service to modify configurations for (not {@code null}).
+ * @param serviceId the service to modify configurations for (not {@code null}).
*/
- void applyLatestConfigurations(StackId stackId, String serviceName);
+ void applyLatestConfigurations(StackId stackId, Long serviceId);
/**
* Removes all configurations for the specified service and stack.
*
* @param stackId the stack to use when finding the configurations to remove (not
* {@code null}).
- * @param serviceName the service to rmeove configurations for (not {@code null}).
+ * @param serviceId the service to remove configurations for (not {@code null}).
*/
- void removeConfigurations(StackId stackId, String serviceName);
+ void removeConfigurations(StackId stackId, Long serviceId);
/**
* Returns whether this cluster was provisioned by a Blueprint or not.
@@ -717,13 +720,13 @@ public interface Cluster {
boolean isUpgradeSuspended();
/**
- * Returns the name of the service that the passed config type belongs to.
+ * Returns the service that the passed config type belongs to.
*
* @param configType the config type to look up the service by
- * @return returns the name of the service that the config type belongs to if
+ * @return returns the service that the config type belongs to if
* there is any otherwise returns null.
*/
- String getServiceByConfigType(String configType);
+ Service getServiceByConfigType(String configType);
/**
* Gets the most recent value of {@code cluster-env/propertyName} where
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
index d729cb8..8c0e656 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
@@ -1117,7 +1117,7 @@ public class ConfigHelper {
AmbariManagementController controller, Map<String, Map<String, String>> batchProperties,
String authenticatedUserName, String serviceVersionNote) throws AmbariException {
- Map<String, Set<Config>> serviceMapped = new HashMap<>();
+ Map<Long, Set<Config>> serviceMapped = new HashMap<>();
for (Map.Entry<String, Map<String, String>> entry : batchProperties.entrySet()) {
String type = entry.getKey();
@@ -1128,7 +1128,7 @@ public class ConfigHelper {
if (null != baseConfig) {
try {
- String service = cluster.getServiceForConfigTypes(Collections.singleton(type));
+ Long service = cluster.getServiceForConfigTypes(Collections.singleton(type));
if (!serviceMapped.containsKey(service)) {
serviceMapped.put(service, new HashSet<>());
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java b/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
index 4fad21d..9c0d32d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/DesiredConfig.java
@@ -33,7 +33,8 @@ import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
public class DesiredConfig {
private String tag;
- private String serviceName;
+ private Long serviceId;
+ private Long serviceGroupId;
private Long version;
private List<HostOverride> hostOverrides = new ArrayList<>();
@@ -55,21 +56,39 @@ public class DesiredConfig {
}
/**
- * Gets the service name (if any) for the desired config.
- * @return the service name
+ * Gets the service id (if any) for the desired config.
+ * @return the service id
*/
@JsonSerialize(include = Inclusion.NON_NULL)
- @JsonProperty("service_name")
- public String getServiceName() {
- return serviceName;
+ @JsonProperty("service_id")
+ public Long getServiceId() {
+ return serviceId;
}
/**
- * Sets the service name (if any) for the desired config.
- * @param name the service name
+ * Sets the service id (if any) for the desired config.
+ * @param serviceId the service id
*/
- public void setServiceName(String name) {
- serviceName = name;
+ public void setServiceId(Long serviceId) {
+ this.serviceId = serviceId;
+ }
+
+ /**
+ * Gets the service group id (if any) for the desired config.
+ * @return the service group id
+ */
+ @JsonSerialize(include = Inclusion.NON_NULL)
+ @JsonProperty("service_group_id")
+ public Long getServiceGroupId() {
+ return serviceGroupId;
+ }
+
+ /**
+ * Sets the service group id (if any) for the desired config.
+ * @param serviceGroupId the service group id
+ */
+ public void setServiceGroupId(Long serviceGroupId) {
+ this.serviceGroupId = serviceGroupId;
}
/**
@@ -160,8 +179,10 @@ public class DesiredConfig {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("tag=").append(tag);
- if (null != serviceName)
- sb.append(", service=").append(serviceName);
+ if (null != serviceGroupId)
+ sb.append(", serviceGroupId=").append(serviceGroupId);
+ if (null != serviceId)
+ sb.append(", serviceId=").append(serviceId);
if (null != hostOverrides && hostOverrides.size() > 0) {
sb.append(", hosts=[");
int i = 0;
@@ -189,7 +210,8 @@ public class DesiredConfig {
return new EqualsBuilder()
.append(tag, that.tag)
- .append(serviceName, that.serviceName)
+ .append(serviceGroupId, that.serviceGroupId)
+ .append(serviceId, that.serviceId)
.append(version, that.version)
.append(hostOverrides, that.hostOverrides)
.isEquals();
@@ -199,7 +221,8 @@ public class DesiredConfig {
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(tag)
- .append(serviceName)
+ .append(serviceGroupId)
+ .append(serviceId)
.append(version)
.append(hostOverrides)
.toHashCode();
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
index 0321701..bfb04be 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
@@ -512,6 +512,15 @@ public class ServiceImpl implements Service {
return isCredentialStoreRequired;
}
+ @Override
+ public String toString() {
+ return "ServiceImpl{" +
+ "serviceId=" + serviceId +
+ ", serviceName='" + serviceName + '\'' +
+ ", displayName='" + displayName + '\'' +
+ ", serviceType='" + serviceType + '\'' +
+ '}';
+ }
/**
* Get a true or false value specifying whether
@@ -635,7 +644,7 @@ public class ServiceImpl implements Service {
@Transactional
void deleteAllServiceConfigs() throws AmbariException {
long clusterId = getClusterId();
- ServiceConfigEntity lastServiceConfigEntity = serviceConfigDAO.findMaxVersion(clusterId, getName());
+ ServiceConfigEntity lastServiceConfigEntity = serviceConfigDAO.findMaxVersion(clusterId, getServiceId());
// de-select every configuration from the service
if (lastServiceConfigEntity != null) {
for (ClusterConfigEntity serviceConfigEntity : lastServiceConfigEntity.getClusterConfigEntities()) {
@@ -649,7 +658,7 @@ public class ServiceImpl implements Service {
LOG.info("Deleting all configuration associations for {} on cluster {}", getName(), cluster.getClusterName());
List<ServiceConfigEntity> serviceConfigEntities =
- serviceConfigDAO.findByService(cluster.getClusterId(), getName());
+ serviceConfigDAO.findByService(cluster.getClusterId(), getServiceId());
for (ServiceConfigEntity serviceConfigEntity : serviceConfigEntities) {
// Only delete the historical version information and not original
http://git-wip-us.apache.org/repos/asf/ambari/blob/527c4a2d/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
index 510072a..a6c6507 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
@@ -972,7 +972,8 @@ public class UpgradeHelper {
// downgrade is easy - just remove the new and make the old current
if (direction == Direction.DOWNGRADE) {
- cluster.applyLatestConfigurations(targetStackId, serviceName);
+ //TODO pass serviceGroupName
+ cluster.applyLatestConfigurations(targetStackId, cluster.getService(null, serviceName).getServiceId());
continue;
}
@@ -1001,8 +1002,10 @@ public class UpgradeHelper {
// find the current, existing configurations for the service
List<Config> existingServiceConfigs = new ArrayList<>();
+
List<ServiceConfigEntity> latestServiceConfigs = m_serviceConfigDAO.getLastServiceConfigsForService(
- cluster.getClusterId(), serviceName);
+ //TODO pass serviceGroupName
+ cluster.getClusterId(), cluster.getService(null, serviceName).getServiceId());
for (ServiceConfigEntity serviceConfig : latestServiceConfigs) {
List<ClusterConfigEntity> existingConfigurations = serviceConfig.getClusterConfigEntities();