@@ -120,10 +120,11 @@ public class HighAvailabilityManagerImpl implements HighAvailabilityManager, Clu
120120 @ Inject
121121 ClusterDetailsDao _clusterDetailsDao ;
122122 long _serverId ;
123- @ com .cloud .utils .component .Inject (adapter = Investigator .class )
124- Adapters <Investigator > _investigators ;
125- @ com .cloud .utils .component .Inject (adapter = FenceBuilder .class )
126- Adapters <FenceBuilder > _fenceBuilders ;
123+
124+ @ Inject
125+ List <Investigator > _investigators ;
126+ @ Inject
127+ List <FenceBuilder > _fenceBuilders ;
127128 @ Inject
128129 AgentManager _agentMgr ;
129130 @ Inject
@@ -164,11 +165,8 @@ public Status investigate(final long hostId) {
164165 return null ;
165166 }
166167
167- final Enumeration <Investigator > en = _investigators .enumeration ();
168168 Status hostState = null ;
169- Investigator investigator = null ;
170- while (en .hasMoreElements ()) {
171- investigator = en .nextElement ();
169+ for (Investigator investigator : _investigators ) {
172170 hostState = investigator .isAgentAlive (host );
173171 if (hostState != null ) {
174172 if (s_logger .isDebugEnabled ()) {
@@ -419,29 +417,28 @@ protected Long restart(HaWorkVO work) {
419417 return null ;
420418 }
421419
422- Enumeration <Investigator > en = _investigators .enumeration ();
423420 Investigator investigator = null ;
424- while ( en . hasMoreElements () ) {
425- investigator = en . nextElement () ;
421+ for ( Investigator it : _investigators ) {
422+ investigator = it ;
426423 alive = investigator .isVmAlive (vm , host );
427424 s_logger .info (investigator .getName () + " found " + vm + "to be alive? " + alive );
428425 if (alive != null ) {
429426 break ;
430427 }
431428 }
429+
432430 boolean fenced = false ;
433431 if (alive == null ) {
434432 s_logger .debug ("Fencing off VM that we don't know the state of" );
435- Enumeration <FenceBuilder > enfb = _fenceBuilders .enumeration ();
436- while (enfb .hasMoreElements ()) {
437- FenceBuilder fb = enfb .nextElement ();
433+ for (FenceBuilder fb : _fenceBuilders ) {
438434 Boolean result = fb .fenceOff (vm , host );
439435 s_logger .info ("Fencer " + fb .getName () + " returned " + result );
440436 if (result != null && result ) {
441437 fenced = true ;
442438 break ;
443439 }
444440 }
441+
445442 } else if (!alive ) {
446443 fenced = true ;
447444 } else {
@@ -697,9 +694,6 @@ public boolean configure(final String name, final Map<String, Object> xmlParams)
697694
698695 _serverId = ((ManagementServer ) ComponentLocator .getComponent (ManagementServer .Name )).getId ();
699696
700- _investigators = locator .getAdapters (Investigator .class );
701- _fenceBuilders = locator .getAdapters (FenceBuilder .class );
702-
703697 Map <String , String > params = new HashMap <String , String >();
704698 final ConfigurationDao configDao = locator .getDao (ConfigurationDao .class );
705699 if (configDao != null ) {
0 commit comments