Commit 225d6749 authored by Anton Beloglazov's avatar Anton Beloglazov

Updated the javadocs, headers, code formatting, and Maven configuration (new…

Updated the javadocs, headers, code formatting, and Maven configuration (new versions of the dependencies)
parent 62de8e30
......@@ -16,7 +16,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<executions>
<execution>
<phase>install</phase>
......
......@@ -14,6 +14,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cloudsim</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
......
......@@ -15,6 +15,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>docs</id>
......@@ -33,12 +34,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<version>2.8</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.2</version>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.sonatype.maven.plugin</groupId>
......@@ -48,7 +49,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.5</version>
<version>2.11</version>
</plugin>
</plugins>
</reporting>
......
......@@ -3,7 +3,7 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
......@@ -11,10 +11,9 @@ package org.cloudbus.cloudsim;
import java.util.List;
/**
* CloudletScheduler is an abstract class that represents the policy of
* scheduling performed by a virtual machine. So, classes
* extending this must execute Cloudlets. Also, the interface for cloudlet
* management is also implemented in this class.
* CloudletScheduler is an abstract class that represents the policy of scheduling performed by a
* virtual machine. So, classes extending this must execute Cloudlets. Also, the interface for
* cloudlet management is also implemented in this class.
*
* @author Rodrigo N. Calheiros
* @author Anton Beloglazov
......@@ -29,8 +28,8 @@ public abstract class CloudletScheduler {
private List<Double> currentMipsShare;
/**
* Creates a new CloudletScheduler object. This method must be invoked
* before starting the actual simulation.
* Creates a new CloudletScheduler object. This method must be invoked before starting the
* actual simulation.
*
* @pre $none
* @post $none
......@@ -44,10 +43,8 @@ public abstract class CloudletScheduler {
*
* @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
*/
......@@ -58,9 +55,7 @@ public abstract class CloudletScheduler {
*
* @param gl 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 a waiting queue
*
* @pre gl != null
* @post $none
*/
......@@ -70,9 +65,7 @@ public abstract class CloudletScheduler {
* Receives an cloudlet to be executed in the VM managed by this scheduler.
*
* @param gl the submited cloudlet
*
* @return expected finish time of this cloudlet, or 0 if it is in a waiting queue
*
* @pre gl != null
* @post $none
*/
......@@ -82,9 +75,7 @@ public abstract class CloudletScheduler {
* Cancels execution of a cloudlet.
*
* @param clId ID of the cloudlet being cancealed
*
* @return the canceled cloudlet, $null if not found
*
* @pre $none
* @post $none
*/
......@@ -94,9 +85,7 @@ public abstract class CloudletScheduler {
* Pauses execution of a cloudlet.
*
* @param clId ID of the cloudlet being paused
*
* @return $true if cloudlet paused, $false otherwise
*
* @pre $none
* @post $none
*/
......@@ -106,9 +95,7 @@ public abstract class CloudletScheduler {
* Resumes execution of a paused cloudlet.
*
* @param clId ID of the cloudlet being resumed
*
* @return expected finish time of the cloudlet, 0.0 if queued
*
* @pre $none
* @post $none
*/
......@@ -118,7 +105,6 @@ public abstract class CloudletScheduler {
* Processes a finished cloudlet.
*
* @param rcl finished cloudlet
*
* @pre rgl != $null
* @post $none
*/
......@@ -128,20 +114,16 @@ public abstract class CloudletScheduler {
* Gets the status of a cloudlet.
*
* @param clId ID of the cloudlet
*
* @return status of the cloudlet, -1 if cloudlet not found
*
* @pre $none
* @post $none
*/
public abstract int getCloudletStatus(int clId);
/**
* 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
*
* @pre $none
* @post $none
*/
......@@ -151,7 +133,6 @@ public abstract class CloudletScheduler {
* Returns the next cloudlet in the finished list, $null if this list is empty.
*
* @return a finished cloudlet
*
* @pre $none
* @post $none
*/
......@@ -161,7 +142,6 @@ public abstract class CloudletScheduler {
* Returns the number of cloudlets runnning in the virtual machine.
*
* @return number of cloudlets runnning
*
* @pre $none
* @post $none
*/
......@@ -171,7 +151,6 @@ public abstract class CloudletScheduler {
* Returns one cloudlet to migrate to another vm.
*
* @return one running cloudlet
*
* @pre $none
* @post $none
*/
......@@ -181,7 +160,6 @@ public abstract class CloudletScheduler {
* Get utilization created by all cloudlets.
*
* @param time the time
*
* @return total utilization
*/
public abstract double getTotalUtilizationOfCpu(double time);
......@@ -198,7 +176,6 @@ public abstract class CloudletScheduler {
*
* @param rcl the rcl
* @param mipsShare the mips share
*
* @return the total current mips
*/
public abstract double getTotalCurrentAvailableMipsForCloudlet(ResCloudlet rcl, List<Double> mipsShare);
......@@ -208,7 +185,6 @@ public abstract class CloudletScheduler {
*
* @param rcl the rcl
* @param time the time
*
* @return the total current requested mips for cloudlet
*/
public abstract double getTotalCurrentRequestedMipsForCloudlet(ResCloudlet rcl, double time);
......@@ -218,7 +194,6 @@ public abstract class CloudletScheduler {
*
* @param rcl the rcl
* @param time the time
*
* @return the total current allocated mips for cloudlet
*/
public abstract double getTotalCurrentAllocatedMipsForCloudlet(ResCloudlet rcl, double time);
......
......@@ -2,7 +2,7 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
......@@ -59,10 +59,8 @@ public class CloudletSchedulerDynamicWorkload extends CloudletSchedulerTimeShare
*
* @param currentTime current simulation time
* @param mipsShare array with MIPS share of each Pe available to the scheduler
*
* @return time predicted completion time of the earliest finishing cloudlet, or 0 if there is
* no next events
*
* @pre currentTime >= 0
* @post $none
*/
......@@ -110,9 +108,7 @@ public class CloudletSchedulerDynamicWorkload extends CloudletSchedulerTimeShare
* Receives an cloudlet to be executed in the VM managed by this scheduler.
*
* @param cl the cl
*
* @return predicted completion time
*
* @pre _gl != null
* @post $none
*/
......@@ -126,9 +122,7 @@ public class CloudletSchedulerDynamicWorkload extends CloudletSchedulerTimeShare
*
* @param cl the cl
* @param fileTransferTime the file transfer time
*
* @return predicted completion time
*
* @pre _gl != null
* @post $none
*/
......@@ -149,7 +143,6 @@ public class CloudletSchedulerDynamicWorkload extends CloudletSchedulerTimeShare
* Processes a finished cloudlet.
*
* @param rcl finished cloudlet
*
* @pre rgl != $null
* @post $none
*/
......@@ -164,7 +157,6 @@ public class CloudletSchedulerDynamicWorkload extends CloudletSchedulerTimeShare
* Get utilization created by all cloudlets.
*
* @param time the time
*
* @return total utilization
*/
@Override
......@@ -205,7 +197,6 @@ public class CloudletSchedulerDynamicWorkload extends CloudletSchedulerTimeShare
*
* @param rcl the rcl
* @param time the time
*
* @return the current mips
*/
@Override
......@@ -218,7 +209,6 @@ public class CloudletSchedulerDynamicWorkload extends CloudletSchedulerTimeShare
*
* @param rcl the rcl
* @param mipsShare the mips share
*
* @return the total current mips
*/
@Override
......@@ -242,7 +232,6 @@ public class CloudletSchedulerDynamicWorkload extends CloudletSchedulerTimeShare
*
* @param rcl the rcl
* @param time the time
*
* @return the current mips
*/
@Override
......
/*
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
......@@ -14,8 +13,7 @@ import java.util.List;
import org.cloudbus.cloudsim.core.CloudSim;
/**
* CloudletSchedulerTimeShared implements a policy of
* scheduling performed by a virtual machine.
* CloudletSchedulerTimeShared implements a policy of scheduling performed by a virtual machine.
* Cloudlets execute time-shared in VM.
*
* @author Rodrigo N. Calheiros
......@@ -37,18 +35,18 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
protected int currentCPUs;
/**
* Creates a new CloudletSchedulerTimeShared object. This method must be invoked
* before starting the actual simulation.
* Creates a new CloudletSchedulerTimeShared object. This method must be invoked before starting
* the actual simulation.
*
* @pre $none
* @post $none
*/
public CloudletSchedulerTimeShared() {
super();
this.cloudletExecList = new ArrayList<ResCloudlet>();
this.cloudletPausedList = new ArrayList<ResCloudlet>();
this.cloudletFinishedList = new ArrayList<ResCloudlet>();
this.currentCPUs = 0;
cloudletExecList = new ArrayList<ResCloudlet>();
cloudletPausedList = new ArrayList<ResCloudlet>();
cloudletFinishedList = new ArrayList<ResCloudlet>();
currentCPUs = 0;
}
/**
......@@ -56,10 +54,8 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
*
* @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
*/
......@@ -79,7 +75,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
// check finished cloudlets
double nextEvent = Double.MAX_VALUE;
int i = 0;
List<ResCloudlet> toRemove = new ArrayList<ResCloudlet>();
for (ResCloudlet rcl : getCloudletExecList()) {
long remainingLength = rcl.getRemainingCloudletLength();
......@@ -88,14 +83,13 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
cloudletFinish(rcl);
continue;
}
i++;
}
getCloudletExecList().removeAll(toRemove);
//estimate finish time of cloudlets
i=0;
// estimate finish time of cloudlets
for (ResCloudlet rcl : getCloudletExecList()) {
double estimatedFinishTime = currentTime + (rcl.getRemainingCloudletLength() / (getCapacity(mipsShare) * rcl.getNumberOfPes()));
double estimatedFinishTime = currentTime
+ (rcl.getRemainingCloudletLength() / (getCapacity(mipsShare) * rcl.getNumberOfPes()));
if (estimatedFinishTime - currentTime < 0.1) {
estimatedFinishTime = currentTime + 0.1;
}
......@@ -103,7 +97,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
if (estimatedFinishTime < nextEvent) {
nextEvent = estimatedFinishTime;
}
i++;
}
setPreviousTime(currentTime);
......@@ -114,7 +107,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
* Gets the capacity.
*
* @param mipsShare the mips share
*
* @return the capacity
*/
private double getCapacity(List<Double> mipsShare) {
......@@ -145,9 +137,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
* Cancels execution of a cloudlet.
*
* @param cloudletId ID of the cloudlet being cancealed
*
* @return the canceled cloudlet, $null if not found
*
* @pre $none
* @post $none
*/
......@@ -212,9 +202,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
* Pauses execution of a cloudlet.
*
* @param cloudletId ID of the cloudlet being paused
*
* @return $true if cloudlet paused, $false otherwise
*
* @pre $none
* @post $none
*/
......@@ -249,7 +237,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
* Processes a finished cloudlet.
*
* @param rcl finished cloudlet
*
* @pre rgl != $null
* @post $none
*/
......@@ -264,9 +251,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
* Resumes execution of a paused cloudlet.
*
* @param cloudletId ID of the cloudlet being resumed
*
* @return expected finish time of the cloudlet, 0.0 if queued
*
* @pre $none
* @post $none
*/
......@@ -293,7 +278,8 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
// first: how many PEs do we have?
double remainingLength = rgl.getRemainingCloudletLength();
double estimatedFinishTime = CloudSim.clock() + (remainingLength / (getCapacity(getCurrentMipsShare()) * rgl.getNumberOfPes()));
double estimatedFinishTime = CloudSim.clock()
+ (remainingLength / (getCapacity(getCurrentMipsShare()) * rgl.getNumberOfPes()));
return estimatedFinishTime;
}
......@@ -306,9 +292,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
*
* @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
*
* @pre gl != null
* @post $none
*/
......@@ -331,7 +315,8 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
return cloudlet.getCloudletLength() / getCapacity(getCurrentMipsShare());
}
/* (non-Javadoc)
/*
* (non-Javadoc)
* @see cloudsim.CloudletScheduler#cloudletSubmit(cloudsim.Cloudlet)
*/
@Override
......@@ -343,9 +328,7 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
* Gets the status of a cloudlet.
*
* @param cloudletId ID of the cloudlet
*
* @return status of the cloudlet, -1 if cloudlet not found
*
* @pre $none
* @post $none
*/
......@@ -368,7 +351,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
* Get utilization created by all cloudlets.
*
* @param time the time
*
* @return total utilization
*/
@Override
......@@ -381,11 +363,9 @@ public class CloudletSchedulerTimeShared 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
*
* @pre $none
* @post $none
*/
......@@ -398,7 +378,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
* Returns the next cloudlet in the finished list, $null if this list is empty.
*
* @return a finished cloudlet
*
* @pre $none
* @post $none
*/
......@@ -414,7 +393,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
* Returns the number of cloudlets runnning in the virtual machine.
*
* @return number of cloudlets runnning
*
* @pre $none
* @post $none
*/
......@@ -427,7 +405,6 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
* Returns one cloudlet to migrate to another vm.
*
* @return one running cloudlet
*
* @pre $none
* @post $none
*/
......@@ -501,44 +478,43 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
this.cloudletFinishedList = cloudletFinishedList;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
* @see cloudsim.CloudletScheduler#getCurrentRequestedMips()
*/
@Override
public List<Double> getCurrentRequestedMips() {
List<Double> mipsShare = new ArrayList<Double>();
// if (getCurrentMipsShare() != null) {
// for (Double mips : getCurrentMipsShare()) {
// mipsShare.add(mips);
// }
// }
//TODO: implement
return mipsShare;
}
/* (non-Javadoc)
* @see cloudsim.CloudletScheduler#getTotalCurrentAvailableMipsForCloudlet(cloudsim.ResCloudlet, java.util.List)
/*
* (non-Javadoc)
* @see cloudsim.CloudletScheduler#getTotalCurrentAvailableMipsForCloudlet(cloudsim.ResCloudlet,
* java.util.List)
*/
@Override
public double getTotalCurrentAvailableMipsForCloudlet(ResCloudlet rcl, List<Double> mipsShare) {
return getCapacity(getCurrentMipsShare());
}
/* (non-Javadoc)
* @see cloudsim.CloudletScheduler#getTotalCurrentAllocatedMipsForCloudlet(cloudsim.ResCloudlet, double)
/*
* (non-Javadoc)
* @see cloudsim.CloudletScheduler#getTotalCurrentAllocatedMipsForCloudlet(cloudsim.ResCloudlet,
* double)
*/
@Override
public double getTotalCurrentAllocatedMipsForCloudlet(ResCloudlet rcl,
double time) {
public double getTotalCurrentAllocatedMipsForCloudlet(ResCloudlet rcl, double time) {
return 0.0;
}
/* (non-Javadoc)
* @see cloudsim.CloudletScheduler#getTotalCurrentRequestedMipsForCloudlet(cloudsim.ResCloudlet, double)
/*
* (non-Javadoc)
* @see cloudsim.CloudletScheduler#getTotalCurrentRequestedMipsForCloudlet(cloudsim.ResCloudlet,
* double)
*/
@Override
public double getTotalCurrentRequestedMipsForCloudlet(ResCloudlet rcl,
double time) {
public double getTotalCurrentRequestedMipsForCloudlet(ResCloudlet rcl, double time) {
// TODO Auto-generated method stub
return 0.0;
}
......
......@@ -2,7 +2,7 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
......@@ -65,7 +65,6 @@ public class Datacenter extends SimEntity {
* @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
......@@ -74,7 +73,6 @@ public class Datacenter extends SimEntity {
* 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
......@@ -124,14 +122,12 @@ public class Datacenter extends SimEntity {
* Processes events or services that are available for this PowerDatacenter.
*
* @param ev a Sim_event object
*
* @pre ev != null
* @post $none
*/
@Override
public void processEvent(SimEvent ev) {
int srcId = -1;
// Log.printLine(CloudSim.clock()+"[PowerDatacenter]: event received:"+ev.getTag());
switch (ev.getTag()) {
// Resource characteristics inquiry
......@@ -357,7 +353,6 @@ public class Datacenter extends SimEntity {
* Processes a ping request.
*
* @param ev a Sim_event object
*
* @pre ev != null
* @post $none
*/
......@@ -375,7 +370,6 @@ public class Datacenter extends SimEntity {
* PowerDatacenter will then send the status back to the User/Broker.
*
* @param ev a Sim_event object
*
* @pre ev != null
* @post $none
*/
......@@ -430,7 +424,6 @@ public class Datacenter extends SimEntity {
* method.
*
* @param ev the received event
*
* @pre $none
* @post $none
*/
......@@ -446,7 +439,6 @@ public class Datacenter extends SimEntity {
*
* @param ev a Sim_event object
* @param ack the ack
*
* @pre ev != null
* @post $none
*/
......@@ -497,7 +489,6 @@ public class Datacenter extends SimEntity {
*
* @param ev a Sim_event object
* @param ack the ack
*
* @pre ev != null
* @post $none
*/
......@@ -581,7 +572,6 @@ public class Datacenter extends SimEntity {
*
* @param ev a Sim_event object
* @param type event type
*
* @pre ev != null
* @pre type > 0
* @post $none
......@@ -648,7 +638,6 @@ public class Datacenter extends SimEntity {
*
* @param receivedData information about the migration
* @param type event tag
*
* @pre receivedData != null
* @pre type > 0
* @post $none
......@@ -690,11 +679,8 @@ public class Datacenter extends SimEntity {
if (vm == null) {
failed = true;
} else {
double fileTransferTime = predictFileTransferTime(cl.getRequiredFiles()); // time
// to
// transfer
// the
// files
// time to transfer the files
double fileTransferTime = predictFileTransferTime(cl.getRequiredFiles());
vm.getCloudletScheduler().cloudletSubmit(cl, fileTransferTime);
}
} else {// the cloudlet will migrate from one resource to another
......@@ -722,7 +708,6 @@ public class Datacenter extends SimEntity {
*
* @param ev a SimEvent object
* @param ack an acknowledgement
*
* @pre ev != null
* @post $none
*/
......@@ -769,29 +754,17 @@ public class Datacenter extends SimEntity {
int userId = cl.getUserId();
int vmId = cl.getVmId();
double fileTransferTime = predictFileTransferTime(cl.getRequiredFiles()); // time to
// transfer
// the files
// time to transfer the files
double fileTransferTime = predictFileTransferTime(cl.getRequiredFiles());
Host host = getVmAllocationPolicy().getHost(vmId, userId);
Vm vm = host.getVm(vmId, userId);
CloudletScheduler scheduler = vm.getCloudletScheduler();
double estimatedFinishTime = scheduler.cloudletSubmit(cl, fileTransferTime);
// if (estimatedFinishTime > 0.0 && estimatedFinishTime < getSchedulingInterval()) {
// //if this cloudlet is in the exec queue
if (estimatedFinishTime > 0.0 && !Double.isInfinite(estimatedFinishTime)) { // if this
// cloudlet
// is in the
// exec
// queue
// double estimatedFinishTime =
// (cl.getCloudletTotalLength()/(capacity*cl.getPesNumber())); //time to process the
// cloudlet
// Log.printLine(estimatedFinishTime+"="+gl.getCloudletLength()+"/("+capacity+"*"+gl.getNumPE()+")");
// if this cloudlet is in the exec queue
if (estimatedFinishTime > 0.0 && !Double.isInfinite(estimatedFinishTime)) {
estimatedFinishTime += fileTransferTime;
// estimatedFinishTime += CloudSim.clock();
// Log.printLine(CloudSim.clock()+": Next event scheduled to +"+estimatedFinishTime);
send(getId(), estimatedFinishTime, CloudSimTags.VM_DATACENTER_EVENT);
}
......@@ -820,7 +793,6 @@ public class Datacenter extends SimEntity {
* Predict file transfer time.
*
* @param requiredFiles the required files
*
* @return the double
*/
protected double predictFileTransferTime(List<String> requiredFiles) {
......@@ -848,7 +820,6 @@ public class Datacenter extends SimEntity {
* @param userId ID of the cloudlet's owner
* @param ack $true if an ack is requested after operation
* @param vmId the vm id
*
* @pre $none
* @post $none
*/
......@@ -884,7 +855,6 @@ public class Datacenter extends SimEntity {
* @param userId ID of the cloudlet's owner
* @param ack $true if an ack is requested after operation
* @param vmId the vm id
*
* @pre $none
* @post $none
*/
......@@ -911,7 +881,6 @@ public class Datacenter extends SimEntity {
* @param cloudletId resuming cloudlet ID
* @param userId ID of the cloudlet's owner
* @param vmId the vm id
*
* @pre $none
* @post $none
*/
......@@ -931,7 +900,6 @@ public class Datacenter extends SimEntity {
* @post $none
*/
protected void updateCloudletProcessing() {
// Log.printLine(CloudSim.clock()+": PowerDatacenter #: updating cloudlet processing.......................................");
// if some time passed since last processing
// R: for term is to allow loop at simulation start. Otherwise, one initial
// simulation step is skipped and schedulers are not properly initialized
......@@ -941,8 +909,8 @@ public class Datacenter extends SimEntity {
// for each host...
for (int i = 0; i < list.size(); i++) {
Host host = list.get(i);
double time = host.updateVmsProcessing(CloudSim.clock());// inform VMs to update
// processing
// inform VMs to update processing
double time = host.updateVmsProcessing(CloudSim.clock());
// what time do we expect that the next cloudlet will finish?
if (time < smallerTime) {
smallerTime = time;
......@@ -986,7 +954,6 @@ public class Datacenter extends SimEntity {
* file, then it will be registered to the RC when the experiment begins.
*
* @param file a DataCloud file
*
* @return a tag number denoting whether this operation is a success or not
*/
public int addFile(File file) {
......@@ -1022,7 +989,6 @@ public class Datacenter extends SimEntity {
* Checks whether the resource has the given file.
*
* @param file a file to be searched
*
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
protected boolean contains(File file) {
......@@ -1036,7 +1002,6 @@ public class Datacenter extends SimEntity {
* Checks whether the resource has the given file.
*
* @param fileName a file name to be searched
*
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
protected boolean contains(String fileName) {
......@@ -1064,7 +1029,6 @@ public class Datacenter extends SimEntity {
* the storage.
*
* @param fileName the name of the file to be deleted
*
* @return the error message
*/
private int deleteFileFromStorage(String fileName) {
......@@ -1102,7 +1066,6 @@ public class Datacenter extends SimEntity {
/*
* (non-Javadoc)
*
* @see cloudsim.core.SimEntity#shutdownEntity()
*/
@Override
......@@ -1112,7 +1075,6 @@ public class Datacenter extends SimEntity {
/*
* (non-Javadoc)
*
* @see cloudsim.core.SimEntity#startEntity()
*/
@Override
......
......@@ -3,7 +3,7 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
......@@ -15,10 +15,9 @@ import org.cloudbus.cloudsim.lists.HostList;
import org.cloudbus.cloudsim.lists.PeList;
/**
* DatacenterCharacteristics represents static properties of a
* resource such as resource architecture, Operating System (OS), management
* policy (time- or space-shared), cost and time zone at which the resource
* is located along resource configuration.
* DatacenterCharacteristics represents static properties of a resource such as resource
* architecture, Operating System (OS), management policy (time- or space-shared), cost and time
* zone at which the resource is located along resource configuration.
*
* @author Manzur Murshed
* @author Rajkumar Buyya
......@@ -58,7 +57,10 @@ public class DatacenterCharacteristics {
/** Assuming all PEs in all Machines have the same rating. */
public static final int OTHER_POLICY_SAME_RATING = 2;
/** Assuming all PEs in a Machine have the same rating. However, each Machine has different rating to each other. */
/**
* Assuming all PEs in a Machine have the same rating. However, each Machine has different
* rating to each other.
*/
public static final int OTHER_POLICY_DIFFERENT_RATING = 3;
/** A resource that supports Advanced Reservation mechanisms. */
......@@ -77,20 +79,19 @@ public class DatacenterCharacteristics {
private double costPerBw;
/**
* Allocates a new DatacenterCharacteristics object.
* If the time zone is invalid, then by default, it will be GMT+0.
* Allocates a new DatacenterCharacteristics object. If the time zone is invalid, then by
* default, it will be GMT+0.
*
* @param architecture the architecture of a resource
* @param os the operating system used
* @param vmm the virtual machine monitor used
* @param hostList list of machines in a resource
* @param timeZone local time zone of a user that owns this reservation.
* Time zone should be of range [GMT-12 ... GMT+13]
* @param timeZone local time zone of a user that owns this reservation. Time zone should be of
* range [GMT-12 ... GMT+13]
* @param costPerSec the cost per sec to use this resource
* @param costPerMem the cost to use memory in this resource
* @param costPerStorage the cost to use storage in this resource
* @param costPerBw the cost per bw
*
* @pre architecture != null
* @pre OS != null
* @pre VMM != null
......@@ -126,12 +127,10 @@ public class DatacenterCharacteristics {
setCostPerBw(costPerBw);
}
/**
* Gets the name of a resource.
*
* @return the resource name
*
* @pre $none
* @post $result != null
*/
......@@ -163,8 +162,8 @@ public class DatacenterCharacteristics {
}
/**
* Gets Millions Instructions Per Second (MIPS) Rating of a Processing
* Element (Pe). It is assumed all PEs' rating is same in a given machine.
* Gets Millions Instructions Per Second (MIPS) Rating of a Processing Element (Pe). It is
* assumed all PEs' rating is same in a given machine.
*
* @return the MIPS Rating or if no PEs are exists.
* @pre $none
......@@ -179,10 +178,8 @@ public class DatacenterCharacteristics {
}
/**
* Gets Millions Instructions Per Second (MIPS) Rating of a Processing
* Element (Pe).
* It is essential to use this method when a resource is made up
* of heterogenous PEs/machines.
* Gets Millions Instructions Per Second (MIPS) Rating of a Processing Element (Pe). It is
* essential to use this method when a resource is made up of heterogenous PEs/machines.
*
* @param id the machine ID
* @param peId the Pe ID
......@@ -200,8 +197,7 @@ public class DatacenterCharacteristics {
}
/**
* Gets the total MIPS rating, which is the sum of MIPS rating of all
* machines in a resource.
* Gets the total MIPS rating, which is the sum of MIPS rating of all machines in a resource.
* <p>
* Total MIPS rating for:
* <ul>
......@@ -209,12 +205,10 @@ public class DatacenterCharacteristics {
* <li>Other policy same rating = same as TimeShared
* <li>SpaceShared = Sum of all PEs in all Machines
* <li>Other policy different rating = same as SpaceShared
* <li>Advance Reservation = 0 or unknown.
* You need to calculate this manually.
* <li>Advance Reservation = 0 or unknown. You need to calculate this manually.
* </ul>
*
* @return the sum of MIPS ratings
*
* @pre $none
* @post $result >= 0
*/
......@@ -244,15 +238,12 @@ public class DatacenterCharacteristics {
}
/**
* Gets the CPU time given the specified parameters (only for TIME_SHARED).
* <tt>NOTE:</tt> The CPU time for SPACE_SHARED and ADVANCE_RESERVATION
* are not yet implemented.
* Gets the CPU time given the specified parameters (only for TIME_SHARED). <tt>NOTE:</tt> The
* CPU time for SPACE_SHARED and ADVANCE_RESERVATION are not yet implemented.
*
* @param cloudletLength the length of a Cloudlet
* @param load the load of a Cloudlet
*
* @return the CPU time
*
* @pre cloudletLength >= 0.0
* @pre load >= 0.0
* @post $result >= 0.0
......@@ -262,7 +253,7 @@ public class DatacenterCharacteristics {
switch (getAllocationPolicy()) {
case DatacenterCharacteristics.TIME_SHARED:
cpuTime = cloudletLength / ( getMipsOfOnePe() * (1.0 - load));
cpuTime = cloudletLength / (getMipsOfOnePe() * (1.0 - load));
break;
default:
......@@ -276,7 +267,6 @@ public class DatacenterCharacteristics {
* Gets the total number of PEs for all Machines.
*
* @return number of PEs
*
* @pre $none
* @post $result >= 0
*/
......@@ -288,7 +278,6 @@ public class DatacenterCharacteristics {
* Gets the total number of <tt>FREE</tt> or non-busy PEs for all Machines.
*
* @return number of PEs
*
* @pre $none
* @post $result >= 0
*/
......@@ -300,7 +289,6 @@ public class DatacenterCharacteristics {
* Gets the total number of <tt>BUSY</tt> PEs for all Machines.
*
* @return number of PEs
*
* @pre $none
* @post $result >= 0
*/
......@@ -314,8 +302,7 @@ public class DatacenterCharacteristics {
* @param status Pe status, either <tt>Pe.FREE</tt> or <tt>Pe.BUSY</tt>
* @param hostId Machine ID
* @param peId Pe id
* @return
* otherwise (Machine id or Pe id might not be exist)
* @return otherwise (Machine id or Pe id might not be exist)
* @pre machineID >= 0
* @pre peID >= 0
* @post $none
......@@ -328,7 +315,6 @@ public class DatacenterCharacteristics {
* Gets the cost per Millions Instruction (MI) associated with a resource.
*
* @return the cost using a resource
*
* @pre $none
* @post $result >= 0.0
*/
......@@ -363,8 +349,7 @@ public class DatacenterCharacteristics {
/**
* Checks whether all machines of this resource are working properly or not.
*
* @return if all machines are working,
* otherwise
* @return if all machines are working, otherwise
*/
public boolean isWorking() {
boolean result = false;
......@@ -388,7 +373,6 @@ public class DatacenterCharacteristics {
* Sets cost to use memory.
*
* @param costPerMem cost to use memory
*
* @pre costPerMem >= 0
* @post $none
*/
......@@ -409,7 +393,6 @@ public class DatacenterCharacteristics {
* Sets cost to use storage.
*
* @param costPerStorage cost to use storage
*
* @pre costPerStorage >= 0
* @post $none
*/
......@@ -430,7 +413,6 @@ public class DatacenterCharacteristics {
* Sets cost to use bw cost to use bw.
*
* @param costPerBw the cost per bw
*
* @pre costPerBw >= 0
* @post $none
*/
......
......@@ -3,7 +3,7 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
......@@ -18,6 +18,7 @@ package org.cloudbus.cloudsim;
public class File {
private String name; // logical file name
private FileAttribute attribute; // a file attribute
// a transaction time for adding / getting /deleting this file
......@@ -38,17 +39,16 @@ public class File {
/** Denotes that the type of this file is a tag data */
public static final int TYPE_TAG_DATA = 3;
/**
* Creates a new DataCloud file with a given size (in MBytes). <br>
* NOTE: By default, a newly-created file is set to a <b>master</b> copy.
*
* @param fileName file name
* @param fileSize file size is in MBytes
* @throws ParameterException This happens when one of the following
* scenarios occur:
* @throws ParameterException This happens when one of the following scenarios occur:
* <ul>
* <li> the file name is empty or <tt>null</tt>
* <li> the file size is zero or negative numbers
* <li>the file name is empty or <tt>null</tt>
* <li>the file size is zero or negative numbers
* </ul>
*/
public File(String fileName, int fileSize) throws ParameterException {
......@@ -66,11 +66,11 @@ public class File {
}
/**
* Copy constructor, i.e. cloning from a source file into this object,
* but this object is set to a <b>replica</b>
* Copy constructor, i.e. cloning from a source file into this object, but this object is set to
* a <b>replica</b>
*
* @param file the source of a File object to copy
* @throws ParameterException This happens when the source file is
* <tt>null</tt>
* @throws ParameterException This happens when the source file is <tt>null</tt>
*/
public File(File file) throws ParameterException {
if (file == null) {
......@@ -85,8 +85,8 @@ public class File {
/**
* Clone this file but the clone file is set to a <b>replica</b>
* @return a clone of this file (as a replica)
* or <tt>null</tt> if an error occurs
*
* @return a clone of this file (as a replica) or <tt>null</tt> if an error occurs
*/
public File makeReplica() {
return makeCopy();
......@@ -94,8 +94,8 @@ public class File {
/**
* Clone this file and make the new file as a <b>master</b> copy as well
* @return a clone of this file (as a master copy)
* or <tt>null</tt> if an error occurs
*
* @return a clone of this file (as a master copy) or <tt>null</tt> if an error occurs
*/
public File makeMasterCopy() {
File file = makeCopy();
......@@ -108,8 +108,8 @@ public class File {
/**
* Makes a copy of this file
* @return a clone of this file (as a replica)
* or <tt>null</tt> if an error occurs
*
* @return a clone of this file (as a replica) or <tt>null</tt> if an error occurs
*/
private File makeCopy() {
File file = null;
......@@ -127,6 +127,7 @@ public class File {
/**
* Gets an attribute of this file
*
* @return a file attribute
*/
public FileAttribute getFileAttribute() {
......@@ -135,8 +136,9 @@ public class File {
/**
* Gets the size of this object (in byte).<br>
* NOTE: This object size is NOT the actual file size. Moreover,
* this size is used for transferring this object over a network.
* NOTE: This object size is NOT the actual file size. Moreover, this size is used for
* transferring this object over a network.
*
* @return the object size (in byte)
*/
public int getAttributeSize() {
......@@ -145,6 +147,7 @@ public class File {
/**
* Sets the resource ID that stores this file
*
* @param resourceID a resource ID
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -154,6 +157,7 @@ public class File {
/**
* Gets the resource ID that stores this file
*
* @return the resource ID
*/
public int getResourceID() {
......@@ -162,6 +166,7 @@ public class File {
/**
* Returns the file name
*
* @return the file name
*/
public String getName() {
......@@ -170,6 +175,7 @@ public class File {
/**
* Sets the file name
*
* @param name the file name
*/
public void setName(String name) {
......@@ -178,6 +184,7 @@ public class File {
/**
* Sets the owner name of this file
*
* @param name the owner name
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -187,6 +194,7 @@ public class File {
/**
* Gets the owner name of this file
*
* @return the owner name or <tt>null</tt> if empty
*/
public String getOwnerName() {
......@@ -195,6 +203,7 @@ public class File {
/**
* Gets the file size (in MBytes)
*
* @return the file size (in MBytes)
*/
public int getSize() {
......@@ -203,6 +212,7 @@ public class File {
/**
* Gets the file size (in bytes)
*
* @return the file size (in bytes)
*/
public int getSizeInByte() {
......@@ -211,6 +221,7 @@ public class File {
/**
* Sets the file size (in MBytes)
*
* @param fileSize the file size (in MBytes)
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -222,6 +233,7 @@ public class File {
* Sets the last update time of this file (in seconds)<br>
* NOTE: This time is relative to the start time. Preferably use
* {@link gridsim.CloudSim#clock()} method.
*
* @param time the last update time (in seconds)
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -231,6 +243,7 @@ public class File {
/**
* Gets the last update time (in seconds)
*
* @return the last update time (in seconds)
*/
public double getLastUpdateTime() {
......@@ -239,6 +252,7 @@ public class File {
/**
* Sets the file registration ID (published by a Replica Catalogue entity)
*
* @param id registration ID
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -248,6 +262,7 @@ public class File {
/**
* Gets the file registration ID
*
* @return registration ID
*/
public int getRegistrationID() {
......@@ -256,6 +271,7 @@ public class File {
/**
* Sets the file type (e.g. raw, tag, etc)
*
* @param type a file type
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -265,6 +281,7 @@ public class File {
/**
* Gets this file type
*
* @return file type
*/
public int getType() {
......@@ -273,6 +290,7 @@ public class File {
/**
* Sets the checksum of this file
*
* @param checksum the checksum of this file
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -282,6 +300,7 @@ public class File {
/**
* Gets the file checksum
*
* @return file checksum
*/
public int getChecksum() {
......@@ -290,6 +309,7 @@ public class File {
/**
* Sets the cost associated with this file
*
* @param cost cost of this file
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -299,6 +319,7 @@ public class File {
/**
* Gets the cost associated with this file
*
* @return the cost of this file
*/
public double getCost() {
......@@ -307,6 +328,7 @@ public class File {
/**
* Gets the file creation time (in millisecond)
*
* @return the file creation time (in millisecond)
*/
public long getCreationTime() {
......@@ -315,6 +337,7 @@ public class File {
/**
* Checks if this file already registered to a Replica Catalogue
*
* @return <tt>true</tt> if it is registered, <tt>false</tt> otherwise
*/
public boolean isRegistered() {
......@@ -323,8 +346,9 @@ public class File {
/**
* Marks this file as a master copy or replica
* @param masterCopy a flag denotes <tt>true</tt> for master copy or
* <tt>false</tt> for a replica
*
* @param masterCopy a flag denotes <tt>true</tt> for master copy or <tt>false</tt> for a
* replica
*/
public void setMasterCopy(boolean masterCopy) {
attribute.setMasterCopy(masterCopy);
......@@ -332,6 +356,7 @@ public class File {
/**
* Checks whether this file is a master copy or replica
*
* @return <tt>true</tt> if it is a master copy or <tt>false</tt> otherwise
*/
public boolean isMasterCopy() {
......@@ -340,8 +365,8 @@ public class File {
/**
* Marks this file as a read only or not
* @param readOnly a flag denotes <tt>true</tt> for read only or
* <tt>false</tt> for re-writeable
*
* @param readOnly a flag denotes <tt>true</tt> for read only or <tt>false</tt> for re-writeable
*/
public void setReadOnly(boolean readOnly) {
attribute.setReadOnly(readOnly);
......@@ -349,6 +374,7 @@ public class File {
/**
* Checks whether this file is a read only or not
*
* @return <tt>true</tt> if it is a read only or <tt>false</tt> otherwise
*/
public boolean isReadOnly() {
......@@ -356,9 +382,9 @@ public class File {
}
/**
* Sets the current transaction time (in second) of this file.
* This transaction time can be related to the operation of adding /
* deleting / getting this file on a resource's storage.
* Sets the current transaction time (in second) of this file. This transaction time can be
* related to the operation of adding / deleting / getting this file on a resource's storage.
*
* @param time the transaction time (in second)
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
* @see gridsim.datagrid.storage.Storage#addFile(File)
......@@ -381,6 +407,7 @@ public class File {
/**
* Gets the last transaction time of this file (in second).
*
* @return the transaction time (in second)
*/
public double getTransactionTime() {
......@@ -388,4 +415,3 @@ public class File {
}
}
......@@ -3,7 +3,7 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
......@@ -13,8 +13,7 @@ import java.util.Date;
import org.cloudbus.cloudsim.core.CloudSim;
/**
* A class for storing related information regarding to a
* {@link gridsim.datagrid.File} entity.
* A class for storing related information regarding to a {@link gridsim.datagrid.File} entity.
*
* @author Uros Cibej
* @author Anthony Sulistio
......@@ -23,41 +22,48 @@ import org.cloudbus.cloudsim.core.CloudSim;
public class FileAttribute {
private String name; // logical file name
private String ownerName; // owner name of this file
private int id; // file ID given by a Replica Catalogue
private int type; // file type, e.g. raw, reconstructed, etc
private int size; // file size in byte
private int checksum; // check sum
private double lastUpdateTime; // last updated time (sec) - relative
private long creationTime; // creation time (ms) - abosulte/relative
private double cost; // price of this file
private boolean masterCopy; // false if it is a replica
private boolean readOnly; // false if it can be rewritten
private int resourceId; // resource ID storing this file
private int resourceId; // resource ID storing this file
/**
* Allocates a new FileAttribute class.
*
* @param fileName file name
* @param fileSize size of this file (in bytes)
* @throws ParameterException This happens when one of the following
* scenarios occur:
* @throws ParameterException This happens when one of the following scenarios occur:
* <ul>
* <li> the file name is empty or <tt>null</tt>
* <li> the file size is zero or negative numbers
* <li>the file name is empty or <tt>null</tt>
* <li>the file size is zero or negative numbers
* </ul>
*/
public FileAttribute(String fileName, int fileSize)
throws ParameterException {
public FileAttribute(String fileName, int fileSize) throws ParameterException {
// check for errors in the input
if (fileName == null || fileName.length() == 0) {
throw new ParameterException(
"FileAttribute(): Error - invalid file name.");
throw new ParameterException("FileAttribute(): Error - invalid file name.");
}
if (fileSize <= 0) {
throw new ParameterException(
"FileAttribute(): Error - size <= 0.");
throw new ParameterException("FileAttribute(): Error - size <= 0.");
}
size = fileSize;
......@@ -84,9 +90,9 @@ public class FileAttribute {
/**
* Copy the values of this object into another FileAttribute class
*
* @param attr a FileAttribute object (the destination)
* @return <tt>true</tt> if the copy operation is successful,
* <tt>false</tt> otherwise
* @return <tt>true</tt> if the copy operation is successful, <tt>false</tt> otherwise
*/
public boolean copyValue(FileAttribute attr) {
if (attr == null) {
......@@ -111,6 +117,7 @@ public class FileAttribute {
/**
* Sets the file creation time (in millisecond)
*
* @param creationTime the file creation time (in millisecond)
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -125,6 +132,7 @@ public class FileAttribute {
/**
* Gets the file creation time (in millisecond)
*
* @return the file creation time (in millisecond)
*/
public long getCreationTime() {
......@@ -133,6 +141,7 @@ public class FileAttribute {
/**
* Sets the resource ID that stores this file
*
* @param resourceID a resource ID
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -141,12 +150,13 @@ public class FileAttribute {
return false;
}
this.resourceId = resourceID;
resourceId = resourceID;
return true;
}
/**
* Gets the resource ID that stores this file
*
* @return the resource ID
*/
public int getResourceID() {
......@@ -155,6 +165,7 @@ public class FileAttribute {
/**
* Sets the owner name of this file
*
* @param name the owner name
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -163,12 +174,13 @@ public class FileAttribute {
return false;
}
this.ownerName = name;
ownerName = name;
return true;
}
/**
* Gets the owner name of this file
*
* @return the owner name or <tt>null</tt> if empty
*/
public String getOwnerName() {
......@@ -177,8 +189,9 @@ public class FileAttribute {
/**
* Gets the size of this object (in byte).<br>
* NOTE: This object size is NOT the actual file size. Moreover,
* this size is used for transferring this object over a network.
* NOTE: This object size is NOT the actual file size. Moreover, this size is used for
* transferring this object over a network.
*
* @return the object size (in byte)
*/
public int getAttributeSize() {
......@@ -196,6 +209,7 @@ public class FileAttribute {
/**
* Sets the file size (in MBytes)
*
* @param fileSize the file size (in MBytes)
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -204,12 +218,13 @@ public class FileAttribute {
return false;
}
this.size = fileSize;
size = fileSize;
return true;
}
/**
* Gets the file size (in MBytes)
*
* @return the file size (in MBytes)
*/
public int getFileSize() {
......@@ -218,17 +233,19 @@ public class FileAttribute {
/**
* Gets the file size (in bytes)
*
* @return the file size (in bytes)
*/
public int getFileSizeInByte() {
return size * 1000000; // 1e6
//return size * 1048576; // 1e6 - more accurate
// return size * 1048576; // 1e6 - more accurate
}
/**
* Sets the last update time of this file (in seconds)<br>
* NOTE: This time is relative to the start time. Preferably use
* {@link gridsim.CloudSim#clock()} method.
*
* @param time the last update time (in seconds)
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -243,6 +260,7 @@ public class FileAttribute {
/**
* Gets the last update time (in seconds)
*
* @return the last update time (in seconds)
*/
public double getLastUpdateTime() {
......@@ -251,6 +269,7 @@ public class FileAttribute {
/**
* Sets the file registration ID (published by a Replica Catalogue entity)
*
* @param id registration ID
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -265,6 +284,7 @@ public class FileAttribute {
/**
* Gets the file registration ID
*
* @return registration ID
*/
public int getRegistrationID() {
......@@ -273,6 +293,7 @@ public class FileAttribute {
/**
* Sets the file type (e.g. raw, tag, etc)
*
* @param type a file type
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -287,6 +308,7 @@ public class FileAttribute {
/**
* Gets this file type
*
* @return file type
*/
public int getType() {
......@@ -295,6 +317,7 @@ public class FileAttribute {
/**
* Sets the checksum of this file
*
* @param checksum the checksum of this file
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -309,6 +332,7 @@ public class FileAttribute {
/**
* Gets the file checksum
*
* @return file checksum
*/
public int getChecksum() {
......@@ -317,6 +341,7 @@ public class FileAttribute {
/**
* Sets the cost associated with this file
*
* @param cost cost of this file
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
......@@ -331,6 +356,7 @@ public class FileAttribute {
/**
* Gets the cost associated with this file
*
* @return the cost of this file
*/
public double getCost() {
......@@ -339,6 +365,7 @@ public class FileAttribute {
/**
* Checks if this file already registered to a Replica Catalogue
*
* @return <tt>true</tt> if it is registered, <tt>false</tt> otherwise
*/
public boolean isRegistered() {
......@@ -352,8 +379,9 @@ public class FileAttribute {
/**
* Marks this file as a master copy or replica
* @param masterCopy a flag denotes <tt>true</tt> for master copy or
* <tt>false</tt> for a replica
*
* @param masterCopy a flag denotes <tt>true</tt> for master copy or <tt>false</tt> for a
* replica
*/
public void setMasterCopy(boolean masterCopy) {
this.masterCopy = masterCopy;
......@@ -361,6 +389,7 @@ public class FileAttribute {
/**
* Checks whether this file is a master copy or replica
*
* @return <tt>true</tt> if it is a master copy or <tt>false</tt> otherwise
*/
public boolean isMasterCopy() {
......@@ -369,8 +398,8 @@ public class FileAttribute {
/**
* Marks this file as a read only or not
* @param readOnly a flag denotes <tt>true</tt> for read only or
* <tt>false</tt> for re-writeable
*
* @param readOnly a flag denotes <tt>true</tt> for read only or <tt>false</tt> for re-writeable
*/
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
......@@ -378,6 +407,7 @@ public class FileAttribute {
/**
* Checks whether this file is a read only or not
*
* @return <tt>true</tt> if it is a read only or <tt>false</tt> otherwise
*/
public boolean isReadOnly() {
......@@ -386,6 +416,7 @@ public class FileAttribute {
/**
* Sets the file name
*
* @param name the file name
*/
public void setName(String name) {
......@@ -394,6 +425,7 @@ public class FileAttribute {
/**
* Returns the file name
*
* @return the file name
*/
public String getName() {
......@@ -401,5 +433,3 @@ public class FileAttribute {
}
}
......@@ -2,7 +2,7 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
......@@ -18,9 +18,7 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner;
/**
* Host executes actions related to management 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.
*
* A host is associated to a datacenter. It can host virtual machines.
* Pe's to virtual machines. A host is associated to a datacenter. It can host virtual machines.
*
* @author Rodrigo N. Calheiros
* @author Anton Beloglazov
......@@ -89,10 +87,8 @@ public class Host {
* Requests updating of processing of cloudlets in the VMs running in this host.
*
* @param currentTime the current time
*
* @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 this host
*
* @pre currentTime >= 0.0
* @post $none
*/
......@@ -187,7 +183,6 @@ public class Host {
* Checks if is suitable for vm.
*
* @param vm the vm
*
* @return true, if is suitable for vm
*/
public boolean isSuitableForVm(Vm vm) {
......@@ -201,9 +196,7 @@ public class Host {
* Allocates PEs and memory to a new VM in the Host.
*
* @param vm Vm being started
*
* @return $true if the VM could be started in the host; $false otherwise
*
* @pre $none
* @post $none
*/
......@@ -245,7 +238,6 @@ public class Host {
* Destroys a VM running in the host.
*
* @param vm the VM
*
* @pre $none
* @post $none
*/
......@@ -286,7 +278,6 @@ public class Host {
/**
* Deallocate all hostList for the VM.
*
*/
protected void vmDeallocateAll() {
getRamProvisioner().deallocateRamForAllVms();
......@@ -299,9 +290,7 @@ public class Host {
*
* @param vmId the vm id
* @param userId ID of VM's owner
*
* @return the virtual machine object, $null if not found
*
* @pre $none
* @post $none
*/
......@@ -346,9 +335,7 @@ public class Host {
*
* @param vm the vm
* @param mipsShare the mips share
*
* @return $true if this policy allows a new VM in the host, $false otherwise
*
* @pre $none
* @post $none
*/
......@@ -360,7 +347,6 @@ public class Host {
* Releases PEs allocated to a VM.
*
* @param vm the vm
*
* @pre $none
* @post $none
*/
......@@ -372,9 +358,7 @@ public class Host {
* Returns the MIPS share of each Pe that is allocated to a given VM.
*
* @param vm the vm
*
* @return an array containing the amount of MIPS of each pe that is available to the VM
*
* @pre $none
* @post $none
*/
......@@ -386,7 +370,6 @@ public class Host {
* Gets the total allocated MIPS for a VM over all the PEs.
*
* @param vm the vm
*
* @return the allocated mips for vm
*/
public double getTotalAllocatedMipsForVm(Vm vm) {
......@@ -415,7 +398,6 @@ public class Host {
* Gets the machine bw.
*
* @return the machine bw
*
* @pre $none
* @post $result > 0
*/
......@@ -427,7 +409,6 @@ public class Host {
* Gets the machine memory.
*
* @return the machine memory
*
* @pre $none
* @post $result > 0
*/
......@@ -439,7 +420,6 @@ public class Host {
* Gets the machine storage.
*
* @return the machine storage
*
* @pre $none
* @post $result >= 0
*/
......@@ -576,7 +556,6 @@ public class Host {
*
* @param resName the name of the resource
* @param failed the failed
*
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
public boolean setFailed(String resName, boolean failed) {
......@@ -590,7 +569,6 @@ public class Host {
* Sets the PEs of this machine to a FAILED status.
*
* @param failed the failed
*
* @return <tt>true</tt> if successful, <tt>false</tt> otherwise
*/
public boolean setFailed(boolean failed) {
......
......@@ -3,7 +3,7 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
......@@ -18,7 +18,7 @@ import org.cloudbus.cloudsim.provisioners.BwProvisioner;
import org.cloudbus.cloudsim.provisioners.RamProvisioner;
/**
* The Class HostDynamicWorkload.
* The class of a host supporting dynamic workloads and performance degradation.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
......@@ -56,7 +56,8 @@ public class HostDynamicWorkload extends Host {
setPreviousUtilizationMips(0);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
* @see cloudsim.Host#updateVmsProcessing(double)
*/
@Override
......@@ -76,36 +77,51 @@ public class HostDynamicWorkload extends Host {
for (Vm vm : getVmList()) {
double totalRequestedMips = vm.getCurrentRequestedTotalMips();
// if (totalRequestedMips == 0) {
// Log.printLine("VM #" + vm.getId() + " has completed its execution and destroyed");
// continue;
// }
double totalAllocatedMips = getVmScheduler().getTotalAllocatedMipsForVm(vm);
if (!Log.isDisabled()) {
Log.formatLine("%.2f: [Host #" + getId() + "] Total allocated MIPS for VM #" + vm.getId() + " (Host #" + vm.getHost().getId() + ") is %.2f, was requested %.2f out of total %.2f (%.2f%%)", CloudSim.clock(), totalAllocatedMips, totalRequestedMips, vm.getMips(), totalRequestedMips / vm.getMips() * 100);
Log.formatLine(
"%.2f: [Host #" + getId() + "] Total allocated MIPS for VM #" + vm.getId()
+ " (Host #" + vm.getHost().getId()
+ ") is %.2f, was requested %.2f out of total %.2f (%.2f%%)",
CloudSim.clock(),
totalAllocatedMips,
totalRequestedMips,
vm.getMips(),
totalRequestedMips / vm.getMips() * 100);
List<Pe> pes = getVmScheduler().getPesAllocatedForVM(vm);
StringBuilder pesString = new StringBuilder();
for (Pe pe : pes) {
pesString.append(String.format(" PE #" + pe.getId() + ": %.2f.", pe.getPeProvisioner().getTotalAllocatedMipsForVm(vm)));
pesString.append(String.format(" PE #" + pe.getId() + ": %.2f.", pe.getPeProvisioner()
.getTotalAllocatedMipsForVm(vm)));
}
Log.formatLine("%.2f: [Host #" + getId() + "] MIPS for VM #" + vm.getId() + " by PEs (" + getNumberOfPes() + " * " + getVmScheduler().getPeCapacity() + ")." + pesString, CloudSim.clock());
Log.formatLine(
"%.2f: [Host #" + getId() + "] MIPS for VM #" + vm.getId() + " by PEs ("
+ getNumberOfPes() + " * " + getVmScheduler().getPeCapacity() + ")."
+ pesString,
CloudSim.clock());
}
if (getVmsMigratingIn().contains(vm)) {
Log.formatLine("%.2f: [Host #" + getId() + "] VM #" + vm.getId() + " is being migrated to Host #" + getId(), CloudSim.clock());
Log.formatLine("%.2f: [Host #" + getId() + "] VM #" + vm.getId()
+ " is being migrated to Host #" + getId(), CloudSim.clock());
} else {
if (totalAllocatedMips + 0.1 < totalRequestedMips) {
Log.formatLine("%.2f: [Host #" + getId() + "] Under allocated MIPS for VM #" + vm.getId() + ": %.2f", CloudSim.clock(), totalRequestedMips - totalAllocatedMips);
Log.formatLine("%.2f: [Host #" + getId() + "] Under allocated MIPS for VM #" + vm.getId()
+ ": %.2f", CloudSim.clock(), totalRequestedMips - totalAllocatedMips);
}
vm.addStateHistoryEntry(currentTime, totalAllocatedMips, totalRequestedMips, (vm.isInMigration() && !getVmsMigratingIn().contains(vm)));
vm.addStateHistoryEntry(
currentTime,
totalAllocatedMips,
totalRequestedMips,
(vm.isInMigration() && !getVmsMigratingIn().contains(vm)));
if (vm.isInMigration()) {
Log.formatLine("%.2f: [Host #" + getId() + "] VM #" + vm.getId() + " is in migration", CloudSim.clock());
Log.formatLine(
"%.2f: [Host #" + getId() + "] VM #" + vm.getId() + " is in migration",
CloudSim.clock());
totalAllocatedMips /= 0.9; // performance degradation due to migration - 10%
}
}
......@@ -114,7 +130,11 @@ public class HostDynamicWorkload extends Host {
hostTotalRequestedMips += totalRequestedMips;
}
addStateHistoryEntry(currentTime, getUtilizationMips(), hostTotalRequestedMips, (getUtilizationMips() > 0));
addStateHistoryEntry(
currentTime,
getUtilizationMips(),
hostTotalRequestedMips,
(getUtilizationMips() > 0));
return smallerTime;
}
......@@ -147,11 +167,9 @@ public class HostDynamicWorkload extends Host {
}
/**
* Gets the max utilization among by all PEs
* allocated to the VM.
* Gets the max utilization among by all PEs allocated to the VM.
*
* @param vm the vm
*
* @return the utilization
*/
public double getMaxUtilizationAmongVmsPes(Vm vm) {
......@@ -264,8 +282,15 @@ public class HostDynamicWorkload extends Host {
* @param requestedMips the requested mips
* @param isActive the is active
*/
public void addStateHistoryEntry(double time, double allocatedMips, double requestedMips, boolean isActive) {
HostStateHistoryEntry newState = new HostStateHistoryEntry(time, allocatedMips, requestedMips, isActive);
public
void
addStateHistoryEntry(double time, double allocatedMips, double requestedMips, boolean isActive) {
HostStateHistoryEntry newState = new HostStateHistoryEntry(
time,
allocatedMips,
requestedMips,
isActive);
if (!getStateHistory().isEmpty()) {
HostStateHistoryEntry previousState = getStateHistory().get(getStateHistory().size() - 1);
if (previousState.getTime() == time) {
......
......@@ -3,7 +3,7 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
......@@ -12,9 +12,8 @@ import java.io.IOException;
import java.io.OutputStream;
/**
* The Log class used for performing loggin of the simulation process.
* It provides the ability to substitute the output stream by any
* OutputStream subclass.
* The Log class used for performing loggin of the simulation process. It provides the ability to
* substitute the output stream by any OutputStream subclass.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
......@@ -93,7 +92,7 @@ public class Log {
* @param format the format
* @param args the args
*/
public static void format(String format, Object... args ) {
public static void format(String format, Object... args) {
if (!isDisabled()) {
print(String.format(format, args));
}
......@@ -105,7 +104,7 @@ public class Log {
* @param format the format
* @param args the args
*/
public static void formatLine(String format, Object... args ) {
public static void formatLine(String format, Object... args) {
if (!isDisabled()) {
printLine(String.format(format, args));
}
......
/*
* ** Network and Service Differentiation Extensions to CloudSim 3.0 **
*
* Gokul Poduval & Chen-Khong Tham
* Computer Communication Networks (CCN) Lab
* Dept of Electrical & Computer Engineering
......@@ -24,8 +22,10 @@ package org.cloudbus.cloudsim;
* @since CloudSim Toolkit 1.0
*/
public interface Packet {
/**
* Returns a string describing this packet in detail.
*
* @return description of this packet
* @pre $none
* @post $none
......@@ -35,6 +35,7 @@ public interface Packet {
/**
* Returns the size of this packet
*
* @return size of the packet
* @pre $none
* @post $none
......@@ -43,6 +44,7 @@ public interface Packet {
/**
* Sets the size of this packet
*
* @param size size of the packet
* @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise
* @pre size >= 0
......@@ -52,6 +54,7 @@ public interface Packet {
/**
* Returns the destination id of this packet.
*
* @return destination id
* @pre $none
* @post $none
......@@ -60,6 +63,7 @@ public interface Packet {
/**
* Returns the ID of this packet
*
* @return packet ID
* @pre $none
* @post $none
......@@ -68,6 +72,7 @@ public interface Packet {
/**
* Returns the ID of the source of this packet.
*
* @return source id
* @pre $none
* @post $none
......@@ -76,6 +81,7 @@ public interface Packet {
/**
* Gets the network service type of this packet
*
* @return the network service type
* @pre $none
* @post $none
......@@ -85,8 +91,9 @@ public interface Packet {
/**
* Sets the network service type of this packet.
* <p>
* By default, the service type is 0 (zero). It is depends on the packet
* scheduler to determine the priority of this service level.
* By default, the service type is 0 (zero). It is depends on the packet scheduler to determine
* the priority of this service level.
*
* @param serviceType this packet's service type
* @pre serviceType >= 0
* @post $none
......@@ -95,6 +102,7 @@ public interface Packet {
/**
* Gets an entity ID from the last hop that this packet has traversed.
*
* @return an entity ID
* @pre $none
* @post $none
......@@ -103,6 +111,7 @@ public interface Packet {
/**
* Sets an entity ID from the last hop that this packet has traversed.
*
* @param last an entity ID from the last hop
* @pre last > 0
* @post $none
......@@ -111,6 +120,7 @@ public interface Packet {
/**
* Gets this packet tag
*
* @return this packet tag
* @pre $none
* @post $none
......
......@@ -17,8 +17,7 @@
package org.cloudbus.cloudsim;
/**
* This exception is to report bad or invalid parameters given during
* constructor.
* This exception is to report bad or invalid parameters given during constructor.
*
* @author Gokul Poduval
* @author Chen-Khong Tham, National University of Singapore
......@@ -47,7 +46,6 @@ public class ParameterException extends Exception {
* Creates a new ParameterException object.
*
* @param message an error message
*
* @pre $none
* @post $none
*/
......@@ -60,7 +58,6 @@ public class ParameterException extends Exception {
* Returns an error message of this object.
*
* @return an error message
*
* @pre $none
* @post $none
*/
......@@ -70,4 +67,3 @@ public class ParameterException extends Exception {
}
}
......@@ -3,14 +3,14 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
/**
* The UtilizationModel interface needs to be implemented in order to
* provide a fine-grained control over resource usage by a Cloudlet.
* The UtilizationModel interface needs to be implemented in order to provide a fine-grained control
* over resource usage by a Cloudlet.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
......@@ -21,7 +21,6 @@ public interface UtilizationModel {
* Returns utilization in percents according to the time.
*
* @param time the time
*
* @return utilization percentage
*/
double getUtilization(double time);
......
......@@ -3,21 +3,22 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
/**
* The UtilizationModelFull class is a simple model, according to which
* a Cloudlet always utilize all the available CPU capacity.
* The UtilizationModelFull class is a simple model, according to which a Cloudlet always utilize
* all the available CPU capacity.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/
public class UtilizationModelFull implements UtilizationModel {
/* (non-Javadoc)
/*
* (non-Javadoc)
* @see cloudsim.power.UtilizationModel#getUtilization(double)
*/
@Override
......
......@@ -3,7 +3,7 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.distributions;
......@@ -18,6 +18,7 @@ public interface ContinuousDistribution {
/**
* Sample the random number generator.
*
* @return The sample
*/
double sample();
......
......@@ -3,7 +3,7 @@
* 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
* Copyright (c) 2009-2012, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.network;
......
This diff is collapsed.
This diff is collapsed.
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