ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adorosz...@apache.org
Subject [19/50] [abbrv] ambari git commit: AMBARI-22244. Use service type instead of service name - addendum (adoroszlai)
Date Wed, 06 Dec 2017 10:10:17 GMT
AMBARI-22244. Use service type instead of service name - addendum (adoroszlai)


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

Branch: refs/heads/branch-feature-AMBARI-14714-blueprintv2
Commit: 6fcfa7474d2f2e2f78daa30576575e93d575d13d
Parents: b163e24
Author: Attila Doroszlai <adoroszlai@hortonworks.com>
Authored: Thu Nov 16 19:00:42 2017 +0100
Committer: Doroszlai, Attila <adoroszlai@hortonworks.com>
Committed: Tue Dec 5 23:55:56 2017 +0100

----------------------------------------------------------------------
 .../checks/ServiceCheckValidityCheck.java       |  7 ++++---
 .../internal/ServiceResourceProvider.java       |  9 ++++----
 .../serveraction/upgrades/ConfigureAction.java  |  5 +++--
 .../ambari/server/state/ConfigHelper.java       | 14 ++++++-------
 .../ambari/server/state/ConfigMergeHelper.java  |  4 ++--
 .../ambari/server/state/UpgradeHelper.java      | 22 ++++++++++----------
 6 files changed, 31 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6fcfa747/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 2582c71..1126424 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
@@ -101,11 +101,12 @@ public class ServiceCheckValidityCheck extends AbstractCheckDescriptor
{
         continue;
       }
       StackId stackId = service.getDesiredStackId();
-      boolean isServiceWitNoConfigs = ambariMetaInfo.get().isServiceWithNoConfigs(stackId.getStackName(),
stackId.getStackVersion(), service.getName());
+      String serviceType = service.getServiceType();
+      boolean isServiceWitNoConfigs = ambariMetaInfo.get().isServiceWithNoConfigs(stackId.getStackName(),
stackId.getStackVersion(), serviceType);
       if (isServiceWitNoConfigs){
-        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()));
+        LOG.info("{} in {} version {} does not have customizable configurations. Skip checking
service configuration history.", serviceType, 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()));
+        LOG.info("{} in {} version {} has customizable configurations. Check service configuration
history.", serviceType, stackId.getStackName(), stackId.getStackVersion());
         ServiceConfigEntity lastServiceConfig = serviceConfigDAO.getLastServiceConfig(clusterId,
service.getServiceId());
         lastServiceConfigUpdates.put(service.getName(), lastServiceConfig.getCreateTimestamp());
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fcfa747/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
index 38e1233..1aadf3a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
@@ -281,8 +281,7 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
       setResourceProperty(resource, SERVICE_SERVICE_TYPE_PROPERTY_ID,
         response.getServiceType(), requestedIds);
       setResourceProperty(resource, SERVICE_SERVICE_STATE_PROPERTY_ID,
-          calculateServiceState(response.getClusterName(), response.getServiceName()),
-          requestedIds);
+          calculateServiceState(response.getClusterName(), response.getServiceType(), response.getServiceName()),
requestedIds);
       setResourceProperty(resource, SERVICE_MAINTENANCE_STATE_PROPERTY_ID,
           response.getMaintenanceState(), requestedIds);
       setResourceProperty(resource, SERVICE_CREDENTIAL_STORE_SUPPORTED_PROPERTY_ID,
@@ -1009,9 +1008,9 @@ public class ServiceResourceProvider extends AbstractControllerResourceProvider
   }
 
   // calculate the service state, accounting for the state of the host components
-  private String calculateServiceState(String clusterName, String serviceName) {
-    ServiceCalculatedState serviceCalculatedState = ServiceCalculatedStateFactory.getServiceStateProvider(serviceName);
-    return serviceCalculatedState.getState(clusterName, serviceName).toString();
+  private State calculateServiceState(String clusterName, String serviceType, String serviceName)
{
+    ServiceCalculatedState serviceCalculatedState = ServiceCalculatedStateFactory.getServiceStateProvider(serviceType);
+    return serviceCalculatedState.getState(clusterName, serviceName);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fcfa747/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 6bb248e..1639e40 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
@@ -43,6 +43,7 @@ import org.apache.ambari.server.state.ConfigMergeHelper;
 import org.apache.ambari.server.state.ConfigMergeHelper.ThreeWayValue;
 import org.apache.ambari.server.state.DesiredConfig;
 import org.apache.ambari.server.state.PropertyInfo;
+import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.UpgradeContext;
 import org.apache.ambari.server.state.stack.upgrade.ConfigUpgradeChangeDefinition.ConfigurationKeyValue;
@@ -596,9 +597,9 @@ public class ConfigureAction extends AbstractUpgradeServerAction {
     // has the correct config type (ie oozie-site or hdfs-site) then add it to
     // the list of original stack propertiess
     Set<String> stackPropertiesForType = new HashSet<>(50);
-    for (String serviceName : cluster.getServices().keySet()) {
+    for (Service service : cluster.getServices().values()) {
       Set<PropertyInfo> serviceProperties = m_ambariMetaInfo.get().getServiceProperties(
-          oldStack.getStackName(), oldStack.getStackVersion(), serviceName);
+          oldStack.getStackName(), oldStack.getStackVersion(), service.getServiceType());
 
       for (PropertyInfo property : serviceProperties) {
         String type = ConfigHelper.fileNameToConfigType(property.getFilename());

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fcfa747/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 4008c21..d794389 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
@@ -512,7 +512,7 @@ public class ConfigHelper {
     Set<String> result = new HashSet<>();
 
     for (Service service : clusters.getCluster(clusterName).getServices().values()) {
-      Set<PropertyInfo> stackProperties = ambariMetaInfo.getServiceProperties(stack.getName(),
stack.getVersion(), service.getName());
+      Set<PropertyInfo> stackProperties = ambariMetaInfo.getServiceProperties(stack.getName(),
stack.getVersion(), service.getServiceType());
       Set<PropertyInfo> stackLevelProperties = ambariMetaInfo.getStackProperties(stack.getName(),
stack.getVersion());
       stackProperties.addAll(stackLevelProperties);
 
@@ -543,7 +543,7 @@ public class ConfigHelper {
     StackInfo stack = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion());
     Map<String, Map<String, String>> result = new HashMap<>();
     Map<String, String> passwordProperties;
-    Set<PropertyInfo> serviceProperties = ambariMetaInfo.getServiceProperties(stack.getName(),
stack.getVersion(), service.getName());
+    Set<PropertyInfo> serviceProperties = ambariMetaInfo.getServiceProperties(stack.getName(),
stack.getVersion(), service.getServiceType());
     for (PropertyInfo serviceProperty : serviceProperties) {
       if (serviceProperty.getPropertyTypes().contains(propertyType)) {
         if (!serviceProperty.getPropertyValueAttributes().isKeyStore()) {
@@ -846,7 +846,7 @@ public class ConfigHelper {
           stackId.getStackVersion());
 
       for (ServiceInfo serviceInfo : stack.getServices()) {
-        Set<PropertyInfo> serviceProperties = ambariMetaInfo.getServiceProperties(stack.getName(),
stack.getVersion(), serviceInfo.getName());
+        Set<PropertyInfo> serviceProperties = ambariMetaInfo.getServiceProperties(stack.getName(),
stack.getVersion(), serviceInfo.getServiceType());
         Set<PropertyInfo> stackProperties = ambariMetaInfo.getStackProperties(stack.getName(),
stack.getVersion());
         serviceProperties.addAll(stackProperties);
 
@@ -922,7 +922,7 @@ public class ConfigHelper {
       StackInfo stack = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion());
 
       for (ServiceInfo serviceInfo : stack.getServices()) {
-        Set<PropertyInfo> serviceProperties = ambariMetaInfo.getServiceProperties(stack.getName(),
stack.getVersion(), serviceInfo.getName());
+        Set<PropertyInfo> serviceProperties = ambariMetaInfo.getServiceProperties(stack.getName(),
stack.getVersion(), serviceInfo.getServiceType());
 
         for (PropertyInfo stackProperty : serviceProperties) {
           String stackPropertyConfigType = fileNameToConfigType(stackProperty.getFilename());
@@ -1237,13 +1237,13 @@ public class ConfigHelper {
    *
    * @param stack
    *          the stack to pull stack-values from (not {@code null})
-   * @param serviceName
+   * @param stackServiceName
    *          the service name {@code null}).
    * @return a mapping of configuration type to map of key/value pairs for the
    *         default configurations.
    * @throws AmbariException
    */
-  public Map<String, Map<String, String>> getDefaultProperties(StackId stack,
String serviceName)
+  public Map<String, Map<String, String>> getDefaultProperties(StackId stack,
String stackServiceName)
       throws AmbariException {
     Map<String, Map<String, String>> defaultPropertiesByType = new HashMap<>();
 
@@ -1264,7 +1264,7 @@ public class ConfigHelper {
 
     // for every installed service, populate the default service properties
     Set<org.apache.ambari.server.state.PropertyInfo> serviceConfigurationProperties
= ambariMetaInfo.getServiceProperties(
-        stack.getStackName(), stack.getStackVersion(), serviceName);
+        stack.getStackName(), stack.getStackVersion(), stackServiceName);
 
     // !!! use new stack as the basis
     for (PropertyInfo serviceDefaultProperty : serviceConfigurationProperties) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fcfa747/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 36918cc..9bede20 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
@@ -63,11 +63,11 @@ public class ConfigMergeHelper {
       Service service = cluster.getService(serviceName);
       oldStack = service.getDesiredStackId();
       Set<PropertyInfo> oldStackProperties = m_ambariMetaInfo.get().getServiceProperties(
-          oldStack.getStackName(), oldStack.getStackVersion(), serviceName);
+          oldStack.getStackName(), oldStack.getStackVersion(), service.getServiceType());
       addToMap(oldMap, oldStackProperties);
 
       Set<PropertyInfo> newStackProperties = m_ambariMetaInfo.get().getServiceProperties(
-          targetStack.getStackName(), targetStack.getStackVersion(), serviceName);
+          targetStack.getStackName(), targetStack.getStackVersion(), service.getServiceType());
       addToMap(newMap, newStackProperties);
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/6fcfa747/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 a6c6507..1a4c27c 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
@@ -971,28 +971,29 @@ public class UpgradeHelper {
       ConfigHelper configHelper = m_configHelperProvider.get();
 
       // downgrade is easy - just remove the new and make the old current
+      Service service = cluster.getService(null, serviceName);
       if (direction == Direction.DOWNGRADE) {
         //TODO pass serviceGroupName
-        cluster.applyLatestConfigurations(targetStackId, cluster.getService(null, serviceName).getServiceId());
+        cluster.applyLatestConfigurations(targetStackId, service.getServiceId());
         continue;
       }
 
       // the auto-merge must take read-only properties even if they have changed
       // - if the properties was read-only in the source stack, then we must
       // take the new stack's value
-      Map<String, Set<String>> readOnlyProperties = getReadOnlyProperties(sourceStackId,
serviceName);
+      Map<String, Set<String>> readOnlyProperties = getReadOnlyProperties(sourceStackId,
service.getServiceType());
 
       // upgrade is a bit harder - we have to merge new stack configurations in
 
       // populate a map of default configurations for the service on the old
       // stack (this is used when determining if a property has been
-      // customized and should be overriden with the new stack value)
+      // customized and should be overridden with the new stack value)
       Map<String, Map<String, String>> oldServiceDefaultConfigsByType = configHelper.getDefaultProperties(
-          sourceStackId, serviceName);
+          sourceStackId, service.getServiceType());
 
       // populate a map with default configurations from the new stack
       Map<String, Map<String, String>> newServiceDefaultConfigsByType = configHelper.getDefaultProperties(
-          targetStackId, serviceName);
+          targetStackId, service.getServiceType());
 
       if (null == oldServiceDefaultConfigsByType || null == newServiceDefaultConfigsByType)
{
         continue;
@@ -1005,7 +1006,7 @@ public class UpgradeHelper {
 
       List<ServiceConfigEntity> latestServiceConfigs = m_serviceConfigDAO.getLastServiceConfigsForService(
           //TODO pass serviceGroupName
-          cluster.getClusterId(), cluster.getService(null, serviceName).getServiceId());
+          cluster.getClusterId(), service.getServiceId());
 
       for (ServiceConfigEntity serviceConfig : latestServiceConfigs) {
         List<ClusterConfigEntity> existingConfigurations = serviceConfig.getClusterConfigEntities();
@@ -1161,13 +1162,12 @@ public class UpgradeHelper {
    *
    * @param stackId
    *          the stack to get read-only properties for (not {@code null}).
-   * @param serviceName
-   *          the namee of the service (not {@code null}).
+   * @param stackServiceName
+   *          the name of the service (not {@code null}).
    * @return a map of configuration type to set of property names which are
    *         read-only
-   * @throws AmbariException
    */
-  private Map<String, Set<String>> getReadOnlyProperties(StackId stackId, String
serviceName)
+  private Map<String, Set<String>> getReadOnlyProperties(StackId stackId, String
stackServiceName)
       throws AmbariException {
     Map<String, Set<String>> readOnlyProperties = new HashMap<>();
 
@@ -1177,7 +1177,7 @@ public class UpgradeHelper {
         stackId.getStackName(), stackId.getStackVersion());
 
     Set<PropertyInfo> serviceProperties = m_ambariMetaInfoProvider.get().getServiceProperties(
-        stackId.getStackName(), stackId.getStackVersion(), serviceName);
+        stackId.getStackName(), stackId.getStackVersion(), stackServiceName);
 
     if (CollectionUtils.isNotEmpty(stackProperties)) {
       properties.addAll(stackProperties);


Mime
View raw message