cloudsimplus/cloudsimplus

Potential Issue with DatacenterBroker Selecting Datacenter for All VMs Before Allocation

Closed this issue · 0 comments

Hello,

First of all, thank you for developing and maintaining CloudSimPlus. It has been a valuable tool for my studies and implementations of various cloud scenarios.

Issue:

I've spotted what may be an annoying behavior about how the DatacenterBroker selects a datacenter for each VM before the actual VM allocation occurs. Specifically, it appears that the DatacenterBroker selects the datacenter for every VM associated with the same broker before they are actually allocated.

Details:

In my current project, I am exploring the use of setDatacenterMapper to implement a worst-fit selection of datacenters. Here is a snippet of the function I am using:

private Datacenter datacenterMapperFunction(Datacenter datacenter, Vm vm) {
    Datacenter dc = null;
    double mostAvailableMips = 0;
    System.out.println("Starting datacenter mapping for VM ID: " + vm.getId());

    for (DatacenterSimple datacenterSimple : datacenters) {
        System.out.println("Checking Datacenter: " + datacenterSimple.getId());

        for (Host host : datacenterSimple.getHostList()) {
            double hostAvailableMips = host.getTotalAvailableMips();
            System.out.println("Host ID: " + host.getId() + " has " + hostAvailableMips + " available MIPS.");

            if (hostAvailableMips > mostAvailableMips) {
                mostAvailableMips = hostAvailableMips;
                dc = datacenterSimple;
                System.out.println("New most available MIPS found: " + mostAvailableMips + " at Datacenter ID: " + datacenterSimple.getId());
            }
        }
    }

    if (dc != null) {
        System.out.println("VM ID: " + vm.getId() + " mapped to Datacenter ID: " + dc.getId());
    } else {
        System.out.println("No suitable Datacenter found for VM ID: " + vm.getId());
    }

    return dc;
}

However, due to the described behavior of the DatacenterBroker, I may need to manually track resource utilization within the simulation code.

Request for Feedback:

I would like to understand if there is a better approach to handle this scenario. Could this be a limitation, or am I possibly misunderstanding the intended use of the DatacenterBroker?

Thank you for your time and assistance.

Best regards,
João Antonio Soares