Skip to content

Commit

Permalink
Refactoring Allocator classes
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanMLima committed May 10, 2024
1 parent 21af134 commit 1ff8f4a
Show file tree
Hide file tree
Showing 4 changed files with 294 additions and 252 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
*/
List<String> listOrderedHostsHypervisorVersionsInDatacenter(long datacenterId, HypervisorType hypervisorType);

List<HostVO> findHostsWithTagRuleThatMatchComputeOferringTags(String computeOfferingTags);
List<HostVO> findHostsWithTagRuleThatMatchComputeOfferingTags(String computeOfferingTags);

List<Long> findClustersThatMatchHostTagRule(String computeOfferingTags);
}
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ private List<Long> findHostByComputeOfferings(String computeOfferingTags){
}
}

public List<HostVO> findHostsWithTagRuleThatMatchComputeOferringTags(String computeOfferingTags) {
public List<HostVO> findHostsWithTagRuleThatMatchComputeOfferingTags(String computeOfferingTags) {

Check warning on line 1352 in engine/schema/src/main/java/com/cloud/host/dao/HostDaoImpl.java

View check run for this annotation

Codecov / codecov/patch

engine/schema/src/main/java/com/cloud/host/dao/HostDaoImpl.java#L1352

Added line #L1352 was not covered by tests
List<HostTagVO> hostTagVOList = _hostTagsDao.findHostRuleTags();
List<HostVO> result = new ArrayList<>();
for (HostTagVO rule: hostTagVOList) {
Expand All @@ -1363,7 +1363,7 @@ public List<HostVO> findHostsWithTagRuleThatMatchComputeOferringTags(String comp

public List<Long> findClustersThatMatchHostTagRule(String computeOfferingTags) {
Set<Long> result = new HashSet<>();
List<HostVO> hosts = findHostsWithTagRuleThatMatchComputeOferringTags(computeOfferingTags);
List<HostVO> hosts = findHostsWithTagRuleThatMatchComputeOfferingTags(computeOfferingTags);

Check warning on line 1366 in engine/schema/src/main/java/com/cloud/host/dao/HostDaoImpl.java

View check run for this annotation

Codecov / codecov/patch

engine/schema/src/main/java/com/cloud/host/dao/HostDaoImpl.java#L1366

Added line #L1366 was not covered by tests
for (HostVO host: hosts) {
result.add(host.getClusterId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private List<Host> findSuitableHosts(VirtualMachineProfile vmProfile, Deployment
hostsCopy = _hostDao.listAllHostsThatHaveNoRuleTag(type, clusterId, podId, dcId);
}
}
hostsCopy = ListUtils.union(hostsCopy, _hostDao.findHostsWithTagRuleThatMatchComputeOferringTags(offeringHostTag));
hostsCopy = ListUtils.union(hostsCopy, _hostDao.findHostsWithTagRuleThatMatchComputeOfferingTags(hostTag));

Check warning on line 124 in plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java

View check run for this annotation

Codecov / codecov/patch

plugins/host-allocators/random/src/main/java/com/cloud/agent/manager/allocator/impl/RandomAllocator.java#L124

Added line #L124 was not covered by tests

if (hostsCopy.isEmpty()) {
logger.error(String.format("No suitable host found for vm [%s] with tags [%s].", vmProfile, hostTag));
Expand Down
Loading

0 comments on commit 1ff8f4a

Please sign in to comment.