@@ -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 );
@@ -158,32 +170,42 @@ private org.apache.cloudstack.agent.lb.IndirectAgentLBAlgorithm getAgentMSLBAlgo
158170 public void propagateMSListToAgents () {
159171 logger .debug ("Propagating management server list update to agents" );
160172 final String lbAlgorithm = getLBAlgorithmName ();
173+ final Long globalLbCheckInterval = getLBPreferredHostCheckInterval (null );
161174 List <DataCenterVO > zones = dataCenterDao .listAll ();
162175 for (DataCenterVO zone : zones ) {
163176 List <Long > zoneHostIds = new ArrayList <>();
177+ List <Long > nonRoutingHostIds = getAllAgentBasedNonRoutingHostsFromDB (zone .getId ());
178+ zoneHostIds .addAll (nonRoutingHostIds );
164179 Map <Long , List <Long >> clusterHostIdsMap = new HashMap <>();
165180 List <Long > clusterIds = clusterDao .listAllClusterIds (zone .getId ());
166181 for (Long clusterId : clusterIds ) {
167- List <Long > hostIds = getAllAgentBasedHostsFromDB (zone .getId (), clusterId );
182+ List <Long > hostIds = getAllAgentBasedRoutingHostsFromDB (zone .getId (), clusterId );
168183 clusterHostIdsMap .put (clusterId , hostIds );
169184 zoneHostIds .addAll (hostIds );
170185 }
171186 zoneHostIds .sort (Comparator .comparingLong (x -> x ));
187+ for (Long nonRoutingHostId : nonRoutingHostIds ) {
188+ setupMSList (nonRoutingHostId , zone .getId (), zoneHostIds , lbAlgorithm , globalLbCheckInterval );
189+ }
172190 for (Long clusterId : clusterIds ) {
173- final Long lbCheckInterval = getLBPreferredHostCheckInterval (clusterId );
191+ final Long clusterLbCheckInterval = 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 , lbAlgorithm , clusterLbCheckInterval );
182195 }
183196 }
184197 }
185198 }
186199
200+ private void setupMSList (final Long hostId , final Long dcId , final List <Long > orderedHostIdList , final String lbAlgorithm , final Long lbCheckInterval ) {
201+ final List <String > msList = getManagementServerList (hostId , dcId , orderedHostIdList );
202+ final SetupMSListCommand cmd = new SetupMSListCommand (msList , lbAlgorithm , lbCheckInterval );
203+ final Answer answer = agentManager .easySend (hostId , cmd );
204+ if (answer == null || !answer .getResult ()) {
205+ logger .warn (String .format ("Failed to setup management servers list to the agent of ID: %d" , hostId ));
206+ }
207+ }
208+
187209 private void configureAlgorithmMap () {
188210 final List <org .apache .cloudstack .agent .lb .IndirectAgentLBAlgorithm > algorithms = new ArrayList <>();
189211 algorithms .add (new IndirectAgentLBStaticAlgorithm ());
0 commit comments