@@ -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