class ConsolidationXenHaPreferenceForBigHostsHomogeneousEnvironment extends ConsolidationScoredPreferenceForBigHosts {

    @Override
    public Map<Long, HostResources> mapVMsToHost(List<HostResources> rankedHosts) {
        Map<Long, HostResources> vmsToHost = new HashMap<>();
        if (rankedHosts.size() > 3) {
            for (int i = rankedHosts.size() - 1; i > 2; i--) {
                for (VmResources vmResources : rankedHosts.get(i).getVmsResources()) {
                    for (HostResources hostCandidateToStayRunning : rankedHosts) {
                        if (canMigrateVmToHost(vmResources, hostCandidateToStayRunning)) {
                            vmsToHost.put(vmResources.getVmId(), hostCandidateToStayRunning);
                            updateHostUsedResources(vmResources, hostCandidateToStayRunning);
                            break;
                        }
                    }
                }
            }
            return vmsToHost;
        }
        vmsDispersionHomogeneousHosts.rankHosts(rankedHosts);
        return vmsDispersionHomogeneousHosts.mapVMsToHost(rankedHosts);
    }

}