Commit 4f25a01a authored by rodrigo.calheiros's avatar rodrigo.calheiros

Removed warnings from Network package

parent b463216f
package org.cloudbus.cloudsim.examples.network.datacenter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
......@@ -10,20 +8,13 @@ import java.util.LinkedList;
import java.util.List;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerSpaceShared;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicySimple;
import org.cloudbus.cloudsim.VmSchedulerTimeShared;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.distributions.UniformDistr;
import org.cloudbus.cloudsim.network.datacenter.AppCloudlet;
import org.cloudbus.cloudsim.network.datacenter.EdgeSwitch;
import org.cloudbus.cloudsim.network.datacenter.NetDatacenterBroker;
import org.cloudbus.cloudsim.network.datacenter.NetworkConstants;
......@@ -37,13 +28,6 @@ import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
public class TestExample {
/**
* @param args
*/
/** The cloudlet list. */
private static List<AppCloudlet> cloudletList;
/** The vmlist. */
private static List<NetworkVm> vmlist;
......@@ -72,11 +56,9 @@ public class TestExample {
// Third step: Create Broker
NetDatacenterBroker broker = createBroker();
int brokerId = broker.getId();
broker.setLinkDC(datacenter0);
// broker.setLinkDC(datacenter0);
// Fifth step: Create one Cloudlet
cloudletList = new ArrayList<AppCloudlet>();
vmlist = new ArrayList<NetworkVm>();
......@@ -92,9 +74,9 @@ public class TestExample {
// Final step: Print results when simulation is over
List<Cloudlet> newList = broker.getCloudletReceivedList();
printCloudletList(newList);
System.out.println("numberofcloudlet " + newList.size()
+ " Cached " + NetDatacenterBroker.cachedcloudlet
+ " Data transfered " + NetworkConstants.totaldatatransfer);
System.out.println("numberofcloudlet " + newList.size() + " Cached "
+ NetDatacenterBroker.cachedcloudlet + " Data transfered "
+ NetworkConstants.totaldatatransfer);
// Print the debt of each user to each datacenter
datacenter0.printDebts();
......@@ -133,70 +115,72 @@ public class TestExample {
// 4. Create Host with its id and list of PEs and add them to the list
// of machines
int hostId = 0;
int ram = 2048; // host memory (MB)
long storage = 1000000; // host storage
int bw = 10000;
for (int i = 0; i < NetworkConstants.EdgeSwitchPort
* NetworkConstants.AggSwitchPort
for (int i = 0; i < NetworkConstants.EdgeSwitchPort * NetworkConstants.AggSwitchPort
* NetworkConstants.RootSwitchPort; i++) {
// 2. A Machine contains one or more PEs or CPUs/Cores.
// In this example, it will have only one core.
// 3. Create PEs and add these into an object of PowerPeList.
List<Pe> peList = new ArrayList<Pe>();
peList.add(new Pe(0, new PeProvisionerSimple(mips))); // need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList.add(new Pe(1, new PeProvisionerSimple(mips))); // need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList.add(new Pe(2, new PeProvisionerSimple(mips))); // need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList.add(new Pe(3, new PeProvisionerSimple(mips))); // need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList.add(new Pe(4, new PeProvisionerSimple(mips))); // need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList.add(new Pe(5, new PeProvisionerSimple(mips))); // need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList.add(new Pe(6, new PeProvisionerSimple(mips))); // need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
peList.add(new Pe(7, new PeProvisionerSimple(mips))); // need to
// store
// PowerPe
// id and
// MIPS
// Rating
// store
// PowerPe
// id and
// MIPS
// Rating
// 4. Create PowerHost with its id and list of PEs and add them to
// the list of machines
hostList.add(new NetworkHost(i, new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw), storage, peList,
hostList.add(new NetworkHost(
i,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeShared(peList))); // This is our machine
}
......@@ -211,23 +195,34 @@ public class TestExample {
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
// resource
double costPerBw = 0.0; // the cost of using bw in this resource
LinkedList<Storage> storageList = new LinkedList<Storage>(); // we are
// not
// adding
// SAN
// not
// adding
// SAN
// devices by now
DatacenterCharacteristics characteristics = new DatacenterCharacteristics(
arch, os, vmm, hostList, time_zone, cost, costPerMem,
costPerStorage, costPerBw);
arch,
os,
vmm,
hostList,
time_zone,
cost,
costPerMem,
costPerStorage,
costPerBw);
// 6. Finally, we need to create a NetworkDatacenter object.
NetworkDatacenter datacenter = null;
try {
datacenter = new NetworkDatacenter(name, characteristics,
new NetworkVmAllocationPolicy(hostList), storageList, 0);
datacenter = new NetworkDatacenter(
name,
characteristics,
new NetworkVmAllocationPolicy(hostList),
storageList,
0);
} catch (Exception e) {
e.printStackTrace();
......@@ -263,17 +258,14 @@ public class TestExample {
* list of Cloudlets
* @throws IOException
*/
private static void printCloudletList(List<Cloudlet> list)
throws IOException {
private static void printCloudletList(List<Cloudlet> list) throws IOException {
int size = list.size();
Cloudlet cloudlet;
double fintime = 0;
String indent = " ";
Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent
+ "Data center ID" + indent + "VM ID" + indent + "Time"
+ indent + "Start Time" + indent + "Finish Time");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent + "Data center ID" + indent + "VM ID"
+ indent + "Time" + indent + "Start Time" + indent + "Finish Time");
DecimalFormat dft = new DecimalFormat("###.##");
for (int i = 0; i < size; i++) {
......@@ -282,13 +274,9 @@ public class TestExample {
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
Log.print("SUCCESS");
fintime = cloudlet.getFinishTime();
Log.printLine(indent + indent + cloudlet.getResourceId()
+ indent + indent + indent + cloudlet.getVmId()
+ indent + indent
+ dft.format(cloudlet.getActualCPUTime()) + indent
+ indent + dft.format(cloudlet.getExecStartTime())
+ indent + indent
Log.printLine(indent + indent + cloudlet.getResourceId() + indent + indent + indent
+ cloudlet.getVmId() + indent + indent + dft.format(cloudlet.getActualCPUTime())
+ indent + indent + dft.format(cloudlet.getExecStartTime()) + indent + indent
+ dft.format(cloudlet.getFinishTime()));
}
}
......@@ -297,24 +285,11 @@ public class TestExample {
static void CreateNetwork(int numhost, NetworkDatacenter dc) {
// //Root Switch
// Switch swroot=new Switch("Root", Constants.ROOT_LEVEL, dc);
// dc.Switchlist.put(swroot.getId(), swroot);
// //Agg Switch
// Switch aggswitch[]=new Switch[(int) Constants.RootSwitchPort];
// for(int j=0;j<Constants.RootSwitchPort;j++)
// {
// aggswitch[j]=new Switch("Agg"+j, Constants.Agg_LEVEL, dc);
// swroot.downlinkswitches.add(aggswitch[j]);
// aggswitch[j].uplinkswitches.add(swroot);
// dc.Switchlist.put(aggswitch[j].getId(), aggswitch[j]);
// }
// Edge Switch
EdgeSwitch edgeswitch[] = new EdgeSwitch[1];
for (int i = 0; i < 1; i++) {
edgeswitch[i] = new EdgeSwitch("Edge" + i,
NetworkConstants.EDGE_LEVEL, dc);
edgeswitch[i] = new EdgeSwitch("Edge" + i, NetworkConstants.EDGE_LEVEL, dc);
// edgeswitch[i].uplinkswitches.add(null);
dc.Switchlist.put(edgeswitch[i].getId(), edgeswitch[i]);
// aggswitch[(int)
......
......@@ -16,10 +16,10 @@ import org.cloudbus.cloudsim.core.predicates.PredicateType;
* It interacts with other switches in order to exchange
* packets. Please refer to following publication for more details:
*
* Saurabh Kumar Garg and Rajkumar Buyya, NetworkCloudSim: Modelling Parallel
* Applications in Cloud Simulations, Proceedings of the 4th IEEE/ACM International
* Conference on Utility and Cloud Computing (UCC 2011, IEEE CS Press, USA),
* Melbourne, Australia, December 5-7, 2011.
* Saurabh Kumar Garg and Rajkumar Buyya, NetworkCloudSim: Modelling Parallel
* Applications in Cloud Simulations, Proceedings of the 4th IEEE/ACM International
* Conference on Utility and Cloud Computing (UCC 2011, IEEE CS Press, USA),
* Melbourne, Australia, December 5-7, 2011.
*
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit 3.0
......@@ -31,25 +31,24 @@ public class EdgeSwitch extends Switch{
/**
* Constructor for Edge Switch
* We have to specify switches that are connected to its downlink and uplink ports,
* and corresponding bandwidths. In this switch downlink ports are
* and corresponding bandwidths. In this switch downlink ports are
* connected to hosts not to a switch.
*
* @param name Name of the switch
* @param name Name of the switch
* @param level At which level switch is with respect to hosts.
* @param dc Pointer to Datacenter
*/
public EdgeSwitch(String name, int level, NetworkDatacenter dc) {
super(name, level, dc);
hostlist=new HashMap<Integer,NetworkHost>();
uplinkswitchpktlist=new HashMap<Integer,List<NetworkPacket>>();
packetTohost=new HashMap<Integer,List<NetworkPacket>>();
uplinkbandwidth=NetworkConstants.BandWidthEdgeAgg;
uplinkbandwidth=NetworkConstants.BandWidthEdgeAgg;
downlinkbandwidth=NetworkConstants.BandWidthEdgeHost;
this.switching_delay=NetworkConstants.SwitchingDelayEdge;
numport=NetworkConstants.EdgeSwitchPort;
uplinkswitches=new ArrayList<Switch>();
// TODO Auto-generated constructor stub
}
/**
* Send Packet to switch connected through a uplink port
......@@ -58,66 +57,64 @@ public class EdgeSwitch extends Switch{
*/
@Override
protected void processpacket_up(SimEvent ev) {
// TODO Auto-generated method stub
//packet coming from down level router/host.
//has to send up
//check which switch to forward to
//check which switch to forward to
//add packet in the switch list
//
//int src=ev.getSource();
NetworkPacket hspkt=(NetworkPacket) ev.getData();
int recvVMid=hspkt.pkt.reciever;
CloudSim.cancelAll(getId(), new PredicateType(CloudSimTags.Network_Event_send));
int recvVMid=hspkt.pkt.reciever;
CloudSim.cancelAll(getId(), new PredicateType(CloudSimTags.Network_Event_send));
schedule(getId(),this.switching_delay, CloudSimTags.Network_Event_send);
// packet is recieved from host
//packet is to be sent to aggregate level or to another host in the same level
int hostid=dc.VmtoHostlist.get(recvVMid);
NetworkHost hs=this.hostlist.get(hostid);
hspkt.recieverhostid=hostid;
//packet needs to go to a host which is connected directly to switch
if(hs!=null)
{
//packet to be sent to host connected to the switch
List<NetworkPacket> pktlist=this.packetTohost.get(hostid);
if(pktlist==null){
pktlist=new ArrayList<NetworkPacket>();
this.packetTohost.put(hostid, pktlist);
}
pktlist.add(hspkt);
return;
}
//otherwise
//packet is to be sent to upper switch
//ASSUMPTION EACH EDGE is Connected to one aggregate level switch
//if there are more than one Aggregate level switch one need to modify following code
Switch sw=this.uplinkswitches.get(0);
List<NetworkPacket> pktlist=this.uplinkswitchpktlist.get(sw.getId());
if(pktlist==null){
pktlist=new ArrayList<NetworkPacket>();
this.uplinkswitchpktlist.put(sw.getId(), pktlist);
}
pktlist.add(hspkt);
return;
// packet is recieved from host
//packet is to be sent to aggregate level or to another host in the same level
int hostid=dc.VmtoHostlist.get(recvVMid);
NetworkHost hs=this.hostlist.get(hostid);
hspkt.recieverhostid=hostid;
//packet needs to go to a host which is connected directly to switch
if(hs!=null)
{
//packet to be sent to host connected to the switch
List<NetworkPacket> pktlist=this.packetTohost.get(hostid);
if(pktlist==null){
pktlist=new ArrayList<NetworkPacket>();
this.packetTohost.put(hostid, pktlist);
}
pktlist.add(hspkt);
return;
}
//otherwise
//packet is to be sent to upper switch
//ASSUMPTION EACH EDGE is Connected to one aggregate level switch
//if there are more than one Aggregate level switch one need to modify following code
Switch sw=this.uplinkswitches.get(0);
List<NetworkPacket> pktlist=this.uplinkswitchpktlist.get(sw.getId());
if(pktlist==null){
pktlist=new ArrayList<NetworkPacket>();
this.uplinkswitchpktlist.put(sw.getId(), pktlist);
}
pktlist.add(hspkt);
return;
}
/**
* Send Packet to hosts connected to the switch
*
* @param ev Event/packet to process
*/
@Override
protected void processpacketforward(SimEvent ev) {
// TODO Auto-generated method stub
//search for the host and packets..send to them
if(this.uplinkswitchpktlist!=null)
{
for(Entry<Integer, List<NetworkPacket>> es:uplinkswitchpktlist.entrySet())
......@@ -132,7 +129,7 @@ public class EdgeSwitch extends Switch{
{
NetworkPacket hspkt=it.next();
double delay=1000*hspkt.pkt.data/avband;
this.send(tosend,delay,CloudSimTags.Network_Event_UP, hspkt);
}
hspktlist.clear();
......@@ -143,8 +140,6 @@ public class EdgeSwitch extends Switch{
{
for(Entry<Integer, List<NetworkPacket>> es:packetTohost.entrySet())
{
int tosend=es.getKey();
NetworkHost hs=this.hostlist.get(tosend);
List<NetworkPacket> hspktlist=es.getValue();
if(!hspktlist.isEmpty()){
double avband=this.downlinkbandwidth/hspktlist.size();
......@@ -157,13 +152,13 @@ public class EdgeSwitch extends Switch{
}
hspktlist.clear();
}
}
}
}
//or to switch at next level.
//clear the list
}
......
......@@ -13,14 +13,8 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.UUID;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletSchedulerSpaceShared;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Vm;
......@@ -29,14 +23,13 @@ import org.cloudbus.cloudsim.core.CloudSimTags;
import org.cloudbus.cloudsim.core.SimEntity;
import org.cloudbus.cloudsim.core.SimEvent;
import org.cloudbus.cloudsim.distributions.UniformDistr;
import org.cloudbus.cloudsim.lists.CloudletList;
import org.cloudbus.cloudsim.lists.VmList;
/**
* NetDatacentreBroker represents a broker acting on behalf of Datacenter
* provider. It hides VM management, as vm creation, submission of cloudlets to
* this VMs and destruction of VMs. NOTE- It is an example only. It work on behalf of a provider not for
* users. One has to implement interaction with user broker to this broker.
* users. One has to implement interaction with user broker to this broker.
*
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit 3.0
......@@ -56,7 +49,7 @@ public class NetDatacenterBroker extends SimEntity {
private List<? extends AppCloudlet> appCloudletList;
/** The Appcloudlet submitted list. */
private Map<Integer, Integer> appCloudletRecieved;
private final Map<Integer, Integer> appCloudletRecieved;
private List<? extends Cloudlet> cloudletSubmittedList;
......@@ -170,8 +163,8 @@ public class NetDatacenterBroker extends SimEntity {
// public void bindCloudletToVm(int cloudletId, int vmId){
// CloudletList.getById(getCloudletList(), cloudletId).setVmId(vmId);
// }
public void setLinkDC(NetworkDatacenter linkDC) {
this.linkDC = linkDC;
public void setLinkDC(NetworkDatacenter alinkDC) {
linkDC = alinkDC;
}
/**
......@@ -191,26 +184,27 @@ public class NetDatacenterBroker extends SimEntity {
case CloudSimTags.RESOURCE_CHARACTERISTICS_REQUEST:
processResourceCharacteristicsRequest(ev);
break;
// Resource characteristics answer
// Resource characteristics answer
case CloudSimTags.RESOURCE_CHARACTERISTICS:
processResourceCharacteristics(ev);
break;
// VM Creation answer
// VM Creation answer
// A finished cloudlet returned
// A finished cloudlet returned
case CloudSimTags.CLOUDLET_RETURN:
processCloudletReturn(ev);
break;
// if the simulation finishes
// if the simulation finishes
case CloudSimTags.END_OF_SIMULATION:
shutdownEntity();
break;
case CloudSimTags.NextCycle:
if (NetworkConstants.BASE)
this.createVmsInDatacenterBase(this.linkDC.getId());
if (NetworkConstants.BASE) {
this.createVmsInDatacenterBase(linkDC.getId());
}
break;
// other unknown tags are processed by this method
// other unknown tags are processed by this method
default:
processOtherEvent(ev);
break;
......@@ -229,7 +223,7 @@ public class NetDatacenterBroker extends SimEntity {
*/
protected void processResourceCharacteristics(SimEvent ev) {
DatacenterCharacteristics characteristics = (DatacenterCharacteristics) ev
.getData();
.getData();
getDatacenterCharacteristicsList().put(characteristics.getId(),
characteristics);
......@@ -341,8 +335,6 @@ public class NetDatacenterBroker extends SimEntity {
// send as much vms as possible for this datacenter before trying the
// next one
int requestedVms = 0;
String datacenterName = CloudSim.getEntityName(datacenterId);
int j = 0;
// All host will have two VMs (assumption) VM is the minimum unit
......@@ -360,16 +352,14 @@ public class NetDatacenterBroker extends SimEntity {
NetworkConstants.currentAppId++;
}
int seed = 5;
int k = 0;
int totalvm = this.vmsCreatedList.size();
int currentvmid = 0;
//schedule the application on VMs
for (AppCloudlet app : this.getAppCloudletList()) {
List<Integer> vmids = new ArrayList<Integer>();
int numVms = this.linkDC.getVmList().size();
int numVms = linkDC.getVmList().size();
UniformDistr ufrnd = new UniformDistr(0, numVms, 5);
for (int i = 0; i < app.numbervm; i++) {
......@@ -409,18 +399,17 @@ public class NetDatacenterBroker extends SimEntity {
CloudSimTags.NextCycle);
}
setVmsRequested(requestedVms);
setVmsAcks(0);
}
private void CreateVMs(int datacenterId) {
// TODO Auto-generated method stub
int numVM = this.linkDC.getHostList().size() * NetworkConstants.maxhostVM; // two
// VMs
// per
// host
int numVM = linkDC.getHostList().size() * NetworkConstants.maxhostVM; // two
// VMs
// per
// host
for (int i = 0; i < numVM; i++) {
int requestedVms = 0;
int vmid = i;
......@@ -429,14 +418,14 @@ public class NetDatacenterBroker extends SimEntity {
int ram = 512; // vm memory (MB)
long bw = 1000;
int pesNumber = NetworkConstants.HOST_PEs / NetworkConstants.maxhostVM; // number
// of
// cpus
// of
// cpus
String vmm = "Xen"; // VMM name
// create VM
NetworkVm vm = new NetworkVm(vmid, this.getId(), mips, pesNumber,
ram, bw, size, vmm, new NetworkCloudletSpaceSharedScheduler());
this.linkDC.processVmCreateNetwork(vm);
linkDC.processVmCreateNetwork(vm);
// add the VM to the vmList
getVmList().add(vm);
requestedVms++;
......@@ -545,6 +534,7 @@ public class NetDatacenterBroker extends SimEntity {
this.cloudletList = cloudletList;
}
@SuppressWarnings("unchecked")
public <T extends AppCloudlet> List<T> getAppCloudletList() {
return (List<T>) appCloudletList;
}
......
......@@ -5,10 +5,11 @@ import java.util.Map;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.UtilizationModel;
/**
* NetworkCloudlet class extends Cloudlet to support simulation of complex applications.
* Each such network Cloudlet represents a task of the application. Each task consists of several
* stages.
* NetworkCloudlet class extends Cloudlet to support simulation of complex
* applications. Each such network Cloudlet represents a task of the
* application. Each task consists of several stages.
*
* Please refer to following publication for more details:
*
......@@ -16,54 +17,61 @@ import org.cloudbus.cloudsim.UtilizationModel;
* Applications in Cloud Simulations, Proceedings of the 4th IEEE/ACM
* International Conference on Utility and Cloud Computing (UCC 2011, IEEE CS
* Press, USA), Melbourne, Australia, December 5-7, 2011.
*
*
*
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit 1.0
*/
public class NetworkCloudlet extends Cloudlet implements Comparable {
public class NetworkCloudlet extends Cloudlet implements Comparable<Object> {
long memory;
public NetworkCloudlet(int cloudletId, long cloudletLength, int pesNumber,
long cloudletFileSize, long cloudletOutputSize, long memory,
public NetworkCloudlet(
int cloudletId,
long cloudletLength,
int pesNumber,
long cloudletFileSize,
long cloudletOutputSize,
long memory,
UtilizationModel utilizationModelCpu,
UtilizationModel utilizationModelRam,
UtilizationModel utilizationModelBw) {
super(cloudletId, cloudletLength, pesNumber, cloudletFileSize,
cloudletOutputSize, utilizationModelCpu, utilizationModelRam,
super(
cloudletId,
cloudletLength,
pesNumber,
cloudletFileSize,
cloudletOutputSize,
utilizationModelCpu,
utilizationModelRam,
utilizationModelBw);
// TODO Auto-generated constructor stub
currStagenum = -1;
this.memory = memory;
stages = new ArrayList<TaskStage>();
}
public double submittime; //time when cloudlet will be submitted
public double finishtime; //time when cloudlet finish execution
public double exetime; //execution time for cloudlet
public double numStage;//number of stages in cloudlet
public int currStagenum; //current stage of cloudlet execution
public double submittime; // time when cloudlet will be submitted
public double finishtime; // time when cloudlet finish execution
public double exetime; // execution time for cloudlet
public double numStage;// number of stages in cloudlet
public int currStagenum; // current stage of cloudlet execution
public double timetostartStage;
public double timespentInStage; //how much time spent in particular stage
public double timespentInStage; // how much time spent in particular stage
public Map<Double, HostPacket> timeCommunicate;
public ArrayList<TaskStage> stages; //all stages which cloudlet execution consists of.
public ArrayList<TaskStage> stages; // all stages which cloudlet execution
// consists of.
public double starttime;
@Override
public int compareTo(Object arg0) {
// TODO Auto-generated method stub
NetworkCloudlet s1 = (NetworkCloudlet) arg0;
int alpha = 0;
return 0;
}
public double getSubmittime() {
// TODO Auto-generated method stub
return submittime;
};
}
}
......@@ -15,17 +15,19 @@ import org.cloudbus.cloudsim.core.CloudSimTags;
public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/*
* Title: CloudSim Toolkit Description: CloudSim (Cloud Simulation) Toolkit for Modeling and
* Simulation of Clouds Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Title: CloudSim Toolkit Description: CloudSim (Cloud Simulation) Toolkit
* for Modeling and Simulation of Clouds Licence: GPL -
* http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
/**
* CloudletSchedulerSpaceShared implements a policy of scheduling performed by a virtual
* machine. It consider that there will be only one cloudlet per VM. Other cloudlets will be in
* a waiting list. We consider that file transfer from cloudlets waiting happens before cloudlet
* execution. I.e., even though cloudlets must wait for CPU, data transfer happens as soon as
* CloudletSchedulerSpaceShared implements a policy of scheduling performed
* by a virtual machine. It consider that there will be only one cloudlet
* per VM. Other cloudlets will be in a waiting list. We consider that file
* transfer from cloudlets waiting happens before cloudlet execution. I.e.,
* even though cloudlets must wait for CPU, data transfer happens as soon as
* cloudlets are submitted.
*
* @author Saurabh Kumar Garg
......@@ -58,8 +60,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
public Map<Integer, List<HostPacket>> pktrecv;
/**
* Creates a new CloudletSchedulerSpaceShared object. This method must be invoked before
* starting the actual simulation.
* Creates a new CloudletSchedulerSpaceShared object. This method must be
* invoked before starting the actual simulation.
*
* @pre $none
* @post $none
......@@ -77,13 +79,17 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
}
/**
* Updates the processing of cloudlets running under management of this scheduler.
* Updates the processing of cloudlets running under management of this
* scheduler.
*
* @param currentTime current simulation time
* @param mipsShare array with MIPS share of each processor available to the scheduler
* @param currentTime
* current simulation time
* @param mipsShare
* array with MIPS share of each processor available to the
* scheduler
*
* @return time predicted completion time of the earliest finishing cloudlet, or 0 if there is
* no next events
* @return time predicted completion time of the earliest finishing
* cloudlet, or 0 if there is no next events
*
* @pre currentTime >= 0
* @post $none
......@@ -91,8 +97,7 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
@Override
public double updateVmProcessing(double currentTime, List<Double> mipsShare) {
setCurrentMipsShare(mipsShare);
double timeSpam = currentTime - getPreviousTime(); // time since last
// update
// update
double capacity = 0.0;
int cpus = 0;
......@@ -106,8 +111,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
capacity /= cpus; // average capacity of each cpu
for (ResCloudlet rcl : getCloudletExecList()) { // each machine in the
// exec list has the
// same amount of cpu
// exec list has the
// same amount of cpu
NetworkCloudlet cl = (NetworkCloudlet) rcl.getCloudlet();
......@@ -139,14 +144,14 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
List<HostPacket> pktlist = pktrecv.get(st.peer);
List<HostPacket> pkttoremove = new ArrayList<HostPacket>();
if (pktlist != null) {
Iterator it = pktlist.iterator();
Iterator<HostPacket> it = pktlist.iterator();
HostPacket pkt = null;
if (it.hasNext()) {
pkt = (HostPacket) it.next();
pkt = it.next();
if (pkt.reciever == cl.getVmId())// Asumption packet
// will not
// arrive in the
// same cycle
// will not
// arrive in the
// same cycle
{
pkt.recievetime = CloudSim.clock();
st.time = CloudSim.clock() - pkt.sendtime;
......@@ -180,11 +185,12 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
}
if (getCloudletExecList().size() == 0 && getCloudletWaitingList().size() == 0) { // no more
// cloudlets
// in
// this
// scheduler
if (getCloudletExecList().size() == 0 && getCloudletWaitingList().size() == 0) { // no
// more
// cloudlets
// in
// this
// scheduler
setPreviousTime(currentTime);
return 0.0;
}
......@@ -247,7 +253,6 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
}
private void changetonextstage(NetworkCloudlet cl, TaskStage st) {
// TODO Auto-generated method stub
cl.timespentInStage = 0;
cl.timetostartStage = CloudSim.clock();
int currstage = cl.currStagenum;
......@@ -255,7 +260,6 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
cl.currStagenum = NetworkConstants.FINISH;
} else {
cl.currStagenum = currstage + 1;
TaskStage st1 = cl.stages.get(cl.currStagenum);
int i = 0;
for (i = cl.currStagenum; i < cl.stages.size(); i++) {
if (cl.stages.get(i).type == NetworkConstants.WAIT_SEND) {
......@@ -302,7 +306,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Cancels execution of a cloudlet.
*
* @param cloudletId ID of the cloudlet being cancealed
* @param cloudletId
* ID of the cloudlet being cancealed
*
* @return the canceled cloudlet, $null if not found
*
......@@ -356,7 +361,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Pauses execution of a cloudlet.
*
* @param cloudletId ID of the cloudlet being paused
* @param cloudletId
* ID of the cloudlet being paused
*
* @return $true if cloudlet paused, $false otherwise
*
......@@ -420,7 +426,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Processes a finished cloudlet.
*
* @param rcl finished cloudlet
* @param rcl
* finished cloudlet
*
* @pre rgl != $null
* @post $none
......@@ -436,7 +443,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Resumes execution of a paused cloudlet.
*
* @param cloudletId ID of the cloudlet being resumed
* @param cloudletId
* ID of the cloudlet being resumed
*
* @return $true if the cloudlet was resumed, $false otherwise
*
......@@ -460,8 +468,9 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
if (found) {
ResCloudlet rcl = getCloudletPausedList().remove(position);
if ((currentCpus - usedPes) >= rcl.getNumberOfPes()) {// it can go to
// the exec list
if ((currentCpus - usedPes) >= rcl.getNumberOfPes()) {// it can go
// to
// the exec list
rcl.setCloudletStatus(Cloudlet.INEXEC);
for (int i = 0; i < rcl.getNumberOfPes(); i++) {
rcl.setMachineAndPeId(0, i);
......@@ -513,19 +522,24 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Receives an cloudlet to be executed in the VM managed by this scheduler.
*
* @param cloudlet the submited cloudlet
* @param fileTransferTime time required to move the required files from the SAN to the VM
* @param cloudlet
* the submited cloudlet
* @param fileTransferTime
* time required to move the required files from the SAN to the
* VM
*
* @return expected finish time of this cloudlet, or 0 if it is in the waiting queue
* @return expected finish time of this cloudlet, or 0 if it is in the
* waiting queue
*
* @pre gl != null
* @post $none
*/
@Override
public double cloudletSubmit(Cloudlet cloudlet, double fileTransferTime) {
if ((currentCpus - usedPes) >= cloudlet.getNumberOfPes()) {// it can go to
// the exec
// list
if ((currentCpus - usedPes) >= cloudlet.getNumberOfPes()) {// it can go
// to
// the exec
// list
ResCloudlet rcl = new ResCloudlet(cloudlet);
rcl.setCloudletStatus(Cloudlet.INEXEC);
for (int i = 0; i < cloudlet.getNumberOfPes(); i++) {
......@@ -577,7 +591,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Gets the status of a cloudlet.
*
* @param cloudletId ID of the cloudlet
* @param cloudletId
* ID of the cloudlet
*
* @return status of the cloudlet, -1 if cloudlet not found
*
......@@ -610,7 +625,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Get utilization created by all cloudlets.
*
* @param time the time
* @param time
* the time
*
* @return total utilization
*/
......@@ -624,9 +640,11 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
}
/**
* Informs about completion of some cloudlet in the VM managed by this scheduler.
* Informs about completion of some cloudlet in the VM managed by this
* scheduler.
*
* @return $true if there is at least one finished cloudlet; $false otherwise
* @return $true if there is at least one finished cloudlet; $false
* otherwise
*
* @pre $none
* @post $none
......@@ -637,7 +655,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
}
/**
* Returns the next cloudlet in the finished list, $null if this list is empty.
* Returns the next cloudlet in the finished list, $null if this list is
* empty.
*
* @return a finished cloudlet
*
......@@ -685,7 +704,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Gets the cloudlet waiting list.
*
* @param <T> the generic type
* @param <T>
* the generic type
* @return the cloudlet waiting list
*/
@SuppressWarnings("unchecked")
......@@ -696,8 +716,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Cloudlet waiting list.
*
* @param <T> the generic type
* @param cloudletWaitingList the cloudlet waiting list
* @param <T>
* the generic type
* @param cloudletWaitingList
* the cloudlet waiting list
*/
protected <T extends ResCloudlet> void cloudletWaitingList(List<T> cloudletWaitingList) {
this.cloudletWaitingList = cloudletWaitingList;
......@@ -706,7 +728,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Gets the cloudlet exec list.
*
* @param <T> the generic type
* @param <T>
* the generic type
* @return the cloudlet exec list
*/
@SuppressWarnings("unchecked")
......@@ -717,8 +740,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Sets the cloudlet exec list.
*
* @param <T> the generic type
* @param cloudletExecList the new cloudlet exec list
* @param <T>
* the generic type
* @param cloudletExecList
* the new cloudlet exec list
*/
protected <T extends ResCloudlet> void setCloudletExecList(List<T> cloudletExecList) {
this.cloudletExecList = cloudletExecList;
......@@ -727,7 +752,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Gets the cloudlet paused list.
*
* @param <T> the generic type
* @param <T>
* the generic type
* @return the cloudlet paused list
*/
@SuppressWarnings("unchecked")
......@@ -738,8 +764,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Sets the cloudlet paused list.
*
* @param <T> the generic type
* @param cloudletPausedList the new cloudlet paused list
* @param <T>
* the generic type
* @param cloudletPausedList
* the new cloudlet paused list
*/
protected <T extends ResCloudlet> void setCloudletPausedList(List<T> cloudletPausedList) {
this.cloudletPausedList = cloudletPausedList;
......@@ -748,7 +776,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Gets the cloudlet finished list.
*
* @param <T> the generic type
* @param <T>
* the generic type
* @return the cloudlet finished list
*/
@SuppressWarnings("unchecked")
......@@ -759,8 +788,10 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/**
* Sets the cloudlet finished list.
*
* @param <T> the generic type
* @param cloudletFinishedList the new cloudlet finished list
* @param <T>
* the generic type
* @param cloudletFinishedList
* the new cloudlet finished list
*/
protected <T extends ResCloudlet> void setCloudletFinishedList(List<T> cloudletFinishedList) {
this.cloudletFinishedList = cloudletFinishedList;
......@@ -785,7 +816,8 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/*
* (non-Javadoc)
*
* @see org.cloudbus.cloudsim.CloudletScheduler# getTotalCurrentAvailableMipsForCloudlet
* @see org.cloudbus.cloudsim.CloudletScheduler#
* getTotalCurrentAvailableMipsForCloudlet
* (org.cloudbus.cloudsim.ResCloudlet, java.util.List)
*/
@Override
......@@ -806,36 +838,34 @@ public class NetworkCloudletSpaceSharedScheduler extends CloudletScheduler {
/*
* (non-Javadoc)
*
* @see org.cloudbus.cloudsim.CloudletScheduler# getTotalCurrentAllocatedMipsForCloudlet
* @see org.cloudbus.cloudsim.CloudletScheduler#
* getTotalCurrentAllocatedMipsForCloudlet
* (org.cloudbus.cloudsim.ResCloudlet, double)
*/
@Override
public double getTotalCurrentAllocatedMipsForCloudlet(ResCloudlet rcl, double time) {
// TODO Auto-generated method stub
return 0.0;
}
/*
* (non-Javadoc)
*
* @see org.cloudbus.cloudsim.CloudletScheduler# getTotalCurrentRequestedMipsForCloudlet
* @see org.cloudbus.cloudsim.CloudletScheduler#
* getTotalCurrentRequestedMipsForCloudlet
* (org.cloudbus.cloudsim.ResCloudlet, double)
*/
@Override
public double getTotalCurrentRequestedMipsForCloudlet(ResCloudlet rcl, double time) {
// TODO Auto-generated method stub
return 0.0;
}
@Override
public double getCurrentRequestedUtilizationOfBw() {
// TODO Auto-generated method stub
return 0;
}
@Override
public double getCurrentRequestedUtilizationOfRam() {
// TODO Auto-generated method stub
return 0;
}
......
package org.cloudbus.cloudsim.network.datacenter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class NetworkConstants {
public static int maxhostVM = 2;
public static int HOST_PEs = 8;
public static int maxhostVM=2;
public static int HOST_PEs=8;
public static double maxMemperVM = 1024 * 1024;// kb
public static double maxMemperVM=1024*1024;//kb
public static int currentCloudletId = 0;
public static int currentAppId = 0;
// stage type
public static final int EXECUTION = 0;
public static final int WAIT_SEND = 1;
public static final int WAIT_RECV = 2;
public static final int FINISH = -2;
// number of switches at each level
public static final int ROOT_LEVEL = 0;
public static final int Agg_LEVEL = 1;
public static final int EDGE_LEVEL = 2;
public static int currentCloudletId=0;
public static int currentAppId=0;
public static final int PES_NUMBER = 4;
public static final int FILE_SIZE = 300;
public static final int OUTPUT_SIZE = 300;
public static final int COMMUNICATION_LENGTH = 1;
//stage type
public static final int EXECUTION=0;
public static final int WAIT_SEND=1;
public static final int WAIT_RECV=2;
public static final int FINISH=-2;
public static boolean BASE = true;
public static long BandWidthEdgeAgg = 100 * 1024 * 1024;// 100 Megabits
public static long BandWidthEdgeHost = 100 * 1024 * 1024;//
public static long BandWidthAggRoot = 20 * 1024 * 1024 * 2;// 40gb
public static double SwitchingDelayRoot = .00285;
public static double SwitchingDelayAgg = .00245;// .00245
public static double SwitchingDelayEdge = .00157;// ms
//number of switches at each level
public static final int ROOT_LEVEL=0;
public static final int Agg_LEVEL=1;
public static final int EDGE_LEVEL=2;
public static double EdgeSwitchPort = 4;// number of host
public static final int PES_NUMBER=4;
public static final int FILE_SIZE=300;
public static final int OUTPUT_SIZE=300;
public static double AggSwitchPort = 1;// number of Edge
public static final int COMMUNICATION_LENGTH=1;
public static double RootSwitchPort = 1;// number of Agg
public static boolean BASE = true;
public static double seed = 199;
public static boolean logflag = false;
public static long BandWidthEdgeAgg=100*1024*1024;//100 Megabits
public static long BandWidthEdgeHost=100*1024*1024;//
public static long BandWidthAggRoot=20*1024*1024*2;//40gb
public static int iteration = 10;
public static int nexttime = 1000;
public static double SwitchingDelayRoot=.00285;
public static double SwitchingDelayAgg=.00245;//.00245
public static double SwitchingDelayEdge=.00157;//ms
public static double EdgeSwitchPort=4;//number of host
public static double AggSwitchPort=1;//number of Edge
public static double RootSwitchPort=1;//number of Agg
public static double seed=199;
public static boolean logflag=false;
public static int iteration=10;
public static int nexttime=1000;
public static int totaldatatransfer=0;
public static int totaldatatransfer = 0;
}
......@@ -8,42 +8,33 @@ package org.cloudbus.cloudsim.network.datacenter;
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.CloudletScheduler;
import org.cloudbus.cloudsim.DataCloudTags;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.DatacenterCharacteristics;
import org.cloudbus.cloudsim.File;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.InfoPacket;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Storage;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicy;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.core.CloudSimTags;
import org.cloudbus.cloudsim.core.SimEntity;
import org.cloudbus.cloudsim.core.SimEvent;
/**
* NetworkDatacenter class is a Datacenter whose hostList are virtualized and
* networked. It contains all the information about internal network. For example,
* which VM is connected to Switch etc.
* It deals with processing of VM queries (i.e., handling of VMs)
* instead of processing Cloudlet-related queries. So, even though an
* AllocPolicy will be instantiated (in the init() method of the superclass, it
* will not be used, as processing of cloudlets are handled by the
* CloudletScheduler and processing of VirtualMachines are handled by the
* VmAllocationPolicy.
* networked. It contains all the information about internal network. For
* example, which VM is connected to Switch etc. It deals with processing of VM
* queries (i.e., handling of VMs) instead of processing Cloudlet-related
* queries. So, even though an AllocPolicy will be instantiated (in the init()
* method of the superclass, it will not be used, as processing of cloudlets are
* handled by the CloudletScheduler and processing of VirtualMachines are
* handled by the VmAllocationPolicy.
*
* Please refer to following publication for more details:
*
......@@ -57,38 +48,42 @@ import org.cloudbus.cloudsim.core.SimEvent;
*/
public class NetworkDatacenter extends Datacenter {
/**
* Allocates a new NetworkDatacenter object.
*
* @param name the name to be associated with this entity (as
* required by Sim_entity class from simjava package)
* @param characteristics an object of DatacenterCharacteristics
* @param storageList a LinkedList of storage elements, for data simulation
* @param vmAllocationPolicy the vmAllocationPolicy
*
* @throws Exception This happens when one of the following scenarios occur:
* <ul>
* <li> creating this entity before initializing CloudSim package
* <li> this entity name is <tt>null</tt> or empty
* <li> this entity has <tt>zero</tt> number of PEs (Processing
* Elements). <br>
* No PEs mean the Cloudlets can't be processed.
* A CloudResource must contain one or more Machines.
* A Machine must contain one or more PEs.
* </ul>
*
*
* @param name
* the name to be associated with this entity (as required by
* Sim_entity class from simjava package)
* @param characteristics
* an object of DatacenterCharacteristics
* @param storageList
* a LinkedList of storage elements, for data simulation
* @param vmAllocationPolicy
* the vmAllocationPolicy
*
* @throws Exception
* This happens when one of the following scenarios occur:
* <ul>
* <li>creating this entity before initializing CloudSim package
* <li>this entity name is <tt>null</tt> or empty
* <li>this entity has <tt>zero</tt> number of PEs (Processing
* Elements). <br>
* No PEs mean the Cloudlets can't be processed. A CloudResource
* must contain one or more Machines. A Machine must contain one
* or more PEs.
* </ul>
*
* @pre name != null
* @pre resource != null
* @post $none
*/
public NetworkDatacenter(String name,
public NetworkDatacenter(
String name,
DatacenterCharacteristics characteristics,
VmAllocationPolicy vmAllocationPolicy, List<Storage> storageList,
VmAllocationPolicy vmAllocationPolicy,
List<Storage> storageList,
double schedulingInterval) throws Exception {
super(name, characteristics, vmAllocationPolicy, storageList,
schedulingInterval);
// TODO Auto-generated constructor stub
super(name, characteristics, vmAllocationPolicy, storageList, schedulingInterval);
VmToSwitchid = new HashMap<Integer, Integer>();
HostToSwitchid = new HashMap<Integer, Integer>();
VmtoHostlist = new HashMap<Integer, Integer>();
......@@ -102,9 +97,9 @@ public class NetworkDatacenter extends Datacenter {
public Map<Integer, Integer> VmtoHostlist;
/**
* Get list of all EdgeSwitches in the Datacenter network
* One can design similar functions for other type of switches.
*
* Get list of all EdgeSwitches in the Datacenter network One can design
* similar functions for other type of switches.
*
*/
public Map<Integer, Switch> getEdgeSwitch() {
Map<Integer, Switch> edgeswitch = new HashMap<Integer, Switch>();
......@@ -116,23 +111,21 @@ public class NetworkDatacenter extends Datacenter {
return edgeswitch;
}
/**
* Create the VM within the NetworkDatacenter.
* It can be directly accessed by Datacenter Broker
* which manage allocation of Cloudlets.
*
*
*/
* Create the VM within the NetworkDatacenter. It can be directly accessed
* by Datacenter Broker which manage allocation of Cloudlets.
*
*
*/
public boolean processVmCreateNetwork(Vm vm) {
boolean result = getVmAllocationPolicy().allocateHostForVm(vm);
if (result) {
this.VmToSwitchid.put(vm.getId(),
((NetworkHost) vm.getHost()).sw.getId());
this.VmToSwitchid.put(vm.getId(), ((NetworkHost) vm.getHost()).sw.getId());
this.VmtoHostlist.put(vm.getId(), vm.getHost().getId());
System.out.println(vm.getId() + " VM is created on "
+ vm.getHost().getId());
System.out.println(vm.getId() + " VM is created on " + vm.getHost().getId());
double amount = 0.0;
if (getDebts().containsKey(vm.getUserId())) {
amount = getDebts().get(vm.getUserId());
......@@ -144,22 +137,24 @@ public class NetworkDatacenter extends Datacenter {
getVmList().add(vm);
vm.updateVmProcessing(CloudSim.clock(), getVmAllocationPolicy()
.getHost(vm).getVmScheduler().getAllocatedMipsForVm(vm));
vm.updateVmProcessing(CloudSim.clock(), getVmAllocationPolicy().getHost(vm).getVmScheduler()
.getAllocatedMipsForVm(vm));
}
return result;
}
/**
* Processes a Cloudlet submission.
*
* @param ev a SimEvent object
* @param ack an acknowledgement
*
* @pre ev != null
* @post $none
*/
/**
* Processes a Cloudlet submission.
*
* @param ev
* a SimEvent object
* @param ack
* an acknowledgement
*
* @pre ev != null
* @post $none
*/
@Override
protected void processCloudletSubmit(SimEvent ev, boolean ack) {
updateCloudletProcessing();
......@@ -170,8 +165,7 @@ public class NetworkDatacenter extends Datacenter {
// checks whether this Cloudlet has finished or not
if (cl.isFinished()) {
String name = CloudSim.getEntityName(cl.getUserId());
Log.printLine(getName() + ": Warning - Cloudlet #"
+ cl.getCloudletId() + " owned by " + name
Log.printLine(getName() + ": Warning - Cloudlet #" + cl.getCloudletId() + " owned by " + name
+ " is already completed/finished.");
Log.printLine("Therefore, it is not being executed again");
Log.printLine();
......@@ -198,27 +192,29 @@ public class NetworkDatacenter extends Datacenter {
}
// process this Cloudlet to this CloudResource
cl.setResourceParameter(getId(), getCharacteristics()
.getCostPerSecond(), getCharacteristics().getCostPerBw());
cl.setResourceParameter(getId(), getCharacteristics().getCostPerSecond(), getCharacteristics()
.getCostPerBw());
int userId = cl.getUserId();
int vmId = cl.getVmId();
double fileTransferTime = predictFileTransferTime(cl
.getRequiredFiles()); // time to transfer the files
double fileTransferTime = predictFileTransferTime(cl.getRequiredFiles()); // time
// to
// transfer
// the
// files
Host host = getVmAllocationPolicy().getHost(vmId, userId);
Vm vm = host.getVm(vmId, userId);
CloudletScheduler scheduler = vm.getCloudletScheduler();
// System.out.println("cloudlet recieved by VM"+vmId);
double estimatedFinishTime = scheduler.cloudletSubmit(cl,
fileTransferTime);
double estimatedFinishTime = scheduler.cloudletSubmit(cl, fileTransferTime);
// if (estimatedFinishTime > 0.0 && estimatedFinishTime <
// getSchedulingInterval()) { //if this cloudlet is in the exec
// queue
if (estimatedFinishTime > 0.0) { // if this cloudlet is in the exec
// queue
// queue
// double estimatedFinishTime =
// (cl.getCloudletTotalLength()/(capacity*cl.getPesNumber()));
// //time to process the cloudlet
......@@ -226,8 +222,7 @@ public class NetworkDatacenter extends Datacenter {
estimatedFinishTime += fileTransferTime;
// estimatedFinishTime += CloudSim.clock();
// Log.printLine(CloudSim.clock()+": Next event scheduled to +"+estimatedFinishTime);
send(getId(), estimatedFinishTime,
CloudSimTags.VM_DATACENTER_EVENT);
send(getId(), estimatedFinishTime, CloudSimTags.VM_DATACENTER_EVENT);
// event to update the stages
send(getId(), 0.0001, CloudSimTags.VM_DATACENTER_EVENT);
......@@ -244,12 +239,10 @@ public class NetworkDatacenter extends Datacenter {
sendNow(cl.getUserId(), tag, data);
}
} catch (ClassCastException c) {
Log.printLine(getName() + ".processCloudletSubmit(): "
+ "ClassCastException error.");
Log.printLine(getName() + ".processCloudletSubmit(): " + "ClassCastException error.");
c.printStackTrace();
} catch (Exception e) {
Log.printLine(getName() + ".processCloudletSubmit(): "
+ "Exception error.");
Log.printLine(getName() + ".processCloudletSubmit(): " + "Exception error.");
e.printStackTrace();
}
......
......@@ -9,13 +9,10 @@
package org.cloudbus.cloudsim.network.datacenter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmScheduler;
......@@ -27,11 +24,11 @@ import org.cloudbus.cloudsim.provisioners.BwProvisioner;
import org.cloudbus.cloudsim.provisioners.RamProvisioner;
/**
* NetworkHost class extends Host to support simulation of networked datacenters.
* It executes actions related to management of packets (send and receive)other than that of
* virtual machines (e.g., creation and destruction). A host has a defined
* policy for provisioning memory and bw, as well as an allocation policy for
* Pe's to virtual machines.
* NetworkHost class extends Host to support simulation of networked
* datacenters. It executes actions related to management of packets (send and
* receive)other than that of virtual machines (e.g., creation and destruction).
* A host has a defined policy for provisioning memory and bw, as well as an
* allocation policy for Pe's to virtual machines.
*
* Please refer to following publication for more details:
*
......@@ -39,10 +36,10 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner;
* Applications in Cloud Simulations, Proceedings of the 4th IEEE/ACM
* International Conference on Utility and Cloud Computing (UCC 2011, IEEE CS
* Press, USA), Melbourne, Australia, December 5-7, 2011.
*
*
*
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit 1.0
* @since CloudSim Toolkit 3.0
*/
public class NetworkHost extends Host {
......@@ -50,20 +47,24 @@ public class NetworkHost extends Host {
public List<NetworkPacket> packetTosendGlobal;
public List<NetworkPacket> packetrecieved;
public double memory;
public Switch sw; //Edge switch in general
public Switch sw; // Edge switch in general
public double bandwidth;// latency
public List<Double> CPUfinTimeCPU = new ArrayList<Double>();// time when
// last job will
// finish on
// CPU1
// last job will
// finish on
// CPU1
public double fintime = 0;
public NetworkHost(int id, RamProvisioner ramProvisioner,
BwProvisioner bwProvisioner, long storage,
List<? extends Pe> peList, VmScheduler vmScheduler) {
public NetworkHost(
int id,
RamProvisioner ramProvisioner,
BwProvisioner bwProvisioner,
long storage,
List<? extends Pe> peList,
VmScheduler vmScheduler) {
super(id, ramProvisioner, bwProvisioner, storage, peList, vmScheduler);
this.packetrecieved = new ArrayList<NetworkPacket>();
this.packetTosendGlobal = new ArrayList<NetworkPacket>();
this.packetTosendLocal = new ArrayList<NetworkPacket>();
......@@ -79,11 +80,12 @@ public class NetworkHost extends Host {
*
* @return expected time of completion of the next cloudlet in all VMs in
* this host. Double.MAX_VALUE if there is no future events expected
* in th is host
* in th is host
*
* @pre currentTime >= 0.0
* @post $none
*/
@Override
public double updateVmsProcessing(double currentTime) {
double smallerTime = Double.MAX_VALUE;
// insert in each vm packet recieved
......@@ -93,18 +95,19 @@ public class NetworkHost extends Host {
// continue;
// }
double time = ((NetworkVm) vm).updateVmProcessing(currentTime,
getVmScheduler().getAllocatedMipsForVm(vm));
double time = ((NetworkVm) vm).updateVmProcessing(currentTime, getVmScheduler()
.getAllocatedMipsForVm(vm));
if (time > 0.0 && time < smallerTime) {
smallerTime = time;
}
}
//send the packets to other hosts/VMs
// send the packets to other hosts/VMs
sendpackets();
return smallerTime;
}
/**
* Receives packet and forward it to the corresponding VM for processing
* host.
......@@ -112,49 +115,49 @@ public class NetworkHost extends Host {
*
*/
private void recvpackets() {
for (NetworkPacket hs : packetrecieved) {
// hs.stime=hs.rtime;
hs.pkt.recievetime = CloudSim.clock();
// insertthe packet in recievedlist of VM
Vm vm = VmList.getById(getVmList(), hs.pkt.reciever);
List<HostPacket> pktlist = ((NetworkCloudletSpaceSharedScheduler) vm
.getCloudletScheduler()).pktrecv.get(hs.pkt.sender);
List<HostPacket> pktlist = ((NetworkCloudletSpaceSharedScheduler) vm.getCloudletScheduler()).pktrecv
.get(hs.pkt.sender);
if (pktlist == null) {
pktlist = new ArrayList<HostPacket>();
((NetworkCloudletSpaceSharedScheduler) vm.getCloudletScheduler()).pktrecv
.put(hs.pkt.sender, pktlist);
((NetworkCloudletSpaceSharedScheduler) vm.getCloudletScheduler()).pktrecv.put(
hs.pkt.sender,
pktlist);
}
pktlist.add(hs.pkt);
}
packetrecieved.clear();
}
/**
* Send packet check whether a packet belongs to a local VM or to a VM hosted on other machine.
* Send packet check whether a packet belongs to a local VM or to a VM
* hosted on other machine.
*
*
*/
private void sendpackets() {
for (Vm vm : super.getVmList()) {
for (Entry<Integer, List<HostPacket>> es : ((NetworkCloudletSpaceSharedScheduler) vm
.getCloudletScheduler()).pkttosend.entrySet())
{
.getCloudletScheduler()).pkttosend.entrySet()) {
List<HostPacket> pktlist = es.getValue();
for (HostPacket pkt : pktlist) {
NetworkPacket hpkt = new NetworkPacket(this.getId(), pkt,
vm.getId(), pkt.sender);
Vm vm2 = VmList
.getById(this.getVmList(), hpkt.recievervmid);
if (vm2 != null)
NetworkPacket hpkt = new NetworkPacket(this.getId(), pkt, vm.getId(), pkt.sender);
Vm vm2 = VmList.getById(this.getVmList(), hpkt.recievervmid);
if (vm2 != null) {
this.packetTosendLocal.add(hpkt);
else
} else {
this.packetTosendGlobal.add(hpkt);
}
}
pktlist.clear();
......@@ -172,12 +175,13 @@ public class NetworkHost extends Host {
Vm vm = VmList.getById(getVmList(), hs.pkt.reciever);
// Vm vm=getVmList().get(hs.pkt.reciever);
List<HostPacket> pktlist = ((NetworkCloudletSpaceSharedScheduler) vm
.getCloudletScheduler()).pktrecv.get(hs.pkt.sender);
List<HostPacket> pktlist = ((NetworkCloudletSpaceSharedScheduler) vm.getCloudletScheduler()).pktrecv
.get(hs.pkt.sender);
if (pktlist == null) {
pktlist = new ArrayList<HostPacket>();
((NetworkCloudletSpaceSharedScheduler) vm.getCloudletScheduler()).pktrecv
.put(hs.pkt.sender, pktlist);
((NetworkCloudletSpaceSharedScheduler) vm.getCloudletScheduler()).pktrecv.put(
hs.pkt.sender,
pktlist);
}
pktlist.add(hs.pkt);
......@@ -188,14 +192,14 @@ public class NetworkHost extends Host {
// continue;
// }
double time = ((NetworkVm) vm).updateVmProcessing(CloudSim
.clock(), getVmScheduler().getAllocatedMipsForVm(vm));
vm.updateVmProcessing(CloudSim.clock(), getVmScheduler().getAllocatedMipsForVm(vm));
}
}
//Sending packet to other VMs therefore packet is forwarded to a Edge switch
// Sending packet to other VMs therefore packet is forwarded to a Edge
// switch
this.packetTosendLocal.clear();
double avband = this.bandwidth / packetTosendGlobal.size();
for (NetworkPacket hs : packetTosendGlobal) {
......@@ -203,16 +207,19 @@ public class NetworkHost extends Host {
NetworkConstants.totaldatatransfer += hs.pkt.data;
// System.out.println(hs.pkt.virtualsendid+" "+hs.pkt.virtualrecvid+" "+hs.pkt.data);
CloudSim.send(this.getDatacenter().getId(), this.sw.getId(), delay,
CloudSimTags.Network_Event_UP, hs);
CloudSim.send(
this.getDatacenter().getId(),
this.sw.getId(),
delay,
CloudSimTags.Network_Event_UP,
hs);
// send to switch with delay
}
this.packetTosendGlobal.clear();
}
@SuppressWarnings("unchecked")
public double getMaxUtilizationAmongVmsPes(Vm vm) {
return PeList.getMaxUtilizationAmongVmsPes((List<Pe>) getPeList(), vm);
return PeList.getMaxUtilizationAmongVmsPes(getPeList(), vm);
}
}
package org.cloudbus.cloudsim.network.datacenter;
import java.util.ArrayList;
import java.util.List;
import org.cloudbus.cloudsim.CloudletScheduler;
import org.cloudbus.cloudsim.Vm;
/**
* NetworkVm class extends Vm to support simulation of networked datacenters.
* It executes actions related to management of packets (send and receive).
* NetworkVm class extends Vm to support simulation of networked datacenters. It
* executes actions related to management of packets (send and receive).
*
* Please refer to following publication for more details:
*
......@@ -16,19 +15,26 @@ import org.cloudbus.cloudsim.Vm;
* Applications in Cloud Simulations, Proceedings of the 4th IEEE/ACM
* International Conference on Utility and Cloud Computing (UCC 2011, IEEE CS
* Press, USA), Melbourne, Australia, December 5-7, 2011.
*
*
*
* @author Saurabh Kumar Garg
* @since CloudSim Toolkit 1.0
* @since CloudSim Toolkit 3.0
*/
public class NetworkVm extends Vm implements Comparable {
public class NetworkVm extends Vm implements Comparable<Object> {
public NetworkVm(
int id,
int userId,
double mips,
int pesNumber,
int ram,
long bw,
long size,
String vmm,
CloudletScheduler cloudletScheduler) {
super(id, userId, mips, pesNumber, ram, bw, size, vmm, cloudletScheduler);
public NetworkVm(int id, int userId, double mips, int pesNumber, int ram,
long bw, long size, String vmm, CloudletScheduler cloudletScheduler) {
super(id, userId, mips, pesNumber, ram, bw, size, vmm,
cloudletScheduler);
// TODO Auto-generated constructor stub
cloudletlist = new ArrayList<NetworkCloudlet>();
}
......@@ -45,10 +51,12 @@ public class NetworkVm extends Vm implements Comparable {
public int compareTo(Object arg0) {
NetworkVm hs = (NetworkVm) arg0;
if (hs.finishtime > this.finishtime)
if (hs.finishtime > this.finishtime) {
return -1;
if (hs.finishtime < this.finishtime)
}
if (hs.finishtime < this.finishtime) {
return 1;
}
return 0;
}
}
......@@ -4,9 +4,9 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Map.Entry;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Vm;
......@@ -67,30 +67,7 @@ public class Switch extends SimEntity {
public Switch(String name, int level, NetworkDatacenter dc) {
super(name);
this.level = level;
/*
* if(level==Constants.EDGE_LEVEL) { hostlist=new HashMap<Integer,HPCHost>();
* uplinkswitchpktlist=new HashMap<Integer,List<HostPacket>>(); packetTohost=new
* HashMap<Integer,List<HostPacket>>(); uplinkbandwidth=Constants.BandWidthEdgeAgg;
* downlinkbandwidth=Constants.BandWidthEdgeHost; latency=Constants.SwitchingDelayEdge;
* numport=Constants.EdgeSwitchPort; uplinkswitches=new ArrayList<Switch>();
*
* } if(level==Constants.Agg_LEVEL) { downlinkswitchpktlist=new
* HashMap<Integer,List<HostPacket>>(); uplinkswitchpktlist=new
* HashMap<Integer,List<HostPacket>>(); uplinkbandwidth=Constants.BandWidthAggRoot;
* downlinkbandwidth=Constants.BandWidthEdgeAgg; latency=Constants.SwitchingDelayAgg;
* numport=Constants.AggSwitchPort; uplinkswitches=new ArrayList<Switch>();
* downlinkswitches=new ArrayList<Switch>(); } if(level==Constants.ROOT_LEVEL) {
* downlinkswitchpktlist=new HashMap<Integer,List<HostPacket>>(); downlinkswitches=new
* ArrayList<Switch>();
*
* downlinkbandwidth=Constants.BandWidthAggRoot; latency=Constants.SwitchingDelayRoot;
* numport=Constants.RootSwitchPort;
*
* }
*/
this.dc = dc;
// TODO Auto-generated constructor stub
}
@Override
......@@ -104,34 +81,33 @@ public class Switch extends SimEntity {
// Log.printLine(CloudSim.clock()+"[Broker]: event received:"+ev.getTag());
switch (ev.getTag()) {
// Resource characteristics request
case CloudSimTags.Network_Event_UP:
// process the packet from down switch or host
processpacket_up(ev);
break;
case CloudSimTags.Network_Event_DOWN:
// process the packet from uplink
processpacket_down(ev);
break;
case CloudSimTags.Network_Event_send:
processpacketforward(ev);
break;
case CloudSimTags.Network_Event_Host:
processhostpacket(ev);
break;
// Resource characteristics answer
case CloudSimTags.RESOURCE_Register:
registerHost(ev);
break;
// other unknown tags are processed by this method
default:
processOtherEvent(ev);
break;
case CloudSimTags.Network_Event_UP:
// process the packet from down switch or host
processpacket_up(ev);
break;
case CloudSimTags.Network_Event_DOWN:
// process the packet from uplink
processpacket_down(ev);
break;
case CloudSimTags.Network_Event_send:
processpacketforward(ev);
break;
case CloudSimTags.Network_Event_Host:
processhostpacket(ev);
break;
// Resource characteristics answer
case CloudSimTags.RESOURCE_Register:
registerHost(ev);
break;
// other unknown tags are processed by this method
default:
processOtherEvent(ev);
break;
}
}
protected void processhostpacket(SimEvent ev) {
// TODO Auto-generated method stub
// Send packet to host
NetworkPacket hspkt = (NetworkPacket) ev.getData();
NetworkHost hs = hostlist.get(hspkt.recieverhostid);
......@@ -139,7 +115,6 @@ public class Switch extends SimEntity {
}
protected void processpacket_down(SimEvent ev) {
// TODO Auto-generated method stub
// packet coming from up level router.
// has to send downward
// check which switch to forward to
......@@ -178,7 +153,6 @@ public class Switch extends SimEntity {
}
protected void processpacket_up(SimEvent ev) {
// TODO Auto-generated method stub
// packet coming from down level router.
// has to send up
// check which switch to forward to
......@@ -277,13 +251,11 @@ public class Switch extends SimEntity {
}
private void registerHost(SimEvent ev) {
// TODO Auto-generated method stub
NetworkHost hs = (NetworkHost) ev.getData();
hostlist.put(hs.getId(), (NetworkHost) ev.getData());
}
protected void processpacket(SimEvent ev) {
// TODO Auto-generated method stub
// send packet to itself with switching delay (discarding other)
CloudSim.cancelAll(getId(), new PredicateType(CloudSimTags.Network_Event_UP));
schedule(getId(), switching_delay, CloudSimTags.Network_Event_UP);
......@@ -294,12 +266,10 @@ public class Switch extends SimEntity {
}
private void processOtherEvent(SimEvent ev) {
// TODO Auto-generated method stub
}
protected void processpacketforward(SimEvent ev) {
// TODO Auto-generated method stub
// search for the host and packets..send to them
if (downlinkswitchpktlist != null) {
......@@ -338,8 +308,6 @@ public class Switch extends SimEntity {
}
if (packetTohost != null) {
for (Entry<Integer, List<NetworkPacket>> es : packetTohost.entrySet()) {
int tosend = es.getKey();
NetworkHost hs = hostlist.get(tosend);
List<NetworkPacket> hspktlist = es.getValue();
if (!hspktlist.isEmpty()) {
double avband = downlinkbandwidth / hspktlist.size();
......@@ -360,8 +328,11 @@ public class Switch extends SimEntity {
}
private NetworkHost getHostwithVM(int vmid) {
// TODO Auto-generated method stub
//
// R: We changed visibility of the below methods from private to protected.
//
protected NetworkHost getHostwithVM(int vmid) {
for (Entry<Integer, NetworkHost> es : hostlist.entrySet()) {
Vm vm = VmList.getById(es.getValue().getVmList(), vmid);
if (vm != null) {
......@@ -371,8 +342,7 @@ public class Switch extends SimEntity {
return null;
}
private List<NetworkVm> getfreeVmlist(int numVMReq) {
// TODO Auto-generated method stub
protected List<NetworkVm> getfreeVmlist(int numVMReq) {
List<NetworkVm> freehostls = new ArrayList<NetworkVm>();
for (Entry<Integer, NetworkVm> et : Vmlist.entrySet()) {
if (et.getValue().isFree()) {
......@@ -386,8 +356,7 @@ public class Switch extends SimEntity {
return freehostls;
}
private List<NetworkHost> getfreehostlist(int numhost) {
// TODO Auto-generated method stub
protected List<NetworkHost> getfreehostlist(int numhost) {
List<NetworkHost> freehostls = new ArrayList<NetworkHost>();
for (Entry<Integer, NetworkHost> et : hostlist.entrySet()) {
if (et.getValue().getNumberOfFreePes() == et.getValue().getNumberOfPes()) {
......
......@@ -22,67 +22,112 @@ import org.cloudbus.cloudsim.UtilizationModel;
import org.cloudbus.cloudsim.UtilizationModelFull;
import org.cloudbus.cloudsim.core.CloudSim;
public class WorkflowApp extends AppCloudlet{
public class WorkflowApp extends AppCloudlet {
public WorkflowApp(int type, int appID, double deadline,
int numbervm, int userId) {
super(type, appID, deadline, numbervm, userId);
// TODO Auto-generated constructor stub
this.exeTime=100;
this.numbervm=3;
public WorkflowApp(int type, int appID, double deadline, int numbervm, int userId) {
super(type, appID, deadline, numbervm, userId);
this.exeTime = 100;
this.numbervm = 3;
}
public void createCloudletList(List<Integer> vmIdList){
@Override
public void createCloudletList(List<Integer> vmIdList) {
long fileSize = NetworkConstants.FILE_SIZE;
long outputSize = NetworkConstants.OUTPUT_SIZE;
int pesNumber = NetworkConstants.PES_NUMBER;
int memory=100;
int memory = 100;
UtilizationModel utilizationModel = new UtilizationModelFull();
int i=0;
//Task A
NetworkCloudlet cl = new NetworkCloudlet(NetworkConstants.currentCloudletId, 0, 1, fileSize, outputSize, memory, utilizationModel, utilizationModel, utilizationModel);
cl.numStage=2;
NetworkConstants.currentCloudletId++;
cl.setUserId(userId);
cl.submittime=CloudSim.clock();
cl.currStagenum=-1;
cl.setVmId(vmIdList.get(i));
//first stage: big computation
cl.stages.add(new TaskStage(NetworkConstants.EXECUTION, 0, 1000*0.8, 0, memory, vmIdList.get(0),cl.getCloudletId()));
cl.stages.add(new TaskStage(NetworkConstants.WAIT_SEND, 1000, 0, 1, memory, vmIdList.get(2),cl.getCloudletId()+2));
clist.add(cl);
i++;
//Task B
NetworkCloudlet clb = new NetworkCloudlet(NetworkConstants.currentCloudletId, 0, 1, fileSize, outputSize, memory, utilizationModel, utilizationModel, utilizationModel);
clb.numStage=2;
NetworkConstants.currentCloudletId++;
clb.setUserId(userId);
clb.submittime=CloudSim.clock();
clb.currStagenum=-1;
clb.setVmId(vmIdList.get(i));
//first stage: big computation
clb.stages.add(new TaskStage(NetworkConstants.EXECUTION, 0, 1000*0.8, 0, memory, vmIdList.get(1),clb.getCloudletId()));
clb.stages.add(new TaskStage(NetworkConstants.WAIT_SEND, 1000, 0, 1, memory, vmIdList.get(2),clb.getCloudletId()+1));
clist.add(clb);
i++;
//Task C
NetworkCloudlet clc = new NetworkCloudlet(NetworkConstants.currentCloudletId, 0, 1, fileSize, outputSize, memory, utilizationModel, utilizationModel, utilizationModel);
clc.numStage=2;
NetworkConstants.currentCloudletId++;
clc.setUserId(userId);
clc.submittime=CloudSim.clock();
clc.currStagenum=-1;
clc.setVmId(vmIdList.get(i));
//first stage: big computation
clc.stages.add(new TaskStage(NetworkConstants.WAIT_RECV, 1000, 0, 0, memory, vmIdList.get(0),cl.getCloudletId()));
clc.stages.add(new TaskStage(NetworkConstants.WAIT_RECV, 1000, 0, 1, memory, vmIdList.get(1),cl.getCloudletId()+1));
clc.stages.add(new TaskStage(NetworkConstants.EXECUTION, 0, 1000*0.8, 1, memory, vmIdList.get(0),clc.getCloudletId()));
clist.add(clc);
int i = 0;
// Task A
NetworkCloudlet cl = new NetworkCloudlet(
NetworkConstants.currentCloudletId,
0,
1,
fileSize,
outputSize,
memory,
utilizationModel,
utilizationModel,
utilizationModel);
cl.numStage = 2;
NetworkConstants.currentCloudletId++;
cl.setUserId(userId);
cl.submittime = CloudSim.clock();
cl.currStagenum = -1;
cl.setVmId(vmIdList.get(i));
// first stage: big computation
cl.stages.add(new TaskStage(NetworkConstants.EXECUTION, 0, 1000 * 0.8, 0, memory, vmIdList.get(0), cl
.getCloudletId()));
cl.stages.add(new TaskStage(NetworkConstants.WAIT_SEND, 1000, 0, 1, memory, vmIdList.get(2), cl
.getCloudletId() + 2));
clist.add(cl);
i++;
// Task B
NetworkCloudlet clb = new NetworkCloudlet(
NetworkConstants.currentCloudletId,
0,
1,
fileSize,
outputSize,
memory,
utilizationModel,
utilizationModel,
utilizationModel);
clb.numStage = 2;
NetworkConstants.currentCloudletId++;
clb.setUserId(userId);
clb.submittime = CloudSim.clock();
clb.currStagenum = -1;
clb.setVmId(vmIdList.get(i));
// first stage: big computation
clb.stages.add(new TaskStage(
NetworkConstants.EXECUTION,
0,
1000 * 0.8,
0,
memory,
vmIdList.get(1),
clb.getCloudletId()));
clb.stages.add(new TaskStage(NetworkConstants.WAIT_SEND, 1000, 0, 1, memory, vmIdList.get(2), clb
.getCloudletId() + 1));
clist.add(clb);
i++;
// Task C
NetworkCloudlet clc = new NetworkCloudlet(
NetworkConstants.currentCloudletId,
0,
1,
fileSize,
outputSize,
memory,
utilizationModel,
utilizationModel,
utilizationModel);
clc.numStage = 2;
NetworkConstants.currentCloudletId++;
clc.setUserId(userId);
clc.submittime = CloudSim.clock();
clc.currStagenum = -1;
clc.setVmId(vmIdList.get(i));
// first stage: big computation
clc.stages.add(new TaskStage(NetworkConstants.WAIT_RECV, 1000, 0, 0, memory, vmIdList.get(0), cl
.getCloudletId()));
clc.stages.add(new TaskStage(NetworkConstants.WAIT_RECV, 1000, 0, 1, memory, vmIdList.get(1), cl
.getCloudletId() + 1));
clc.stages.add(new TaskStage(
NetworkConstants.EXECUTION,
0,
1000 * 0.8,
1,
memory,
vmIdList.get(0),
clc.getCloudletId()));
clist.add(clc);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment