Professional Documents
Culture Documents
200948Gridbus
CloudSimSimJava
WindowsLinuxCloudSimGridSim
Cloud-Bursts
CloudSim GridSim
CloudSim
CloudSim CloudSim
CISCloud Information Service DataCenterBroker
DataCenterBroker
1CloudSim
(1)Cloudlet
(2)DataCenter
VMProvisioner
(3)DataCenterBroker
(4)Host (PE)
Host
(5)VirtualMachine Host
VMScheduler
(6)VMScheduler
(7)VMCharacteristics
(8)VMMAllocationPolicy Host
(9)VMProvisioner
2CloudSim
(1)JDK
http://www.oracle.com/technetwork/java/javase/downloads/index.html JDK
jdk1.7.0_02CloudSim JDK1.6 JDK
Path C:/Program Files/Java/jdk1.7.0_02/bin;
ClassPath C:/Program Files/Java/jdk1.7.0_02/lib/dt.jar;
C:/Program Files/Java/jdk1.7.0_02/lib/tools.jar;
(2)CloudSim
http://code.google.com/p/cloudsim/downloads/list CloudSim 3.0
(3.0.1,3.0.2) Zip tar.gz
4.
(4) Netbeans Cloudsim 6
3CloudSim
CloudSim windows Xp linux
CloudSim
4 CloudSim
(1) CloudSim
CloudSim.init(num_user, calendar, trace_flag);
(2) CloudSim
vmlist.add(vm1);
// Broker
broker.submitVmList(vmlist);
(5)
new
UtilizationModel utilizationModel =new
UtilizationModelFull();
Cloudlet cloudlet1 = new Cloudlet(id, length, pesNumber,
fileSize, outputSize, utilizationModel, utilizationModel,
utilizationModel);
cloudlet1.setUserId(brokerId);
//
cloudletList.add(cloudlet1);
//Broker
broker.submitCloudletList(cloudletList);
(6)
CloudSim.startSimulation();
(7)
List<Cloudlet> newList = broker.getCloudletReceivedList();
CloudSim.stopSimulation();
printCloudletList(newList);
datacenter0.printDebts();
5
DatacenterBroker
,
Cloudsim MI
MIPS T=MI / MIPS
MI MIPS
a
1
DatacenterBroker bindCloudletsToVmsSimple()
2
DatacenterBroker bindCloudletsToVmsTimeAwared()
time[i][j] i j
time MI MIPS
//cloudletListMI, vmMIPS
new CloudletComparator());
Collections.sort(cloudletList,new
new VmComparator());
Collections.sort(vmList,new
//////////For test//////////////////////////////////
System.out.println("///////////For
test///////////////");
int i=0;i<cloudletNum;i++){
for
for(int
System.out.print(cloudletList.get(i).getCloudletId()+":"+cloudletList.get
(i).getCloudletLength()+" ");
}
System.out.println();
int i=0;i<vmNum;i++){
for
for(int
System.out.print(vmList.get(i).getId()+":"+vmList.get(i).getMips()+" ");
}
System.out.println();
System.out.println("//////////////////////////////////");
//////////////////////////////////////////////////////////////////////
for
int i=0;i<cloudletNum;i++){
for(int
int j=0;j<vmNum;j++){
for
for(int
time[i][j]=
double
(double
double)cloudletList.get(i).getCloudletLength()/vmList.get(j).getMips();
System.out.print("time["+i+"]["+j+"]="+time[i][j]+"
//For test
}
System.out.println();
//For test
double
new double
double[] vmLoad=new
double[vmNum];//
new int
int
int[] vmTasks=new
int[vmNum]; //Vm
double minLoad=0;//
int idx=0;//
//cloudletvm
vmLoad[vmNum-1]=time[0][vmNum-1];
vmTasks[vmNum-1]=1;
cloudletList.get(0).setVmId(vmList.get(vmNum-1).getId());
int i=1;i<cloudletNum;i++){
for
for(int
minLoad=vmLoad[vmNum-1]+time[i][vmNum-1];
idx=vmNum-1;
int j=vmNum-2;j>=0;j--){
for
for(int
//
if
if(vmLoad[j]==0){
if
if(minLoad>=time[i][j])idx=j;
");
break
break;
}
if
if(minLoad>vmLoad[j]+time[i][j]){
minLoad=vmLoad[j]+time[i][j];
idx=j;
}
//
else
if
if(minLoad==vmLoad[j]+time[i][j]&&vmTasks[j]<vmTasks[idx])
idx=j;
}
vmLoad[idx]+=time[i][idx];
vmTasks[idx]++;
cloudletList.get(i).setVmId(vmList.get(idx).getId());
System.out.print(i+"th
"+"vmLoad["+idx+"]="+vmLoad[idx]+"
minLoad="+minLoad);
System.out.println();
}
}
//CloudletMI
private class CloudletComparator implements Comparator<Cloudlet>{
public int compare(Cloudlet cl1,Cloudlet cl2){
int
return (int
int)(cl2.getCloudletLength()-cl1.getCloudletLength());
}
}
//VmMIPS
private class VmComparator implements Comparator<Vm>{
public int compare(Vm vm1,Vm vm2){
int
return (int
int)(vm1.getMips()-vm2.getMips());
}
}
/////////////////////////////////////////////////////////////////////////
t
org.cloudbus.cloudsim.examples MyAllocationTes
MyAllocationTest
package org.cloudbus.cloudsim.examples;
import java.text.DecimalFormat;
import
import
import
import
java.util.ArrayList;
java.util.Calendar;
java.util.LinkedList;
java.util.List;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
org.cloudbus.cloudsim.Cloudlet;
org.cloudbus.cloudsim.CloudletSchedulerSpaceShared;
org.cloudbus.cloudsim.CloudletSchedulerTimeShared;
org.cloudbus.cloudsim.Datacenter;
org.cloudbus.cloudsim.DatacenterBroker;
org.cloudbus.cloudsim.DatacenterCharacteristics;
org.cloudbus.cloudsim.Host;
org.cloudbus.cloudsim.Log;
org.cloudbus.cloudsim.Pe;
org.cloudbus.cloudsim.Storage;
org.cloudbus.cloudsim.UtilizationModel;
org.cloudbus.cloudsim.UtilizationModelFull;
org.cloudbus.cloudsim.Vm;
org.cloudbus.cloudsim.VmAllocationPolicySimple;
org.cloudbus.cloudsim.VmSchedulerTimeShared;
org.cloudbus.cloudsim.core.CloudSim;
org.cloudbus.cloudsim.provisioners.BwProvisionerSimple;
org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
datacenter1
long
long[]
lengths
=
long
long[]{19365,49809,32018,44157,16754,
18336,20045,31493,30727,31017};
long fileSize = 300;
long outputSize = 300;
UtilizationModel
utilizationModel
UtilizationModelFull();
new
new
new
outputSize,utilizationModel,utilizationModel,utilizationModel)
;
//add the cloudlets to the list
cloudlet.setUserId(brokerId);
cloudletList.add(cloudlet);
id++;
}
//submit cloudlet list to the broker
broker.submitCloudletList(cloudletList);
printCloudletList(newList);
//Print the debt of each user to each datacenter
datacenter0.printDebts();
Log.printLine("TestAllocation finished!");
}
catch (Exception e) {
e.printStackTrace();
Log.printLine("Unwanted errors happen");
}
}
private static Datacenter createDatacenter(String name){
// Here are the steps needed to create a PowerDatacenter:
// 1. We need to create a list to store
//
our machine
List<Host> hostList = new ArrayList<Host>();
// PE and its properties
int mips = 1000;
int hostId=0;
int ram = 2048; //host memory (MB)
long storage = 1000000; //host storage
int bw = 10000;
// 2. A Machine contains one or more PEs or CPUs/Cores.
List<Pe> peList = new ArrayList<Pe>();
// 3. Create PEs and add these into a list.
new Pe(0, new PeProvisionerSimple(mips))); //
peList.add(new
need to store Pe id and MIPS Rating
//4. Create Host with its id and list of PEs and add them
to the list of machines
hostList.add(
new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeShared(peList)
)
); // This is our machine
//
of
time zone
//
and its price (G$/Pe time unit).
String arch = "x86";
// system architecture
String os = "Linux";
// operating system
String vmm = "Xen";
double time_zone = 10.0;
// time zone this resource
located
double cost = 3.0;
// the cost of using
processing in this resource
double costPerMem = 0.05;
// the cost of using memory
in this resource
double costPerStorage = 0.001;
// the cost of using
storage in this resource
double costPerBw = 0.0;
// the cost of using bw in
this resource
LinkedList<Storage>
storageList
=
new
LinkedList<Storage>(); //we are not adding SAN devices by now
//
DatacenterCharacteristics characteristics = new
DatacenterCharacteristics(
arch, os, vmm, hostList, time_zone, cost, costPerMem,
costPerStorage, costPerBw);
+
indent
indent
indent
indent
dft.format(cloudlet.getActualCPUTime()) +
dft.format(cloudlet.getExecStartTime())+
indent
+
dft.format(cloudlet.getFinishTime()));
}
}
indent
}
}
bindCloudletsToVmsSimple()
bindCloudletsToVmsSimple()
========== OUTPUT ==========
Cloudlet ID
STATUS
Data center ID
VM ID
Time
Start Time
Finish
Time
0
SUCCESS
69.66
0.1
SUCCESS
65.96
69.76
SUCCESS
172.35
0.1
172.45
SUCCESS
211.28
0.1
211.38
SUCCESS
69.36
172.45
SUCCESS
242.55
0.1
SUCCESS
147.01
211.38
358.39
SUCCESS
238.58
242.65
481.23
*****Datacenter: Datacenter_0*****
User id
3
Debt
91.2
**********************************
TestAllocation finished!
69.76
135.72
241.81
242.65
bindCloudletsToVmsTimeAwared()
bindCloudletsToVmsTimeAwared()
========== OUTPUT ==========
Cloudlet ID
STATUS
Data center ID
VM ID
Time
Start Time
Finish
Time
2
SUCCESS
115.17
0.1
115.27
SUCCESS
150.68
0.1
150.78
SUCCESS
154.39
0.1
154.49
SUCCESS
70.09
154.49
SUCCESS
111.57
115.27
SUCCESS
232.77
0.1
SUCCESS
87.73
150.78
238.51
SUCCESS
58.58
224.58
283.16
224.58
226.84
232.87
*****Datacenter: Datacenter_0*****
User id
3
Debt
91.2
**********************************
TestAllocation finished!
10 cloudlet5
8 cloudlet4
6
6.1 Eclipse
eclipse
File->new ->Project -> java Project
Project name finish;
project
Project explorer project->new->class
name java
finish Project explorer
project src ->run as->java application
6.2 flanagan
flanagan.jar
http://www.ee.ucl.ac.uk/~mflanaga/java/#down
flanagan.jar cloudsim jars Eclipse
jar Build Path Add to Build Path
7 Netbeans Cloudsim
Step1
open Netbeans (any version greater then 5.0) ,Go to file-->>new project
Step 2
select "Java" folder then select first option java Application ,Press next
Step3
Now give name to the project as you wish ,then un-check the "create main class" press next.
Step 4
Now your project is been created as shown.
Step5
Go to library ,right click on it ,a menu will come ,click on "Add jars/Folders"
Now browse the cloudsim folder which you have extracted from zip file .and go to "cloudsim-3.0.2\jars"
and select "cloudsim-3.0.2.jar" .
Step6
Now simply copy the "org" folder in "cloudsim-3.0.2\examples" and paste it to net beans source folder as
shown.go to source and right click select
Paste.
Step 7
To run the example go to source ->> org.cloudbus.cloudsim.examples->>select any example ,right click
on it and select "run" option the output will be displayed in the output window at the bottom.