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

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

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