Prechádzať zdrojové kódy

AMBARI-6245 - Ambari-server log is full of ServiceComponentHostNotFoundException

tbeerbower 11 rokov pred
rodič
commit
33fd0ca179

+ 11 - 7
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java

@@ -857,15 +857,19 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
             r.setMaintenanceState(maintenanceStateHelper.getEffectiveState(sch, host).name());
             response.add(r);
           } catch (ServiceComponentHostNotFoundException e) {
-            if (request.getServiceName() != null && request.getComponentName() != null) {
-              LOG.error("ServiceComponentHost not found ", e);
+            if (request.getServiceName() == null || request.getComponentName() == null) {
+              // Ignore the exception if either the service name or component name are not specified.
+              // This is an artifact of how we get host_components and can happen in the case where
+              // we get all host_components for a host, for example.
+              LOG.debug("Ignoring not specified host_component ", e);
+
+            } else {
+              // Otherwise rethrow the exception and let the caller decide if it's an error condition.
+              // Logging the exception as debug since this does not necessarily indicate an error
+              // condition.
+              LOG.debug("ServiceComponentHost not found ", e);
               throw new ServiceComponentHostNotFoundException(cluster.getClusterName(),
                   request.getServiceName(), request.getComponentName(), request.getHostname());
-            } else {
-              LOG.debug("Ignoring not specified host_component ", e);
-              // ignore this since host_component was not specified
-              // this is an artifact of how we get host_components and can happen
-              // in case where we get all host_components for a host
             }
           }
         } else {

+ 2 - 2
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterControllerImpl.java

@@ -142,8 +142,8 @@ public class ClusterControllerImpl implements ClusterController {
                                          Request request,
                                          Predicate predicate) throws SystemException {
     Set<Resource> keepers = resources;
-
-    for (PropertyProvider propertyProvider : propertyProviders.get(type)) {
+    List<PropertyProvider> propertyProviders = ensurePropertyProviders(type);
+    for (PropertyProvider propertyProvider : propertyProviders) {
       if (providesRequestProperties(propertyProvider, request, predicate)) {
         keepers = propertyProvider.populateResources(keepers, request, predicate);
       }