class ClusterResourcesService {

    public ClusterResourcesUp createClusterResourcesUp(long clusterId, String clusterName, List<HostResources> hostsResources) {
        long clusterUsedCpu = 0, clusterCpuSpeed = 0, clusterMemory = 0, clusterUsedMemory = 0;
        int clusterCpus = 0;
        for (HostResources currentHost : hostsResources) {
            clusterMemory += currentHost.getTotalMemoryInBytes() * currentHost.getMemoryOverprovisioning();
            clusterUsedMemory += currentHost.getUsedMemoryInMegaBytes();
            clusterUsedCpu += currentHost.getUsedCpu();
            clusterCpuSpeed += currentHost.getSpeed() * currentHost.getCpuOverprovisioning();
            clusterCpus += currentHost.getCpus();
        }

        ClusterResourcesUp clusterResourcesUp = new ClusterResourcesUp(clusterId, clusterName, clusterCpuSpeed, clusterUsedCpu, clusterCpus, clusterMemory, clusterUsedMemory,
                hostsResources);

        return clusterResourcesUp;
    }

}