Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2143C200D53 for ; Mon, 30 Oct 2017 20:04:44 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 1FA97160C06; Mon, 30 Oct 2017 19:04:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B61B0160BFD for ; Mon, 30 Oct 2017 20:04:42 +0100 (CET) Received: (qmail 66830 invoked by uid 500); 30 Oct 2017 19:04:41 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 66461 invoked by uid 99); 30 Oct 2017 19:04:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Oct 2017 19:04:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 56380E0885; Mon, 30 Oct 2017 19:04:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mradhakrishnan@apache.org To: commits@ambari.apache.org Date: Mon, 30 Oct 2017 19:04:41 -0000 Message-Id: In-Reply-To: <653b5043ff8f4865939773ba579749a2@git.apache.org> References: <653b5043ff8f4865939773ba579749a2@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [05/30] ambari git commit: AMBARI-22181 : Remove cluster-stackid dependency related to Configs (mradhakrishnan) archived-at: Mon, 30 Oct 2017 19:04:44 -0000 AMBARI-22181 : Remove cluster-stackid dependency related to Configs (mradhakrishnan) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b0ff5da4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b0ff5da4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b0ff5da4 Branch: refs/heads/branch-feature-AMBARI-14714-ui Commit: b0ff5da4606ae194390c20491a6d8b779c898820 Parents: a5d0f0c Author: Madhuvanthi Radhakrishnan Authored: Fri Oct 13 09:33:33 2017 -0700 Committer: Madhuvanthi Radhakrishnan Committed: Fri Oct 13 09:33:33 2017 -0700 ---------------------------------------------------------------------- .../server/checks/AbstractCheckDescriptor.java | 8 +-- .../AmbariCustomCommandExecutionHelper.java | 2 +- .../AmbariManagementControllerImpl.java | 21 +++--- .../controller/DeleteIdentityHandler.java | 4 +- .../ambari/server/state/ConfigHelper.java | 72 +++++++++++--------- .../ambari/server/state/ConfigMergeHelper.java | 4 +- .../ambari/server/state/UpgradeHelper.java | 17 +++-- .../server/state/cluster/ClusterImpl.java | 7 +- 8 files changed, 75 insertions(+), 60 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java index 6726d30..ae23897 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java @@ -35,7 +35,7 @@ import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.Clusters; import org.apache.ambari.server.state.Config; import org.apache.ambari.server.state.DesiredConfig; -import org.apache.ambari.server.state.ServiceInfo; +import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.repository.ClusterVersionSummary; import org.apache.ambari.server.state.repository.VersionDefinitionXml; import org.apache.ambari.server.state.stack.PrereqCheckStatus; @@ -238,14 +238,12 @@ public abstract class AbstractCheckDescriptor { AmbariMetaInfo metaInfo = ambariMetaInfo.get(); Cluster c = clusters.getCluster(request.getClusterName()); - Map services = metaInfo.getServices( - c.getDesiredStackVersion().getStackName(), - c.getDesiredStackVersion().getStackVersion()); + Map services = c.getServices(); LinkedHashSet displays = new LinkedHashSet<>(); for (String name : names) { if (services.containsKey(name)) { - displays.add(services.get(name).getDisplayName()); + displays.add(services.get(name).getName()); } else { displays.add(name); } http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java index e12477e..ff35e80 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java @@ -1544,7 +1544,7 @@ public class AmbariCustomCommandExecutionHelper { } if (stackId == null) { - stackId = cluster.getDesiredStackVersion(); + throw new AmbariException("StackId should not be null. Service " + serviceName + " should have a desiredStackId"); } AmbariMetaInfo ambariMetaInfo = managementController.getAmbariMetaInfo(); http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java index 28b5c28..58f1cbd 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java @@ -2401,7 +2401,11 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle HostEntity hostEntity = host.getHostEntity(); Map hostAttributes = gson.fromJson(hostEntity.getHostAttributes(), hostAttributesType); String osFamily = host.getOSFamilyFromHostAttributes(hostAttributes); - + Map services = cluster.getServices(); + Map servicesMap = new HashMap<>(); + for(String clusterServiceName : services.keySet() ){ + servicesMap.put(clusterServiceName, ambariMetaInfo.getService(services.get(clusterServiceName))); + } StackId stackId = scHost.getServiceComponent().getDesiredStackId(); ServiceInfo serviceInfo = ambariMetaInfo.getService(stackId.getStackName(), @@ -2411,7 +2415,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle serviceName, componentName); StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion()); - Map servicesMap = ambariMetaInfo.getServices(stackInfo.getName(), stackInfo.getVersion()); ExecutionCommandWrapper execCmdWrapper = stage.getExecutionCommandWrapper(hostname, componentName); ExecutionCommand execCmd = execCmdWrapper.getExecutionCommand(); @@ -2445,12 +2448,14 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle // Propagate HCFS service type info for (Service service : cluster.getServices().values()) { ServiceInfo serviceInfoInstance = servicesMap.get(service.getName()); - LOG.debug("Iterating service type Instance in createHostAction: {}", serviceInfoInstance.getName()); - String serviceType = serviceInfoInstance.getServiceType(); - if (serviceType != null) { - LOG.info("Adding service type info in createHostAction: {}", serviceType); - commandParams.put("dfs_type", serviceType); - break; + if(serviceInfoInstance != null){ + LOG.debug("Iterating service type Instance in createHostAction: {}", serviceInfoInstance.getName()); + String serviceType = serviceInfoInstance.getServiceType(); + if (serviceType != null) { + LOG.info("Adding service type info in createHostAction: {}", serviceType); + commandParams.put("dfs_type", serviceType); + break; + } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java index 29f8e2a..f5d51c3 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/DeleteIdentityHandler.java @@ -47,6 +47,7 @@ import org.apache.ambari.server.serveraction.kerberos.KerberosOperationHandler; import org.apache.ambari.server.serveraction.kerberos.KerberosServerAction; import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.Config; +import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.StackId; import org.apache.ambari.server.state.kerberos.KerberosDescriptor; import org.apache.ambari.server.state.svccomphost.ServiceComponentHostServerActionEvent; @@ -263,7 +264,8 @@ class DeleteIdentityHandler { private Set configTypesOfService(String serviceName) { try { - StackId stackId = getCluster().getCurrentStackVersion(); + Service service = getCluster().getService(serviceName); + StackId stackId = service.getDesiredStackId(); StackServiceRequest stackServiceRequest = new StackServiceRequest(stackId.getStackName(), stackId.getStackVersion(), serviceName); return AmbariServer.getController().getStackServices(singleton(stackServiceRequest)).stream() .findFirst() http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java index 58b0300..e89f3dc 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java @@ -684,24 +684,26 @@ public class ConfigHelper { } for (Service service : cluster.getServices().values()) { - Set serviceProperties = new HashSet<>(servicesMap.get(service.getName()).getProperties()); - for (PropertyInfo serviceProperty : serviceProperties) { - if (serviceProperty.getPropertyTypes().contains(propertyType)) { - String stackPropertyConfigType = fileNameToConfigType(serviceProperty.getFilename()); - try { - String property = actualConfigs.get(stackPropertyConfigType).getProperties().get(serviceProperty.getName()); - if (null == property){ - LOG.error(String.format("Unable to obtain property values for %s with property attribute %s. " - + "The property does not exist in version %s of %s configuration.", - serviceProperty.getName(), - propertyType, - desiredConfigs.get(stackPropertyConfigType), - stackPropertyConfigType - )); - } else { - result.put(serviceProperty, property); + if (servicesMap.containsKey(service.getName())) { + Set serviceProperties = new HashSet<>(servicesMap.get(service.getName()).getProperties()); + for (PropertyInfo serviceProperty : serviceProperties) { + if (serviceProperty.getPropertyTypes().contains(propertyType)) { + String stackPropertyConfigType = fileNameToConfigType(serviceProperty.getFilename()); + try { + String property = actualConfigs.get(stackPropertyConfigType).getProperties().get(serviceProperty.getName()); + if (null == property) { + LOG.error(String.format("Unable to obtain property values for %s with property attribute %s. " + + "The property does not exist in version %s of %s configuration.", + serviceProperty.getName(), + propertyType, + desiredConfigs.get(stackPropertyConfigType), + stackPropertyConfigType + )); + } else { + result.put(serviceProperty, property); + } + } catch (Exception ignored) { } - } catch (Exception ignored) { } } } @@ -763,24 +765,26 @@ public class ConfigHelper { } for (Service service : cluster.getServices().values()) { - Set serviceProperties = new HashSet<>(servicesMap.get(service.getName()).getProperties()); - for (PropertyInfo serviceProperty : serviceProperties) { - if (serviceProperty.getPropertyTypes().contains(propertyType)) { - String stackPropertyConfigType = fileNameToConfigType(serviceProperty.getFilename()); - try { - String property = actualConfigs.get(stackPropertyConfigType).getProperties().get(serviceProperty.getName()); - if (null == property){ - LOG.error(String.format("Unable to obtain property values for %s with property attribute %s. " - + "The property does not exist in version %s of %s configuration.", - serviceProperty.getName(), - propertyType, - desiredConfigs.get(stackPropertyConfigType), - stackPropertyConfigType - )); - } else { - result.add(property); + if (servicesMap.containsKey(service.getName())) { + Set serviceProperties = new HashSet<>(servicesMap.get(service.getName()).getProperties()); + for (PropertyInfo serviceProperty : serviceProperties) { + if (serviceProperty.getPropertyTypes().contains(propertyType)) { + String stackPropertyConfigType = fileNameToConfigType(serviceProperty.getFilename()); + try { + String property = actualConfigs.get(stackPropertyConfigType).getProperties().get(serviceProperty.getName()); + if (null == property) { + LOG.error(String.format("Unable to obtain property values for %s with property attribute %s. " + + "The property does not exist in version %s of %s configuration.", + serviceProperty.getName(), + propertyType, + desiredConfigs.get(stackPropertyConfigType), + stackPropertyConfigType + )); + } else { + result.add(property); + } + } catch (Exception ignored) { } - } catch (Exception ignored) { } } } http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigMergeHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigMergeHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigMergeHelper.java index cf55660..36918cc 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigMergeHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigMergeHelper.java @@ -53,13 +53,15 @@ public class ConfigMergeHelper { @SuppressWarnings("unchecked") public Map> getConflicts(String clusterName, StackId targetStack) throws AmbariException { Cluster cluster = m_clusters.get().getCluster(clusterName); - StackId oldStack = cluster.getCurrentStackVersion(); + StackId oldStack = null; Map> oldMap = new HashMap<>(); Map> newMap = new HashMap<>(); // Collect service-level properties for old and new stack for (String serviceName : cluster.getServices().keySet()) { + Service service = cluster.getService(serviceName); + oldStack = service.getDesiredStackId(); Set oldStackProperties = m_ambariMetaInfo.get().getServiceProperties( oldStack.getStackName(), oldStack.getStackVersion(), serviceName); addToMap(oldMap, oldStackProperties); http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java index 8f9d8e1..ebc82ee 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java @@ -219,8 +219,6 @@ public class UpgradeHelper { * {@code Direction} of the upgrade * @param upgradeType * The {@code UpgradeType} - * @param targetStackName - * The destination target stack name. * @param preferredUpgradePackName * For unit test, need to prefer an upgrade pack since multiple * matches can be found. @@ -805,18 +803,19 @@ public class UpgradeHelper { /** * Helper to set service and component display names on the context * @param context the context to update - * @param service the service name + * @param serviceName the service name * @param component the component name */ - private void setDisplayNames(UpgradeContext context, String service, String component) { - StackId stackId = context.getCluster().getDesiredStackVersion(); + private void setDisplayNames(UpgradeContext context, String serviceName, String component) { + Cluster c = context.getCluster(); + try { - ServiceInfo serviceInfo = m_ambariMetaInfoProvider.get().getService(stackId.getStackName(), - stackId.getStackVersion(), service); - context.setServiceDisplay(service, serviceInfo.getDisplayName()); + Service service = c.getService(serviceName); + ServiceInfo serviceInfo = m_ambariMetaInfoProvider.get().getService(service); + context.setServiceDisplay(serviceName, serviceInfo.getDisplayName()); ComponentInfo compInfo = serviceInfo.getComponentByName(component); - context.setComponentDisplay(service, component, compInfo.getDisplayName()); + context.setComponentDisplay(serviceName, component, compInfo.getDisplayName()); } catch (AmbariException e) { LOG.debug("Could not get service detail", e); http://git-wip-us.apache.org/repos/asf/ambari/blob/b0ff5da4/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java index 3bde889..fcc07b6 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java @@ -97,6 +97,7 @@ import org.apache.ambari.server.orm.entities.RepositoryVersionEntity; import org.apache.ambari.server.orm.entities.RequestScheduleEntity; import org.apache.ambari.server.orm.entities.ResourceEntity; import org.apache.ambari.server.orm.entities.ServiceConfigEntity; +import org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity; import org.apache.ambari.server.orm.entities.ServiceGroupEntity; import org.apache.ambari.server.orm.entities.StackEntity; import org.apache.ambari.server.orm.entities.TopologyRequestEntity; @@ -431,13 +432,17 @@ public class ClusterImpl implements Cluster { } for (ClusterServiceEntity serviceEntity : clusterEntity.getClusterServiceEntities()) { - StackId stackId = getCurrentStackVersion(); + ServiceDesiredStateEntity serviceDesiredStateEntity = serviceEntity.getServiceDesiredStateEntity(); + StackEntity stackEntity = serviceDesiredStateEntity.getDesiredStack(); + StackId stackId = new StackId(stackEntity); try { if (ambariMetaInfo.getService(stackId.getStackName(), stackId.getStackVersion(), serviceEntity.getServiceName()) != null) { services.put(serviceEntity.getServiceName(), serviceFactory.createExisting(this, getServiceGroup(serviceEntity.getServiceGroupId()), serviceEntity)); + stackId = getService(serviceEntity.getServiceName()).getDesiredStackId(); } + } catch (AmbariException e) { LOG.error(String.format( "Can not get service info: stackName=%s, stackVersion=%s, serviceName=%s",