Skip to content

Commit 4ac8861

Browse files
committed
Merge branch '4.19' of https://github.com/apache/cloudstack into 4.20
2 parents d1df418 + d32065f commit 4ac8861

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

framework/cluster/src/main/java/com/cloud/cluster/ClusterManagerImpl.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,12 +1101,24 @@ public boolean stop() {
11011101
}
11021102

11031103
if (_mshostId != null) {
1104-
final ManagementServerHostVO mshost = _mshostDao.findByMsid(_msId);
1105-
final ManagementServerStatusVO mshostStatus = mshostStatusDao.findByMsId(mshost.getUuid());
1106-
mshost.setState(ManagementServerHost.State.Down);
1107-
mshostStatus.setLastJvmStop(new Date());
1108-
_mshostDao.update(_mshostId, mshost);
1109-
mshostStatusDao.update(mshostStatus.getId(), mshostStatus);
1104+
ManagementServerHostVO mshost = _mshostDao.findByMsid(_msId);
1105+
if (mshost != null) {
1106+
ManagementServerStatusVO mshostStatus = mshostStatusDao.findByMsId(mshost.getUuid());
1107+
if (mshostStatus != null) {
1108+
mshost.setState(ManagementServerHost.State.Down);
1109+
mshostStatus.setLastJvmStop(new Date());
1110+
_mshostDao.update(_mshostId, mshost);
1111+
mshostStatusDao.update(mshostStatus.getId(), mshostStatus);
1112+
} else {
1113+
s_logger.warn(String.format("Found a management server host [%s] without a status. This should never happen!", mshost));
1114+
mshostStatus = new ManagementServerStatusVO();
1115+
mshostStatus.setMsId(mshost.getUuid());
1116+
mshostStatus.setLastSystemBoot(new Date());
1117+
mshostStatus.setLastJvmStart(new Date());
1118+
mshostStatus.setUpdated(new Date());
1119+
mshostStatusDao.persist(mshostStatus);
1120+
}
1121+
}
11101122
}
11111123

11121124
_heartbeatScheduler.shutdownNow();

0 commit comments

Comments
 (0)