Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1080,18 +1080,23 @@ private AgentAttache handleConnectedAgent(final Link link, final StartupCommand[
ReadyCommand ready = null;
try {
final List<String> agentMSHostList = new ArrayList<>();
String lbAlgorithm = null;
if (startup != null && startup.length > 0) {
final String agentMSHosts = startup[0].getMsHostList();
if (!Strings.isNullOrEmpty(agentMSHosts)) {
agentMSHostList.addAll(Arrays.asList(agentMSHosts.split(",")));
String[] msHosts = agentMSHosts.split("@");
if (msHosts.length > 1) {
lbAlgorithm = msHosts[1];
}
agentMSHostList.addAll(Arrays.asList(msHosts[0].split(",")));
}
}

final HostVO host = _resourceMgr.createHostVOForConnectedAgent(startup);
if (host != null) {
ready = new ReadyCommand(host.getDataCenterId(), host.getId());

if (!indirectAgentLB.compareManagementServerList(host.getId(), host.getDataCenterId(), agentMSHostList)) {
if (!indirectAgentLB.compareManagementServerList(host.getId(), host.getDataCenterId(), agentMSHostList, lbAlgorithm)) {
final List<String> newMSList = indirectAgentLB.getManagementServerList(host.getId(), host.getDataCenterId(), null);
ready.setMsHostList(newMSList);
ready.setLbAlgorithm(indirectAgentLB.getLBAlgorithmName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface IndirectAgentLB {
* @param receivedMSHosts received management server list
* @return true if mgmtHosts is up to date, false if not
*/
boolean compareManagementServerList(Long hostId, Long dcId, List<String> receivedMSHosts);
boolean compareManagementServerList(Long hostId, Long dcId, List<String> receivedMSHosts, String lbAlgorithm);

/**
* Returns the configure LB algorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ public List<String> getManagementServerList(final Long hostId, final Long dcId,
}

@Override
public boolean compareManagementServerList(final Long hostId, final Long dcId, final List<String> receivedMSHosts) {
public boolean compareManagementServerList(final Long hostId, final Long dcId, final List<String> receivedMSHosts, final String lbAlgorithm) {
if (receivedMSHosts == null || receivedMSHosts.size() < 1) {
return false;
}
if (getLBAlgorithmName() != lbAlgorithm) {
return false;
}
final List<String> expectedMSList = getManagementServerList(hostId, dcId, null);
final org.apache.cloudstack.agent.lb.IndirectAgentLBAlgorithm algorithm = getAgentMSLBAlgorithm();
return algorithm.compare(expectedMSList, receivedMSHosts);
Expand Down