@@ -749,36 +749,46 @@ public CheckRouterTask() {
749749 }
750750
751751 private void updateRoutersRedundantState (List <DomainRouterVO > routers ) {
752+ boolean updated = false ;
752753 for (DomainRouterVO router : routers ) {
754+ updated = false ;
753755 if (!router .getIsRedundantRouter ()) {
754756 continue ;
755757 }
756- String privateIP = router .getPrivateIpAddress ();
757- HostVO host = _hostDao .findById (router .getHostId ());
758- /* Only cover hosts managed by this management server */
759- if (host .getManagementServerId () != ManagementServerNode .getManagementServerId ()) {
760- continue ;
761- }
762- if (privateIP != null ) {
763- final CheckRouterCommand command = new CheckRouterCommand ();
764- command .setAccessDetail (NetworkElementCommand .ROUTER_IP , router .getPrivateIpAddress ());
765- command .setAccessDetail (NetworkElementCommand .ROUTER_NAME , router .getInstanceName ());
766- final CheckRouterAnswer answer = (CheckRouterAnswer ) _agentMgr .easySend (router .getHostId (), command );
767- RedundantState state = RedundantState .UNKNOWN ;
768- if (answer != null && answer .getResult ()) {
769- if (answer .getIsMaster ()) {
770- state = RedundantState .MASTER ;
771- } else {
772- if (answer .getDetails () != null ) {
773- if (answer .getDetails ().equals ("Status: BACKUP" )) {
774- state = RedundantState .BACKUP ;
775- } else if (answer .getDetails ().startsWith ("Status: FAULT" )) {
776- state = RedundantState .FAULT ;
758+ if (router .getState () != State .Running ) {
759+ router .setRedundantState (RedundantState .UNKNOWN );
760+ updated = true ;
761+ } else {
762+ String privateIP = router .getPrivateIpAddress ();
763+ HostVO host = _hostDao .findById (router .getHostId ());
764+ /* Only cover hosts managed by this management server */
765+ if (host .getManagementServerId () != ManagementServerNode .getManagementServerId ()) {
766+ continue ;
767+ }
768+ if (privateIP != null ) {
769+ final CheckRouterCommand command = new CheckRouterCommand ();
770+ command .setAccessDetail (NetworkElementCommand .ROUTER_IP , router .getPrivateIpAddress ());
771+ command .setAccessDetail (NetworkElementCommand .ROUTER_NAME , router .getInstanceName ());
772+ final CheckRouterAnswer answer = (CheckRouterAnswer ) _agentMgr .easySend (router .getHostId (), command );
773+ RedundantState state = RedundantState .UNKNOWN ;
774+ if (answer != null && answer .getResult ()) {
775+ if (answer .getIsMaster ()) {
776+ state = RedundantState .MASTER ;
777+ } else {
778+ if (answer .getDetails () != null ) {
779+ if (answer .getDetails ().equals ("Status: BACKUP" )) {
780+ state = RedundantState .BACKUP ;
781+ } else if (answer .getDetails ().startsWith ("Status: FAULT" )) {
782+ state = RedundantState .FAULT ;
783+ }
777784 }
778785 }
779786 }
787+ router .setRedundantState (state );
788+ updated = true ;
780789 }
781- router .setRedundantState (state );
790+ }
791+ if (updated ) {
782792 Transaction txn = Transaction .open (Transaction .CLOUD_DB );
783793 try {
784794 txn .start ();
0 commit comments