KNOX-1319 - Better logging when discovery fails to access service configurations
authorPhil Zampino <pzampino@apache.org>
Thu, 17 May 2018 15:07:48 +0000 (11:07 -0400)
committerPhil Zampino <pzampino@apache.org>
Thu, 17 May 2018 15:07:48 +0000 (11:07 -0400)
gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscovery.java
gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscoveryMessages.java
gateway-discovery-ambari/src/main/java/org/apache/knox/gateway/topology/discovery/ambari/PropertyEqualsHandler.java

index 4deb25f..821dc0e 100644 (file)
@@ -293,9 +293,12 @@ class AmbariServiceDiscovery implements ServiceDiscovery {
             // Service configurations
             Map<String, Map<String, AmbariCluster.ServiceConfiguration>> serviceConfigurations =
                 ambariClient.getActiveServiceConfigurations(discoveryAddress,
-                    clusterName,
-                    discoveryUser,
-                    discoveryPwdAlias);
+                                                            clusterName,
+                                                            discoveryUser,
+                                                            discoveryPwdAlias);
+            if (serviceConfigurations.isEmpty()) {
+                log.failedToAccessServiceConfigs(clusterName);
+            }
             for (Entry<String, Map<String, AmbariCluster.ServiceConfiguration>> serviceConfiguration : serviceConfigurations.entrySet()) {
                 for (Map.Entry<String, AmbariCluster.ServiceConfiguration> serviceConfig : serviceConfiguration.getValue().entrySet()) {
                     cluster.addServiceConfiguration(serviceConfiguration.getKey(), serviceConfig.getKey(), serviceConfig.getValue());
index 5cc764c..036d7a7 100644 (file)
@@ -58,20 +58,21 @@ public interface AmbariServiceDiscoveryMessages {
                                                          @StackTrace(level = MessageLevel.ERROR) Exception e);
 
     @Message(level = MessageLevel.ERROR,
-             text = "Encountered an error during cluster {0} discovery: {1}")
+             text = "Encountered an error during cluster ({0}) discovery: {1}")
     void clusterDiscoveryError(final String clusterName, @StackTrace(level = MessageLevel.DEBUG) Exception e);
 
+    @Message(level = MessageLevel.ERROR,
+        text = "Failed to access the service configurations for cluster ({0}) discovery")
+    void failedToAccessServiceConfigs(final String clusterName);
 
     @Message(level = MessageLevel.ERROR,
              text = "REST invocation {0} timed out")
     void restInvocationTimedOut(final String url, @StackTrace(level = MessageLevel.DEBUG) Exception e);
 
-
     @Message(level = MessageLevel.DEBUG,
              text = "REST invocation {0} failed: {1}")
     void restInvocationError(final String url, @StackTrace(level = MessageLevel.DEBUG) Exception e);
 
-
     @Message(level = MessageLevel.ERROR,
             text = "No address for Ambari service discovery has been configured.")
     void missingDiscoveryAddress();
index 6b81356..1a92cfd 100644 (file)
@@ -65,7 +65,7 @@ class PropertyEqualsHandler implements ConditionalValueHandler {
             }
 
             if (result == null) {
-                if (propertyValue.equals(value)) {
+                if (propertyValue != null && propertyValue.equals(value)) {
                     result = affirmativeResult.evaluate(config, cluster);
                 } else if (negativeResult != null) {
                     result = negativeResult.evaluate(config, cluster);