ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject [1/2] git commit: AMBARI-7729. Ambari throws Runtime exception for unrecognized components in DB. (aonishuk)
Date Sun, 12 Oct 2014 09:05:17 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 c35186726 -> 989a7e361
  refs/heads/trunk c826bcf06 -> 183ab7a80


AMBARI-7729. Ambari throws Runtime exception for unrecognized components in DB. (aonishuk)


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

Branch: refs/heads/trunk
Commit: 183ab7a801b2425bd9db57491e8809de0b7dcd71
Parents: c826bcf
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Sun Oct 12 12:05:05 2014 +0300
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Sun Oct 12 12:05:05 2014 +0300

----------------------------------------------------------------------
 .../ambari/server/state/ServiceComponentImpl.java    |  2 +-
 .../org/apache/ambari/server/state/ServiceImpl.java  | 15 ++++++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/183ab7a8/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
index 2661282..45ea1f9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
@@ -134,7 +134,7 @@ public class ServiceComponentImpl implements ServiceComponent {
         stackId.getStackName(), stackId.getStackVersion(), service.getName(),
         getName());
     if (compInfo == null) {
-      throw new RuntimeException("Trying to create a ServiceComponent"
+      throw new AmbariException("Trying to create a ServiceComponent"
           + " not recognized in stack info"
           + ", clusterName=" + service.getCluster().getClusterName()
           + ", serviceName=" + service.getName()

http://git-wip-us.apache.org/repos/asf/ambari/blob/183ab7a8/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 d7880c4..bb5057f 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
@@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
 import com.google.gson.Gson;
 import com.google.inject.Inject;
 import com.google.inject.Injector;
+import com.google.inject.ProvisionException;
 import com.google.inject.assistedinject.Assisted;
 import com.google.inject.assistedinject.AssistedInject;
 import com.google.inject.persist.Transactional;
@@ -129,9 +130,17 @@ public class ServiceImpl implements Service {
     if (!serviceEntity.getServiceComponentDesiredStateEntities().isEmpty()) {
       for (ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity
           : serviceEntity.getServiceComponentDesiredStateEntities()) {
-        components.put(serviceComponentDesiredStateEntity.getComponentName(),
-            serviceComponentFactory.createExisting(this,
-                serviceComponentDesiredStateEntity));
+        try {
+            components.put(serviceComponentDesiredStateEntity.getComponentName(),
+                serviceComponentFactory.createExisting(this,
+                    serviceComponentDesiredStateEntity));
+          } catch(ProvisionException ex) {
+            StackId stackId = cluster.getCurrentStackVersion();
+            LOG.error(String.format("Can not get component info: stackName=%s, stackVersion=%s,
serviceName=%s, componentName=%s",
+                stackId.getStackName(), stackId.getStackVersion(),
+                serviceEntity.getServiceName(),serviceComponentDesiredStateEntity.getComponentName()));
+            ex.printStackTrace();
+          }
       }
     }
 


Mime
View raw message