本文整理汇总了Java中org.cloudbus.cloudsim.Cloudlet类的典型用法代码示例。如果您正苦于以下问题:Java Cloudlet类的具体用法?Java Cloudlet怎么用?Java Cloudlet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cloudlet类属于org.cloudbus.cloudsim包,在下文中一共展示了Cloudlet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCloudlet
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
private static List<Cloudlet> createCloudlet(int userId, int cloudlets){
// Creates a container to store Cloudlets
LinkedList<Cloudlet> list = new LinkedList<Cloudlet>();
//cloudlet parameters
long length ;
long fileSize = 300;
long outputSize = 300;
int pesNumber = 1;
UtilizationModel utilizationModel = new UtilizationModelFull();
Random r1 = new Random(1);
// Random r2 = new Random(2);
Cloudlet[] cloudlet = new Cloudlet[cloudlets];
for(int i=0;i<cloudlets;i++){
length = 100 + r1.nextInt(900);
// fileSize = 100 + r2.nextInt(200);
cloudlet[i] = new Cloudlet(i, length, pesNumber, fileSize, outputSize, utilizationModel, utilizationModel, utilizationModel);
// setting the owner of these Cloudlets
cloudlet[i].setUserId(userId);
list.add(cloudlet[i]);
}
return list;
}
示例2: main
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
/**
* The main method.
*
* @param args the arguments
* @throws IOException Signals that an I/O exception has occurred.
*/
public static void main(String[] args) throws IOException {
String experimentName = "planetlab_npa";
String outputFolder = "output";
String inputFolder = NonPowerAware.class.getClassLoader().getResource("workload/planetlab/20110303")
.getPath();
Log.setDisabled(!Constants.ENABLE_OUTPUT);
Log.printLine("Starting " + experimentName);
try {
CloudSim.init(1, Calendar.getInstance(), false);
DatacenterBroker broker = Helper.createBroker();
int brokerId = broker.getId();
List<Cloudlet> cloudletList = PlanetLabHelper.createCloudletListPlanetLab(brokerId, inputFolder);
List<Vm> vmList = Helper.createVmList(brokerId, cloudletList.size());
List<PowerHost> hostList = Helper.createHostList(PlanetLabConstants.NUMBER_OF_HOSTS);
PowerDatacenterNonPowerAware datacenter = (PowerDatacenterNonPowerAware) Helper.createDatacenter(
"Datacenter",
PowerDatacenterNonPowerAware.class,
hostList,
new PowerVmAllocationPolicySimple(hostList));
datacenter.setDisableMigrations(true);
broker.submitVmList(vmList);
broker.submitCloudletList(cloudletList);
CloudSim.terminateSimulation(Constants.SIMULATION_LIMIT);
double lastClock = CloudSim.startSimulation();
List<Cloudlet> newList = broker.getCloudletReceivedList();
Log.printLine("Received " + newList.size() + " cloudlets");
CloudSim.stopSimulation();
Helper.printResults(
datacenter,
vmList,
lastClock,
experimentName,
Constants.OUTPUT_CSV,
outputFolder);
} catch (Exception e) {
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an unexpected error");
System.exit(0);
}
Log.printLine("Finished " + experimentName);
}
示例3: NetDatacenterBroker
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
/**
* Created a new DatacenterBroker object.
*
* @param name name to be associated with this entity (as required by Sim_entity class from
* simjava package)
*
* @throws Exception the exception
*
* @pre name != null
* @post $none
*/
public NetDatacenterBroker(String name) throws Exception {
super(name);
setVmList(new ArrayList<NetworkVm>());
setVmsCreatedList(new ArrayList<NetworkVm>());
setCloudletList(new ArrayList<NetworkCloudlet>());
setAppCloudletList(new ArrayList<AppCloudlet>());
setCloudletSubmittedList(new ArrayList<Cloudlet>());
setCloudletReceivedList(new ArrayList<Cloudlet>());
appCloudletRecieved = new HashMap<Integer, Integer>();
cloudletsSubmitted = 0;
setVmsRequested(0);
setVmsAcks(0);
setVmsDestroyed(0);
setDatacenterIdsList(new LinkedList<Integer>());
setDatacenterRequestedIdsList(new ArrayList<Integer>());
setVmsToDatacentersMap(new HashMap<Integer, Integer>());
setDatacenterCharacteristicsList(new HashMap<Integer, DatacenterCharacteristics>());
}
示例4: processCloudletReturn
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
/**
* Process a cloudlet return event.
*
* @param ev a SimEvent object
*
* @pre ev != $null
* @post $none
*/
protected void processCloudletReturn(SimEvent ev) {
Cloudlet cloudlet = (Cloudlet) ev.getData();
getCloudletReceivedList().add(cloudlet);
cloudletsSubmitted--;
// all cloudlets executed
if (getCloudletList().size() == 0 && cloudletsSubmitted == 0 && NetworkConstants.iteration > 10) {
Log.printLine(CloudSim.clock() + ": " + getName() + ": All Cloudlets executed. Finishing...");
clearDatacenters();
finishExecution();
} else { // some cloudlets haven't finished yet
if (getAppCloudletList().size() > 0 && cloudletsSubmitted == 0) {
// all the cloudlets sent finished. It means that some bount
// cloudlet is waiting its VM be created
clearDatacenters();
createVmsInDatacenterBase(0);
}
}
}
示例5: checkCloudletCompletion
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
@Override
protected void checkCloudletCompletion() {
if(!nos.isApplicationDeployed())
{
super.checkCloudletCompletion();
return;
}
List<? extends Host> list = getVmAllocationPolicy().getHostList();
for (int i = 0; i < list.size(); i++) {
Host host = list.get(i);
for (Vm vm : host.getVmList()) {
while (vm.getCloudletScheduler().isFinishedCloudlets()) {
Cloudlet cl = vm.getCloudletScheduler().getNextFinishedCloudlet();
if (cl != null) {
int hostAddress = nos.getHostAddressByVmId(cl.getVmId());
sendNow(hostAddress, CloudSimTags.CLOUDLET_RETURN, cl);
}
}
}
}
}
示例6: printCloudletList
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
public static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;
Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.print(String.format(fString, "Cloudlet_ID"));
Log.print(String.format(fString, "STATUS" ));
Log.print(String.format(fString, "DataCenter_ID"));
Log.print(String.format(fString, "VM_ID"));
Log.print(String.format(fString, "Length"));
Log.print(String.format(fString, "Time"));
Log.print(String.format(fString, "Start Time"));
Log.print(String.format(fString, "Finish Time"));
Log.print("\n");
//DecimalFormat dft = new DecimalFormat("######.##");
for (int i = 0; i < size; i++) {
cloudlet = list.get(i);
printCloudlet(cloudlet);
}
}
示例7: printCloudlet
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
private static void printCloudlet(Cloudlet cloudlet) {
Log.print(String.format(fInt, cloudlet.getCloudletId()));
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
Log.print(String.format(fString, "SUCCESS"));
Log.print(String.format(fInt, cloudlet.getResourceId()));
Log.print(String.format(fInt, cloudlet.getVmId()));
Log.print(String.format(fInt, cloudlet.getCloudletLength()));
Log.print(String.format(fFloat, cloudlet.getActualCPUTime()));
Log.print(String.format(fFloat, cloudlet.getExecStartTime()));
Log.print(String.format(fFloat, cloudlet.getFinishTime()));
Log.print("\n");
}
else {
Log.printLine("FAILED");
}
}
示例8: processActivity
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
private void processActivity(Activity ac, Request req, int vmId) {
if(ac instanceof Transmission) {
Transmission tr = (Transmission)ac;
Package pkg = tr.getPackage();
//send package to router via channel (NOS)
nos.addPackageToChannel(this, pkg);
pkg.setStartTime(CloudSim.clock());
}
else if(ac instanceof Processing) {
Cloudlet cl = ((Processing) ac).getCloudlet();
cl.setVmId(vmId);
requestsTable.put(cl, req);
sendNow(host.getDatacenter().getId(),CloudSimTags.CLOUDLET_SUBMIT,cl);
} else {
Log.printLine(CloudSim.clock() + ": " + getName() + ": Activity is unknown..");
}
}
示例9: output
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
public void output(){
try {
// Final step: Print hosts' total utilization.
List<Host> hostList = nos.getHostList();
printEnergyConsumption(hostList);
//Final step: Print results when simulation is over
List<Cloudlet> newList = broker.getCloudletReceivedList();
printCloudletList(newList);
List<Workload> wls = broker.getWorkloads();
printWorkloadList(wls);
append("CloudSim SDN finished!");
} catch (Exception e) {
e.printStackTrace();
append("====== OUTPUT ERROR ======");
}
}
示例10: printCloudletList
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
private void printCloudletList(List<Cloudlet> list) {
int size = list.size();
String content = "";
Cloudlet cloudlet;
append("");
append("========== OUTPUT ==========");
content = String.format(fString, "Cloudlet_ID") +
String.format(fString, "STATUS" ) +
String.format(fString, "DataCenter_ID") +
String.format(fString, "VM_ID") +
String.format(fString, "Length") +
String.format(fString, "Time") +
String.format(fString, "Start Time") +
String.format(fString, "Finish Time");
append(content);
//DecimalFormat dft = new DecimalFormat("######.##");
for (int i = 0; i < size; i++) {
cloudlet = list.get(i);
printCloudlet(cloudlet);
}
}
示例11: printCloudlet
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
private void printCloudlet(Cloudlet cloudlet) {
String content = String.format(fInt, cloudlet.getCloudletId());
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
content = content +
String.format(fString, "SUCCESS") +
String.format(fInt, cloudlet.getResourceId()) +
String.format(fInt, cloudlet.getVmId()) +
String.format(fInt, cloudlet.getCloudletLength()) +
String.format(fFloat, cloudlet.getActualCPUTime()) +
String.format(fFloat, cloudlet.getExecStartTime()) +
String.format(fFloat, cloudlet.getFinishTime());
}
else {
content += "FAILED";
}
append(content);
}
示例12: createJob
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
/**
* Creates a Gridlet with the given information and adds to the list
*
* @param id a Gridlet ID
* @param submitTime Gridlet's submit time
* @param runTime Gridlet's run time
* @param numProc number of processors
* @param reqRunTime user estimated run time
* @param userID user id
* @param groupID user's group id
* @pre id >= 0
* @pre submitTime >= 0
* @pre runTime >= 0
* @pre numProc > 0
* @post $none
*/
private void createJob(
final int id,
final long submitTime,
final int runTime,
final int numProc,
final int reqRunTime,
final int userID,
final int groupID) {
// create the cloudlet
final int len = runTime * rating;
UtilizationModel utilizationModel = new UtilizationModelFull();
final Cloudlet wgl = new Cloudlet(
id,
len,
numProc,
0,
0,
utilizationModel,
utilizationModel,
utilizationModel);
jobs.add(wgl);
}
示例13: sort
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
/**
* Sorts the Cloudlets in a list based on their lengths.
*
* @param cloudletList the cloudlet list
* @pre $none
* @post $none
*/
public static <T extends Cloudlet> void sort(List<T> cloudletList) {
Collections.sort(cloudletList, new Comparator<T>() {
/**
* Compares two objects.
*
* @param a the first Object to be compared
* @param b the second Object to be compared
* @return the value 0 if both Objects are numerically equal; a value less than 0 if the
* first Object is numerically less than the second Object; and a value greater
* than 0 if the first Object is numerically greater than the second Object.
* @throws ClassCastException <tt>a</tt> and <tt>b</tt> are expected to be of type
* <tt>Cloudlet</tt>
* @pre a != null
* @pre b != null
* @post $none
*/
@Override
public int compare(T a, T b) throws ClassCastException {
Double cla = Double.valueOf(a.getCloudletTotalLength());
Double clb = Double.valueOf(b.getCloudletTotalLength());
return cla.compareTo(clb);
}
});
}
示例14: printCloudletList
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
/**
* Prints a list of cloudlets in a formatted way in the configured log
*
* @param list
* the list of cloudlets
*/
public static void printCloudletList(List<Cloudlet> list) {
int size = list.size();
Cloudlet cloudlet;
DecimalFormat fmt = new DecimalFormat("0.0000");
Log.printLine("Cloudlets: " + list.size());
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + "\t" + "STATUS" + "\t" + "Lenght" + "\t" + "Data center ID" + "\t" + "VM ID"
+ "\t" + "Time" + "\t" + "Arrival" + "\t" + "Start" + "\t" + "Finish");
for (int i = 0; i < size; i++) {
cloudlet = list.get(i);
Log.print(cloudlet.getCloudletId() + "\t");
if (cloudlet.getCloudletStatusString().equals(Cloudlet.getStatusString(Cloudlet.SUCCESS))) {
Log.print("SUCCESS");
Log.printLine("\t" + cloudlet.getCloudletLength() + "\t" + cloudlet.getResourceId() + "\t#"
+ cloudlet.getVmId() + "\t" + fmt.format(cloudlet.getActualCPUTime()).replace('.', ',') + "\t"
+ fmt.format(cloudlet.getSubmissionTime()).replace('.', ',') + "\t"
+ fmt.format(cloudlet.getExecStartTime()).replace('.', ',') + "\t"
+ fmt.format(cloudlet.getFinishTime()).replace('.', ','));
}
}
}
示例15: checkCloudletTransmissionCompletion
import org.cloudbus.cloudsim.Cloudlet; //导入依赖的package包/类
/**
* Verifies if some cloudlet inside this Datacenter already finished to be
* transmitted. If yes, send it to the User/Broker
*
* @pre $none
* @post $none
*/
// OK
protected void checkCloudletTransmissionCompletion() {
List<? extends Host> list = getVmAllocationPolicy().getHostList();
for (int i = 0; i < list.size(); i++) {
Host host = list.get(i);
for (Vm vm : host.getVmList()) {
while (((PSCloudletSchedulerSpaceShared) vm.getCloudletScheduler()).isTransmittedCloudlets()) {
Cloudlet cl = ((PSCloudletSchedulerSpaceShared) vm.getCloudletScheduler())
.getNextTransmittedCloudlet();
if (cl != null) {
sendNow(cl.getUserId(), PSCloudSimTags.CLOUDLET_TRANSMITTED, cl);
}
}
}
}
}