Exp No: 7 Simulation of A Cloud Scenario Using Cloudsim and Run A Scheduling Algorithm
Exp No: 7 Simulation of A Cloud Scenario Using Cloudsim and Run A Scheduling Algorithm
Exp No: 7 Simulation of A Cloud Scenario Using Cloudsim and Run A Scheduling Algorithm
AIM:
SOFTWARE REQUIRED:
DESCRIPTION:
CloudSim is a framework for modeling and simulation of cloud computing infrastructures and
services Originally built primarily at the Cloud Computing and Distributed Systems (CLOUDS)
Laboratory, the University of Melbourne, Australia, CloudSim has become one of the most
popular open source cloud simulators in the research and academia. CloudSim is completely
written in Java.
ALGORITHM:
1. Input the processes along with their burst time (bt).
2. Find waiting time (wt) for all processes.
3. As the first process that comes need not to wait so
process i ->
total_waiting_time / no_of_processes.
total_turn_around_time / no_of_processes.
PROGRAM:
FCFS_SCheduler
package com.sjfs;
import org.cloudbus.cloudsim.*;
import org.cloudbus.cloudsim.core.CloudSim;
//import utils.Constants;
//import utils.DatacenterCreator;
//import utils.GenerateMatrices;
import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
//Creates a container to store VMs. This list is passed to the broker later
long bw = 1000;
//create VMs
vm[i] = new Vm(datacenter[i].getId(), userId, mips, pesNumber, ram, bw, size, vmm,
new CloudletSchedulerSpaceShared());
list.add(vm[i]);
return list;
//cloudlet parameters
long fileSize = 300;
int pesNumber = 1;
cloudlet[i].setUserId(userId);
cloudlet[i].setVmId(dcId + 2);
list.add(cloudlet[i]);
return list;
new GenerateMatrices();
execMatrix = GenerateMatrices.getExecMatrix();
commMatrix = GenerateMatrices.getCommMatrix();
try {
//Fourth step: Create VMs and Cloudlets and send them to broker
broker.submitVmList(vmList);
broker.submitCloudletList(cloudletList);
// Fifth step: Starts the simulation
CloudSim.startSimulation();
//newList.addAll(globalBroker.getBroker().getCloudletReceivedList());
CloudSim.stopSimulation();
printCloudletList(newList);
} catch (Exception e) {
e.printStackTrace();
/**
*/
Cloudlet cloudlet;
Log.printLine();
dft.setMinimumIntegerDigits(2);
cloudlet = list.get(i);
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
Log.print("SUCCESS");
Log.printLine(indent + indent + dft.format(cloudlet.getResourceId()) +
double makespan = 0;
if (dcWorkingTime[dcId] != 0) --dcWorkingTime[dcId];
return makespan;
}
FCFsDatacenterBroker
package com.sjfs;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.core.SimEvent;
import java.util.ArrayList;
/**
* @author Linda J
*/
super(name);
//scheduling function
clist.add(cloudlet);
setCloudletReceivedList(clist);
@Override
getCloudletReceivedList().add(cloudlet);
+ " received");
cloudletsSubmitted--;
scheduleTaskstoVms();
cloudletExecution(cloudlet);
}
protected void cloudletExecution(Cloudlet cloudlet) {
clearDatacenters();
finishExecution();
clearDatacenters();
createVmsInDatacenter(0);
} } }}
OUTPUT:
RESULT:
Simulation of cloud scenarios using cloudsim was done successfully and a scheduling algorithm
was compiled.