Commit 817a6782 authored by Manoel Campos's avatar Manoel Campos

Removal of duplicated documentation on methods inherited from a superclass or interface.

The documentation was updated in subclasses that effectively had any difference from the inherited class/interface.
In these cases, the tag {@inheritDoc} was used to extend the documentation in the subclass and avoid documentation duplication.
parent 35c31997
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
* *
* Copyright (c) 2009-2012, The University of Melbourne, Australia * Copyright (c) 2009-2012, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import java.text.DecimalFormat; import java.text.DecimalFormat;
...@@ -16,1520 +15,1623 @@ import java.util.List; ...@@ -16,1520 +15,1623 @@ import java.util.List;
import org.cloudbus.cloudsim.core.CloudSim; import org.cloudbus.cloudsim.core.CloudSim;
/** /**
* Cloudlet is an extension to the cloudlet. * Cloudlet is an extension to the cloudlet. It stores, despite all the
* It stores, despite all the information encapsulated in the Cloudlet, the ID of the VM running it. * information encapsulated in the Cloudlet, the ID of the VM running it.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @author Anton Beloglazov * @author Anton Beloglazov
* @since CloudSim Toolkit 1.0 * @since CloudSim Toolkit 1.0
* @todo The documentation is wrong. Cloudlet isn't extending any class. * @todo The documentation is wrong. Cloudlet isn't extending any class.
*/ */
public class Cloudlet { public class Cloudlet {
/** The cloudlet ID. */
private final int cloudletId;
/**
* The User or Broker ID. It is advisable that broker set this ID with its own ID, so that
* CloudResource returns to it after the execution.
**/
private int userId;
/**
* The execution length of this Cloudlet (Unit: in Million Instructions (MI)).
* According to this length and the power of the processor
* (in Million Instruction Per Second - MIPS)
* where the cloudlet will be run, the cloudlet will take a given time
* to finish processing. For instance, for a cloudlet of 10000 MI
* running on a processor of 2000 MIPS, the cloudlet will
* spend 5 seconds using the processor in order to be completed
* (that may be uninterrupted or not, depending on the scheduling policy).
*
* @see #setNumberOfPes(int)
*
*/
private long cloudletLength;
/**
* The input file size of this Cloudlet before execution (unit: in byte).
* This size has to be considered the program + input data sizes.
*/
private final long cloudletFileSize;
/** The output file size of this Cloudlet after execution (unit: in byte).
* @todo See <a href="https://groups.google.com/forum/#!topic/cloudsim/MyZ7OnrXuuI">this discussion</a>
*/
private final long cloudletOutputSize;
/** The number of Processing Elements (Pe) required to execute this cloudlet (job).
* @see #setNumberOfPes(int)
*/
private int numberOfPes;
/** The execution status of this Cloudlet.
* @todo It would be an enum, to avoid using int constants.
*/
private int status;
/**
* The execution start time of this Cloudlet. With new functionalities, such as CANCEL, PAUSED and
* RESUMED, this attribute only stores the latest execution time. Previous execution time are
* ignored.
*/
private double execStartTime;
/** The time where this Cloudlet completes. */
private double finishTime;
/** The ID of a reservation made for this cloudlet.
* @todo This attribute doesn't appear to be used
*/
private int reservationId = -1;
/** Indicates if transaction history records for this Cloudlet
* is to be outputted. */
private final boolean record;
/** Stores the operating system line separator. */
private String newline;
/** The cloudlet transaction history. */
private StringBuffer history;
/** The list of every resource where the cloudlet has been executed.
In case it starts and finishes executing in a single cloud resource,
without being migrated, this list will have only one item.*/
private final List<Resource> resList;
/** The index of the last resource where the cloudlet was executed.
If the cloudlet is migrated during its execution, this index
is updated. The value -1 indicates the cloudlet has not been executed
yet.*/
private int index;
/** The classType or priority of this Cloudlet for scheduling on a resource. */
private int classType;
/** The Type of Service (ToS) of IPv4 for sending Cloudlet over the network. */
private int netToS;
/** The format of decimal numbers. */
private DecimalFormat num;
// //////////////////////////////////////////
// Below are CONSTANTS attributes
/** The Cloudlet has been created and added to the CloudletList object. */
public static final int CREATED = 0;
/** The Cloudlet has been assigned to a CloudResource object to be executed as planned. */
public static final int READY = 1;
/** The Cloudlet has moved to a Cloud node. */
public static final int QUEUED = 2;
/** The Cloudlet is in execution in a Cloud node. */
public static final int INEXEC = 3;
/** The Cloudlet has been executed successfully. */
public static final int SUCCESS = 4;
/** The Cloudlet has failed. */
public static final int FAILED = 5;
/** The Cloudlet has been canceled. */ /**
public static final int CANCELED = 6; * The cloudlet ID.
*/
/** private final int cloudletId;
* The Cloudlet has been paused. It can be resumed by changing the status into <tt>RESUMED</tt>.
*/ /**
public static final int PAUSED = 7; * The User or Broker ID. It is advisable that broker set this ID with its
* own ID, so that CloudResource returns to it after the execution.
/** The Cloudlet has been resumed from <tt>PAUSED</tt> state. */ *
public static final int RESUMED = 8; */
private int userId;
/** The cloudlet has failed due to a resource failure. */
public static final int FAILED_RESOURCE_UNAVAILABLE = 9; /**
* The execution length of this Cloudlet (Unit: in Million Instructions
/** The id of the vm that is planned to execute the cloudlet. */ * (MI)). According to this length and the power of the processor (in
protected int vmId; * Million Instruction Per Second - MIPS) where the cloudlet will be run,
* the cloudlet will take a given time to finish processing. For instance,
/** The cost of each byte of bandwidth (bw) consumed. */ * for a cloudlet of 10000 MI running on a processor of 2000 MIPS, the
protected double costPerBw; * cloudlet will spend 5 seconds using the processor in order to be
* completed (that may be uninterrupted or not, depending on the scheduling
/** The total bandwidth (bw) cost for transferring the cloudlet by the network, * policy).
* according to the {@link #cloudletFileSize}. */ *
protected double accumulatedBwCost; * @see #setNumberOfPes(int)
*
// Utilization */
private long cloudletLength;
/** The utilization model that defines how the cloudlet will use the VM's CPU. */
private UtilizationModel utilizationModelCpu; /**
* The input file size of this Cloudlet before execution (unit: in byte).
/** The utilization model that defines how the cloudlet will use the VM's RAM. */ * This size has to be considered the program + input data sizes.
private UtilizationModel utilizationModelRam; */
private final long cloudletFileSize;
/** The utilization model that defines how the cloudlet will use the VM's bandwidth (bw). */
private UtilizationModel utilizationModelBw; /**
* The output file size of this Cloudlet after execution (unit: in byte).
// Data cloudlet *
/** The required files to be used by the cloudlet (if any). * @todo See
* The time to transfer these files by the network is considered when * <a href="https://groups.google.com/forum/#!topic/cloudsim/MyZ7OnrXuuI">this
* placing the cloudlet inside a given VM */ * discussion</a>
private List<String> requiredFiles = null; */
private final long cloudletOutputSize;
/**
* Allocates a new Cloudlet object. The Cloudlet length, input and output file sizes should be /**
* greater than or equal to 1. By default this constructor sets the history of this object. * The number of Processing Elements (Pe) required to execute this cloudlet
* * (job).
* @param cloudletId the unique ID of this Cloudlet *
* @param cloudletLength the length or size (in MI) of this cloudlet to be executed in a * @see #setNumberOfPes(int)
* PowerDatacenter */
* @param cloudletFileSize the file size (in byte) of this cloudlet <tt>BEFORE</tt> submitting private int numberOfPes;
* to a Datacenter
* @param cloudletOutputSize the file size (in byte) of this cloudlet <tt>AFTER</tt> finish /**
* executing by a Datacenter * The execution status of this Cloudlet.
* @param pesNumber the pes number *
* @param utilizationModelCpu the utilization model of cpu * @todo It would be an enum, to avoid using int constants.
* @param utilizationModelRam the utilization model of ram */
* @param utilizationModelBw the utilization model of bw private int status;
*
* @pre cloudletID >= 0 /**
* @pre cloudletLength >= 0.0 * The execution start time of this Cloudlet. With new functionalities, such
* @pre cloudletFileSize >= 1 * as CANCEL, PAUSED and RESUMED, this attribute only stores the latest
* @pre cloudletOutputSize >= 1 * execution time. Previous execution time are ignored.
* @post $none */
*/ private double execStartTime;
public Cloudlet(
final int cloudletId, /**
final long cloudletLength, * The time where this Cloudlet completes.
final int pesNumber, */
final long cloudletFileSize, private double finishTime;
final long cloudletOutputSize,
final UtilizationModel utilizationModelCpu, /**
final UtilizationModel utilizationModelRam, * The ID of a reservation made for this cloudlet.
final UtilizationModel utilizationModelBw) { *
this( * @todo This attribute doesn't appear to be used
cloudletId, */
cloudletLength, private int reservationId = -1;
pesNumber,
cloudletFileSize, /**
cloudletOutputSize, * Indicates if transaction history records for this Cloudlet is to be
utilizationModelCpu, * outputted.
utilizationModelRam, */
utilizationModelBw, private final boolean record;
false);
vmId = -1; /**
accumulatedBwCost = 0.0; * Stores the operating system line separator.
costPerBw = 0.0; */
private String newline;
requiredFiles = new LinkedList<String>();
} /**
* The cloudlet transaction history.
/** */
* Allocates a new Cloudlet object. The Cloudlet length, input and output file sizes should be private StringBuffer history;
* greater than or equal to 1.
* /**
* @param cloudletId the unique ID of this cloudlet * The list of every resource where the cloudlet has been executed. In case
* @param cloudletLength the length or size (in MI) of this cloudlet to be executed in a * it starts and finishes executing in a single cloud resource, without
* PowerDatacenter * being migrated, this list will have only one item.
* @param cloudletFileSize the file size (in byte) of this cloudlet <tt>BEFORE</tt> submitting */
* to a PowerDatacenter private final List<Resource> resList;
* @param cloudletOutputSize the file size (in byte) of this cloudlet <tt>AFTER</tt> finish
* executing by a PowerDatacenter /**
* @param record record the history of this object or not * The index of the last resource where the cloudlet was executed. If the
* @param fileList list of files required by this cloudlet * cloudlet is migrated during its execution, this index is updated. The
* @param pesNumber the pes number * value -1 indicates the cloudlet has not been executed
* @param utilizationModelCpu the utilization model of cpu yet.
* @param utilizationModelRam the utilization model of ram */
* @param utilizationModelBw the utilization model of bw private int index;
*
* @pre cloudletID >= 0 /**
* @pre cloudletLength >= 0.0 * The classType or priority of this Cloudlet for scheduling on a resource.
* @pre cloudletFileSize >= 1 */
* @pre cloudletOutputSize >= 1 private int classType;
* @post $none
*/ /**
public Cloudlet( * The Type of Service (ToS) of IPv4 for sending Cloudlet over the network.
final int cloudletId, */
final long cloudletLength, private int netToS;
final int pesNumber,
final long cloudletFileSize, /**
final long cloudletOutputSize, * The format of decimal numbers.
final UtilizationModel utilizationModelCpu, */
final UtilizationModel utilizationModelRam, private DecimalFormat num;
final UtilizationModel utilizationModelBw,
final boolean record, // //////////////////////////////////////////
final List<String> fileList) { // Below are CONSTANTS attributes
this( /**
cloudletId, * The Cloudlet has been created and added to the CloudletList object.
cloudletLength, */
pesNumber, public static final int CREATED = 0;
cloudletFileSize,
cloudletOutputSize, /**
utilizationModelCpu, * The Cloudlet has been assigned to a CloudResource object to be executed
utilizationModelRam, * as planned.
utilizationModelBw, */
record); public static final int READY = 1;
vmId = -1;
accumulatedBwCost = 0.0; /**
costPerBw = 0.0; * The Cloudlet has moved to a Cloud node.
*/
requiredFiles = fileList; public static final int QUEUED = 2;
}
/**
/** * The Cloudlet is in execution in a Cloud node.
* Allocates a new Cloudlet object. The Cloudlet length, input and output file sizes should be */
* greater than or equal to 1. By default this constructor sets the history of this object. public static final int INEXEC = 3;
*
* @param cloudletId the unique ID of this Cloudlet /**
* @param cloudletLength the length or size (in MI) of this cloudlet to be executed in a * The Cloudlet has been executed successfully.
* PowerDatacenter */
* @param cloudletFileSize the file size (in byte) of this cloudlet <tt>BEFORE</tt> submitting public static final int SUCCESS = 4;
* to a PowerDatacenter
* @param cloudletOutputSize the file size (in byte) of this cloudlet <tt>AFTER</tt> finish /**
* executing by a PowerDatacenter * The Cloudlet has failed.
* @param fileList list of files required by this cloudlet */
* @param pesNumber the pes number public static final int FAILED = 5;
* @param utilizationModelCpu the utilization model of cpu
* @param utilizationModelRam the utilization model of ram /**
* @param utilizationModelBw the utilization model of bw * The Cloudlet has been canceled.
* */
* @pre cloudletID >= 0 public static final int CANCELED = 6;
* @pre cloudletLength >= 0.0
* @pre cloudletFileSize >= 1 /**
* @pre cloudletOutputSize >= 1 * The Cloudlet has been paused. It can be resumed by changing the status
* @post $none * into <tt>RESUMED</tt>.
*/ */
public Cloudlet( public static final int PAUSED = 7;
final int cloudletId,
final long cloudletLength, /**
final int pesNumber, * The Cloudlet has been resumed from <tt>PAUSED</tt> state.
final long cloudletFileSize, */
final long cloudletOutputSize, public static final int RESUMED = 8;
final UtilizationModel utilizationModelCpu,
final UtilizationModel utilizationModelRam, /**
final UtilizationModel utilizationModelBw, * The cloudlet has failed due to a resource failure.
final List<String> fileList) { */
this( public static final int FAILED_RESOURCE_UNAVAILABLE = 9;
cloudletId,
cloudletLength, /**
pesNumber, * The id of the vm that is planned to execute the cloudlet.
cloudletFileSize, */
cloudletOutputSize, protected int vmId;
utilizationModelCpu,
utilizationModelRam, /**
utilizationModelBw, * The cost of each byte of bandwidth (bw) consumed.
false); */
vmId = -1; protected double costPerBw;
accumulatedBwCost = 0.0;
costPerBw = 0.0; /**
* The total bandwidth (bw) cost for transferring the cloudlet by the
requiredFiles = fileList; * network, according to the {@link #cloudletFileSize}.
} */
protected double accumulatedBwCost;
/**
* Allocates a new Cloudlet object. The Cloudlet length, input and output file sizes should be // Utilization
* greater than or equal to 1. /**
* * The utilization model that defines how the cloudlet will use the VM's
* @param cloudletId the unique ID of this cloudlet * CPU.
* @param cloudletLength the length or size (in MI) of this cloudlet to be executed in a */
* PowerDatacenter private UtilizationModel utilizationModelCpu;
* @param cloudletFileSize the file size (in byte) of this cloudlet <tt>BEFORE</tt> submitting
* to a PowerDatacenter /**
* @param cloudletOutputSize the file size (in byte) of this cloudlet <tt>AFTER</tt> finish * The utilization model that defines how the cloudlet will use the VM's
* executing by a PowerDatacenter * RAM.
* @param record record the history of this object or not */
* @param pesNumber the pes number private UtilizationModel utilizationModelRam;
* @param utilizationModelCpu the utilization model of cpu
* @param utilizationModelRam the utilization model of ram /**
* @param utilizationModelBw the utilization model of bw * The utilization model that defines how the cloudlet will use the VM's
* * bandwidth (bw).
* @pre cloudletID >= 0 */
* @pre cloudletLength >= 0.0 private UtilizationModel utilizationModelBw;
* @pre cloudletFileSize >= 1
* @pre cloudletOutputSize >= 1 // Data cloudlet
* @post $none /**
*/ * The required files to be used by the cloudlet (if any). The time to
public Cloudlet( * transfer these files by the network is considered when placing the
final int cloudletId, * cloudlet inside a given VM
final long cloudletLength, */
final int pesNumber, private List<String> requiredFiles = null;
final long cloudletFileSize,
final long cloudletOutputSize, /**
final UtilizationModel utilizationModelCpu, * Allocates a new Cloudlet object. The Cloudlet length, input and output
final UtilizationModel utilizationModelRam, * file sizes should be greater than or equal to 1. By default this
final UtilizationModel utilizationModelBw, * constructor sets the history of this object.
final boolean record) { *
userId = -1; // to be set by a Broker or user * @param cloudletId the unique ID of this Cloudlet
status = CREATED; * @param cloudletLength the length or size (in MI) of this cloudlet to be
this.cloudletId = cloudletId; * executed in a PowerDatacenter
numberOfPes = pesNumber; * @param cloudletFileSize the file size (in byte) of this cloudlet
execStartTime = 0.0; * <tt>BEFORE</tt> submitting to a Datacenter
finishTime = -1.0; // meaning this Cloudlet hasn't finished yet * @param cloudletOutputSize the file size (in byte) of this cloudlet
classType = 0; * <tt>AFTER</tt> finish executing by a Datacenter
netToS = 0; * @param pesNumber the pes number
* @param utilizationModelCpu the utilization model of cpu
// Cloudlet length, Input and Output size should be at least 1 byte. * @param utilizationModelRam the utilization model of ram
this.cloudletLength = Math.max(1, cloudletLength); * @param utilizationModelBw the utilization model of bw
this.cloudletFileSize = Math.max(1, cloudletFileSize); *
this.cloudletOutputSize = Math.max(1, cloudletOutputSize); * @pre cloudletID >= 0
* @pre cloudletLength >= 0.0
* @pre cloudletFileSize >= 1
* @pre cloudletOutputSize >= 1
* @post $none
*/
public Cloudlet(
final int cloudletId,
final long cloudletLength,
final int pesNumber,
final long cloudletFileSize,
final long cloudletOutputSize,
final UtilizationModel utilizationModelCpu,
final UtilizationModel utilizationModelRam,
final UtilizationModel utilizationModelBw) {
this(
cloudletId,
cloudletLength,
pesNumber,
cloudletFileSize,
cloudletOutputSize,
utilizationModelCpu,
utilizationModelRam,
utilizationModelBw,
false);
vmId = -1;
accumulatedBwCost = 0;
costPerBw = 0;
requiredFiles = new LinkedList<String>();
}
/**
* Allocates a new Cloudlet object. The Cloudlet length, input and output
* file sizes should be greater than or equal to 1.
*
* @param cloudletId the unique ID of this cloudlet
* @param cloudletLength the length or size (in MI) of this cloudlet to be
* executed in a PowerDatacenter
* @param cloudletFileSize the file size (in byte) of this cloudlet
* <tt>BEFORE</tt> submitting to a PowerDatacenter
* @param cloudletOutputSize the file size (in byte) of this cloudlet
* <tt>AFTER</tt> finish executing by a PowerDatacenter
* @param record record the history of this object or not
* @param fileList list of files required by this cloudlet
* @param pesNumber the pes number
* @param utilizationModelCpu the utilization model of cpu
* @param utilizationModelRam the utilization model of ram
* @param utilizationModelBw the utilization model of bw
*
* @pre cloudletID >= 0
* @pre cloudletLength >= 0.0
* @pre cloudletFileSize >= 1
* @pre cloudletOutputSize >= 1
* @post $none
*/
public Cloudlet(
final int cloudletId,
final long cloudletLength,
final int pesNumber,
final long cloudletFileSize,
final long cloudletOutputSize,
final UtilizationModel utilizationModelCpu,
final UtilizationModel utilizationModelRam,
final UtilizationModel utilizationModelBw,
final boolean record,
final List<String> fileList) {
this(
cloudletId,
cloudletLength,
pesNumber,
cloudletFileSize,
cloudletOutputSize,
utilizationModelCpu,
utilizationModelRam,
utilizationModelBw,
record);
vmId = -1;
accumulatedBwCost = 0.0;
costPerBw = 0.0;
requiredFiles = fileList;
}
/**
* Allocates a new Cloudlet object. The Cloudlet length, input and output
* file sizes should be greater than or equal to 1. By default this
* constructor sets the history of this object.
*
* @param cloudletId the unique ID of this Cloudlet
* @param cloudletLength the length or size (in MI) of this cloudlet to be
* executed in a PowerDatacenter
* @param cloudletFileSize the file size (in byte) of this cloudlet
* <tt>BEFORE</tt> submitting to a PowerDatacenter
* @param cloudletOutputSize the file size (in byte) of this cloudlet
* <tt>AFTER</tt> finish executing by a PowerDatacenter
* @param fileList list of files required by this cloudlet
* @param pesNumber the pes number
* @param utilizationModelCpu the utilization model of cpu
* @param utilizationModelRam the utilization model of ram
* @param utilizationModelBw the utilization model of bw
*
* @pre cloudletID >= 0
* @pre cloudletLength >= 0.0
* @pre cloudletFileSize >= 1
* @pre cloudletOutputSize >= 1
* @post $none
*/
public Cloudlet(
final int cloudletId,
final long cloudletLength,
final int pesNumber,
final long cloudletFileSize,
final long cloudletOutputSize,
final UtilizationModel utilizationModelCpu,
final UtilizationModel utilizationModelRam,
final UtilizationModel utilizationModelBw,
final List<String> fileList) {
this(
cloudletId,
cloudletLength,
pesNumber,
cloudletFileSize,
cloudletOutputSize,
utilizationModelCpu,
utilizationModelRam,
utilizationModelBw,
false);
vmId = -1;
accumulatedBwCost = 0.0;
costPerBw = 0.0;
requiredFiles = fileList;
}
/**
* Allocates a new Cloudlet object. The Cloudlet length, input and output
* file sizes should be greater than or equal to 1.
*
* @param cloudletId the unique ID of this cloudlet
* @param cloudletLength the length or size (in MI) of this cloudlet to be
* executed in a PowerDatacenter
* @param cloudletFileSize the file size (in byte) of this cloudlet
* <tt>BEFORE</tt> submitting to a PowerDatacenter
* @param cloudletOutputSize the file size (in byte) of this cloudlet
* <tt>AFTER</tt> finish executing by a PowerDatacenter
* @param record record the history of this object or not
* @param pesNumber the pes number
* @param utilizationModelCpu the utilization model of cpu
* @param utilizationModelRam the utilization model of ram
* @param utilizationModelBw the utilization model of bw
*
* @pre cloudletID >= 0
* @pre cloudletLength >= 0.0
* @pre cloudletFileSize >= 1
* @pre cloudletOutputSize >= 1
* @post $none
*/
public Cloudlet(
final int cloudletId,
final long cloudletLength,
final int pesNumber,
final long cloudletFileSize,
final long cloudletOutputSize,
final UtilizationModel utilizationModelCpu,
final UtilizationModel utilizationModelRam,
final UtilizationModel utilizationModelBw,
final boolean record) {
userId = -1; // to be set by a Broker or user
status = CREATED;
this.cloudletId = cloudletId;
numberOfPes = pesNumber;
execStartTime = 0.0;
finishTime = -1.0; // meaning this Cloudlet hasn't finished yet
classType = 0;
netToS = 0;
// Cloudlet length, Input and Output size should be at least 1 byte.
this.cloudletLength = Math.max(1, cloudletLength);
this.cloudletFileSize = Math.max(1, cloudletFileSize);
this.cloudletOutputSize = Math.max(1, cloudletOutputSize);
// Normally, a Cloudlet is only executed on a resource without being // Normally, a Cloudlet is only executed on a resource without being
// migrated to others. Hence, to reduce memory consumption, set the // migrated to others. Hence, to reduce memory consumption, set the
// size of this ArrayList to be less than the default one. // size of this ArrayList to be less than the default one.
resList = new ArrayList<Resource>(2); resList = new ArrayList<Resource>(2);
index = -1; index = -1;
this.record = record; this.record = record;
vmId = -1; vmId = -1;
accumulatedBwCost = 0.0; accumulatedBwCost = 0.0;
costPerBw = 0.0; costPerBw = 0.0;
requiredFiles = new LinkedList<String>(); requiredFiles = new LinkedList<String>();
setUtilizationModelCpu(utilizationModelCpu); setUtilizationModelCpu(utilizationModelCpu);
setUtilizationModelRam(utilizationModelRam); setUtilizationModelRam(utilizationModelRam);
setUtilizationModelBw(utilizationModelBw); setUtilizationModelBw(utilizationModelBw);
} }
// ////////////////////// INTERNAL CLASS /////////////////////////////////// // ////////////////////// INTERNAL CLASS ///////////////////////////////////
/**
* Internal class that keeps track of Cloudlet's movement in different
* CloudResources. Each time a cloudlet is run on a given VM, the cloudlet's
* execution history on each VM is registered at {@link Cloudlet#resList}
*/
private static class Resource {
/**
* Cloudlet's submission (arrival) time to a CloudResource.
*/
public double submissionTime = 0.0;
/** /**
* Internal class that keeps track of Cloudlet's movement in different CloudResources. * The time this Cloudlet resides in a CloudResource (from arrival time
* Each time a cloudlet is run on a given VM, the cloudlet's execution history * until departure time, that may include waiting time).
* on each VM is registered at {@link Cloudlet#resList} */
*/ public double wallClockTime = 0.0;
private static class Resource {
/** Cloudlet's submission (arrival) time to a CloudResource. */
public double submissionTime = 0.0;
/**
* The time this Cloudlet resides in a CloudResource (from arrival time until departure
* time, that may include waiting time).
*/
public double wallClockTime = 0.0;
/** The total time the Cloudlet spent being executed in a CloudResource. */ /**
public double actualCPUTime = 0.0; * The total time the Cloudlet spent being executed in a CloudResource.
*/
public double actualCPUTime = 0.0;
/** Cost per second a CloudResource charge to execute this Cloudlet. */ /**
public double costPerSec = 0.0; * Cost per second a CloudResource charge to execute this Cloudlet.
*/
public double costPerSec = 0.0;
/** Cloudlet's length finished so far. */ /**
public long finishedSoFar = 0; * Cloudlet's length finished so far.
*/
public long finishedSoFar = 0;
/** a CloudResource id. */ /**
public int resourceId = -1; * a CloudResource id.
*/
public int resourceId = -1;
/** a CloudResource name. */ /**
public String resourceName = null; * a CloudResource name.
*/
public String resourceName = null;
} }
// ////////////////////// End of Internal Class ////////////////////////// // ////////////////////// End of Internal Class //////////////////////////
/**
/** * Sets the id of the reservation made for this cloudlet.
* Sets the id of the reservation made for this cloudlet. *
* * @param resId the reservation ID
* @param resId the reservation ID * @return <tt>true</tt> if the ID has successfully been set or
* @return <tt>true</tt> if the ID has successfully been set or <tt>false</tt> otherwise. * <tt>false</tt> otherwise.
*/ */
public boolean setReservationId(final int resId) { public boolean setReservationId(final int resId) {
if (resId <= 0) { if (resId <= 0) {
return false; return false;
} }
reservationId = resId; reservationId = resId;
return true; return true;
} }
/** /**
* Gets the reservation ID that owns this Cloudlet. * Gets the reservation ID that owns this Cloudlet.
* *
* @return a reservation ID * @return a reservation ID
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public int getReservationId() { public int getReservationId() {
return reservationId; return reservationId;
} }
/** /**
* Checks whether this Cloudlet is submitted by reserving or not. * Checks whether this Cloudlet is submitted by reserving or not.
* *
* @return <tt>true</tt> if this Cloudlet has reserved before, <tt>false</tt> otherwise * @return <tt>true</tt> if this Cloudlet has reserved before,
*/ * <tt>false</tt> otherwise
public boolean hasReserved() { */
if (reservationId == -1) { public boolean hasReserved() {
return false; if (reservationId == -1) {
} return false;
return true; }
} return true;
}
/**
* Sets the length or size (in MI) of this Cloudlet to be executed in a CloudResource. /**
* It has to be the length for each individual Pe, <tt>not</tt> the total length (the sum of * Sets the length or size (in MI) of this Cloudlet to be executed in a
* length to be executed by each Pe). * CloudResource. It has to be the length for each individual Pe,
* * <tt>not</tt> the total length (the sum of length to be executed by each
* @param cloudletLength the length or size (in MI) of this Cloudlet to be executed in a * Pe).
* CloudResource *
* @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise * @param cloudletLength the length or size (in MI) of this Cloudlet to be
* * executed in a CloudResource
* @see #getCloudletTotalLength() } * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise
* @pre cloudletLength > 0 *
* @post $none * @see #getCloudletTotalLength() }
*/ * @pre cloudletLength > 0
public boolean setCloudletLength(final long cloudletLength) { * @post $none
if (cloudletLength <= 0) { */
return false; public boolean setCloudletLength(final long cloudletLength) {
} if (cloudletLength <= 0) {
return false;
this.cloudletLength = cloudletLength; }
return true;
} this.cloudletLength = cloudletLength;
return true;
/** }
* Sets the network service level (ToS) for sending this cloudlet over a network.
* /**
* @param netServiceLevel determines the type of service (ToS) this cloudlet receives in the network * Sets the network service level (ToS) for sending this cloudlet over a
* (applicable to selected PacketScheduler class only) * network.
* @return <code>true</code> if successful. *
* @pre netServiceLevel >= 0 * @param netServiceLevel determines the type of service (ToS) this cloudlet
* @post $none * receives in the network (applicable to selected PacketScheduler class
* * only)
* @todo The name of the setter is inconsistent with the attribute name, what * @return <code>true</code> if successful.
* might be misinterpreted by other developers. * @pre netServiceLevel >= 0
*/ * @post $none
public boolean setNetServiceLevel(final int netServiceLevel) { *
boolean success = false; * @todo The name of the setter is inconsistent with the attribute name,
if (netServiceLevel > 0) { * what might be misinterpreted by other developers.
netToS = netServiceLevel; */
success = true; public boolean setNetServiceLevel(final int netServiceLevel) {
} boolean success = false;
if (netServiceLevel > 0) {
return success; netToS = netServiceLevel;
} success = true;
}
/**
* Gets the network service level (ToS) for sending this cloudlet over a network. return success;
* }
* @return the network service level
* @pre $none /**
* @post $none * Gets the network service level (ToS) for sending this cloudlet over a
* @todo The name of the getter is inconsistent with the attribute name, what * network.
* might be misinterpreted by other developers. *
*/ * @return the network service level
public int getNetServiceLevel() { * @pre $none
return netToS; * @post $none
} * @todo The name of the getter is inconsistent with the attribute name,
* what might be misinterpreted by other developers.
/** */
* Gets the time the cloudlet had to wait before start executing on a resource. public int getNetServiceLevel() {
* return netToS;
* @return the waiting time }
* @pre $none
* @post $none /**
*/ * Gets the time the cloudlet had to wait before start executing on a
public double getWaitingTime() { * resource.
if (index == -1) { *
return 0; * @return the waiting time
} * @pre $none
* @post $none
// use the latest resource submission time */
final double subTime = resList.get(index).submissionTime; public double getWaitingTime() {
return execStartTime - subTime; if (index == -1) {
} return 0;
}
/**
* Sets the classType or priority of this Cloudlet for scheduling on a resource. // use the latest resource submission time
* final double subTime = resList.get(index).submissionTime;
* @param classType classType of this Cloudlet return execStartTime - subTime;
* @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise }
*
* @pre classType > 0 /**
* @post $none * Sets the classType or priority of this Cloudlet for scheduling on a
*/ * resource.
public boolean setClassType(final int classType) { *
boolean success = false; * @param classType classType of this Cloudlet
if (classType > 0) { * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise
this.classType = classType; *
success = true; * @pre classType > 0
} * @post $none
*/
return success; public boolean setClassType(final int classType) {
} boolean success = false;
if (classType > 0) {
/** this.classType = classType;
* Gets the classtype or priority of this Cloudlet for scheduling on a resource. success = true;
* }
* @return classtype of this cloudlet
* @pre $none return success;
* @post $none }
*/
public int getClassType() { /**
return classType; * Gets the classtype or priority of this Cloudlet for scheduling on a
} * resource.
*
/** * @return classtype of this cloudlet
* Sets the number of PEs required to run this Cloudlet. <br> * @pre $none
* NOTE: The Cloudlet length is computed only for 1 Pe for simplicity. <br> * @post $none
* For example, consider a Cloudlet that has a length of 500 MI and requires 2 PEs. */
* This means each Pe will execute 500 MI of this Cloudlet. public int getClassType() {
* return classType;
* @param numberOfPes number of Pe }
* @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise
* /**
* @pre numPE > 0 * Sets the number of PEs required to run this Cloudlet. <br>
* @post $none * NOTE: The Cloudlet length is computed only for 1 Pe for simplicity. <br>
*/ * For example, consider a Cloudlet that has a length of 500 MI and requires
public boolean setNumberOfPes(final int numberOfPes) { * 2 PEs. This means each Pe will execute 500 MI of this Cloudlet.
if (numberOfPes > 0) { *
this.numberOfPes = numberOfPes; * @param numberOfPes number of Pe
return true; * @return <tt>true</tt> if it is successful, <tt>false</tt> otherwise
} *
return false; * @pre numPE > 0
} * @post $none
*/
/** public boolean setNumberOfPes(final int numberOfPes) {
* Gets the number of PEs required to run this Cloudlet. if (numberOfPes > 0) {
* this.numberOfPes = numberOfPes;
* @return number of PEs return true;
* }
* @pre $none return false;
* @post $none }
*/
public int getNumberOfPes() { /**
return numberOfPes; * Gets the number of PEs required to run this Cloudlet.
} *
* @return number of PEs
/** *
* Gets the transaction history of this Cloudlet. * @pre $none
* The layout of this history is in a readable table column * @post $none
* with <tt>time</tt> and <tt>description</tt> as headers. */
* public int getNumberOfPes() {
* @return a String containing the history of this Cloudlet object. return numberOfPes;
* @pre $none }
* @post $result != null
*/ /**
public String getCloudletHistory() { * Gets the transaction history of this Cloudlet. The layout of this history
String msg = null; * is in a readable table column with <tt>time</tt> and <tt>description</tt>
if (history == null) { * as headers.
msg = "No history is recorded for Cloudlet #" + cloudletId; *
} else { * @return a String containing the history of this Cloudlet object.
msg = history.toString(); * @pre $none
} * @post $result != null
*/
return msg; public String getCloudletHistory() {
} String msg = null;
if (history == null) {
/** msg = "No history is recorded for Cloudlet #" + cloudletId;
* Gets the length of this Cloudlet that has been executed so far from the latest CloudResource. } else {
* This method is useful when trying to move this Cloudlet into different CloudResources or to msg = history.toString();
* cancel it. }
*
* @return the length of a partially executed Cloudlet or the full Cloudlet length if it is return msg;
* completed }
* @pre $none
* @post $result >= 0.0 /**
*/ * Gets the length of this Cloudlet that has been executed so far from the
public long getCloudletFinishedSoFar() { * latest CloudResource. This method is useful when trying to move this
if (index == -1) { * Cloudlet into different CloudResources or to cancel it.
return cloudletLength; *
} * @return the length of a partially executed Cloudlet or the full Cloudlet
* length if it is completed
final long finish = resList.get(index).finishedSoFar; * @pre $none
if (finish > cloudletLength) { * @post $result >= 0.0
return cloudletLength; */
} public long getCloudletFinishedSoFar() {
if (index == -1) {
return finish; return cloudletLength;
} }
/** final long finish = resList.get(index).finishedSoFar;
* Checks whether this Cloudlet has finished execution or not. if (finish > cloudletLength) {
* return cloudletLength;
* @return <tt>true</tt> if this Cloudlet has finished execution, <tt>false</tt> otherwise }
* @pre $none
* @post $none return finish;
*/ }
public boolean isFinished() {
if (index == -1) { /**
return false; * Checks whether this Cloudlet has finished execution or not.
} *
* @return <tt>true</tt> if this Cloudlet has finished execution,
boolean completed = false; * <tt>false</tt> otherwise
* @pre $none
// if result is 0 or -ve then this Cloudlet has finished * @post $none
final long finish = resList.get(index).finishedSoFar; */
final long result = cloudletLength - finish; public boolean isFinished() {
if (result <= 0.0) { if (index == -1) {
completed = true; return false;
} }
return completed;
} boolean completed = false;
/** // if result is 0 or -ve then this Cloudlet has finished
* Sets the length of this Cloudlet that has been executed so far. This method is used by final long finish = resList.get(index).finishedSoFar;
* ResCloudlet class when an application is decided to cancel or to move this Cloudlet into final long result = cloudletLength - finish;
* different CloudResources. if (result <= 0.0) {
* completed = true;
* @param length length of this Cloudlet }
* @see gridsim.AllocPolicy return completed;
* @see gridsim.ResCloudlet }
* @pre length >= 0.0
* @post $none /**
*/ * Sets the length of this Cloudlet that has been executed so far. This
public void setCloudletFinishedSoFar(final long length) { * method is used by ResCloudlet class when an application is decided to
// if length is -ve then ignore * cancel or to move this Cloudlet into different CloudResources.
if (length < 0.0 || index < 0) { *
return; * @param length length of this Cloudlet
} * @see gridsim.AllocPolicy
* @see gridsim.ResCloudlet
final Resource res = resList.get(index); * @pre length >= 0.0
res.finishedSoFar = length; * @post $none
*/
if (record) { public void setCloudletFinishedSoFar(final long length) {
write("Sets the length's finished so far to " + length); // if length is -ve then ignore
} if (length < 0.0 || index < 0) {
} return;
}
/**
* Sets the user or owner ID of this Cloudlet. It is <tt>VERY</tt> important to set the user ID, final Resource res = resList.get(index);
* otherwise this Cloudlet will not be executed in a CloudResource. res.finishedSoFar = length;
*
* @param id the user ID if (record) {
* @pre id >= 0 write("Sets the length's finished so far to " + length);
* @post $none }
*/ }
public void setUserId(final int id) {
userId = id; /**
if (record) { * Sets the user or owner ID of this Cloudlet. It is <tt>VERY</tt> important
write("Assigns the Cloudlet to " + CloudSim.getEntityName(id) + " (ID #" + id + ")"); * to set the user ID, otherwise this Cloudlet will not be executed in a
} * CloudResource.
} *
* @param id the user ID
/** * @pre id >= 0
* Gets the user or owner ID of this Cloudlet. * @post $none
* */
* @return the user ID or <tt>-1</tt> if the user ID has not been set before public void setUserId(final int id) {
* @pre $none userId = id;
* @post $result >= -1 if (record) {
*/ write("Assigns the Cloudlet to " + CloudSim.getEntityName(id) + " (ID #" + id + ")");
public int getUserId() { }
return userId; }
}
/**
/** * Gets the user or owner ID of this Cloudlet.
* Gets the latest resource ID that processes this Cloudlet. *
* * @return the user ID or <tt>-1</tt> if the user ID has not been set before
* @return the resource ID or <tt>-1</tt> if none * @pre $none
* @pre $none * @post $result >= -1
* @post $result >= -1 */
*/ public int getUserId() {
public int getResourceId() { return userId;
if (index == -1) { }
return -1;
} /**
return resList.get(index).resourceId; * Gets the latest resource ID that processes this Cloudlet.
} *
* @return the resource ID or <tt>-1</tt> if none
/** * @pre $none
* Gets the input file size of this Cloudlet <tt>BEFORE</tt> submitting to a CloudResource. * @post $result >= -1
* */
* @return the input file size of this Cloudlet public int getResourceId() {
* @pre $none if (index == -1) {
* @post $result >= 1 return -1;
*/ }
public long getCloudletFileSize() { return resList.get(index).resourceId;
return cloudletFileSize; }
}
/**
/** * Gets the input file size of this Cloudlet <tt>BEFORE</tt> submitting to a
* Gets the output size of this Cloudlet <tt>AFTER</tt> submitting and executing to a * CloudResource.
* CloudResource. *
* * @return the input file size of this Cloudlet
* @return the Cloudlet output file size * @pre $none
* @pre $none * @post $result >= 1
* @post $result >= 1 */
*/ public long getCloudletFileSize() {
public long getCloudletOutputSize() { return cloudletFileSize;
return cloudletOutputSize; }
}
/**
/** * Gets the output size of this Cloudlet <tt>AFTER</tt> submitting and
* Sets the resource parameters for which the Cloudlet is going to be executed. * executing to a CloudResource.
* From the second time this method is called, every call make *
* the cloudlet to be migrated to the indicated resource.<br> * @return the Cloudlet output file size
* * @pre $none
* NOTE: This method <tt>should</tt> be called only by a resource entity, not the user or owner * @post $result >= 1
* of this Cloudlet. */
* public long getCloudletOutputSize() {
* @param resourceID the CloudResource ID return cloudletOutputSize;
* @param cost the cost running this CloudResource per second }
*
* @pre resourceID >= 0 /**
* @pre cost > 0.0 * Sets the resource parameters for which the Cloudlet is going to be
* @post $none * executed. From the second time this method is called, every call make the
*/ * cloudlet to be migrated to the indicated resource.<br>
public void setResourceParameter(final int resourceID, final double cost) { *
final Resource res = new Resource(); * NOTE: This method <tt>should</tt> be called only by a resource entity,
res.resourceId = resourceID; * not the user or owner of this Cloudlet.
res.costPerSec = cost; *
res.resourceName = CloudSim.getEntityName(resourceID); * @param resourceID the CloudResource ID
* @param cost the cost running this CloudResource per second
// add into a list if moving to a new grid resource *
resList.add(res); * @pre resourceID >= 0
* @pre cost > 0.0
if (index == -1 && record) { * @post $none
write("Allocates this Cloudlet to " + res.resourceName + " (ID #" + resourceID */
+ ") with cost = $" + cost + "/sec"); public void setResourceParameter(final int resourceID, final double cost) {
} else if (record) { final Resource res = new Resource();
final int id = resList.get(index).resourceId; res.resourceId = resourceID;
final String name = resList.get(index).resourceName; res.costPerSec = cost;
write("Moves Cloudlet from " + name + " (ID #" + id + ") to " + res.resourceName + " (ID #" res.resourceName = CloudSim.getEntityName(resourceID);
+ resourceID + ") with cost = $" + cost + "/sec");
} // add into a list if moving to a new grid resource
resList.add(res);
index++; // initially, index = -1
} if (index == -1 && record) {
write("Allocates this Cloudlet to " + res.resourceName + " (ID #" + resourceID
/** + ") with cost = $" + cost + "/sec");
* Sets the submission (arrival) time of this Cloudlet into a CloudResource. } else if (record) {
* final int id = resList.get(index).resourceId;
* @param clockTime the submission time final String name = resList.get(index).resourceName;
* @pre clockTime >= 0.0 write("Moves Cloudlet from " + name + " (ID #" + id + ") to " + res.resourceName + " (ID #"
* @post $none + resourceID + ") with cost = $" + cost + "/sec");
*/ }
public void setSubmissionTime(final double clockTime) {
if (clockTime < 0.0 || index < 0) { index++; // initially, index = -1
return; }
}
/**
final Resource res = resList.get(index); * Sets the submission (arrival) time of this Cloudlet into a CloudResource.
res.submissionTime = clockTime; *
* @param clockTime the submission time
if (record) { * @pre clockTime >= 0.0
write("Sets the submission time to " + num.format(clockTime)); * @post $none
} */
} public void setSubmissionTime(final double clockTime) {
if (clockTime < 0.0 || index < 0) {
/** return;
* Gets the submission (arrival) time of this Cloudlet from the latest CloudResource. }
*
* @return the submission time or <tt>0.0</tt> if none final Resource res = resList.get(index);
* @pre $none res.submissionTime = clockTime;
* @post $result >= 0.0
*/ if (record) {
public double getSubmissionTime() { write("Sets the submission time to " + num.format(clockTime));
if (index == -1) { }
return 0.0; }
}
return resList.get(index).submissionTime; /**
} * Gets the submission (arrival) time of this Cloudlet from the latest
* CloudResource.
/** *
* Sets the execution start time of this Cloudlet inside a CloudResource. * @return the submission time or <tt>0.0</tt> if none
* <br/> * @pre $none
* <b>NOTE:</b> With new * @post $result >= 0.0
* functionalities, such as being able to cancel / to pause / to resume this Cloudlet, the */
* execution start time only holds the latest one. Meaning, all previous execution start time public double getSubmissionTime() {
* are ignored. if (index == -1) {
* return 0.0;
* @param clockTime the latest execution start time }
* @pre clockTime >= 0.0 return resList.get(index).submissionTime;
* @post $none }
*/
public void setExecStartTime(final double clockTime) { /**
execStartTime = clockTime; * Sets the execution start time of this Cloudlet inside a CloudResource.
if (record) { * <br/>
write("Sets the execution start time to " + num.format(clockTime)); * <b>NOTE:</b> With new functionalities, such as being able to cancel / to
} * pause / to resume this Cloudlet, the execution start time only holds the
} * latest one. Meaning, all previous execution start time are ignored.
*
/** * @param clockTime the latest execution start time
* Gets the latest execution start time. * @pre clockTime >= 0.0
* * @post $none
* @return the latest execution start time */
* @pre $none public void setExecStartTime(final double clockTime) {
* @post $result >= 0.0 execStartTime = clockTime;
*/ if (record) {
public double getExecStartTime() { write("Sets the execution start time to " + num.format(clockTime));
return execStartTime; }
} }
/** /**
* Sets the Cloudlet's execution parameters. These parameters are set by the CloudResource * Gets the latest execution start time.
* before departure or sending back to the original Cloudlet's owner. *
* * @return the latest execution start time
* @param wallTime the time of this Cloudlet resides in a CloudResource * @pre $none
* (from arrival time until departure time). * @post $result >= 0.0
* @param actualTime the total execution time of this Cloudlet in a CloudResource. */
* public double getExecStartTime() {
* @see Resource#wallClockTime return execStartTime;
* @see Resource#actualCPUTime }
*
* @pre wallTime >= 0.0 /**
* @pre actualTime >= 0.0 * Sets the Cloudlet's execution parameters. These parameters are set by the
* @post $none * CloudResource before departure or sending back to the original Cloudlet's
*/ * owner.
public void setExecParam(final double wallTime, final double actualTime) { *
if (wallTime < 0.0 || actualTime < 0.0 || index < 0) { * @param wallTime the time of this Cloudlet resides in a CloudResource
return; * (from arrival time until departure time).
} * @param actualTime the total execution time of this Cloudlet in a
* CloudResource.
final Resource res = resList.get(index); *
res.wallClockTime = wallTime; * @see Resource#wallClockTime
res.actualCPUTime = actualTime; * @see Resource#actualCPUTime
*
if (record) { * @pre wallTime >= 0.0
write("Sets the wall clock time to " + num.format(wallTime) + " and the actual CPU time to " * @pre actualTime >= 0.0
+ num.format(actualTime)); * @post $none
} */
} public void setExecParam(final double wallTime, final double actualTime) {
if (wallTime < 0.0 || actualTime < 0.0 || index < 0) {
/** return;
* Sets the execution status code of this Cloudlet. }
*
* @param newStatus the status code of this Cloudlet final Resource res = resList.get(index);
* @throws Exception Invalid range of Cloudlet status res.wallClockTime = wallTime;
* @pre newStatus >= 0 && newStatus <= 8 res.actualCPUTime = actualTime;
* @post $none
* if (record) {
* @todo It has to throw an specific (unckecked) exception write("Sets the wall clock time to " + num.format(wallTime) + " and the actual CPU time to "
*/ + num.format(actualTime));
public void setCloudletStatus(final int newStatus) throws Exception { }
// if the new status is same as current one, then ignore the rest }
if (status == newStatus) {
return; /**
} * Sets the execution status code of this Cloudlet.
*
// throws an exception if the new status is outside the range * @param newStatus the status code of this Cloudlet
if (newStatus < Cloudlet.CREATED || newStatus > Cloudlet.FAILED_RESOURCE_UNAVAILABLE) { * @throws Exception Invalid range of Cloudlet status
throw new Exception( * @pre newStatus >= 0 && newStatus <= 8
"Cloudlet.setCloudletStatus() : Error - Invalid integer range for Cloudlet status."); * @
} * post $none
*
if (newStatus == Cloudlet.SUCCESS) { * @todo It has to throw an specific (unckecked) exception
finishTime = CloudSim.clock(); */
} public void setCloudletStatus(final int newStatus) throws Exception {
// if the new status is same as current one, then ignore the rest
if (record) { if (status == newStatus) {
write("Sets Cloudlet status from " + getCloudletStatusString() + " to " return;
+ Cloudlet.getStatusString(newStatus)); }
}
// throws an exception if the new status is outside the range
status = newStatus; if (newStatus < Cloudlet.CREATED || newStatus > Cloudlet.FAILED_RESOURCE_UNAVAILABLE) {
} throw new Exception(
"Cloudlet.setCloudletStatus() : Error - Invalid integer range for Cloudlet status.");
/** }
* Gets the status code of this Cloudlet.
* if (newStatus == Cloudlet.SUCCESS) {
* @return the status code of this Cloudlet finishTime = CloudSim.clock();
* @pre $none }
* @post $result >= 0
* @deprecated Use the getter {@link #getStatus()} instead if (record) {
*/ write("Sets Cloudlet status from " + getCloudletStatusString() + " to "
@Deprecated + Cloudlet.getStatusString(newStatus));
public int getCloudletStatus() { }
return status;
} status = newStatus;
}
/**
* Gets the string representation of the current Cloudlet status code. /**
* * Gets the status code of this Cloudlet.
* @return the Cloudlet status code as a string or <tt>null</tt> if the status code is unknown *
* @pre $none * @return the status code of this Cloudlet
* @post $none * @pre $none
*/ * @post $result >= 0
public String getCloudletStatusString() { * @deprecated Use the getter {@link #getStatus()} instead
return Cloudlet.getStatusString(status); */
} @Deprecated
public int getCloudletStatus() {
/** return status;
* Gets the string representation of the given Cloudlet status code. }
*
* @param status the Cloudlet status code /**
* @return the Cloudlet status code as a string or <tt>null</tt> if the status code is unknown * Gets the string representation of the current Cloudlet status code.
* @pre $none *
* @post $none * @return the Cloudlet status code as a string or <tt>null</tt> if the
*/ * status code is unknown
public static String getStatusString(final int status) { * @pre $none
String statusString = null; * @post $none
switch (status) { */
case Cloudlet.CREATED: public String getCloudletStatusString() {
statusString = "Created"; return Cloudlet.getStatusString(status);
break; }
case Cloudlet.READY: /**
statusString = "Ready"; * Gets the string representation of the given Cloudlet status code.
break; *
* @param status the Cloudlet status code
case Cloudlet.INEXEC: * @return the Cloudlet status code as a string or <tt>null</tt> if the
statusString = "InExec"; * status code is unknown
break; * @pre $none
* @post $none
case Cloudlet.SUCCESS: */
statusString = "Success"; public static String getStatusString(final int status) {
break; String statusString = null;
switch (status) {
case Cloudlet.QUEUED: case Cloudlet.CREATED:
statusString = "Queued"; statusString = "Created";
break; break;
case Cloudlet.FAILED: case Cloudlet.READY:
statusString = "Failed"; statusString = "Ready";
break; break;
case Cloudlet.CANCELED: case Cloudlet.INEXEC:
statusString = "Canceled"; statusString = "InExec";
break; break;
case Cloudlet.PAUSED: case Cloudlet.SUCCESS:
statusString = "Paused"; statusString = "Success";
break; break;
case Cloudlet.RESUMED: case Cloudlet.QUEUED:
statusString = "Resumed"; statusString = "Queued";
break; break;
case Cloudlet.FAILED_RESOURCE_UNAVAILABLE: case Cloudlet.FAILED:
statusString = "Failed_resource_unavailable"; statusString = "Failed";
break; break;
default: case Cloudlet.CANCELED:
break; statusString = "Canceled";
} break;
return statusString; case Cloudlet.PAUSED:
} statusString = "Paused";
break;
/**
* Gets the length of this Cloudlet. case Cloudlet.RESUMED:
* statusString = "Resumed";
* @return the length of this Cloudlet break;
* @pre $none
* @post $result >= 0.0 case Cloudlet.FAILED_RESOURCE_UNAVAILABLE:
*/ statusString = "Failed_resource_unavailable";
public long getCloudletLength() { break;
return cloudletLength;
} default:
break;
/** }
* Gets the total length (across all PEs) of this Cloudlet.
* It considers the {@link #cloudletLength} of the cloudlet to be executed return statusString;
* in each Pe and the {@link #numberOfPes}.<br/> }
*
* For example, setting the cloudletLenght as 10000 MI and {@link #numberOfPes} /**
* to 4, each Pe will execute 10000 MI. Thus, the entire cloudlet * Gets the length of this Cloudlet.
* has a total length of 40000 MI. *
* * @return the length of this Cloudlet
* * @pre $none
* @return the total length of this Cloudlet * @post $result >= 0.0
* */
* @see #setCloudletLength(long) public long getCloudletLength() {
* @pre $none return cloudletLength;
* @post $result >= 0.0 }
*/
public long getCloudletTotalLength() { /**
return getCloudletLength() * getNumberOfPes(); * Gets the total length (across all PEs) of this Cloudlet. It considers the
} * {@link #cloudletLength} of the cloudlet to be executed in each Pe and the
* {@link #numberOfPes}.<br/>
/** *
* Gets the cost/sec of running the Cloudlet in the latest CloudResource. * For example, setting the cloudletLenght as 10000 MI and
* * {@link #numberOfPes} to 4, each Pe will execute 10000 MI. Thus, the
* @return the cost associated with running this Cloudlet or <tt>0.0</tt> if none * entire cloudlet has a total length of 40000 MI.
* @pre $none *
* @post $result >= 0.0 *
*/ * @return the total length of this Cloudlet
public double getCostPerSec() { *
if (index == -1) { * @see #setCloudletLength(long)
return 0.0; * @pre $none
} * @post $result >= 0.0
return resList.get(index).costPerSec; */
} public long getCloudletTotalLength() {
return getCloudletLength() * getNumberOfPes();
/** }
* Gets the time of this Cloudlet resides in the latest CloudResource (from arrival time until
* departure time). /**
* * Gets the cost/sec of running the Cloudlet in the latest CloudResource.
* @return the time of this Cloudlet resides in a CloudResource *
* @pre $none * @return the cost associated with running this Cloudlet or <tt>0.0</tt> if
* @post $result >= 0.0 * none
*/ * @pre $none
public double getWallClockTime() { * @post $result >= 0.0
if (index == -1) { */
return 0.0; public double getCostPerSec() {
} if (index == -1) {
return resList.get(index).wallClockTime; return 0.0;
} }
return resList.get(index).costPerSec;
/** }
* Gets all the CloudResource names that executed this Cloudlet.
* /**
* @return an array of CloudResource names or <tt>null</tt> if it has none * Gets the time of this Cloudlet resides in the latest CloudResource (from
* @pre $none * arrival time until departure time).
* @post $none *
*/ * @return the time of this Cloudlet resides in a CloudResource
public String[] getAllResourceName() { * @pre $none
final int size = resList.size(); * @post $result >= 0.0
String[] data = null; */
public double getWallClockTime() {
if (size > 0) { if (index == -1) {
data = new String[size]; return 0.0;
for (int i = 0; i < size; i++) { }
data[i] = resList.get(i).resourceName; return resList.get(index).wallClockTime;
} }
}
/**
return data; * Gets all the CloudResource names that executed this Cloudlet.
} *
* @return an array of CloudResource names or <tt>null</tt> if it has none
/** * @pre $none
* Gets all the CloudResource IDs that executed this Cloudlet. * @post $none
* */
* @return an array of CloudResource IDs or <tt>null</tt> if it has none public String[] getAllResourceName() {
* @pre $none final int size = resList.size();
* @post $none String[] data = null;
*/
public int[] getAllResourceId() { if (size > 0) {
final int size = resList.size(); data = new String[size];
int[] data = null; for (int i = 0; i < size; i++) {
data[i] = resList.get(i).resourceName;
if (size > 0) { }
data = new int[size]; }
for (int i = 0; i < size; i++) {
data[i] = resList.get(i).resourceId; return data;
} }
}
/**
return data; * Gets all the CloudResource IDs that executed this Cloudlet.
} *
* @return an array of CloudResource IDs or <tt>null</tt> if it has none
/** * @pre $none
* Gets the total execution time of this Cloudlet in a given CloudResource ID. * @post $none
* */
* @param resId a CloudResource entity ID public int[] getAllResourceId() {
* @return the total execution time of this Cloudlet in a CloudResource or <tt>0.0</tt> if not final int size = resList.size();
* found int[] data = null;
* @pre resId >= 0
* @post $result >= 0.0 if (size > 0) {
*/ data = new int[size];
public double getActualCPUTime(final int resId) { for (int i = 0; i < size; i++) {
Resource resource = getResourceById(resId); data[i] = resList.get(i).resourceId;
if (resource != null) { }
return resource.actualCPUTime; }
}
return 0.0; return data;
} }
/** /**
* Gets the cost running this Cloudlet in a given CloudResource ID. * Gets the total execution time of this Cloudlet in a given CloudResource
* * ID.
* @param resId a CloudResource entity ID *
* @return the cost associated with running this Cloudlet or <tt>0.0</tt> if not found * @param resId a CloudResource entity ID
* @pre resId >= 0 * @return the total execution time of this Cloudlet in a CloudResource or
* @post $result >= 0.0 * <tt>0.0</tt> if not found
*/ * @pre resId >= 0
public double getCostPerSec(final int resId) { * @post $result >= 0.0
Resource resource = getResourceById(resId); */
if (resource != null) { public double getActualCPUTime(final int resId) {
return resource.costPerSec; Resource resource = getResourceById(resId);
} if (resource != null) {
return 0.0; return resource.actualCPUTime;
} }
return 0.0;
/** }
* Gets the length of this Cloudlet that has been executed so far in a given CloudResource ID.
* This method is useful when trying to move this Cloudlet into different CloudResources or to /**
* cancel it. * Gets the cost running this Cloudlet in a given CloudResource ID.
* *
* @param resId a CloudResource entity ID * @param resId a CloudResource entity ID
* @return the length of a partially executed Cloudlet or the full Cloudlet length if it is * @return the cost associated with running this Cloudlet or <tt>0.0</tt> if
* completed or <tt>0.0</tt> if not found * not found
* @pre resId >= 0 * @pre resId >= 0
* @post $result >= 0.0 * @post $result >= 0.0
*/ */
public long getCloudletFinishedSoFar(final int resId) { public double getCostPerSec(final int resId) {
Resource resource = getResourceById(resId); Resource resource = getResourceById(resId);
if (resource != null) { if (resource != null) {
return resource.finishedSoFar; return resource.costPerSec;
} }
return 0; return 0.0;
} }
/** /**
* Gets the submission (arrival) time of this Cloudlet in the given CloudResource ID. * Gets the length of this Cloudlet that has been executed so far in a given
* * CloudResource ID. This method is useful when trying to move this Cloudlet
* @param resId a CloudResource entity ID * into different CloudResources or to cancel it.
* @return the submission time or <tt>0.0</tt> if not found *
* @pre resId >= 0 * @param resId a CloudResource entity ID
* @post $result >= 0.0 * @return the length of a partially executed Cloudlet or the full Cloudlet
*/ * length if it is completed or <tt>0.0</tt> if not found
public double getSubmissionTime(final int resId) { * @pre resId >= 0
Resource resource = getResourceById(resId); * @post $result >= 0.0
if (resource != null) { */
return resource.submissionTime; public long getCloudletFinishedSoFar(final int resId) {
} Resource resource = getResourceById(resId);
return 0.0; if (resource != null) {
} return resource.finishedSoFar;
}
/** return 0;
* Gets the time of this Cloudlet resides in a given CloudResource ID (from arrival time until }
* departure time).
* /**
* @param resId a CloudResource entity ID * Gets the submission (arrival) time of this Cloudlet in the given
* @return the time of this Cloudlet resides in the CloudResource or <tt>0.0</tt> if not found * CloudResource ID.
* @pre resId >= 0 *
* @post $result >= 0.0 * @param resId a CloudResource entity ID
*/ * @return the submission time or <tt>0.0</tt> if not found
public double getWallClockTime(final int resId) { * @pre resId >= 0
Resource resource = getResourceById(resId); * @post $result >= 0.0
if (resource != null) { */
return resource.wallClockTime; public double getSubmissionTime(final int resId) {
} Resource resource = getResourceById(resId);
return 0.0; if (resource != null) {
} return resource.submissionTime;
}
/** return 0.0;
* Gets the CloudResource name based on its ID. }
*
* @param resId a CloudResource entity ID /**
* @return the CloudResource name or <tt>null</tt> if not found * Gets the time of this Cloudlet resides in a given CloudResource ID (from
* @pre resId >= 0 * arrival time until departure time).
* @post $none *
*/ * @param resId a CloudResource entity ID
public String getResourceName(final int resId) { * @return the time of this Cloudlet resides in the CloudResource or
Resource resource = getResourceById(resId); * <tt>0.0</tt> if not found
if (resource != null) { * @pre resId >= 0
return resource.resourceName; * @post $result >= 0.0
} */
return null; public double getWallClockTime(final int resId) {
} Resource resource = getResourceById(resId);
if (resource != null) {
/** return resource.wallClockTime;
* Gets the resource by id. }
* return 0.0;
* @param resourceId the resource id }
* @return the resource by id
*/ /**
public Resource getResourceById(final int resourceId) { * Gets the CloudResource name based on its ID.
for (Resource resource : resList) { *
if (resource.resourceId == resourceId) { * @param resId a CloudResource entity ID
return resource; * @return the CloudResource name or <tt>null</tt> if not found
} * @pre resId >= 0
} * @post $none
return null; */
} public String getResourceName(final int resId) {
Resource resource = getResourceById(resId);
/** if (resource != null) {
* Gets the finish time of this Cloudlet in a CloudResource. return resource.resourceName;
* }
* @return the finish or completion time of this Cloudlet or <tt>-1</tt> if not finished yet. return null;
* @pre $none }
* @post $result >= -1
*/ /**
public double getFinishTime() { * Gets the resource by id.
return finishTime; *
} * @param resourceId the resource id
* @return the resource by id
*/
public Resource getResourceById(final int resourceId) {
for (Resource resource : resList) {
if (resource.resourceId == resourceId) {
return resource;
}
}
return null;
}
/**
* Gets the finish time of this Cloudlet in a CloudResource.
*
* @return the finish or completion time of this Cloudlet or <tt>-1</tt> if
* not finished yet.
* @pre $none
* @post $result >= -1
*/
public double getFinishTime() {
return finishTime;
}
// //////////////////////// PROTECTED METHODS ////////////////////////////// // //////////////////////// PROTECTED METHODS //////////////////////////////
/**
/** * Writes this particular history transaction of this Cloudlet into a log.
* Writes this particular history transaction of this Cloudlet into a log. *
* * @param str a history transaction of this Cloudlet
* @param str a history transaction of this Cloudlet * @pre str != null
* @pre str != null * @post $none
* @post $none */
*/ protected void write(final String str) {
protected void write(final String str) { if (!record) {
if (!record) { return;
return; }
}
if (num == null || history == null) { // Creates the history or
if (num == null || history == null) { // Creates the history or // transactions of this Cloudlet
// transactions of this Cloudlet newline = System.getProperty("line.separator");
newline = System.getProperty("line.separator"); num = new DecimalFormat("#0.00#"); // with 3 decimal spaces
num = new DecimalFormat("#0.00#"); // with 3 decimal spaces history = new StringBuffer(1000);
history = new StringBuffer(1000); history.append("Time below denotes the simulation time.");
history.append("Time below denotes the simulation time."); history.append(System.getProperty("line.separator"));
history.append(System.getProperty("line.separator")); history.append("Time (sec) Description Cloudlet #" + cloudletId);
history.append("Time (sec) Description Cloudlet #" + cloudletId); history.append(System.getProperty("line.separator"));
history.append(System.getProperty("line.separator")); history.append("------------------------------------------");
history.append("------------------------------------------"); history.append(System.getProperty("line.separator"));
history.append(System.getProperty("line.separator")); history.append(num.format(CloudSim.clock()));
history.append(num.format(CloudSim.clock())); history.append(" Creates Cloudlet ID #" + cloudletId);
history.append(" Creates Cloudlet ID #" + cloudletId); history.append(System.getProperty("line.separator"));
history.append(System.getProperty("line.separator")); }
}
history.append(num.format(CloudSim.clock()));
history.append(num.format(CloudSim.clock())); history.append(" " + str + newline);
history.append(" " + str + newline); }
}
/**
/** * Get the status of the Cloudlet.
* Get the status of the Cloudlet. *
* * @return status of the Cloudlet
* @return status of the Cloudlet * @pre $none
* @pre $none * @post $none
* @post $none *
* */
*/ public int getStatus() {
public int getStatus() { return status;
return status; }
}
/**
/** * Gets the ID of this Cloudlet.
* Gets the ID of this Cloudlet. *
* * @return Cloudlet Id
* @return Cloudlet Id * @pre $none
* @pre $none * @post $none
* @post $none */
*/ public int getCloudletId() {
public int getCloudletId() { return cloudletId;
return cloudletId; }
}
/**
/** * Gets the ID of the VM that will run this Cloudlet.
* Gets the ID of the VM that will run this Cloudlet. *
* * @return VM Id, -1 if the Cloudlet was not assigned to a VM
* @return VM Id, -1 if the Cloudlet was not assigned to a VM * @pre $none
* @pre $none * @post $none
* @post $none */
*/ public int getVmId() {
public int getVmId() { return vmId;
return vmId; }
}
/**
/** * Sets the ID of the VM that will run this Cloudlet.
* Sets the ID of the VM that will run this Cloudlet. *
* * @param vmId the vm id
* @param vmId the vm id * @pre id >= 0
* @pre id >= 0 * @post $none
* @post $none */
*/ public void setVmId(final int vmId) {
public void setVmId(final int vmId) { this.vmId = vmId;
this.vmId = vmId; }
}
/**
/** * Returns the execution time of the Cloudlet.
* Returns the execution time of the Cloudlet. *
* * @return time in which the Cloudlet was running
* @return time in which the Cloudlet was running * @pre $none
* @pre $none * @post $none
* @post $none */
*/ public double getActualCPUTime() {
public double getActualCPUTime() { return getFinishTime() - getExecStartTime();
return getFinishTime() - getExecStartTime(); }
}
/**
/** * Sets the resource parameters for which this Cloudlet is going to be
* Sets the resource parameters for which this Cloudlet is going to be executed. <br> * executed. <br>
* NOTE: This method <tt>should</tt> be called only by a resource entity, not the user or owner * NOTE: This method <tt>should</tt> be called only by a resource entity,
* of this Cloudlet. * not the user or owner of this Cloudlet.
* *
* @param resourceID the CloudResource ID * @param resourceID the CloudResource ID
* @param costPerCPU the cost per second of running this Cloudlet * @param costPerCPU the cost per second of running this Cloudlet
* @param costPerBw the cost per byte of data transfer to the Datacenter * @param costPerBw the cost per byte of data transfer to the Datacenter
* *
* @pre resourceID >= 0 * @pre resourceID >= 0
* @pre cost > 0.0 * @pre cost > 0.0
* @post $none * @post $none
*/ */
public void setResourceParameter(final int resourceID, final double costPerCPU, final double costPerBw) { public void setResourceParameter(final int resourceID, final double costPerCPU, final double costPerBw) {
setResourceParameter(resourceID, costPerCPU); setResourceParameter(resourceID, costPerCPU);
this.costPerBw = costPerBw; this.costPerBw = costPerBw;
accumulatedBwCost = costPerBw * getCloudletFileSize(); accumulatedBwCost = costPerBw * getCloudletFileSize();
} }
/** /**
* Gets the total cost of processing or executing this Cloudlet * Gets the total cost of processing or executing this Cloudlet
* <tt>Processing Cost = input data transfer + processing cost + output transfer cost</tt> . * <tt>Processing Cost = input data transfer + processing cost + output
* * transfer cost</tt> .
* @return the total cost of processing Cloudlet *
* @pre $none * @return the total cost of processing Cloudlet
* @post $result >= 0.0 * @pre $none
*/ * @post $result >= 0.0
public double getProcessingCost() { */
public double getProcessingCost() {
// cloudlet cost: execution cost... // cloudlet cost: execution cost...
// double cost = getProcessingCost(); // double cost = getProcessingCost();
double cost = 0; double cost = 0;
// ...plus input data transfer cost... // ...plus input data transfer cost...
cost += accumulatedBwCost; cost += accumulatedBwCost;
// ...plus output cost // ...plus output cost
cost += costPerBw * getCloudletOutputSize(); cost += costPerBw * getCloudletOutputSize();
return cost; return cost;
} }
// Data cloudlet // Data cloudlet
/**
/** * Gets the required files.
* Gets the required files. *
* * @return the required files
* @return the required files */
*/ public List<String> getRequiredFiles() {
public List<String> getRequiredFiles() { return requiredFiles;
return requiredFiles; }
}
/**
/** * Sets the required files.
* Sets the required files. *
* * @param requiredFiles the new required files
* @param requiredFiles the new required files */
*/ protected void setRequiredFiles(final List<String> requiredFiles) {
protected void setRequiredFiles(final List<String> requiredFiles) { this.requiredFiles = requiredFiles;
this.requiredFiles = requiredFiles; }
}
/**
/** * Adds the required filename to the list.
* Adds the required filename to the list. *
* * @param fileName the required filename
* @param fileName the required filename * @return <tt>true</tt> if succesful, <tt>false</tt> otherwise
* @return <tt>true</tt> if succesful, <tt>false</tt> otherwise */
*/ public boolean addRequiredFile(final String fileName) {
public boolean addRequiredFile(final String fileName) { // if the list is empty
// if the list is empty if (getRequiredFiles() == null) {
if (getRequiredFiles() == null) { setRequiredFiles(new LinkedList<String>());
setRequiredFiles(new LinkedList<String>()); }
}
// then check whether filename already exists or not
// then check whether filename already exists or not boolean result = false;
boolean result = false; for (int i = 0; i < getRequiredFiles().size(); i++) {
for (int i = 0; i < getRequiredFiles().size(); i++) { final String temp = getRequiredFiles().get(i);
final String temp = getRequiredFiles().get(i); if (temp.equals(fileName)) {
if (temp.equals(fileName)) { result = true;
result = true; break;
break; }
} }
}
if (!result) {
if (!result) { getRequiredFiles().add(fileName);
getRequiredFiles().add(fileName); }
}
return result;
return result; }
}
/**
/** * Deletes the given filename from the list.
* Deletes the given filename from the list. *
* * @param filename the given filename to be deleted
* @param filename the given filename to be deleted * @return <tt>true</tt> if succesful, <tt>false</tt> otherwise
* @return <tt>true</tt> if succesful, <tt>false</tt> otherwise */
*/ public boolean deleteRequiredFile(final String filename) {
public boolean deleteRequiredFile(final String filename) { boolean result = false;
boolean result = false; if (getRequiredFiles() == null) {
if (getRequiredFiles() == null) { return result;
return result; }
}
for (int i = 0; i < getRequiredFiles().size(); i++) {
for (int i = 0; i < getRequiredFiles().size(); i++) { final String temp = getRequiredFiles().get(i);
final String temp = getRequiredFiles().get(i);
if (temp.equals(filename)) {
if (temp.equals(filename)) { getRequiredFiles().remove(i);
getRequiredFiles().remove(i); result = true;
result = true;
break;
break; }
} }
}
return result;
return result; }
}
/**
/** * Checks whether this cloudlet requires any files or not.
* Checks whether this cloudlet requires any files or not. *
* * @return <tt>true</tt> if required, <tt>false</tt> otherwise
* @return <tt>true</tt> if required, <tt>false</tt> otherwise */
*/ public boolean requiresFiles() {
public boolean requiresFiles() { boolean result = false;
boolean result = false; if (getRequiredFiles() != null && getRequiredFiles().size() > 0) {
if (getRequiredFiles() != null && getRequiredFiles().size() > 0) { result = true;
result = true; }
}
return result;
return result; }
}
/**
/** * Gets the utilization model of cpu.
* Gets the utilization model of cpu. *
* * @return the utilization model cpu
* @return the utilization model cpu */
*/ public UtilizationModel getUtilizationModelCpu() {
public UtilizationModel getUtilizationModelCpu() { return utilizationModelCpu;
return utilizationModelCpu; }
}
/**
/** * Sets the utilization model of cpu.
* Sets the utilization model of cpu. *
* * @param utilizationModelCpu the new utilization model of cpu
* @param utilizationModelCpu the new utilization model of cpu */
*/ public void setUtilizationModelCpu(final UtilizationModel utilizationModelCpu) {
public void setUtilizationModelCpu(final UtilizationModel utilizationModelCpu) { this.utilizationModelCpu = utilizationModelCpu;
this.utilizationModelCpu = utilizationModelCpu; }
}
/**
/** * Gets the utilization model of ram.
* Gets the utilization model of ram. *
* * @return the utilization model of ram
* @return the utilization model of ram */
*/ public UtilizationModel getUtilizationModelRam() {
public UtilizationModel getUtilizationModelRam() { return utilizationModelRam;
return utilizationModelRam; }
}
/**
/** * Sets the utilization model of ram.
* Sets the utilization model of ram. *
* * @param utilizationModelRam the new utilization model of ram
* @param utilizationModelRam the new utilization model of ram */
*/ public void setUtilizationModelRam(final UtilizationModel utilizationModelRam) {
public void setUtilizationModelRam(final UtilizationModel utilizationModelRam) { this.utilizationModelRam = utilizationModelRam;
this.utilizationModelRam = utilizationModelRam; }
}
/**
/** * Gets the utilization model of bw.
* Gets the utilization model of bw. *
* * @return the utilization model of bw
* @return the utilization model of bw */
*/ public UtilizationModel getUtilizationModelBw() {
public UtilizationModel getUtilizationModelBw() { return utilizationModelBw;
return utilizationModelBw; }
}
/**
/** * Sets the utilization model of bw.
* Sets the utilization model of bw. *
* * @param utilizationModelBw the new utilization model of bw
* @param utilizationModelBw the new utilization model of bw */
*/ public void setUtilizationModelBw(final UtilizationModel utilizationModelBw) {
public void setUtilizationModelBw(final UtilizationModel utilizationModelBw) { this.utilizationModelBw = utilizationModelBw;
this.utilizationModelBw = utilizationModelBw; }
}
/**
/** * Gets the utilization percentage of cpu.
* Gets the utilization percentage of cpu. *
* * @param time the time
* @param time the time * @return the utilization of cpu
* @return the utilization of cpu */
*/ public double getUtilizationOfCpu(final double time) {
public double getUtilizationOfCpu(final double time) { return getUtilizationModelCpu().getUtilization(time);
return getUtilizationModelCpu().getUtilization(time); }
}
/**
/** * Gets the utilization percentage of memory.
* Gets the utilization percentage of memory. *
* * @param time the time
* @param time the time * @return the utilization of memory
* @return the utilization of memory */
*/ public double getUtilizationOfRam(final double time) {
public double getUtilizationOfRam(final double time) { return getUtilizationModelRam().getUtilization(time);
return getUtilizationModelRam().getUtilization(time); }
}
/**
/** * Gets the utilization percentage of bw.
* Gets the utilization percentage of bw. *
* * @param time the time
* @param time the time * @return the utilization of bw
* @return the utilization of bw */
*/ public double getUtilizationOfBw(final double time) {
public double getUtilizationOfBw(final double time) { return getUtilizationModelBw().getUtilization(time);
return getUtilizationModelBw().getUtilization(time); }
}
} }
...@@ -392,11 +392,12 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler { ...@@ -392,11 +392,12 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
} }
/** /**
* Returns the first cloudlet to migrate to another vm. * Returns the first cloudlet to migrate to another VM.
* *
* @return the first running cloudlet * @return the first running cloudlet
* @pre $none * @pre $none
* @post $none * @post $none
*
* @todo it doesn't check if the list is empty * @todo it doesn't check if the list is empty
*/ */
@Override @Override
......
...@@ -122,14 +122,6 @@ public class Datacenter extends SimEntity { ...@@ -122,14 +122,6 @@ public class Datacenter extends SimEntity {
// empty. This should be override by a child class // empty. This should be override by a child class
} }
/**
* Processes events or services that are available for this Datacenter.
*
* @param ev information about the event just happened
*
* @pre ev != null
* @post $none
*/
@Override @Override
public void processEvent(SimEvent ev) { public void processEvent(SimEvent ev) {
int srcId = -1; int srcId = -1;
......
...@@ -146,13 +146,6 @@ public class DatacenterBroker extends SimEntity { ...@@ -146,13 +146,6 @@ public class DatacenterBroker extends SimEntity {
CloudletList.getById(getCloudletList(), cloudletId).setVmId(vmId); CloudletList.getById(getCloudletList(), cloudletId).setVmId(vmId);
} }
/**
* Processes events available for this Broker.
*
* @param ev a SimEvent object
* @pre ev != null
* @post $none
*/
@Override @Override
public void processEvent(SimEvent ev) { public void processEvent(SimEvent ev) {
switch (ev.getTag()) { switch (ev.getTag()) {
......
...@@ -111,21 +111,11 @@ public class HarddriveStorage implements Storage { ...@@ -111,21 +111,11 @@ public class HarddriveStorage implements Storage {
maxTransferRate = 133; // in MB/sec maxTransferRate = 133; // in MB/sec
} }
/**
* Gets the available space on this storage in MB.
*
* @return the available space in MB
*/
@Override @Override
public double getAvailableSpace() { public double getAvailableSpace() {
return capacity - currentSize; return capacity - currentSize;
} }
/**
* Checks if the storage is full or not.
*
* @return <tt>true</tt> if the storage is full, <tt>false</tt> otherwise
*/
@Override @Override
public boolean isFull() { public boolean isFull() {
if (Math.abs(currentSize - capacity) < .0000001) { // currentSize == capacity if (Math.abs(currentSize - capacity) < .0000001) { // currentSize == capacity
...@@ -134,22 +124,11 @@ public class HarddriveStorage implements Storage { ...@@ -134,22 +124,11 @@ public class HarddriveStorage implements Storage {
return false; return false;
} }
/**
* Gets the number of files stored on this hard drive.
*
* @return the number of stored files
*/
@Override @Override
public int getNumStoredFile() { public int getNumStoredFile() {
return fileList.size(); return fileList.size();
} }
/**
* Reserves space on the hard drive to store a file.
*
* @param fileSize the size to be reserved in MB
* @return <tt>true</tt> if reservation succeeded, <tt>false</tt> otherwise
*/
@Override @Override
public boolean reserveSpace(int fileSize) { public boolean reserveSpace(int fileSize) {
if (fileSize <= 0) { if (fileSize <= 0) {
...@@ -164,13 +143,6 @@ public class HarddriveStorage implements Storage { ...@@ -164,13 +143,6 @@ public class HarddriveStorage implements Storage {
return true; return true;
} }
/**
* Adds a file for which the space has already been reserved. The time taken (in seconds) for
* adding the file can also be found using {@link gridsim.datagrid.File#getTransactionTime()}.
*
* @param file the file to be added
* @return the time (in seconds) required to add the file
*/
@Override @Override
public double addReservedFile(File file) { public double addReservedFile(File file) {
if (file == null) { if (file == null) {
...@@ -188,12 +160,6 @@ public class HarddriveStorage implements Storage { ...@@ -188,12 +160,6 @@ public class HarddriveStorage implements Storage {
return result; return result;
} }
/**
* Checks whether there is enough space on the hard drive for a certain file.
*
* @param fileSize a FileAttribute object to compare to
* @return <tt>true</tt> if enough space available, <tt>false</tt> otherwise
*/
@Override @Override
public boolean hasPotentialAvailableSpace(int fileSize) { public boolean hasPotentialAvailableSpace(int fileSize) {
if (fileSize <= 0) { if (fileSize <= 0) {
...@@ -227,31 +193,16 @@ public class HarddriveStorage implements Storage { ...@@ -227,31 +193,16 @@ public class HarddriveStorage implements Storage {
return result; return result;
} }
/**
* Gets the total capacity of the storage in MB.
*
* @return the capacity of the storage in MB
*/
@Override @Override
public double getCapacity() { public double getCapacity() {
return capacity; return capacity;
} }
/**
* Gets the current size of the stored files in MB.
*
* @return the current size of the stored files in MB
*/
@Override @Override
public double getCurrentSize() { public double getCurrentSize() {
return currentSize; return currentSize;
} }
/**
* Gets the name of the storage.
*
* @return the name of this storage
*/
@Override @Override
public String getName() { public String getName() {
return name; return name;
...@@ -281,12 +232,6 @@ public class HarddriveStorage implements Storage { ...@@ -281,12 +232,6 @@ public class HarddriveStorage implements Storage {
return latency; return latency;
} }
/**
* Sets the maximum transfer rate of this storage system in MB/sec.
*
* @param rate the maximum transfer rate in MB/sec
* @return <tt>true</tt> if the setting succeeded, <tt>false</tt> otherwise
*/
@Override @Override
public boolean setMaxTransferRate(int rate) { public boolean setMaxTransferRate(int rate) {
if (rate <= 0) { if (rate <= 0) {
...@@ -297,11 +242,6 @@ public class HarddriveStorage implements Storage { ...@@ -297,11 +242,6 @@ public class HarddriveStorage implements Storage {
return true; return true;
} }
/**
* Gets the maximum transfer rate of the storage in MB/sec.
*
* @return the maximum transfer rate in MB/sec
*/
@Override @Override
public double getMaxTransferRate() { public double getMaxTransferRate() {
return maxTransferRate; return maxTransferRate;
...@@ -344,13 +284,6 @@ public class HarddriveStorage implements Storage { ...@@ -344,13 +284,6 @@ public class HarddriveStorage implements Storage {
return avgSeekTime; return avgSeekTime;
} }
/**
* Gets the file with the specified name. The time taken (in seconds) for getting the file can
* also be found using {@link gridsim.datagrid.File#getTransactionTime()}.
*
* @param fileName the name of the needed file
* @return the file with the specified filename
*/
@Override @Override
public File getFile(String fileName) { public File getFile(String fileName) {
// check first whether file name is valid or not // check first whether file name is valid or not
...@@ -392,11 +325,6 @@ public class HarddriveStorage implements Storage { ...@@ -392,11 +325,6 @@ public class HarddriveStorage implements Storage {
return obj; return obj;
} }
/**
* Gets the list of file names located on this storage.
*
* @return a List of file names
*/
@Override @Override
public List<String> getFileNameList() { public List<String> getFileNameList() {
return nameList; return nameList;
...@@ -464,13 +392,13 @@ public class HarddriveStorage implements Storage { ...@@ -464,13 +392,13 @@ public class HarddriveStorage implements Storage {
} }
/** /**
* Adds a file to the storage. First, the method checks if there is enough space on the storage, * {@inheritDoc}
* then it checks if the file with the same name is already taken to avoid duplicate filenames. <br> *
* The time taken (in seconds) for adding the file can also be found using * <p/>First, the method checks if there is enough space on the storage,
* {@link gridsim.datagrid.File#getTransactionTime()}. * then it checks if the file with the same name is already taken to avoid duplicate filenames.
* *
* @param file the file to be added * @param file {@inheritDoc}
* @return the time taken (in seconds) for adding the specified file * @return {@inheritDoc}
*/ */
@Override @Override
public double addFile(File file) { public double addFile(File file) {
...@@ -500,14 +428,6 @@ public class HarddriveStorage implements Storage { ...@@ -500,14 +428,6 @@ public class HarddriveStorage implements Storage {
return result; return result;
} }
/**
* Adds a set of files to the storage. Runs through the list of files and save all of them. The
* time taken (in seconds) for adding each file can also be found using
* {@link gridsim.datagrid.File#getTransactionTime()}.
*
* @param list the files to be added
* @return the time taken (in seconds) for adding the specified files
*/
@Override @Override
public double addFile(List<File> list) { public double addFile(List<File> list) {
double result = 0.0; double result = 0.0;
...@@ -525,13 +445,6 @@ public class HarddriveStorage implements Storage { ...@@ -525,13 +445,6 @@ public class HarddriveStorage implements Storage {
return result; return result;
} }
/**
* Removes a file from the storage. The time taken (in seconds) for deleting the file can also
* be found using {@link gridsim.datagrid.File#getTransactionTime()}.
*
* @param fileName the name of the file to be removed
* @return the deleted file
*/
@Override @Override
public File deleteFile(String fileName) { public File deleteFile(String fileName) {
if (fileName == null || fileName.length() == 0) { if (fileName == null || fileName.length() == 0) {
...@@ -556,26 +469,11 @@ public class HarddriveStorage implements Storage { ...@@ -556,26 +469,11 @@ public class HarddriveStorage implements Storage {
return file; return file;
} }
/**
* Removes a file from the storage. The time taken (in seconds) for deleting the file can also
* be found using {@link gridsim.datagrid.File#getTransactionTime()}.
*
* @param fileName the name of the file to be removed
* @param file the file which is removed from the storage is returned through this parameter
* @return the time taken (in seconds) for deleting the specified file
*/
@Override @Override
public double deleteFile(String fileName, File file) { public double deleteFile(String fileName, File file) {
return deleteFile(file); return deleteFile(file);
} }
/**
* Removes a file from the storage. The time taken (in seconds) for deleting the file can also
* be found using {@link gridsim.datagrid.File#getTransactionTime()}.
*
* @param file the file which is removed from the storage is returned through this parameter
* @return the time taken (in seconds) for deleting the specified file
*/
@Override @Override
public double deleteFile(File file) { public double deleteFile(File file) {
double result = 0.0; double result = 0.0;
...@@ -597,12 +495,6 @@ public class HarddriveStorage implements Storage { ...@@ -597,12 +495,6 @@ public class HarddriveStorage implements Storage {
return result; return result;
} }
/**
* Checks whether a certain file is on the storage or not.
*
* @param fileName the name of the file we are looking for
* @return <tt>true</tt> if the file is in the storage, <tt>false</tt> otherwise
*/
@Override @Override
public boolean contains(String fileName) { public boolean contains(String fileName) {
boolean result = false; boolean result = false;
...@@ -622,12 +514,6 @@ public class HarddriveStorage implements Storage { ...@@ -622,12 +514,6 @@ public class HarddriveStorage implements Storage {
return result; return result;
} }
/**
* Checks whether a certain file is on the storage or not.
*
* @param file the file we are looking for
* @return <tt>true</tt> if the file is in the storage, <tt>false</tt> otherwise
*/
@Override @Override
public boolean contains(File file) { public boolean contains(File file) {
boolean result = false; boolean result = false;
...@@ -639,14 +525,6 @@ public class HarddriveStorage implements Storage { ...@@ -639,14 +525,6 @@ public class HarddriveStorage implements Storage {
return result; return result;
} }
/**
* Renames a file on the storage. The time taken (in seconds) for renaming the file can also be
* found using {@link gridsim.datagrid.File#getTransactionTime()}.
*
* @param file the file we would like to rename
* @param newName the new name of the file
* @return <tt>true</tt> if the renaming succeeded, <tt>false</tt> otherwise
*/
@Override @Override
public boolean renameFile(File file, String newName) { public boolean renameFile(File file, String newName) {
// check whether the new filename is conflicting with existing ones // check whether the new filename is conflicting with existing ones
......
...@@ -55,13 +55,6 @@ public class ParameterException extends Exception { ...@@ -55,13 +55,6 @@ public class ParameterException extends Exception {
this.message = message; this.message = message;
} }
/**
* Returns an error message of this object.
*
* @return an error message
* @pre $none
* @post $none
*/
@Override @Override
public String toString() { public String toString() {
return message; return message;
......
...@@ -60,12 +60,6 @@ public class SanStorage extends HarddriveStorage { ...@@ -60,12 +60,6 @@ public class SanStorage extends HarddriveStorage {
this.networkLatency = networkLatency; this.networkLatency = networkLatency;
} }
/**
* Adds a file for which the space has already been reserved.
*
* @param file the file to be added
* @return the time (in seconds) required to add the file
*/
@Override @Override
public double addReservedFile(File file) { public double addReservedFile(File file) {
double time = super.addReservedFile(file); double time = super.addReservedFile(file);
...@@ -75,11 +69,6 @@ public class SanStorage extends HarddriveStorage { ...@@ -75,11 +69,6 @@ public class SanStorage extends HarddriveStorage {
return time; return time;
} }
/**
* Gets the maximum transfer rate of the storage in MB/sec.
*
* @return the maximum transfer rate in MB/sec
*/
@Override @Override
public double getMaxTransferRate() { public double getMaxTransferRate() {
...@@ -93,12 +82,6 @@ public class SanStorage extends HarddriveStorage { ...@@ -93,12 +82,6 @@ public class SanStorage extends HarddriveStorage {
return bandwidth; return bandwidth;
} }
/**
* Adds a file to the storage.
*
* @param file the file to be added
* @return the time taken (in seconds) for adding the specified file
*/
@Override @Override
public double addFile(File file) { public double addFile(File file) {
double time = super.addFile(file); double time = super.addFile(file);
...@@ -109,14 +92,6 @@ public class SanStorage extends HarddriveStorage { ...@@ -109,14 +92,6 @@ public class SanStorage extends HarddriveStorage {
return time; return time;
} }
/**
* Adds a set of files to the storage. Runs through the list of files and save all of them. The
* time taken (in seconds) for adding each file can also be found using
* {@link gridsim.datagrid.File#getTransactionTime()}.
*
* @param list the files to be added
* @return the time taken (in seconds) for adding the specified files
*/
@Override @Override
public double addFile(List<File> list) { public double addFile(List<File> list) {
double result = 0.0; double result = 0.0;
...@@ -134,26 +109,11 @@ public class SanStorage extends HarddriveStorage { ...@@ -134,26 +109,11 @@ public class SanStorage extends HarddriveStorage {
return result; return result;
} }
/**
* Removes a file from the storage. The time taken (in seconds) for deleting the file can also
* be found using {@link gridsim.datagrid.File#getTransactionTime()}.
*
* @param fileName the name of the file to be removed
* @param file the file which is removed from the storage is returned through this parameter
* @return the time taken (in seconds) for deleting the specified file
*/
@Override @Override
public double deleteFile(String fileName, File file) { public double deleteFile(String fileName, File file) {
return this.deleteFile(file); return this.deleteFile(file);
} }
/**
* Removes a file from the storage. The time taken (in seconds) for deleting the file can also
* be found using {@link gridsim.datagrid.File#getTransactionTime()}.
*
* @param file the file which is removed from the storage is returned through this parameter
* @return the time taken (in seconds) for deleting the specified file
*/
@Override @Override
public double deleteFile(File file) { public double deleteFile(File file) {
double time = super.deleteFile(file); double time = super.deleteFile(file);
......
...@@ -91,7 +91,7 @@ public interface Storage { ...@@ -91,7 +91,7 @@ public interface Storage {
/** /**
* Adds a file for which the space has already been reserved. The time taken (in seconds) for * Adds a file for which the space has already been reserved. The time taken (in seconds) for
* adding the specified file can also be found using * adding the specified file can also be found using
* {@link gridsim.datagrid.File#getTransactionTime()}. * {@link org.cloudbus.cloudsim.File#getTransactionTime()}.
* *
* @param file the file to be added * @param file the file to be added
* @return the time (in seconds) required to add the file * @return the time (in seconds) required to add the file
...@@ -108,7 +108,7 @@ public interface Storage { ...@@ -108,7 +108,7 @@ public interface Storage {
/** /**
* Gets the file with the specified name. The time taken (in seconds) for getting the specified * Gets the file with the specified name. The time taken (in seconds) for getting the specified
* file can also be found using {@link gridsim.datagrid.File#getTransactionTime()}. * file can also be found using {@link org.cloudbus.cloudsim.File#getTransactionTime()}.
* *
* @param fileName the name of the needed file * @param fileName the name of the needed file
* @return the file with the specified filename * @return the file with the specified filename
...@@ -124,7 +124,7 @@ public interface Storage { ...@@ -124,7 +124,7 @@ public interface Storage {
/** /**
* Adds a file to the storage. The time taken (in seconds) for adding the specified file can * Adds a file to the storage. The time taken (in seconds) for adding the specified file can
* also be found using {@link gridsim.datagrid.File#getTransactionTime()}. * also be found using {@link org.cloudbus.cloudsim.File#getTransactionTime()}.
* *
* @param file the file to be added * @param file the file to be added
* @return the time taken (in seconds) for adding the specified file * @return the time taken (in seconds) for adding the specified file
...@@ -154,7 +154,7 @@ public interface Storage { ...@@ -154,7 +154,7 @@ public interface Storage {
* can also be found using {@link gridsim.datagrid.File#getTransactionTime()}. * can also be found using {@link gridsim.datagrid.File#getTransactionTime()}.
* *
* @param fileName the name of the file to be removed * @param fileName the name of the file to be removed
* @param file the file which is removed from the storage is returned through this parameter * @param file the file removed from the storage is returned through this parameter
* @return the time taken (in seconds) for deleting the specified file * @return the time taken (in seconds) for deleting the specified file
*/ */
double deleteFile(String fileName, File file); double deleteFile(String fileName, File file);
...@@ -163,13 +163,13 @@ public interface Storage { ...@@ -163,13 +163,13 @@ public interface Storage {
* Removes a file from the storage. The time taken (in seconds) for deleting the specified file * Removes a file from the storage. The time taken (in seconds) for deleting the specified file
* can also be found using {@link gridsim.datagrid.File#getTransactionTime()}. * can also be found using {@link gridsim.datagrid.File#getTransactionTime()}.
* *
* @param file the file which is removed from the storage is returned through this parameter * @param file the file to be removed
* @return the time taken (in seconds) for deleting the specified file * @return the time taken (in seconds) for deleting the specified file
*/ */
double deleteFile(File file); double deleteFile(File file);
/** /**
* Checks whether a file is stored in the storage or not. * Checks whether a file exists in the storage or not.
* *
* @param fileName the name of the file we are looking for * @param fileName the name of the file we are looking for
* @return <tt>true</tt> if the file is in the storage, <tt>false</tt> otherwise * @return <tt>true</tt> if the file is in the storage, <tt>false</tt> otherwise
...@@ -186,7 +186,7 @@ public interface Storage { ...@@ -186,7 +186,7 @@ public interface Storage {
/** /**
* Renames a file on the storage. The time taken (in seconds) for renaming the specified file * Renames a file on the storage. The time taken (in seconds) for renaming the specified file
* can also be found using {@link gridsim.datagrid.File#getTransactionTime()}. * can also be found using {@link org.cloudbus.cloudsim.File#getTransactionTime()}.
* *
* @param file the file we would like to rename * @param file the file we would like to rename
* @param newName the new name of the file * @param newName the new name of the file
......
...@@ -38,10 +38,9 @@ public abstract class VmAllocationPolicy { ...@@ -38,10 +38,9 @@ public abstract class VmAllocationPolicy {
} }
/** /**
* Allocates a host for a given VM. The host to be allocated is the one that was already * Allocates a host for a given VM.
* reserved.
* *
* @param vm virtual machine which the host is reserved to * @param vm the VM to allocate a host to
* @return $true if the host could be allocated; $false otherwise * @return $true if the host could be allocated; $false otherwise
* @pre $none * @pre $none
* @post $none * @post $none
...@@ -76,7 +75,7 @@ public abstract class VmAllocationPolicy { ...@@ -76,7 +75,7 @@ public abstract class VmAllocationPolicy {
/** /**
* Releases the host used by a VM. * Releases the host used by a VM.
* *
* @param vm the vm * @param vm the vm to get its host released
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
......
...@@ -58,10 +58,10 @@ public class VmAllocationPolicySimple extends VmAllocationPolicy { ...@@ -58,10 +58,10 @@ public class VmAllocationPolicySimple extends VmAllocationPolicy {
} }
/** /**
* Allocates a host for a given VM. * Allocates the host with less PEs in use for a given VM.
* *
* @param vm the VM to allocate a host to * @param vm {@inheritDoc}
* @return $true if the host could be allocated; $false otherwise * @return {@inheritDoc}
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
...@@ -108,13 +108,6 @@ public class VmAllocationPolicySimple extends VmAllocationPolicy { ...@@ -108,13 +108,6 @@ public class VmAllocationPolicySimple extends VmAllocationPolicy {
return result; return result;
} }
/**
* Releases the host used by a VM.
*
* @param vm the vm to get its host released
* @pre $none
* @post none
*/
@Override @Override
public void deallocateHostForVm(Vm vm) { public void deallocateHostForVm(Vm vm) {
Host host = getVmTable().remove(vm.getUid()); Host host = getVmTable().remove(vm.getUid());
......
...@@ -76,12 +76,6 @@ public class CloudInformationService extends SimEntity { ...@@ -76,12 +76,6 @@ public class CloudInformationService extends SimEntity {
public void startEntity() { public void startEntity() {
} }
/**
* Processes events scheduled for the CIS.
*
* @param ev the event to be handled.
* @see SimEntity#processEvent(SimEvent)
*/
@Override @Override
public void processEvent(SimEvent ev) { public void processEvent(SimEvent ev) {
int id = -1; // requester id int id = -1; // requester id
...@@ -138,9 +132,6 @@ public class CloudInformationService extends SimEntity { ...@@ -138,9 +132,6 @@ public class CloudInformationService extends SimEntity {
} }
} }
/**
* Shutdowns the CloudInformationService.
*/
@Override @Override
public void shutdownEntity() { public void shutdownEntity() {
notifyAllEntity(); notifyAllEntity();
......
...@@ -81,7 +81,7 @@ public class CloudSimShutdown extends SimEntity { ...@@ -81,7 +81,7 @@ public class CloudSimShutdown extends SimEntity {
public void startEntity() { public void startEntity() {
// do nothing // do nothing
} }
/** /**
* The method has no effect at the current class. * The method has no effect at the current class.
*/ */
...@@ -89,5 +89,4 @@ public class CloudSimShutdown extends SimEntity { ...@@ -89,5 +89,4 @@ public class CloudSimShutdown extends SimEntity {
public void shutdownEntity() { public void shutdownEntity() {
// do nothing // do nothing
} }
} }
...@@ -394,14 +394,19 @@ public abstract class SimEntity implements Cloneable { ...@@ -394,14 +394,19 @@ public abstract class SimEntity implements Cloneable {
public abstract void startEntity(); public abstract void startEntity();
/** /**
* Processes events or services that are available for the entity.
* This method is invoked by the {@link CloudSim} class whenever there is an event in the * This method is invoked by the {@link CloudSim} class whenever there is an event in the
* deferred queue, which needs to be processed by the entity. * deferred queue, which needs to be processed by the entity.
* *
* @param ev the event to be processed by the entity * @param ev information about the event just happened
*
* @pre ev != null
* @post $none
*/ */
public abstract void processEvent(SimEvent ev); public abstract void processEvent(SimEvent ev);
/** /**
* Shuts down the entity.
* This method is invoked by the {@link CloudSim} before the simulation finishes. If you want * This method is invoked by the {@link CloudSim} before the simulation finishes. If you want
* to save data in log files this is the method in which the corresponding code would be placed. * to save data in log files this is the method in which the corresponding code would be placed.
*/ */
......
...@@ -215,11 +215,6 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> { ...@@ -215,11 +215,6 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
return data; return data;
} }
/**
* Create an exact copy of this event.
*
* @return The event's copy
*/
@Override @Override
public Object clone() { public Object clone() {
return new SimEvent(etype, time, entSrc, entDst, tag, data); return new SimEvent(etype, time, entSrc, entDst, tag, data);
......
...@@ -29,7 +29,7 @@ public class PredicateAny extends Predicate { ...@@ -29,7 +29,7 @@ public class PredicateAny extends Predicate {
* Considers there is no criteria to match an event, * Considers there is no criteria to match an event,
* so any event received by the predicate will match. * so any event received by the predicate will match.
* *
* @param ev the event received * @param ev {@inheritDoc}
* @return always true to indicate that any received event is accepted * @return always true to indicate that any received event is accepted
*/ */
@Override @Override
......
...@@ -45,8 +45,8 @@ public class PredicateFrom extends Predicate { ...@@ -45,8 +45,8 @@ public class PredicateFrom extends Predicate {
/** /**
* Matches any event received from the registered sources. * Matches any event received from the registered sources.
* *
* @param ev the event to check * @param ev {@inheritDoc}
* @return <code>true</code> if the event matches the predicate, <code>false</code> otherwise * @return {@inheritDoc}
* @see #ids * @see #ids
*/ */
@Override @Override
......
...@@ -26,12 +26,11 @@ public class PredicateNone extends Predicate { ...@@ -26,12 +26,11 @@ public class PredicateNone extends Predicate {
/** /**
* Considers that no event received by the predicate matches. * Considers that no event received by the predicate matches.
* *
* @param ev the event received * @param ev {@inheritDoc}
* @return always false to indicate that no event is accepted * @return always false to indicate that no event is accepted
*/ */
@Override @Override
public boolean match(SimEvent ev) { public boolean match(SimEvent ev) {
return false; return false;
} }
} }
...@@ -44,8 +44,8 @@ public class PredicateNotFrom extends Predicate { ...@@ -44,8 +44,8 @@ public class PredicateNotFrom extends Predicate {
/** /**
* Matches any event <b>not</b> received from the registered sources. * Matches any event <b>not</b> received from the registered sources.
* *
* @param ev the event to check * @param ev {@inheritDoc}
* @return <code>true</code> if the event matches the predicate, <code>false</code> otherwise * @return {@inheritDoc}
* @see #ids * @see #ids
*/ */
@Override @Override
......
...@@ -44,8 +44,8 @@ public class PredicateNotType extends Predicate { ...@@ -44,8 +44,8 @@ public class PredicateNotType extends Predicate {
/** /**
* Matches any event that hasn't one of the specified {@link #tags}. * Matches any event that hasn't one of the specified {@link #tags}.
* *
* @param ev the event to check * @param ev {@inheritDoc}
* @return <code>true</code> if the event matches the predicate, <code>false</code> otherwise * @return {@inheritDoc}
* @see #tags * @see #tags
*/ */
@Override @Override
......
...@@ -44,8 +44,8 @@ public class PredicateType extends Predicate { ...@@ -44,8 +44,8 @@ public class PredicateType extends Predicate {
/** /**
* Matches any event that has one of the specified {@link #tags}. * Matches any event that has one of the specified {@link #tags}.
* *
* @param ev the event to check * @param ev {@inheritDoc}
* @return <code>true</code> if the event matches the predicate, <code>false</code> otherwise * @return {@inheritDoc}
* @see #tags * @see #tags
*/ */
@Override @Override
......
...@@ -67,13 +67,13 @@ public class CloudletList { ...@@ -67,13 +67,13 @@ public class CloudletList {
Collections.sort(cloudletList, new Comparator<T>() { Collections.sort(cloudletList, new Comparator<T>() {
/** /**
* Compares two objects. * Compares two Cloudlets.
* *
* @param a the first Object to be compared * @param a the first Cloudlet to be compared
* @param b the second Object to be compared * @param b the second Cloudlet to be compared
* @return the value 0 if both Objects are numerically equal; a value less than 0 if the * @return the value 0 if both Cloudlets are numerically equal; a value less than 0 if the
* first Object is numerically less than the second Object; and a value greater * first Object is numerically less than the second Cloudlet; and a value greater
* than 0 if the first Object is numerically greater than the second Object. * than 0 if the first Cloudlet is numerically greater than the second Cloudlet.
* @throws ClassCastException <tt>a</tt> and <tt>b</tt> are expected to be of type * @throws ClassCastException <tt>a</tt> and <tt>b</tt> are expected to be of type
* <tt>Cloudlet</tt> * <tt>Cloudlet</tt>
* @pre a != null * @pre a != null
......
...@@ -20,8 +20,8 @@ import org.cloudbus.cloudsim.VmAllocationPolicy; ...@@ -20,8 +20,8 @@ import org.cloudbus.cloudsim.VmAllocationPolicy;
import org.cloudbus.cloudsim.core.CloudSim; import org.cloudbus.cloudsim.core.CloudSim;
/** /**
* NetworkVmAllocationPolicy is an {@link VmAllocationPolicy} that chooses, as the host for a VM, the host * NetworkVmAllocationPolicy is an {@link VmAllocationPolicy} that chooses,
* with less PEs in use. * as the host for a VM, the host with less PEs in use.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @author Anton Beloglazov * @author Anton Beloglazov
...@@ -63,11 +63,11 @@ public class NetworkVmAllocationPolicy extends VmAllocationPolicy { ...@@ -63,11 +63,11 @@ public class NetworkVmAllocationPolicy extends VmAllocationPolicy {
} }
/** /**
* Allocates a host for a given VM. * Allocates the host with less PEs in use for a given VM.
* *
* @param vm VM specification * @param vm {@inheritDoc}
* *
* @return $true if the host could be allocated; $false otherwise * @return {@inheritDoc}
* *
* @pre $none * @pre $none
* @post $none * @post $none
...@@ -145,14 +145,6 @@ public class NetworkVmAllocationPolicy extends VmAllocationPolicy { ...@@ -145,14 +145,6 @@ public class NetworkVmAllocationPolicy extends VmAllocationPolicy {
return maxUtilization; return maxUtilization;
} }
/**
* Releases the host used by a VM.
*
* @param vm the vm
*
* @pre $none
* @post none
*/
@Override @Override
public void deallocateHostForVm(Vm vm) { public void deallocateHostForVm(Vm vm) {
Host host = getVmTable().remove(vm.getUid()); Host host = getVmTable().remove(vm.getUid());
...@@ -164,32 +156,11 @@ public class NetworkVmAllocationPolicy extends VmAllocationPolicy { ...@@ -164,32 +156,11 @@ public class NetworkVmAllocationPolicy extends VmAllocationPolicy {
} }
} }
/**
* Gets the host that is executing the given VM.
*
* @param vm the vm to get its host
*
* @return the Host of the given vm; $null if not found
*
* @pre $none
* @post $none
*/
@Override @Override
public Host getHost(Vm vm) { public Host getHost(Vm vm) {
return getVmTable().get(vm.getUid()); return getVmTable().get(vm.getUid());
} }
/**
* Gets the host that is executing the given VM belonging to the given user.
*
* @param vmId the vm id
* @param userId the user id
*
* @return the Host of the given vm and user; $null if not found
*
* @pre $none
* @post $none
*/
@Override @Override
public Host getHost(int vmId, int userId) { public Host getHost(int vmId, int userId) {
return getVmTable().get(Vm.getUid(userId, vmId)); return getVmTable().get(Vm.getUid(userId, vmId));
......
...@@ -15,8 +15,7 @@ import org.cloudbus.cloudsim.Host; ...@@ -15,8 +15,7 @@ import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Vm; import org.cloudbus.cloudsim.Vm;
/** /**
* A class representing a simple VM allocation policy that does not perform any * A simple VM allocation policy that does <b>not</b> perform any optimization on VM allocation.
* optimization of the VM allocation.
* *
* <br/>If you are using any algorithms, policies or workload included in the power package please cite * <br/>If you are using any algorithms, policies or workload included in the power package please cite
* the following paper:<br/> * the following paper:<br/>
......
...@@ -25,9 +25,10 @@ import org.cloudbus.cloudsim.Cloudlet; ...@@ -25,9 +25,10 @@ import org.cloudbus.cloudsim.Cloudlet;
public interface WorkloadModel { public interface WorkloadModel {
/** /**
* Generates a list of jobs to be executed ({@link Cloudlet Cloudlets}). * Generates a list of jobs ({@link Cloudlet Cloudlets}) to be executed.
* *
* @return a list with the jobs generated by the workload or null in case of failure. * @return a list with the jobs ({@link Cloudlet Cloudlets})
* generated by the workload or null in case of failure.
*/ */
List<Cloudlet> generateWorkload(); List<Cloudlet> generateWorkload();
......
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