package cloudsimulator.clustersimulator;

import cloudsimulator.clustersimulator.dto.Cluster;
import cloudsimulator.clustersimulator.dto.TCGroup;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.File;
import java.io.IOException;

/**
 * Implements operations on the Cluster.
 */
public class ClusterManager {

    private static final long RPS_FOR_VM = 100;
    private Cluster cluster;

    /**
     * Read Cluster configuration date from Json file.
     */
    public ClusterManager() {
        ClassLoader classLoader = getClass().getClassLoader();
        String path = classLoader.getResource("clusterConfiguration.json").getFile();

        ObjectMapper mapper = new ObjectMapper();

        try {
            cluster = mapper.readValue(new File(path), Cluster.class);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * Return the Cluster used by the ClusterManager.
     *
     * @return Cluster used by the ClusterManager.
     */
    public Cluster getCluster() {
        return cluster;
    }

    /**
     * Compute the maximum RPS supported by the Cluster managed by the ClusterManager.
     *
     * @return maximum number of request that can be fulfilled by the Cluster in one second.
     */
    public long computeMaxRps() {
        return cluster.getCluster()
                .stream()
                .mapToLong(TCGroup::getVmNumber)
                .sum() * RPS_FOR_VM;
    }

}

@@ -190,16 +190,117 @@
 tMapper;
+%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.stereotype.Component;
 %0A%0Aimport
@@ -392,16 +392,27 @@
 er.%0A */%0A
+@Component%0A
 public c
@@ -434,16 +434,16 @@
 ager %7B%0A%0A
-
     priv
@@ -480,16 +480,17 @@
 VM = 100
+0
 ;%0A    pr

Define ClusterManager as a Spring Component.