You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ad...@apache.org on 2018/05/17 15:59:45 UTC

[ambari] branch trunk updated: AMBARI-23838. Ambari Server NPE due to Agent failure during registration (#1285)

This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new d9bfcac  AMBARI-23838. Ambari Server NPE due to Agent failure during registration (#1285)
d9bfcac is described below

commit d9bfcac2c53fc44ffb9a45c5ea29c592153ad069
Author: kasakrisz <33...@users.noreply.github.com>
AuthorDate: Thu May 17 17:59:42 2018 +0200

    AMBARI-23838. Ambari Server NPE due to Agent failure during registration (#1285)
---
 .../java/org/apache/ambari/server/state/host/HostImpl.java | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
index 94a0dc0..cb7af46 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
@@ -22,6 +22,7 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -1254,16 +1255,21 @@ public class HostImpl implements Host {
       String status = scHost.getState().name();
 
       String category = componentInfo.getCategory();
+      if (category == null) {
+        LOG.warn("In stack {}-{} service {} component {} category is null!",
+                stackId.getStackName(), stackId.getStackVersion(), scHost.getServiceName(), scHost.getServiceComponentName());
+        continue;
+      }
 
       if (MaintenanceState.OFF == maintenanceStateHelper.getEffectiveState(scHost, this)) {
-        if (category.equals("MASTER")) {
+        if (Objects.equals("MASTER", category)) {
           ++masterCount;
-          if (status.equals("STARTED")) {
+          if (Objects.equals("STARTED", status)) {
             ++mastersRunning;
           }
-        } else if (category.equals("SLAVE")) {
+        } else if (Objects.equals("SLAVE", category)) {
           ++slaveCount;
-          if (status.equals("STARTED")) {
+          if (Objects.equals("STARTED", status)) {
             ++slavesRunning;
           }
         }

-- 
To stop receiving notification emails like this one, please contact
adoroszlai@apache.org.