mirror of https://github.com/apache/cloudstack.git
improve agentlb sort when host list not needed
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
a1ee64344d
commit
e1a5bd9ef2
|
|
@ -42,4 +42,8 @@ public interface IndirectAgentLBAlgorithm {
|
|||
* @return true if the lists are equal, false if not
|
||||
*/
|
||||
boolean compare(final List<String> msList, final List<String> receivedMsList);
|
||||
|
||||
default boolean isHostListNeeded() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,9 +86,10 @@ public class IndirectAgentLBServiceImpl extends ComponentLifecycleBase implement
|
|||
return msList;
|
||||
}
|
||||
|
||||
final org.apache.cloudstack.agent.lb.IndirectAgentLBAlgorithm algorithm = getAgentMSLBAlgorithm();
|
||||
List<Long> hostIdList = orderedHostIdList;
|
||||
if (hostIdList == null) {
|
||||
hostIdList = getOrderedHostIdList(dcId);
|
||||
hostIdList = algorithm.isHostListNeeded() ? getOrderedHostIdList(dcId) : new ArrayList<>();
|
||||
}
|
||||
|
||||
// just in case we have a host in creating state make sure it is in the list:
|
||||
|
|
@ -98,8 +99,6 @@ public class IndirectAgentLBServiceImpl extends ComponentLifecycleBase implement
|
|||
}
|
||||
hostIdList.add(hostId);
|
||||
}
|
||||
|
||||
final org.apache.cloudstack.agent.lb.IndirectAgentLBAlgorithm algorithm = getAgentMSLBAlgorithm();
|
||||
return algorithm.sort(msList, hostIdList, hostId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,4 +56,9 @@ public class IndirectAgentLBRoundRobinAlgorithm implements IndirectAgentLBAlgori
|
|||
public boolean compare(final List<String> msList, final List<String> receivedMsList) {
|
||||
return msList != null && receivedMsList != null && msList.equals(receivedMsList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHostListNeeded() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue