1

running-and-using-cloud-analyst

Here is code How Round Robin Scheduling is applied

public class RoundRobinVmLoadBalancer extends VmLoadBalancer 

{

    private Map<Integer, VirtualMachineState> vmStatesList;

    private int currVm = -1;

    public RoundRobinVmLoadBalancer(Map<Integer, VirtualMachineState> vmStatesList)

    {

        super();
        this.vmStatesList = vmStatesList;
    }

    /* (non-Javadoc)
     * @see cloudsim.ext.VMLoadBalancer#getVM()
     */
    public int getNextAvailableVm(){
        currVm++;

        if (currVm >= vmStatesList.size()){
            currVm = 0;
        }

        allocatedVm(currVm);

        return currVm;

    }
}

VmLoadBalancer

import java.util.Map;

import java.util.HashMap;

/**
 * This is the base class defining the behaviour of a Virtual Machine load 

balancer

 * used by a {@link DatacenterController}. The main method all load balancers 

should implement


 * is <c
ode>public int getNextAvailableVm()</code>.
 * 
 * This class provides a basic load balancing statistic collection that can be used by 
 * implementing classes. The implementing classes should call the  <code>void allocatedVM(int currVm)</code>
 *  method to use the statisitics collection feature.
 * 
 */
abstract public class VmLoadBalancer 
{

/** Holds the count of allocations for each VM */

protected Map<Integer, Integer> vmAllocationCounts;

    /** No args contructor */

    public VmLoadBalancer(){

    vmAllocationCounts = new HashMap<Integer, Integer>();

    }

    /**
     * The main contract of {@link VmLoadBalancer}. All load balancers should implement
     * this method according to their specific load balancing policy.
     * 
     * @return id of the next available Virtual Machine to which the next task should be
     *          allocated 
     */

    abstract public int getNextAvailableVm();

    /**
     * Used internally to update VM allocation statistics. Should be called by all impelementing
     * classes to notify when a new VM is allocated.
     * 
     * @param currVm
     */

    protected void allocatedVm(int currVm){


    Integer currCount = vmAllocationCounts.get(currVm);

    if (currCount == null){

        currCount = 0;

    }

        vmAllocationCounts.put(currVm, currCount + 1);      

}

    /**
     * Returns a {@link Map} indexed by VM id and having the number of allocations for each VM.
     * @return
     */

public Map<Integer, Integer> getVmAllocationCounts()

{

    return vmAllocationCounts;

}

}

Like Round Robin I want to apply Ant Colony optimization as Load Balancing Policy. But It is Not clear that How Round Robin is being implemented there is no code of Round Robin seen in cloud_analyst cloudsim project then how do i apply A C O , kindly share A C O code snippet applied in cloudsim

isuruAb
  • 2,202
  • 5
  • 26
  • 39
aristocrat
  • 49
  • 5
  • Like Round Robin I want to apply Ant Colony optimization as Load Balancing Policy. But It is Not clear that How Round Robin is being implemented there is no code of Round Robin seen in cloud_analyst cloudsim project then how do i apply A C O , kindly share A C O code snippet applied in cloudsim – aristocrat Oct 27 '15 at 05:49
  • How Round Robin is used as Load Balancing Policy in Cloud sim ,cloud analyst , any specific code for Round Robin – aristocrat Oct 30 '15 at 05:15
  • did you find a proper way for this ? – isuruAb Jul 16 '17 at 00:40

2 Answers2

1

With my little experience in CloudSim, I think you shall try creating a new VmAllocationPolicy rather than the VmLoadBalancer. So, in case you are trying to use Ant Colony optimization, then your class shall look something like this.

public final class MyPolicyNew extends VmAllocationPolicy {

    private Map<String, Host> vmTable;//vm table
    private Map<String, Integer> usedPes;//used pes
    private List<Integer> freePes;//free pes

    public MyPolicyNew(List<? extends Host> list) {
        ....
    }

    @Override
    public boolean allocateHostForVm(Vm vm) {

        **Your code for ACO goes here**
        **You do all the processing here and at the end allocate the vm to a host**
        **using host.vmCreate(vm) which returns a boolean on success of allocation, which you return from the function**
    }

    ....

}

You must try looking at the VmAllocationPolicy.java class and the examples of Cloudsim simulation included in the cloudsim, which will help you.

P.S. I know its been more than a month you asked, but just in case it could help you, I would be glad!

user007
  • 2,156
  • 2
  • 20
  • 35
0

if you use TimeShareScheduling for Vm/Cloudlet it would act like roundrobin algorithm. Different combination of VM/cloudlet scheduler can make different scheduling policy. Figure 4 of this might help you.

Chanda Korat
  • 2,453
  • 2
  • 19
  • 23