@@ -953,46 +953,49 @@ public boolean updateState(Status oldStatus, Event event, Status newStatus, Host
953953 int result = update (ub , sc , null );
954954 assert result <= 1 : "How can this update " + result + " rows? " ;
955955
956- if (status_logger . isDebugEnabled () && result == 0 ) {
956+ if (result == 0 ) {
957957 HostVO ho = findById (host .getId ());
958958 assert ho != null : "How how how? : " + host .getId ();
959959
960- StringBuilder str = new StringBuilder ("Unable to update host for event:" ).append (event .toString ());
961- str .append (". Name=" ).append (host .getName ());
962- str .append ("; New=[status=" )
963- .append (newStatus .toString ())
964- .append (":msid=" )
965- .append (newStatus .lostConnection () ? "null" : host .getManagementServerId ())
966- .append (":lastpinged=" )
967- .append (host .getLastPinged ())
968- .append ("]" );
969- str .append ("; Old=[status=" )
970- .append (oldStatus .toString ())
971- .append (":msid=" )
972- .append (host .getManagementServerId ())
973- .append (":lastpinged=" )
974- .append (oldPingTime )
975- .append ("]" );
976- str .append ("; DB=[status=" )
977- .append (vo .getStatus ().toString ())
978- .append (":msid=" )
979- .append (vo .getManagementServerId ())
980- .append (":lastpinged=" )
981- .append (vo .getLastPinged ())
982- .append (":old update count=" )
983- .append (oldUpdateCount )
984- .append ("]" );
985- status_logger .debug (str .toString ());
986- } else {
987- StringBuilder msg = new StringBuilder ("Agent status update: [" );
988- msg .append ("id = " + host .getId ());
989- msg .append ("; name = " + host .getName ());
990- msg .append ("; old status = " + oldStatus );
991- msg .append ("; event = " + event );
992- msg .append ("; new status = " + newStatus );
993- msg .append ("; old update count = " + oldUpdateCount );
994- msg .append ("; new update count = " + newUpdateCount + "]" );
995- status_logger .debug (msg .toString ());
960+ if (status_logger .isDebugEnabled ()) {
961+
962+ StringBuilder str = new StringBuilder ("Unable to update host for event:" ).append (event .toString ());
963+ str .append (". Name=" ).append (host .getName ());
964+ str .append ("; New=[status=" )
965+ .append (newStatus .toString ())
966+ .append (":msid=" )
967+ .append (newStatus .lostConnection () ? "null" : host .getManagementServerId ())
968+ .append (":lastpinged=" )
969+ .append (host .getLastPinged ())
970+ .append ("]" );
971+ str .append ("; Old=[status=" ).append (oldStatus .toString ()).append (":msid=" ).append (host .getManagementServerId ()).append (":lastpinged=" ).append (oldPingTime )
972+ .append ("]" );
973+ str .append ("; DB=[status=" )
974+ .append (vo .getStatus ().toString ())
975+ .append (":msid=" )
976+ .append (vo .getManagementServerId ())
977+ .append (":lastpinged=" )
978+ .append (vo .getLastPinged ())
979+ .append (":old update count=" )
980+ .append (oldUpdateCount )
981+ .append ("]" );
982+ status_logger .debug (str .toString ());
983+ } else {
984+ StringBuilder msg = new StringBuilder ("Agent status update: [" );
985+ msg .append ("id = " + host .getId ());
986+ msg .append ("; name = " + host .getName ());
987+ msg .append ("; old status = " + oldStatus );
988+ msg .append ("; event = " + event );
989+ msg .append ("; new status = " + newStatus );
990+ msg .append ("; old update count = " + oldUpdateCount );
991+ msg .append ("; new update count = " + newUpdateCount + "]" );
992+ status_logger .debug (msg .toString ());
993+ }
994+
995+ if (ho .getState () == newStatus ) {
996+ status_logger .debug ("Host " + ho .getName () + " state has already been updated to " + newStatus );
997+ return true ;
998+ }
996999 }
9971000
9981001 return result > 0 ;
0 commit comments