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. Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/60f130c5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/60f130c5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/60f130c5 Branch: refs/heads/master Commit: 60f130c5097c87bb4aa40d15c0b6fb1b4057fefd Parents: 61a19eb Author: Prachi Damle <[email protected]> Authored: Thu Sep 6 16:00:58 2012 -0700 Committer: Prachi Damle <[email protected]> Committed: Thu Sep 6 16:31:00 2012 -0700 ---------------------------------------------------------------------- .../com/cloud/resource/ResourceManagerImpl.java | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/60f130c5/server/src/com/cloud/resource/ResourceManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index 988f438..ced601b 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*/ } }
