From e1b3f0cf871a59bb9799f6a4f81b1df972dfd423 Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Thu, 6 Sep 2012 16:00:58 -0700 Subject: [PATCH] CS-16258: Load Test - 1 host stuck in "Rebalancing" state forever. "java.lang.NullPointerException" seen in "Cluster-Worker" thread that was handling this process. - Using temp to not affect the return value for the method. --- .../com/cloud/resource/ResourceManagerImpl.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index 988f4382cb3..ced601b179b 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -1639,19 +1639,21 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma if (cmds != null) { resource.disconnected(); } - if(host == null){ + //In case of some db errors, we may land with the sitaution that host is null. We need to reload host from db and call disconnect on it so that it will be loaded for reconnection next time + HostVO tempHost = host; + if(tempHost == null){ if (cmds != null) { StartupCommand firstCmd = cmds[0]; - host = findHostByGuid(firstCmd.getGuid()); - if (host == null) { - host = findHostByGuid(firstCmd.getGuidWithoutResource()); + tempHost = findHostByGuid(firstCmd.getGuid()); + if (tempHost == null) { + tempHost = findHostByGuid(firstCmd.getGuidWithoutResource()); } } } - if (host != null) { + if (tempHost != null) { /* Change agent status to Alert */ - _agentMgr.agentStatusTransitTo(host, Status.Event.AgentDisconnected, _nodeId); + _agentMgr.agentStatusTransitTo(tempHost, Status.Event.AgentDisconnected, _nodeId); /* Don't change resource state here since HostVO is already in database, which means resource state has had an appropriate value*/ } }