use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class HostedEngineHAClusterWeightPolicyUnit method score.
@Override
public List<Pair<Guid, Integer>> score(Cluster cluster, List<VDS> hosts, VM vm, Map<String, String> parameters) {
List<Pair<Guid, Integer>> scores = new ArrayList<>();
boolean isHostedEngine = vm.isHostedEngine();
if (isHostedEngine) {
// If the max HA score is higher than the max weight, then we normalize. Otherwise the ratio is 1, keeping the value as is
float ratio = MAXIMUM_HA_SCORE > MaxSchedulerWeight ? ((float) MaxSchedulerWeight / MAXIMUM_HA_SCORE) : 1;
for (VDS host : hosts) {
scores.add(new Pair<>(host.getId(), MaxSchedulerWeight - Math.round(host.getHighlyAvailableScore() * ratio)));
}
} else {
fillDefaultScores(hosts, scores);
}
return scores;
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class VmAffinityWeightPolicyUnit method score.
@Override
public List<Pair<Guid, Integer>> score(Cluster cluster, List<VDS> hosts, VM vm, Map<String, String> parameters) {
Map<Guid, Integer> acceptableHosts = getAcceptableHostsWithPriorities(false, hosts, vm, new PerHostMessages());
int maxNonmigratableVms = acceptableHosts.values().stream().reduce(0, Integer::max);
List<Pair<Guid, Integer>> retList = new ArrayList<>();
for (VDS host : hosts) {
int score = acceptableHosts.containsKey(host.getId()) ? DEFAULT_SCORE + maxNonmigratableVms - acceptableHosts.get(host.getId()) : MaxSchedulerWeight;
retList.add(new Pair<>(host.getId(), score));
}
return retList;
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class VmToHostAffinityWeightPolicyUnit method score.
@Override
public List<Pair<Guid, Integer>> score(Cluster cluster, List<VDS> hosts, VM vm, Map<String, String> parameters) {
Map<Guid, Integer> hostViolations = getHostViolationCount(false, hosts, vm, new PerHostMessages());
List<Pair<Guid, Integer>> retList = new ArrayList<>();
int score;
for (VDS host : hosts) {
score = hostViolations.containsKey(host.getId()) ? hostViolations.get(host.getId()) : DEFAULT_SCORE;
retList.add(new Pair<>(host.getId(), score));
}
return retList;
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class UpdateVmDiskCommandTest method mockGetVmsListForDisk.
private void mockGetVmsListForDisk(VM vm) {
VmDevice device = createVmDevice(diskImageGuid, vm.getId());
when(vmDao.getVmsWithPlugInfo(diskImageGuid)).thenReturn(Collections.singletonList(new Pair<>(vm, device)));
}
use of org.ovirt.engine.core.common.utils.Pair in project ovirt-engine by oVirt.
the class AbstractGetStorageDomainsWithAttachedStoragePoolGuidQueryTestCase method testEmptyStorageDomainListQuery.
@Test
public void testEmptyStorageDomainListQuery() {
StoragePool storagePool = new StoragePool();
storagePool.setStatus(StoragePoolStatus.Up);
mockStoragePoolDao(storagePool);
// Create parameters
List<StorageDomain> storageDomainList = new ArrayList<>();
StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
when(paramsMock.getStorageDomainList()).thenReturn(storageDomainList);
// Run 'HSMGetStorageDomainInfo' command
VDSReturnValue returnValue = new VDSReturnValue();
returnValue.setSucceeded(true);
Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), Guid.newGuid());
returnValue.setReturnValue(storageDomainToPoolId);
when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
// Execute command
getQuery().executeQueryCommand();
// Assert the query's results
List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
Aggregations