package cloud.cluster.sim.clustersimulator;

import cloud.cluster.sim.clustersimulator.dto.Chance;
import cloud.cluster.sim.clustersimulator.dto.MicroDataCenter;
import cloud.cluster.sim.clustersimulator.dto.Vm;

import java.util.List;

public class FailureChanceComputer {

    public double failAtTheSameTime(ClusterManager clusterManager, MicroDataCenter mDC) {

        // compute chance for the cluster
        double chanceFailAtTheSameTime = clusterManager.getCluster().getVms().stream()
                .mapToDouble(clusterVm ->
                        new FailureChance().compute(clusterVm.getMicroDataCenter().getSla()).getChance())
                .reduce(1, (a,b) -> a * b );

        // add the new VM that might be added to the cluster
        chanceFailAtTheSameTime *= new FailureChance().compute(mDC.getSla()).getChance();

        return chanceFailAtTheSameTime;
    }
}

@@ -88,152 +88,25 @@
 dto.
-Chance;%0Aimport cloud.cluster.sim.clustersimulator.dto.MicroDataCenter;%0Aimport cloud.cluster.sim.clustersimulator.dto.Vm;%0A%0Aimport java.util.List;
+MicroDataCenter;%0A
 %0A%0Apu

Remove unused imports.