ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [07/17] ambari git commit: AMBARI-18459: Print error messages if bulkcommand section of a component includes non-existing component (dili)
Date Wed, 28 Sep 2016 17:28:00 GMT
AMBARI-18459: Print error messages if bulkcommand section of a component includes non-existing
component (dili)


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

Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 53b4bd41518a5292d3c6c9cdafecee3898d046f3
Parents: 87423d6
Author: Di Li <dili@apache.org>
Authored: Tue Sep 27 10:58:59 2016 -0400
Committer: Di Li <dili@apache.org>
Committed: Tue Sep 27 10:58:59 2016 -0400

----------------------------------------------------------------------
 .../ambari/server/stack/ServiceModule.java      |  4 +--
 .../apache/ambari/server/stack/StackModule.java | 37 ++++++++++++++++++--
 2 files changed, 37 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/53b4bd41/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
b/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
index 650bdf1..34e65c3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/stack/ServiceModule.java
@@ -180,7 +180,7 @@ public class ServiceModule extends BaseModule<ServiceModule, ServiceInfo>
implem
       return;
     }
 
-    LOG.info("Resolve service");
+    LOG.debug("Resolve service");
 
     // If resolving against parent stack service module (stack inheritance), do not merge
if an
     // explicit parent is specified
@@ -193,7 +193,7 @@ public class ServiceModule extends BaseModule<ServiceModule, ServiceInfo>
implem
     if (serviceInfo.getComment() == null) {
       serviceInfo.setComment(parent.getComment());
     }
-    LOG.info("Display name service/parent: " + serviceInfo.getDisplayName() + "/" + parent.getDisplayName());
+    LOG.info(String.format("Display name service/parent: %s/%s", serviceInfo.getDisplayName(),
parent.getDisplayName()));
     if (serviceInfo.getDisplayName() == null) {
       serviceInfo.setDisplayName(parent.getDisplayName());
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/53b4bd41/ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java
index 93eeb7e..d9eaf27 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/stack/StackModule.java
@@ -31,6 +31,8 @@ import java.util.Set;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
+import org.apache.ambari.server.state.BulkCommandDefinition;
+import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.ExtensionInfo;
 import org.apache.ambari.server.state.PropertyDependencyInfo;
@@ -182,7 +184,7 @@ public class StackModule extends BaseModule<StackModule, StackInfo>
implements V
       StackModule parentModule, Map<String, StackModule> allStacks, Map<String,
ServiceModule> commonServices, Map<String, ExtensionModule> extensions)
       throws AmbariException {
     moduleState = ModuleState.VISITED;
-    LOG.info("Resolve: " + stackInfo.getName() + ":" + stackInfo.getVersion());
+    LOG.info(String.format("Resolve: %s:%s", stackInfo.getName(), stackInfo.getVersion()));
     String parentVersion = stackInfo.getParentStackVersion();
     mergeServicesWithExplicitParent(allStacks, commonServices, extensions);
     addExtensionServices();
@@ -204,6 +206,7 @@ public class StackModule extends BaseModule<StackModule, StackInfo>
implements V
     processUpgradePacks();
     processRepositories();
     processPropertyDependencies();
+    validateBulkCommandComponents(allStacks);
     moduleState = ModuleState.RESOLVED;
   }
 
@@ -351,7 +354,7 @@ public class StackModule extends BaseModule<StackModule, StackInfo>
implements V
       Map<String, ServiceModule> commonServices, Map<String, ExtensionModule>
extensions)
       throws AmbariException {
 
-    LOG.info("mergeServiceWithExplicitParent" + parent);
+    LOG.info(String.format("Merge service %s with explicit parent: %s", service.getModuleInfo().getName(),
parent));
     if(isCommonServiceParent(parent)) {
       mergeServiceWithCommonServiceParent(service, parent, allStacks, commonServices, extensions);
     } else if(isExtensionServiceParent(parent)) {
@@ -1198,6 +1201,36 @@ public class StackModule extends BaseModule<StackModule, StackInfo>
implements V
     }
   }
 
+  /**
+   * Validate the component defined in the bulkCommand section is defined for the service
+   * This needs to happen after the stack is resolved
+   * */
+  private void validateBulkCommandComponents(Map<String, StackModule> allStacks){
+    if (null != stackInfo) {
+      String currentStackId = stackInfo.getName() + StackManager.PATH_DELIMITER + stackInfo.getVersion();
+      LOG.debug("Validate bulk command components for: " + currentStackId);
+      StackModule currentStack = allStacks.get(currentStackId);
+      if (null != currentStack){
+        for (ServiceModule serviceModule : currentStack.getServiceModules().values()) {
+          ServiceInfo service = serviceModule.getModuleInfo();
+          for(ComponentInfo component: service.getComponents()){
+            BulkCommandDefinition bcd = component.getBulkCommandDefinition();
+            if (null != bcd && null != bcd.getMasterComponent()){
+              String name = bcd.getMasterComponent();
+              ComponentInfo targetComponent = service.getComponentByName(name);
+              if (null == targetComponent){
+                String serviceName = service.getName();
+                LOG.error(
+                    String.format("%s bulk command section for service %s in stack %s references
a component %s which doesn't exist.",
+                        component.getName(), serviceName, currentStackId, name));
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+
   @Override
   public boolean isValid() {
     return valid;


Mime
View raw message