You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2014/10/12 11:05:18 UTC

[2/2] git commit: AMBARI-7729. Ambari throws Runtime exception for unrecognized components in DB. (aonishuk)

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/989a7e36
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/989a7e36
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/989a7e36

Branch: refs/heads/branch-1.7.0
Commit: 989a7e361b4603d18352b0f72b3a44cec6539006
Parents: c351867
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Sun Oct 12 12:05:07 2014 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Sun Oct 12 12:05:07 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/989a7e36/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/989a7e36/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 36aa65f..6279c2b 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
@@ -42,6 +42,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;
@@ -121,9 +122,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();
+          }
       }
     }