@@ -74,6 +74,8 @@ public class IndirectAgentLBServiceImpl extends ComponentLifecycleBase implement
7474 ResourceState .ErrorInMaintenance , ResourceState .PrepareForMaintenance );
7575 private static final List <Host .Type > agentValidHostTypes = List .of (Host .Type .Routing , Host .Type .ConsoleProxy ,
7676 Host .Type .SecondaryStorage , Host .Type .SecondaryStorageVM );
77+ private static final List <Host .Type > agentNonRoutingHostTypes = List .of (Host .Type .ConsoleProxy ,
78+ Host .Type .SecondaryStorage , Host .Type .SecondaryStorageVM );
7779 private static final List <Hypervisor .HypervisorType > agentValidHypervisorTypes = List .of (
7880 Hypervisor .HypervisorType .KVM , Hypervisor .HypervisorType .LXC );
7981
@@ -136,6 +138,16 @@ List<Long> getOrderedHostIdList(final Long dcId) {
136138 return hostIdList ;
137139 }
138140
141+ private List <Long > getAllAgentBasedNonRoutingHostsFromDB (final Long zoneId ) {
142+ return hostDao .findHostIdsByZoneClusterResourceStateTypeAndHypervisorType (zoneId , null ,
143+ agentValidResourceStates , agentNonRoutingHostTypes , agentValidHypervisorTypes );
144+ }
145+
146+ private List <Long > getAllAgentBasedRoutingHostsFromDB (final Long zoneId , final Long clusterId ) {
147+ return hostDao .findHostIdsByZoneClusterResourceStateTypeAndHypervisorType (zoneId , clusterId ,
148+ agentValidResourceStates , List .of (Host .Type .Routing ), agentValidHypervisorTypes );
149+ }
150+
139151 private List <Long > getAllAgentBasedHostsFromDB (final Long zoneId , final Long clusterId ) {
140152 return hostDao .findHostIdsByZoneClusterResourceStateTypeAndHypervisorType (zoneId , clusterId ,
141153 agentValidResourceStates , agentValidHostTypes , agentValidHypervisorTypes );
@@ -161,29 +173,40 @@ public void propagateMSListToAgents() {
161173 List <DataCenterVO > zones = dataCenterDao .listAll ();
162174 for (DataCenterVO zone : zones ) {
163175 List <Long > zoneHostIds = new ArrayList <>();
176+ List <Long > nonRoutingHostIds = getAllAgentBasedNonRoutingHostsFromDB (zone .getId ());
177+ zoneHostIds .addAll (nonRoutingHostIds );
164178 Map <Long , List <Long >> clusterHostIdsMap = new HashMap <>();
165179 List <Long > clusterIds = clusterDao .listAllClusterIds (zone .getId ());
166180 for (Long clusterId : clusterIds ) {
167- List <Long > hostIds = getAllAgentBasedHostsFromDB (zone .getId (), clusterId );
181+ List <Long > hostIds = getAllAgentBasedRoutingHostsFromDB (zone .getId (), clusterId );
168182 clusterHostIdsMap .put (clusterId , hostIds );
169183 zoneHostIds .addAll (hostIds );
170184 }
171185 zoneHostIds .sort (Comparator .comparingLong (x -> x ));
186+ Long lbCheckInterval = getLBPreferredHostCheckInterval (null );
187+ for (Long nonRoutingHostId : nonRoutingHostIds ) {
188+ setupMSList (nonRoutingHostId , zone .getId (), zoneHostIds , lbCheckInterval );
189+ }
172190 for (Long clusterId : clusterIds ) {
173- final Long lbCheckInterval = getLBPreferredHostCheckInterval (clusterId );
191+ lbCheckInterval = getLBPreferredHostCheckInterval (clusterId );
174192 List <Long > hostIds = clusterHostIdsMap .get (clusterId );
175193 for (Long hostId : hostIds ) {
176- final List <String > msList = getManagementServerList (hostId , zone .getId (), zoneHostIds );
177- final SetupMSListCommand cmd = new SetupMSListCommand (msList , lbAlgorithm , lbCheckInterval );
178- final Answer answer = agentManager .easySend (hostId , cmd );
179- if (answer == null || !answer .getResult ()) {
180- logger .warn ("Failed to setup management servers list to the agent of ID: {}" , hostId );
181- }
194+ setupMSList (hostId , zone .getId (), zoneHostIds , lbCheckInterval );
182195 }
183196 }
184197 }
185198 }
186199
200+ private void setupMSList (final Long hostId , final Long dcId , final List <Long > orderedHostIdList , final Long lbCheckInterval ) {
201+ final List <String > msList = getManagementServerList (hostId , dcId , orderedHostIdList );
202+ final String lbAlgorithm = getLBAlgorithmName ();
203+ final SetupMSListCommand cmd = new SetupMSListCommand (msList , lbAlgorithm , lbCheckInterval );
204+ final Answer answer = agentManager .easySend (hostId , cmd );
205+ if (answer == null || !answer .getResult ()) {
206+ logger .warn (String .format ("Failed to setup management servers list to the agent of ID: %d" , hostId ));
207+ }
208+ }
209+
187210 private void configureAlgorithmMap () {
188211 final List <org .apache .cloudstack .agent .lb .IndirectAgentLBAlgorithm > algorithms = new ArrayList <>();
189212 algorithms .add (new IndirectAgentLBStaticAlgorithm ());
0 commit comments