class AdministrationAgent implements InitializingBean {

    protected void mapAndExecuteVMsMigrations(ClusterVO cluster, ClusterAdministrationHeuristicAlgorithm administrationAlgorithm) {
        List<HostResources> hosts = getClusterUpHosts(cluster);
        long clusterId = cluster.getId();

        if (CollectionUtils.isEmpty(hosts) || hosts.size() == 1) {
            logger.debug(String.format("No hosts or single host on cluster[id=%d], no need to migrate virtual machines.", clusterId));
            return;
        }

        logger.info(String.format("Starting ranking hosts for cluster[id=%d] administration.", clusterId));
        List<HostResources> rankedHosts = administrationAlgorithm.rankHosts(hosts);
        logger.info(String.format("Starting mapping VMs for cluster[id=%d] administration.", clusterId));
        Map<Long, HostResources> migrations = administrationAlgorithm.mapVMsToHost(rankedHosts);
        logger.info(String.format("Starting migrating VMs for cluster[id=%d] administration.", clusterId));

        for (Entry<Long, HostResources> mappedMig : migrations.entrySet()) {
            Long vmId = mappedMig.getKey();
            HostVO targetHost = hostService.findHostById(mappedMig.getValue().getHostId());
            migrateVM(virtualMachineService.searchVmInstanceById(vmId), targetHost);
        }
        logger.info(String.format("Migration of VMs for cluster[id=%d] administration was finished.", clusterId));
    }

}