Commit 45cfcbff authored by Anton Beloglazov's avatar Anton Beloglazov

- Updated headers (copyrights)

- Updated javadocs (authors and some class descriptions)
parent 53023e7a
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import java.util.List; import java.util.List;
/** /**
* This class represents the coordinator of a federation of clouds. * This class represents the coordinator of a federation of clouds.
* It interacts with other clouds coordinators in order to exchange * It interacts with other clouds coordinators in order to exchange
* virtual machines and user applicatoins, if required. * virtual machines and user applicatoins, if required.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @since CloudSim Toolkit 1.0
* @invariant $none
*/ */
public abstract class CloudCoordinator { public abstract class CloudCoordinator {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -20,9 +19,9 @@ import org.cloudbus.cloudsim.core.CloudSim; ...@@ -20,9 +19,9 @@ import org.cloudbus.cloudsim.core.CloudSim;
* Cloudlet is an extension to the cloudlet. It stores, despite all the information * Cloudlet is an extension to the cloudlet. It stores, despite all the information
* encapsulated in the Cloudlet, the ID of the VM running it. * encapsulated in the Cloudlet, the ID of the VM running it.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class Cloudlet { public class Cloudlet {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -17,9 +16,9 @@ import java.util.List; ...@@ -17,9 +16,9 @@ import java.util.List;
* extending this must execute Cloudlets. Also, the interface for cloudlet * extending this must execute Cloudlets. Also, the interface for cloudlet
* management is also implemented in this class. * management is also implemented in this class.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public abstract class CloudletScheduler { public abstract class CloudletScheduler {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2008, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -19,6 +18,9 @@ import java.util.Map; ...@@ -19,6 +18,9 @@ import java.util.Map;
* scheduling performed by a virtual machine assuming * scheduling performed by a virtual machine assuming
* that there is just one cloudlet which is working as * that there is just one cloudlet which is working as
* an online service. * an online service.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class CloudletSchedulerSingleService extends CloudletSchedulerTimeShared { public class CloudletSchedulerSingleService extends CloudletSchedulerTimeShared {
...@@ -33,9 +35,9 @@ public class CloudletSchedulerSingleService extends CloudletSchedulerTimeShared ...@@ -33,9 +35,9 @@ public class CloudletSchedulerSingleService extends CloudletSchedulerTimeShared
/** The under allocated mips. */ /** The under allocated mips. */
private Map<String, Double> underAllocatedMips; private Map<String, Double> underAllocatedMips;
private double cachePreviousTime; private double cachePreviousTime;
private List<Double> cacheCurrentRequestedMips; private List<Double> cacheCurrentRequestedMips;
/** /**
...@@ -191,7 +193,7 @@ public class CloudletSchedulerSingleService extends CloudletSchedulerTimeShared ...@@ -191,7 +193,7 @@ public class CloudletSchedulerSingleService extends CloudletSchedulerTimeShared
for (int i = 0; i < getPesNumber(); i++) { for (int i = 0; i < getPesNumber(); i++) {
currentMips.add(mipsForPe); currentMips.add(mipsForPe);
} }
setCachePreviousTime(getPreviousTime()); setCachePreviousTime(getPreviousTime());
setCacheCurrentRequestedMips(currentMips); setCacheCurrentRequestedMips(currentMips);
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -22,9 +21,9 @@ import org.cloudbus.cloudsim.core.CloudSim; ...@@ -22,9 +21,9 @@ import org.cloudbus.cloudsim.core.CloudSim;
* before cloudlet execution. I.e., even though cloudlets must wait for CPU, * before cloudlet execution. I.e., even though cloudlets must wait for CPU,
* data transfer happens as soon as cloudlets are submitted. * data transfer happens as soon as cloudlets are submitted.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class CloudletSchedulerSpaceShared extends CloudletScheduler { public class CloudletSchedulerSpaceShared extends CloudletScheduler {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -19,9 +18,9 @@ import org.cloudbus.cloudsim.core.CloudSim; ...@@ -19,9 +18,9 @@ import org.cloudbus.cloudsim.core.CloudSim;
* 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
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class CloudletSchedulerTimeShared extends CloudletScheduler { public class CloudletSchedulerTimeShared extends CloudletScheduler {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2006, The University of Melbourne, Australia and *
* University of Ljubljana, Slovenia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -14,8 +13,9 @@ package org.cloudbus.cloudsim; ...@@ -14,8 +13,9 @@ package org.cloudbus.cloudsim;
* such as file information retrieval, file transfers, and * such as file information retrieval, file transfers, and
* storage info. * storage info.
* *
* @author Uros Cibej and Anthony Sulistio * @author Uros Cibej
* @since CloudSim Toolkit 4.0 * @author Anthony Sulistio
* @since CloudSim Toolkit 1.0
*/ */
public final class DataCloudTags { public final class DataCloudTags {
// to prevent a conflict with the existing CloudSimTags values // to prevent a conflict with the existing CloudSimTags values
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -30,9 +29,9 @@ import org.cloudbus.cloudsim.core.SimEvent; ...@@ -30,9 +29,9 @@ import org.cloudbus.cloudsim.core.SimEvent;
* it will not be used, as processing of cloudlets are handled by the CloudletScheduler * it will not be used, as processing of cloudlets are handled by the CloudletScheduler
* and processing of VirtualMachines are handled by the VmAllocationPolicy. * and processing of VirtualMachines are handled by the VmAllocationPolicy.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class Datacenter extends SimEntity { public class Datacenter extends SimEntity {
...@@ -629,9 +628,7 @@ public class Datacenter extends SimEntity { ...@@ -629,9 +628,7 @@ public class Datacenter extends SimEntity {
debts.put(vm.getUserId(), amount); debts.put(vm.getUserId(), amount);
if (!Log.isDisabled()) { Log.formatLine("%.2f: Migration of VM #%d to Host #%d is completed", CloudSim.clock(), vm.getId(), host.getId());
Log.print(String.format("%.2f: Migration of VM #%d to Host #%d is completed\n", CloudSim.clock(), vm.getId(), host.getId()));
}
vm.setInMigration(false); vm.setInMigration(false);
} }
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -28,9 +27,9 @@ import org.cloudbus.cloudsim.lists.VmList; ...@@ -28,9 +27,9 @@ import org.cloudbus.cloudsim.lists.VmList;
* as vm creation, sumbission of cloudlets to this VMs * as vm creation, sumbission of cloudlets to this VMs
* and destruction of VMs. * and destruction of VMs.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class DatacenterBroker extends SimEntity { public class DatacenterBroker extends SimEntity {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -21,10 +20,11 @@ import org.cloudbus.cloudsim.lists.PeList; ...@@ -21,10 +20,11 @@ import org.cloudbus.cloudsim.lists.PeList;
* policy (time- or space-shared), cost and time zone at which the resource * policy (time- or space-shared), cost and time zone at which the resource
* is located along resource configuration. * is located along resource configuration.
* *
* @author Manzur Murshed and Rajkumar Buyya * @author Manzur Murshed
* @author Rajkumar Buyya
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class DatacenterCharacteristics { public class DatacenterCharacteristics {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -32,8 +31,7 @@ import org.cloudbus.cloudsim.core.SimEvent; ...@@ -32,8 +31,7 @@ import org.cloudbus.cloudsim.core.SimEvent;
* and processing of VirtualMachines are handled by the VmAllocationPolicy. * and processing of VirtualMachines are handled by the VmAllocationPolicy.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @since CloudSim Toolkit 1.0
* @invariant $none
*/ */
public class FederatedDatacenter extends SimEntity { public class FederatedDatacenter extends SimEntity {
...@@ -658,9 +656,7 @@ public class FederatedDatacenter extends SimEntity { ...@@ -658,9 +656,7 @@ public class FederatedDatacenter extends SimEntity {
debts.put(vm.getUserId(), amount); debts.put(vm.getUserId(), amount);
if (!Log.isDisabled()) { Log.formatLine("%.2f: Migration of VM #%d to Host #%d is completed", CloudSim.clock(), vm.getId(), host.getId());
Log.print(String.format("%.2f: Migration of VM #%d to Host #%d is completed\n", CloudSim.clock(), vm.getId(), host.getId()));
}
vm.setInMigration(false); vm.setInMigration(false);
} }
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2006, The University of Melbourne, Australia and *
* University of Ljubljana, Slovenia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
/** /**
* A class for representing a physical file in a DataCloud environment * A class for representing a physical file in a DataCloud environment
* *
* @author Uros Cibej and Anthony Sulistio * @author Uros Cibej
* @since CloudSim Toolkit 4.0 * @author Anthony Sulistio
* @since CloudSim Toolkit 1.0
*/ */
public class File { public class File {
private String name; // logical file name private String name; // logical file name
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2006, The University of Melbourne, Australia and *
* University of Ljubljana, Slovenia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -13,15 +12,14 @@ import java.util.Date; ...@@ -13,15 +12,14 @@ 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 and Anthony Sulistio * @author Uros Cibej
* @since CloudSim Toolkit 4.0 * @author Anthony Sulistio
* @since CloudSim Toolkit 1.0
*/ */
public class FileAttribute { public class FileAttribute {
private String name; // logical file name private String name; // logical file name
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2006, The University of Melbourne, Australia and *
* University of Ljubljana, Slovenia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -25,9 +24,9 @@ import org.cloudbus.cloudsim.distributions.ContinuousDistribution; ...@@ -25,9 +24,9 @@ import org.cloudbus.cloudsim.distributions.ContinuousDistribution;
* <li> max transfer rate = 133 MB/sec * <li> max transfer rate = 133 MB/sec
* </ul> * </ul>
* *
* @author Uros Cibej and Anthony Sulistio * @author Uros Cibej
* @since CloudSim Toolkit 4.0 * @author Anthony Sulistio
* @see gridsim.datagrid.storage.Storage * @since CloudSim Toolkit 1.0
*/ */
public class HarddriveStorage implements Storage { public class HarddriveStorage implements Storage {
...@@ -123,7 +122,8 @@ public class HarddriveStorage implements Storage { ...@@ -123,7 +122,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the available space in MB * @return the available space in MB
*/ */
public double getAvailableSpace() { @Override
public double getAvailableSpace() {
return capacity - currentSize; return capacity - currentSize;
} }
...@@ -133,7 +133,8 @@ public class HarddriveStorage implements Storage { ...@@ -133,7 +133,8 @@ public class HarddriveStorage implements Storage {
* @return <tt>true</tt> if the storage is full, <tt>false</tt> * @return <tt>true</tt> if the storage is full, <tt>false</tt>
* otherwise * otherwise
*/ */
public boolean isFull() { @Override
public boolean isFull() {
if (Math.abs(currentSize - capacity) < .0000001) { // currentSize == capacity if (Math.abs(currentSize - capacity) < .0000001) { // currentSize == capacity
return true; return true;
} }
...@@ -145,7 +146,8 @@ public class HarddriveStorage implements Storage { ...@@ -145,7 +146,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the number of stored files * @return the number of stored files
*/ */
public int getNumStoredFile() { @Override
public int getNumStoredFile() {
return fileList.size(); return fileList.size();
} }
...@@ -157,7 +159,8 @@ public class HarddriveStorage implements Storage { ...@@ -157,7 +159,8 @@ public class HarddriveStorage implements Storage {
* @return <tt>true</tt> if reservation succeeded, <tt>false</tt> * @return <tt>true</tt> if reservation succeeded, <tt>false</tt>
* otherwise * otherwise
*/ */
public boolean reserveSpace(int fileSize) { @Override
public boolean reserveSpace(int fileSize) {
if (fileSize <= 0) { if (fileSize <= 0) {
return false; return false;
} }
...@@ -179,7 +182,8 @@ public class HarddriveStorage implements Storage { ...@@ -179,7 +182,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the time (in seconds) required to add the file * @return the time (in seconds) required to add the file
*/ */
public double addReservedFile(File file) { @Override
public double addReservedFile(File file) {
if (file == null) { if (file == null) {
return 0; return 0;
} }
...@@ -203,7 +207,8 @@ public class HarddriveStorage implements Storage { ...@@ -203,7 +207,8 @@ public class HarddriveStorage implements Storage {
* @return <tt>true</tt> if enough space available, <tt>false</tt> * @return <tt>true</tt> if enough space available, <tt>false</tt>
* otherwise * otherwise
*/ */
public boolean hasPotentialAvailableSpace(int fileSize) { @Override
public boolean hasPotentialAvailableSpace(int fileSize) {
if (fileSize <= 0) { if (fileSize <= 0) {
return false; return false;
} }
...@@ -240,7 +245,8 @@ public class HarddriveStorage implements Storage { ...@@ -240,7 +245,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the capacity of the storage in MB * @return the capacity of the storage in MB
*/ */
public double getCapacity() { @Override
public double getCapacity() {
return capacity; return capacity;
} }
...@@ -249,7 +255,8 @@ public class HarddriveStorage implements Storage { ...@@ -249,7 +255,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the current size of the stored files in MB * @return the current size of the stored files in MB
*/ */
public double getCurrentSize() { @Override
public double getCurrentSize() {
return currentSize; return currentSize;
} }
...@@ -258,7 +265,8 @@ public class HarddriveStorage implements Storage { ...@@ -258,7 +265,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the name of this storage * @return the name of this storage
*/ */
public String getName() { @Override
public String getName() {
return name; return name;
} }
...@@ -296,7 +304,8 @@ public class HarddriveStorage implements Storage { ...@@ -296,7 +304,8 @@ public class HarddriveStorage implements Storage {
* @return <tt>true</tt> if the setting succeeded, <tt>false</tt> * @return <tt>true</tt> if the setting succeeded, <tt>false</tt>
* otherwise * otherwise
*/ */
public boolean setMaxTransferRate(int rate) { @Override
public boolean setMaxTransferRate(int rate) {
if (rate <= 0) { if (rate <= 0) {
return false; return false;
} }
...@@ -310,7 +319,8 @@ public class HarddriveStorage implements Storage { ...@@ -310,7 +319,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the maximum transfer rate in MB/sec * @return the maximum transfer rate in MB/sec
*/ */
public double getMaxTransferRate() { @Override
public double getMaxTransferRate() {
return maxTransferRate; return maxTransferRate;
} }
...@@ -364,7 +374,8 @@ public class HarddriveStorage implements Storage { ...@@ -364,7 +374,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the file with the specified filename * @return the file with the specified filename
*/ */
public File getFile(String fileName) { @Override
public File getFile(String fileName) {
// check first whether file name is valid or not // check first whether file name is valid or not
File obj = null; File obj = null;
if (fileName == null || fileName.length() == 0) { if (fileName == null || fileName.length() == 0) {
...@@ -410,7 +421,8 @@ public class HarddriveStorage implements Storage { ...@@ -410,7 +421,8 @@ public class HarddriveStorage implements Storage {
* *
* @return a List of file names * @return a List of file names
*/ */
public List<String> getFileNameList() { @Override
public List<String> getFileNameList() {
return nameList; return nameList;
} }
...@@ -493,7 +505,8 @@ public class HarddriveStorage implements Storage { ...@@ -493,7 +505,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the time taken (in seconds) for adding the specified file * @return the time taken (in seconds) for adding the specified file
*/ */
public double addFile(File file) { @Override
public double addFile(File file) {
double result = 0.0; double result = 0.0;
// check if the file is valid or not // check if the file is valid or not
if (!isFileValid(file, "addFile()")) { if (!isFileValid(file, "addFile()")) {
...@@ -531,7 +544,8 @@ public class HarddriveStorage implements Storage { ...@@ -531,7 +544,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the time taken (in seconds) for adding the specified files * @return the time taken (in seconds) for adding the specified files
*/ */
public double addFile(List<File> list) { @Override
public double addFile(List<File> list) {
double result = 0.0; double result = 0.0;
if (list == null || list.isEmpty()) { if (list == null || list.isEmpty()) {
Log.printLine(name + ".addFile(): Warning - list is empty."); Log.printLine(name + ".addFile(): Warning - list is empty.");
...@@ -556,7 +570,8 @@ public class HarddriveStorage implements Storage { ...@@ -556,7 +570,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the deleted file * @return the deleted file
*/ */
public File deleteFile(String fileName) { @Override
public File deleteFile(String fileName) {
if (fileName == null || fileName.length() == 0) { if (fileName == null || fileName.length() == 0) {
return null; return null;
} }
...@@ -590,7 +605,8 @@ public class HarddriveStorage implements Storage { ...@@ -590,7 +605,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the time taken (in seconds) for deleting the specified file * @return the time taken (in seconds) for deleting the specified file
*/ */
public double deleteFile(String fileName, File file) { @Override
public double deleteFile(String fileName, File file) {
return deleteFile(file); return deleteFile(file);
} }
...@@ -604,7 +620,8 @@ public class HarddriveStorage implements Storage { ...@@ -604,7 +620,8 @@ public class HarddriveStorage implements Storage {
* *
* @return the time taken (in seconds) for deleting the specified file * @return the time taken (in seconds) for deleting the specified file
*/ */
public double deleteFile(File file) { @Override
public double deleteFile(File file) {
double result = 0.0; double result = 0.0;
// check if the file is valid or not // check if the file is valid or not
if (!isFileValid(file, "deleteFile()")) { if (!isFileValid(file, "deleteFile()")) {
...@@ -632,7 +649,8 @@ public class HarddriveStorage implements Storage { ...@@ -632,7 +649,8 @@ public class HarddriveStorage implements Storage {
* @return <tt>true</tt> if the file is in the storage, <tt>false</tt> * @return <tt>true</tt> if the file is in the storage, <tt>false</tt>
* otherwise * otherwise
*/ */
public boolean contains(String fileName) { @Override
public boolean contains(String fileName) {
boolean result = false; boolean result = false;
if (fileName == null || fileName.length() == 0) { if (fileName == null || fileName.length() == 0) {
Log.printLine(name Log.printLine(name
...@@ -659,7 +677,8 @@ public class HarddriveStorage implements Storage { ...@@ -659,7 +677,8 @@ public class HarddriveStorage implements Storage {
* @return <tt>true</tt> if the file is in the storage, <tt>false</tt> * @return <tt>true</tt> if the file is in the storage, <tt>false</tt>
* otherwise * otherwise
*/ */
public boolean contains(File file) { @Override
public boolean contains(File file) {
boolean result = false; boolean result = false;
if (!isFileValid(file, "contains()")) { if (!isFileValid(file, "contains()")) {
return result; return result;
...@@ -680,7 +699,8 @@ public class HarddriveStorage implements Storage { ...@@ -680,7 +699,8 @@ public class HarddriveStorage implements Storage {
* @return <tt>true</tt> if the renaming succeeded, <tt>false</tt> * @return <tt>true</tt> if the renaming succeeded, <tt>false</tt>
* otherwise * otherwise
*/ */
public boolean renameFile(File file, String newName) { @Override
public boolean renameFile(File file, String newName) {
// check whether the new filename is conflicting with existing ones // check whether the new filename is conflicting with existing ones
// or not // or not
boolean result = false; boolean result = false;
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -25,9 +24,9 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner; ...@@ -25,9 +24,9 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner;
* *
* 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
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class Host { public class Host {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -12,6 +20,9 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner; ...@@ -12,6 +20,9 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner;
/** /**
* The Class HostDynamicWorkload. * The Class HostDynamicWorkload.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class HostDynamicWorkload extends Host { public class HostDynamicWorkload extends Host {
...@@ -88,9 +99,7 @@ public class HostDynamicWorkload extends Host { ...@@ -88,9 +99,7 @@ public class HostDynamicWorkload extends Host {
updateUnderAllocatedMips(vm, totalRequestedMips, totalAllocatedMips); updateUnderAllocatedMips(vm, totalRequestedMips, totalAllocatedMips);
if (!Log.isDisabled()) { Log.formatLine("%.2f: 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.print(String.format("%.2f: Total allocated MIPS for VM #" + vm.getId() + " (Host #" + vm.getHost().getId() + ") is %.2f, was requested %.2f out of total %.2f (%.2f%%)\n", CloudSim.clock(), totalAllocatedMips, totalRequestedMips, vm.getMips(), totalRequestedMips / vm.getMips() * 100));
}
if (vm.isInMigration()) { if (vm.isInMigration()) {
Log.printLine("VM #" + vm.getId() + " is in migration"); Log.printLine("VM #" + vm.getId() + " is in migration");
......
...@@ -35,11 +35,10 @@ import org.cloudbus.cloudsim.core.CloudSimTags; ...@@ -35,11 +35,10 @@ import org.cloudbus.cloudsim.core.CloudSimTags;
* class of an InfoPacket to the same as the NetPacket, and send it to the same * class of an InfoPacket to the same as the NetPacket, and send it to the same
* destination from the same source. * destination from the same source.
* *
* @since CloudSim Toolkit 3.1 * @author Gokul Poduval
* @author Gokul Poduval & Chen-Khong Tham, National University of Singapore * @author Chen-Khong Tham, National University of Singapore
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class InfoPacket implements Packet { public class InfoPacket implements Packet {
/** The name. */ /** The name. */
...@@ -145,7 +144,8 @@ public class InfoPacket implements Packet { ...@@ -145,7 +144,8 @@ public class InfoPacket implements Packet {
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public int getId() { @Override
public int getId() {
return packetId; return packetId;
} }
...@@ -246,7 +246,8 @@ public class InfoPacket implements Packet { ...@@ -246,7 +246,8 @@ public class InfoPacket implements Packet {
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public long getSize() { @Override
public long getSize() {
return size; return size;
} }
...@@ -260,6 +261,7 @@ public class InfoPacket implements Packet { ...@@ -260,6 +261,7 @@ public class InfoPacket implements Packet {
* @pre size >= 0 * @pre size >= 0
* @post $none * @post $none
*/ */
@Override
public boolean setSize(long size) { public boolean setSize(long size) {
if (size < 0) { if (size < 0) {
return false; return false;
...@@ -277,7 +279,8 @@ public class InfoPacket implements Packet { ...@@ -277,7 +279,8 @@ public class InfoPacket implements Packet {
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public int getDestId() { @Override
public int getDestId() {
return destId; return destId;
} }
...@@ -289,7 +292,8 @@ public class InfoPacket implements Packet { ...@@ -289,7 +292,8 @@ public class InfoPacket implements Packet {
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public int getSrcId() { @Override
public int getSrcId() {
return srcId; return srcId;
} }
...@@ -504,7 +508,8 @@ public class InfoPacket implements Packet { ...@@ -504,7 +508,8 @@ public class InfoPacket implements Packet {
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public int getLast() { @Override
public int getLast() {
return last; return last;
} }
...@@ -516,7 +521,8 @@ public class InfoPacket implements Packet { ...@@ -516,7 +521,8 @@ public class InfoPacket implements Packet {
* @pre last > 0 * @pre last > 0
* @post $none * @post $none
*/ */
public void setLast(int last) { @Override
public void setLast(int last) {
this.last = last; this.last = last;
} }
...@@ -528,7 +534,8 @@ public class InfoPacket implements Packet { ...@@ -528,7 +534,8 @@ public class InfoPacket implements Packet {
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public int getNetServiceType() { @Override
public int getNetServiceType() {
return netServiceType ; return netServiceType ;
} }
...@@ -540,7 +547,8 @@ public class InfoPacket implements Packet { ...@@ -540,7 +547,8 @@ public class InfoPacket implements Packet {
* @pre netServiceType >= 0 * @pre netServiceType >= 0
* @post $none * @post $none
*/ */
public void setNetServiceType(int netServiceType) { @Override
public void setNetServiceType(int netServiceType) {
this.netServiceType = netServiceType ; this.netServiceType = netServiceType ;
} }
...@@ -552,7 +560,8 @@ public class InfoPacket implements Packet { ...@@ -552,7 +560,8 @@ public class InfoPacket implements Packet {
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public int getTag() { @Override
public int getTag() {
return tag ; return tag ;
} }
......
/* /*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
/** /**
* The Class Log. * The Log class used for performing loggin of the simulation process.
* It provides the ability to substitute the output stream by any
* OutputStream subclass.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class Log { public class Log {
/** The Constant LINE_SEPARATOR. */
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
/** The output. */ /** The output. */
private static OutputStream output; private static OutputStream output;
...@@ -21,8 +34,6 @@ public class Log { ...@@ -21,8 +34,6 @@ public class Log {
* Prints the message. * Prints the message.
* *
* @param message the message * @param message the message
*
* @throws IOException Signals that an I/O exception has occurred.
*/ */
public static void print(String message) { public static void print(String message) {
if (!isDisabled()) { if (!isDisabled()) {
...@@ -35,70 +46,68 @@ public class Log { ...@@ -35,70 +46,68 @@ public class Log {
} }
/** /**
* Prints the message. * Prints the message passed as a non-String object.
* *
* @param message the message * @param message the message
*
* @throws IOException Signals that an I/O exception has occurred.
*/ */
public static void print(long message) { public static void print(Object message) {
print(String.valueOf(message)); if (!isDisabled()) {
print(String.valueOf(message));
}
} }
/** /**
* Prints the message. * Prints the line.
* *
* @param message the message * @param message the message
*
* @throws IOException Signals that an I/O exception has occurred.
*/ */
public static void print(double message) { public static void printLine(String message) {
print(String.valueOf(message)); if (!isDisabled()) {
print(message + LINE_SEPARATOR);
}
} }
/** /**
* Prints the line. * Prints the empty line.
*
* @param message the message
*
* @throws IOException Signals that an I/O exception has occurred.
*/ */
public static void printLine(String message) { public static void printLine() {
if (!isDisabled()) { if (!isDisabled()) {
print(message + System.getProperty("line.separator")); print(LINE_SEPARATOR);
} }
} }
/** /**
* Prints the line. * Prints the line passed as a non-String object.
* *
* @param message the message * @param message the message
*
* @throws IOException Signals that an I/O exception has occurred.
*/ */
public static void printLine(long message) { public static void printLine(Object message) {
printLine(String.valueOf(message)); if (!isDisabled()) {
printLine(String.valueOf(message));
}
} }
/** /**
* Prints the line. * Prints a string formated as in String.format().
*
* @param message the message
* *
* @throws IOException Signals that an I/O exception has occurred. * @param format the format
* @param args the args
*/ */
public static void printLine(double message) { public static void format(String format, Object... args ) {
printLine(String.valueOf(message)); if (!isDisabled()) {
print(String.format(format, args));
}
} }
/** /**
* Prints the empty line. * Prints a line formated as in String.format().
* *
* @throws IOException Signals that an I/O exception has occurred. * @param format the format
* @param args the args
*/ */
public static void printLine() { public static void formatLine(String format, Object... args ) {
if (!isDisabled()) { if (!isDisabled()) {
printLine(""); printLine(String.format(format, args));
} }
} }
...@@ -126,7 +135,7 @@ public class Log { ...@@ -126,7 +135,7 @@ public class Log {
/** /**
* Sets the disable output flag. * Sets the disable output flag.
* *
* @param disabled the new disabled * @param _disabled the new disabled
*/ */
public static void setDisabled(boolean _disabled) { public static void setDisabled(boolean _disabled) {
disabled = _disabled; disabled = _disabled;
...@@ -141,4 +150,18 @@ public class Log { ...@@ -141,4 +150,18 @@ public class Log {
return disabled; return disabled;
} }
/**
* Disables the output.
*/
public static void disable() {
setDisabled(true);
}
/**
* Enables the output.
*/
public static void enable() {
setDisabled(false);
}
} }
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -20,7 +19,6 @@ import org.cloudbus.cloudsim.network.TopologicalGraph; ...@@ -20,7 +19,6 @@ import org.cloudbus.cloudsim.network.TopologicalGraph;
import org.cloudbus.cloudsim.network.TopologicalLink; import org.cloudbus.cloudsim.network.TopologicalLink;
import org.cloudbus.cloudsim.network.TopologicalNode; import org.cloudbus.cloudsim.network.TopologicalNode;
/** /**
* NetworkTopology is a class that implements network layer * NetworkTopology is a class that implements network layer
* in CloudSim. It reads a BRITE file and generates a * in CloudSim. It reads a BRITE file and generates a
...@@ -34,13 +32,13 @@ import org.cloudbus.cloudsim.network.TopologicalNode; ...@@ -34,13 +32,13 @@ import org.cloudbus.cloudsim.network.TopologicalNode;
* one (and only one) BRITE node to allow proper work of the * one (and only one) BRITE node to allow proper work of the
* network simulation. Each BRITE node can be mapped to only * network simulation. Each BRITE node can be mapped to only
* one entity at a time. * one entity at a time.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class NetworkTopology { public class NetworkTopology {
protected static int nextIdx=0; protected static int nextIdx=0;
private static boolean networkEnabled = false; private static boolean networkEnabled = false;
protected static DelayMatrix_Float delayMatrix = null; protected static DelayMatrix_Float delayMatrix = null;
...@@ -57,21 +55,21 @@ public class NetworkTopology { ...@@ -57,21 +55,21 @@ public class NetworkTopology {
* @pre fileName != null * @pre fileName != null
* @post $none * @post $none
*/ */
public static void buildNetworkTopology(String fileName) { public static void buildNetworkTopology(String fileName) {
Log.printLine("Topology file: " + fileName); Log.printLine("Topology file: " + fileName);
//try to find the file //try to find the file
GraphReaderBrite reader = new GraphReaderBrite(); GraphReaderBrite reader = new GraphReaderBrite();
try{ try{
graph = reader.readGraphFile(fileName); graph = reader.readGraphFile(fileName);
map = new HashMap<Integer,Integer>(); map = new HashMap<Integer,Integer>();
generateMatrices(); generateMatrices();
} catch(IOException e){ } catch(IOException e){
//problem with the file. Does not simulate network //problem with the file. Does not simulate network
Log.printLine("Problem in processing BRITE file. Network simulation is disabled. Error: "+e.getMessage()); Log.printLine("Problem in processing BRITE file. Network simulation is disabled. Error: "+e.getMessage());
} }
} }
/** /**
...@@ -82,13 +80,13 @@ public class NetworkTopology { ...@@ -82,13 +80,13 @@ public class NetworkTopology {
private static void generateMatrices() { private static void generateMatrices() {
//creates the delay matrix //creates the delay matrix
delayMatrix = new DelayMatrix_Float(graph, false); delayMatrix = new DelayMatrix_Float(graph, false);
//creates the bw matrix //creates the bw matrix
bwMatrix = createBwMatrix(graph,false); bwMatrix = createBwMatrix(graph,false);
networkEnabled=true; networkEnabled=true;
} }
/** /**
* Adds a new link in the network topology * Adds a new link in the network topology
* @param srcId ID of the link's source * @param srcId ID of the link's source
...@@ -100,64 +98,64 @@ public class NetworkTopology { ...@@ -100,64 +98,64 @@ public class NetworkTopology {
* @post $none * @post $none
*/ */
public static void addLink(int srcId, int destId, double bw, double lat){ public static void addLink(int srcId, int destId, double bw, double lat){
if(graph==null){ if(graph==null){
graph = new TopologicalGraph(); graph = new TopologicalGraph();
} }
if(map==null){ if(map==null){
map = new HashMap<Integer,Integer>(); map = new HashMap<Integer,Integer>();
} }
//maybe add the nodes //maybe add the nodes
if(!map.containsKey(srcId)){ if(!map.containsKey(srcId)){
graph.addNode(new TopologicalNode(nextIdx)); graph.addNode(new TopologicalNode(nextIdx));
map.put(srcId, nextIdx); map.put(srcId, nextIdx);
nextIdx++; nextIdx++;
} }
if(!map.containsKey(destId)){ if(!map.containsKey(destId)){
graph.addNode(new TopologicalNode(nextIdx)); graph.addNode(new TopologicalNode(nextIdx));
map.put(destId, nextIdx); map.put(destId, nextIdx);
nextIdx++; nextIdx++;
} }
//generate a new link //generate a new link
graph.addLink(new TopologicalLink((int)map.get(srcId),(int)map.get(destId),(float)lat,(float)bw)); graph.addLink(new TopologicalLink(map.get(srcId),map.get(destId),(float)lat,(float)bw));
generateMatrices(); generateMatrices();
} }
/** /**
* Creates the matrix containiing the available bandiwdth beteen two nodes * Creates the matrix containiing the available bandiwdth beteen two nodes
* @param graph topological graph describing the topology * @param graph topological graph describing the topology
* @param directed true if the graph is directed; false otherwise * @param directed true if the graph is directed; false otherwise
* @return the bandwidth graph * @return the bandwidth graph
*/ */
private static double[][] createBwMatrix(TopologicalGraph graph, boolean directed) { private static double[][] createBwMatrix(TopologicalGraph graph, boolean directed) {
int nodes = graph.getNumberOfNodes(); int nodes = graph.getNumberOfNodes();
double[][] mtx = new double[nodes][nodes]; double[][] mtx = new double[nodes][nodes];
//cleanup matrix //cleanup matrix
for(int i=0;i<nodes;i++){ for(int i=0;i<nodes;i++){
for(int j=0;j<nodes;j++){ for(int j=0;j<nodes;j++){
mtx[i][j] = 0.0; mtx[i][j] = 0.0;
} }
} }
Iterator<TopologicalLink> iter = graph.getLinkIterator(); Iterator<TopologicalLink> iter = graph.getLinkIterator();
while(iter.hasNext()){ while(iter.hasNext()){
TopologicalLink edge = iter.next(); TopologicalLink edge = iter.next();
mtx[edge.getSrcNodeID()][edge.getDestNodeID()] = edge.getLinkBw(); mtx[edge.getSrcNodeID()][edge.getDestNodeID()] = edge.getLinkBw();
if(!directed){ if(!directed){
mtx[edge.getDestNodeID()][edge.getSrcNodeID()] = edge.getLinkBw(); mtx[edge.getDestNodeID()][edge.getSrcNodeID()] = edge.getLinkBw();
} }
} }
return mtx; return mtx;
} }
...@@ -169,7 +167,7 @@ public class NetworkTopology { ...@@ -169,7 +167,7 @@ public class NetworkTopology {
* @pre briteID >= 0 * @pre briteID >= 0
* @post $none * @post $none
*/ */
public static void mapNode(int cloudSimEntityID, int briteID){ public static void mapNode(int cloudSimEntityID, int briteID){
if(networkEnabled){ if(networkEnabled){
try{ try{
if(!map.containsKey(cloudSimEntityID)){ //this CloudSim entity was already mapped? if(!map.containsKey(cloudSimEntityID)){ //this CloudSim entity was already mapped?
...@@ -186,14 +184,14 @@ public class NetworkTopology { ...@@ -186,14 +184,14 @@ public class NetworkTopology {
} }
} }
} }
/** /**
* Unmaps a previously mapped CloudSim entity to a node in the network topology * Unmaps a previously mapped CloudSim entity to a node in the network topology
* @param cloudSimEntityID ID of the entity being unmapped * @param cloudSimEntityID ID of the entity being unmapped
* @pre cloudSimEntityID >= 0 * @pre cloudSimEntityID >= 0
* @post $none * @post $none
*/ */
public static void unmapNode(int cloudSimEntityID){ public static void unmapNode(int cloudSimEntityID){
if(networkEnabled){ if(networkEnabled){
try{ try{
map.remove(cloudSimEntityID); map.remove(cloudSimEntityID);
...@@ -202,7 +200,7 @@ public class NetworkTopology { ...@@ -202,7 +200,7 @@ public class NetworkTopology {
} }
} }
} }
/** /**
* Calculates the delay between two nodes * Calculates the delay between two nodes
* @param srcID ID of the source node * @param srcID ID of the source node
...@@ -212,20 +210,20 @@ public class NetworkTopology { ...@@ -212,20 +210,20 @@ public class NetworkTopology {
* @pre destID >= 0 * @pre destID >= 0
* @post $none * @post $none
*/ */
public static double getDelay(int srcID, int destID){ public static double getDelay(int srcID, int destID){
if(networkEnabled){ if(networkEnabled){
try{ try{
//add the network latency //add the network latency
double delay = delayMatrix.getDelay(map.get(srcID),map.get(destID)); double delay = delayMatrix.getDelay(map.get(srcID),map.get(destID));
return delay; return delay;
} catch (Exception e){ } catch (Exception e){
//in case of error, just keep running and return 0.0 //in case of error, just keep running and return 0.0
} }
} }
return 0.0; return 0.0;
} }
/** /**
* This method returns true if network simulation is working. If there were some problem * This method returns true if network simulation is working. If there were some problem
* during creation of network (e.g., during parsing of BRITE file) that does not allow * during creation of network (e.g., during parsing of BRITE file) that does not allow
......
...@@ -16,22 +16,22 @@ ...@@ -16,22 +16,22 @@
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
/** /**
* This class contains the structure for a network packet. * This class contains the structure for a network packet.
* *
* @since CloudSim Toolkit 3.1 * @author Gokul Poduval
* @author Gokul Poduval & Chen-Khong Tham, National University of Singapore * @author Chen-Khong Tham, National University of Singapore
* @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
*/ */
String toString(); @Override
String toString();
/** /**
* Returns the size of this packet * Returns the size of this packet
...@@ -117,5 +117,4 @@ public interface Packet ...@@ -117,5 +117,4 @@ public interface Packet
*/ */
int getTag(); int getTag();
} // end interface }
...@@ -20,9 +20,9 @@ package org.cloudbus.cloudsim; ...@@ -20,9 +20,9 @@ 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.
* *
* @invariant $none * @author Gokul Poduval
* @since CloudSim Toolkit 3.1 * @author Chen-Khong Tham, National University of Singapore
* @author Gokul Poduval & Chen-Khong Tham, National University of Singapore * @since CloudSim Toolkit 1.0
*/ */
public class ParameterException extends Exception { public class ParameterException extends Exception {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2002, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -15,13 +14,13 @@ import org.cloudbus.cloudsim.provisioners.PeProvisioner; ...@@ -15,13 +14,13 @@ import org.cloudbus.cloudsim.provisioners.PeProvisioner;
* CloudSim Pe (Processing Element) class represents CPU unit, * CloudSim Pe (Processing Element) class represents CPU unit,
* defined in terms of Millions Instructions Per Second (MIPS) rating.<br> * defined in terms of Millions Instructions Per Second (MIPS) rating.<br>
* <b>ASSUMPTION:<b> All PEs under the same Machine have the same MIPS rating. * <b>ASSUMPTION:<b> All PEs under the same Machine have the same MIPS rating.
* *
* @author Manzur Murshed and Rajkumar Buyya * @author Manzur Murshed
* @since CloudSim Toolkit 1.0 * @author Rajkumar Buyya
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class Pe { public class Pe {
/** Denotes Pe is FREE for allocation. */ /** Denotes Pe is FREE for allocation. */
public static final int FREE = 1; public static final int FREE = 1;
...@@ -30,23 +29,23 @@ public class Pe { ...@@ -30,23 +29,23 @@ public class Pe {
/** Denotes Pe is failed and hence it can't process any Cloudlet at this moment. This Pe is failed because it belongs to a machine which is also failed. */ /** Denotes Pe is failed and hence it can't process any Cloudlet at this moment. This Pe is failed because it belongs to a machine which is also failed. */
public static final int FAILED = 3; public static final int FAILED = 3;
/** The id. */ /** The id. */
private int id; private int id;
// FOR SPACE SHARED RESOURCE: Jan 21 // FOR SPACE SHARED RESOURCE: Jan 21
/** The status of Pe: FREE, BUSY, FAILED: . */ /** The status of Pe: FREE, BUSY, FAILED: . */
private int status; private int status;
/** The pe provisioner. */ /** The pe provisioner. */
private PeProvisioner peProvisioner; private PeProvisioner peProvisioner;
/** /**
* Allocates a new Pe object. * Allocates a new Pe object.
* *
* @param id the Pe ID * @param id the Pe ID
* @param peProvisioner the pe provisioner * @param peProvisioner the pe provisioner
* *
* @pre id >= 0 * @pre id >= 0
* @pre peProvisioner != null * @pre peProvisioner != null
* @post $none * @post $none
...@@ -61,16 +60,16 @@ public class Pe { ...@@ -61,16 +60,16 @@ public class Pe {
/** /**
* Sets the id. * Sets the id.
* *
* @param id the new id * @param id the new id
*/ */
protected void setId(int id) { protected void setId(int id) {
this.id = id; this.id = id;
} }
/** /**
* Gets the id. * Gets the id.
* *
* @return the id * @return the id
*/ */
public int getId() { public int getId() {
...@@ -79,9 +78,9 @@ public class Pe { ...@@ -79,9 +78,9 @@ public class Pe {
/** /**
* Sets the MIPS Rating of this Pe. * Sets the MIPS Rating of this Pe.
* *
* @param d the mips * @param d the mips
* *
* @pre mips >= 0 * @pre mips >= 0
* @post $none * @post $none
*/ */
...@@ -91,9 +90,9 @@ public class Pe { ...@@ -91,9 +90,9 @@ public class Pe {
/** /**
* Gets the MIPS Rating of this Pe. * Gets the MIPS Rating of this Pe.
* *
* @return the MIPS Rating * @return the MIPS Rating
* *
* @pre $none * @pre $none
* @post $result >= 0 * @post $result >= 0
*/ */
...@@ -103,9 +102,9 @@ public class Pe { ...@@ -103,9 +102,9 @@ public class Pe {
/** /**
* Gets the status of this Pe. * Gets the status of this Pe.
* *
* @return the status of this Pe * @return the status of this Pe
* *
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
...@@ -116,7 +115,7 @@ public class Pe { ...@@ -116,7 +115,7 @@ public class Pe {
/** /**
* Sets Pe status to free, meaning it is available for processing. * Sets Pe status to free, meaning it is available for processing.
* This should be used by SPACE shared hostList only. * This should be used by SPACE shared hostList only.
* *
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
...@@ -127,17 +126,17 @@ public class Pe { ...@@ -127,17 +126,17 @@ public class Pe {
/** /**
* Sets Pe status to busy, meaning it is already executing Cloudlets. * Sets Pe status to busy, meaning it is already executing Cloudlets.
* This should be used by SPACE shared hostList only. * This should be used by SPACE shared hostList only.
* *
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public void setStatusBusy() { public void setStatusBusy() {
setStatus(BUSY); setStatus(BUSY);
} }
/** /**
* Sets this Pe to FAILED. * Sets this Pe to FAILED.
* *
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
...@@ -147,10 +146,10 @@ public class Pe { ...@@ -147,10 +146,10 @@ public class Pe {
/** /**
* Sets Pe status to either <tt>Pe.FREE</tt> or <tt>Pe.BUSY</tt> * Sets Pe status to either <tt>Pe.FREE</tt> or <tt>Pe.BUSY</tt>
* *
* @param status Pe status, <tt>true</tt> if it is FREE, <tt>false</tt> * @param status Pe status, <tt>true</tt> if it is FREE, <tt>false</tt>
* if BUSY. * if BUSY.
* *
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
...@@ -160,9 +159,9 @@ public class Pe { ...@@ -160,9 +159,9 @@ public class Pe {
/** /**
* Gets the byte size of this class. * Gets the byte size of this class.
* *
* @return the byte size * @return the byte size
* *
* @pre $none * @pre $none
* @post $result > 0 * @post $result > 0
*/ */
...@@ -171,24 +170,24 @@ public class Pe { ...@@ -171,24 +170,24 @@ public class Pe {
// int totalInt = 2 * 4; // NOTE: static int doesn't count // int totalInt = 2 * 4; // NOTE: static int doesn't count
// return totalInt; // return totalInt;
// } // }
/** /**
* Sets the pe provisioner. * Sets the pe provisioner.
* *
* @param peProvisioner the new pe provisioner * @param peProvisioner the new pe provisioner
*/ */
protected void setPeProvisioner(PeProvisioner peProvisioner) { protected void setPeProvisioner(PeProvisioner peProvisioner) {
this.peProvisioner = peProvisioner; this.peProvisioner = peProvisioner;
} }
/** /**
* Gets the Pe provisioner. * Gets the Pe provisioner.
* *
* @return the Pe provisioner * @return the Pe provisioner
*/ */
public PeProvisioner getPeProvisioner() { public PeProvisioner getPeProvisioner() {
return this.peProvisioner; return this.peProvisioner;
} }
} }
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -16,31 +15,30 @@ import java.util.List; ...@@ -16,31 +15,30 @@ import java.util.List;
* SANStorage represents a storage area network composed of a set of * SANStorage represents a storage area network composed of a set of
* harddisks connected in a LAN. Capacity of individual disks are abstracted, * harddisks connected in a LAN. Capacity of individual disks are abstracted,
* thus only the overall capacity of the SAN is considered. * thus only the overall capacity of the SAN is considered.
* *
* WARNING: This class is not yet fully functional. Effects of network contention * WARNING: This class is not yet fully functional. Effects of network contention
* are not considered in the simulation. So, time for file transfer is underestimated * are not considered in the simulation. So, time for file transfer is underestimated
* in the presence of high network load. * in the presence of high network load.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @since CloudSim Toolkit 1.0
* @invariant $none
*/ */
public class SanStorage extends HarddriveStorage { public class SanStorage extends HarddriveStorage {
/** The bandwidth. */ /** The bandwidth. */
double bandwidth; double bandwidth;
/** The network latency. */ /** The network latency. */
double networkLatency; double networkLatency;
/** /**
* Creates a new SAN with a given capacity, latency, and bandwidth of * Creates a new SAN with a given capacity, latency, and bandwidth of
* the network connection. * the network connection.
* *
* @param capacity Storage device capacity * @param capacity Storage device capacity
* @param bandwidth Network bandwidth * @param bandwidth Network bandwidth
* @param networkLatency Network latency * @param networkLatency Network latency
* *
* @throws ParameterException when the name and the capacity are not valid * @throws ParameterException when the name and the capacity are not valid
*/ */
public SanStorage(double capacity, double bandwidth, double networkLatency) throws ParameterException { public SanStorage(double capacity, double bandwidth, double networkLatency) throws ParameterException {
...@@ -48,16 +46,16 @@ public class SanStorage extends HarddriveStorage { ...@@ -48,16 +46,16 @@ public class SanStorage extends HarddriveStorage {
this.bandwidth=bandwidth; this.bandwidth=bandwidth;
this.networkLatency=networkLatency; this.networkLatency=networkLatency;
} }
/** /**
* Creates a new SAN with a given capacity, latency, and bandwidth of * Creates a new SAN with a given capacity, latency, and bandwidth of
* the network connection. * the network connection.
* *
* @param name the name of the new harddrive storage * @param name the name of the new harddrive storage
* @param capacity Storage device capacity * @param capacity Storage device capacity
* @param bandwidth Network bandwidth * @param bandwidth Network bandwidth
* @param networkLatency Network latency * @param networkLatency Network latency
* *
* @throws ParameterException when the name and the capacity are not valid * @throws ParameterException when the name and the capacity are not valid
*/ */
public SanStorage(String name, double capacity, double bandwidth, double networkLatency) throws ParameterException { public SanStorage(String name, double capacity, double bandwidth, double networkLatency) throws ParameterException {
...@@ -65,64 +63,70 @@ public class SanStorage extends HarddriveStorage { ...@@ -65,64 +63,70 @@ public class SanStorage extends HarddriveStorage {
this.bandwidth=bandwidth; this.bandwidth=bandwidth;
this.networkLatency=networkLatency; this.networkLatency=networkLatency;
} }
/** /**
* Adds a file for which the space has already been reserved. * Adds a file for which the space has already been reserved.
* *
* @param file the file to be added * @param file the file to be added
* *
* @return the time (in seconds) required to add the file * @return the time (in seconds) required to add the file
*/ */
@Override
public double addReservedFile(File file) { public double addReservedFile(File file) {
double time = super.addReservedFile(file); double time = super.addReservedFile(file);
time+=this.networkLatency; time+=this.networkLatency;
time+=file.getSize()*this.bandwidth; time+=file.getSize()*this.bandwidth;
return time; return time;
} }
/** /**
* Gets the maximum transfer rate of the storage in MB/sec. * Gets the maximum transfer rate of the storage in MB/sec.
* *
* @return the maximum transfer rate in MB/sec * @return the maximum transfer rate in MB/sec
*/ */
@Override
public double getMaxTransferRate() { public double getMaxTransferRate() {
double diskRate=super.getMaxTransferRate(); double diskRate=super.getMaxTransferRate();
//the max transfer rate is the minimum between //the max transfer rate is the minimum between
//the network bandwidth and the disk rate //the network bandwidth and the disk rate
if(diskRate<this.bandwidth) return diskRate; if(diskRate<this.bandwidth) {
return diskRate;
}
return this.bandwidth; return this.bandwidth;
} }
/** /**
* Adds a file to the storage. * Adds a file to the storage.
* *
* @param file the file to be added * @param file the file to be added
* *
* @return the time taken (in seconds) for adding the specified file * @return the time taken (in seconds) for adding the specified file
*/ */
public double addFile(File file) { @Override
public double addFile(File file) {
double time=super.addFile(file); double time=super.addFile(file);
time+=this.networkLatency; time+=this.networkLatency;
time+=file.getSize()*this.bandwidth; time+=file.getSize()*this.bandwidth;
return time; return time;
} }
/** /**
* Adds a set of files to the storage. * Adds a set of files to the storage.
* Runs through the list of files and save all of them. * Runs through the list of files and save all of them.
* The time taken (in seconds) for adding each file can also be * The time taken (in seconds) for adding each file can also be
* found using {@link gridsim.datagrid.File#getTransactionTime()}. * found using {@link gridsim.datagrid.File#getTransactionTime()}.
* *
* @param list the files to be added * @param list the files to be added
* *
* @return the time taken (in seconds) for adding the specified files * @return the time taken (in seconds) for adding the specified files
*/ */
public double addFile(List<File> list) { @Override
public double addFile(List<File> list) {
double result = 0.0; double result = 0.0;
if (list == null || list.size() == 0) { if (list == null || list.size() == 0) {
Log.printLine(this.getName() + ".addFile(): Warning - list is empty."); Log.printLine(this.getName() + ".addFile(): Warning - list is empty.");
...@@ -142,34 +146,36 @@ public class SanStorage extends HarddriveStorage { ...@@ -142,34 +146,36 @@ public class SanStorage extends HarddriveStorage {
* Removes a file from the storage. * Removes a file from the storage.
* The time taken (in seconds) for deleting the file can also be * The time taken (in seconds) for deleting the file can also be
* found using {@link gridsim.datagrid.File#getTransactionTime()}. * found using {@link gridsim.datagrid.File#getTransactionTime()}.
* *
* @param fileName the name of the file to be removed * @param fileName the name of the file to be removed
* @param file the file which is removed from the storage is returned * @param file the file which is removed from the storage is returned
* through this parameter * through this parameter
* *
* @return the time taken (in seconds) for deleting the specified file * @return the time taken (in seconds) for deleting the specified file
*/ */
public double deleteFile(String fileName, File file) { @Override
public double deleteFile(String fileName, File file) {
return this.deleteFile(file); return this.deleteFile(file);
} }
/** /**
* Removes a file from the storage. * Removes a file from the storage.
* The time taken (in seconds) for deleting the file can also be * The time taken (in seconds) for deleting the file can also be
* found using {@link gridsim.datagrid.File#getTransactionTime()}. * found using {@link gridsim.datagrid.File#getTransactionTime()}.
* *
* @param file the file which is removed from the storage is returned * @param file the file which is removed from the storage is returned
* through this parameter * through this parameter
* *
* @return the time taken (in seconds) for deleting the specified file * @return the time taken (in seconds) for deleting the specified file
*/ */
public double deleteFile(File file) { @Override
public double deleteFile(File file) {
double time=super.deleteFile(file); double time=super.deleteFile(file);
time+=this.networkLatency; time+=this.networkLatency;
time+=file.getSize()*this.bandwidth; time+=file.getSize()*this.bandwidth;
return time; return time;
} }
} }
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
/** /**
* This interface must be implemented by sensors to * This interface must be implemented by sensors to
* specific data center features. * specific data center features.
* @author Rodrigo N. Calheiros *
* @since CloudSim Toolkit 1.0 Beta * @author Rodrigo N. Calheiros
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public interface Sensor<T extends Number> { public interface Sensor<T extends Number> {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2006, The University of Melbourne, Australia and *
* University of Ljubljana, Slovenia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -19,10 +18,9 @@ import java.util.List; ...@@ -19,10 +18,9 @@ import java.util.List;
* required to execute some common operations on the storage, e.g. storing a * required to execute some common operations on the storage, e.g. storing a
* file, getting a file and deleting a file. * file, getting a file and deleting a file.
* *
* @author Uros Cibej and Anthony Sulistio * @author Uros Cibej
* @since CloudSim Toolkit 4.0 * @author Anthony Sulistio
* @see gridsim.datagrid.storage.HarddriveStorage * @since CloudSim Toolkit 1.0
* @see gridsim.datagrid.storage.TapeStorage
*/ */
public interface Storage { public interface Storage {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
/** /**
* The Interface UtilizationModel. * The UtilizationModel interface needs to be implemented in order to
* provide a fine-grained control over resource usage by a Cloudlet.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public interface UtilizationModel { 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);
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
/** /**
* The Class UtilizationModelFull. * The UtilizationModelFull class is a simple model, according to which
* a Cloudlet always utilize all the available CPU capacity.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class UtilizationModelFull implements UtilizationModel { public class UtilizationModelFull implements UtilizationModel {
/* (non-Javadoc) /* (non-Javadoc)
* @see cloudsim.power.UtilizationModel#getUtilization(double) * @see cloudsim.power.UtilizationModel#getUtilization(double)
*/ */
@Override
public double getUtilization(double time) { public double getUtilization(double time) {
return 1; return 1;
} }
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -8,13 +16,17 @@ import java.util.HashMap; ...@@ -8,13 +16,17 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
* The Class UtilizationModelStochastic. * The UtilizationModelStochastic class implements a model, according to which
* a Cloudlet generates random CPU utilization every time frame.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class UtilizationModelStochastic implements UtilizationModel { public class UtilizationModelStochastic implements UtilizationModel {
/** The history. */ /** The history. */
private Map<Double, Double> history; private Map<Double, Double> history;
/** /**
* Instantiates a new utilization model stochastic. * Instantiates a new utilization model stochastic.
*/ */
...@@ -25,11 +37,12 @@ public class UtilizationModelStochastic implements UtilizationModel { ...@@ -25,11 +37,12 @@ public class UtilizationModelStochastic implements UtilizationModel {
/* (non-Javadoc) /* (non-Javadoc)
* @see cloudsim.power.UtilizationModel#getUtilization(double) * @see cloudsim.power.UtilizationModel#getUtilization(double)
*/ */
@Override
public double getUtilization(double time) { public double getUtilization(double time) {
if (getHistory().containsKey(time)) { if (getHistory().containsKey(time)) {
return getHistory().get(time); return getHistory().get(time);
} }
double utilization = Math.random(); double utilization = Math.random();
getHistory().put(time, utilization); getHistory().put(time, utilization);
return utilization; return utilization;
...@@ -37,7 +50,7 @@ public class UtilizationModelStochastic implements UtilizationModel { ...@@ -37,7 +50,7 @@ public class UtilizationModelStochastic implements UtilizationModel {
/** /**
* Gets the history. * Gets the history.
* *
* @return the history * @return the history
*/ */
protected Map<Double, Double> getHistory() { protected Map<Double, Double> getHistory() {
...@@ -46,32 +59,32 @@ public class UtilizationModelStochastic implements UtilizationModel { ...@@ -46,32 +59,32 @@ public class UtilizationModelStochastic implements UtilizationModel {
/** /**
* Sets the history. * Sets the history.
* *
* @param history the history * @param history the history
*/ */
protected void setHistory(Map<Double, Double> history) { protected void setHistory(Map<Double, Double> history) {
this.history = history; this.history = history;
} }
/** /**
* Save history. * Save history.
* *
* @param filename the filename * @param filename the filename
* *
* @throws Exception the exception * @throws Exception the exception
*/ */
public void saveHistory(String filename) throws Exception { public void saveHistory(String filename) throws Exception {
FileOutputStream fos = new FileOutputStream(filename); FileOutputStream fos = new FileOutputStream(filename);
ObjectOutputStream oos = new ObjectOutputStream(fos); ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(getHistory()); oos.writeObject(getHistory());
oos.close(); oos.close();
} }
/** /**
* Load history. * Load history.
* *
* @param filename the filename * @param filename the filename
* *
* @throws Exception the exception * @throws Exception the exception
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -79,7 +92,7 @@ public class UtilizationModelStochastic implements UtilizationModel { ...@@ -79,7 +92,7 @@ public class UtilizationModelStochastic implements UtilizationModel {
FileInputStream fis = new FileInputStream(filename); FileInputStream fis = new FileInputStream(filename);
ObjectInputStream ois = new ObjectInputStream(fis); ObjectInputStream ois = new ObjectInputStream(fis);
setHistory((Map<Double, Double>) ois.readObject()); setHistory((Map<Double, Double>) ois.readObject());
ois.close(); ois.close();
} }
} }
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -18,9 +17,9 @@ import java.util.List; ...@@ -18,9 +17,9 @@ import java.util.List;
* to a policy, defined by the CloudletScheduler. Each VM has a owner, which can * to a policy, defined by the CloudletScheduler. Each VM has a owner, which can
* submit cloudlets to the VM to be executed * submit cloudlets to the VM to be executed
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class Vm { public class Vm {
...@@ -29,7 +28,7 @@ public class Vm { ...@@ -29,7 +28,7 @@ public class Vm {
/** The user id. */ /** The user id. */
private int userId; private int userId;
private String uid; private String uid;
/** The size. */ /** The size. */
...@@ -159,7 +158,7 @@ public class Vm { ...@@ -159,7 +158,7 @@ public class Vm {
break; break;
} }
} }
//if (mipsIsNull && isRecentlyCreated()) { //if (mipsIsNull && isRecentlyCreated()) {
if (mipsIsNull) { if (mipsIsNull) {
currentRequestedMips = new ArrayList<Double>(); currentRequestedMips = new ArrayList<Double>();
...@@ -224,7 +223,7 @@ public class Vm { ...@@ -224,7 +223,7 @@ public class Vm {
public double getTotalUtilizationOfCpuMips(double time) { public double getTotalUtilizationOfCpuMips(double time) {
return getTotalUtilizationOfCpu(time) * getMips(); return getTotalUtilizationOfCpu(time) * getMips();
} }
public void setUid(String uid) { public void setUid(String uid) {
this.uid = uid; this.uid = uid;
} }
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -18,13 +17,9 @@ import java.util.Map; ...@@ -18,13 +17,9 @@ import java.util.Map;
* commit of reservation of hosts: first, we reserve the host and, once * commit of reservation of hosts: first, we reserve the host and, once
* commited by the user, it is effectivelly allocated to he/she * commited by the user, it is effectivelly allocated to he/she
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/
/**
* @author abe
*
*/ */
public abstract class VmAllocationPolicy { public abstract class VmAllocationPolicy {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -21,9 +20,9 @@ import org.cloudbus.cloudsim.core.CloudSim; ...@@ -21,9 +20,9 @@ import org.cloudbus.cloudsim.core.CloudSim;
* chooses, as the host for a VM, the host with * chooses, as the host for a VM, the host with
* less PEs in use. * less PEs in use.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class VmAllocationPolicySimple extends VmAllocationPolicy { public class VmAllocationPolicySimple extends VmAllocationPolicy {
...@@ -263,9 +262,7 @@ public class VmAllocationPolicySimple extends VmAllocationPolicy { ...@@ -263,9 +262,7 @@ public class VmAllocationPolicySimple extends VmAllocationPolicy {
public boolean allocateHostForVm(Vm vm, Host host) { public boolean allocateHostForVm(Vm vm, Host host) {
if (host.vmCreate(vm)) { //if vm has been succesfully created in the host if (host.vmCreate(vm)) { //if vm has been succesfully created in the host
getVmTable().put(vm.getUid(), host); getVmTable().put(vm.getUid(), host);
if (!Log.isDisabled()) { Log.formatLine("%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(), CloudSim.clock());
Log.print(String.format("%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId() + "\n", CloudSim.clock()));
}
return true; return true;
} }
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
...@@ -20,9 +19,9 @@ import org.cloudbus.cloudsim.lists.PeList; ...@@ -20,9 +19,9 @@ import org.cloudbus.cloudsim.lists.PeList;
* policy used by a VMM to share processing power among VMs running * policy used by a VMM to share processing power among VMs running
* in a host. * in a host.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public abstract class VmScheduler { public abstract class VmScheduler {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import java.util.HashMap; import java.util.HashMap;
...@@ -23,9 +21,9 @@ import java.util.Map; ...@@ -23,9 +21,9 @@ import java.util.Map;
* However, if there is free PEs, they are scheduled to the VMs * However, if there is free PEs, they are scheduled to the VMs
* This policy ignores requested number of MIPS. * This policy ignores requested number of MIPS.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class VmSchedulerOportunisticSpaceShared extends VmScheduler { public class VmSchedulerOportunisticSpaceShared extends VmScheduler {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import java.util.HashMap; import java.util.HashMap;
...@@ -22,9 +20,9 @@ import java.util.Vector; ...@@ -22,9 +20,9 @@ import java.util.Vector;
* of PEs. If there is no free PEs to the VM, allocation fails. * of PEs. If there is no free PEs to the VM, allocation fails.
* Free PEs are not allocated to VMs * Free PEs are not allocated to VMs
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class VmSchedulerSpaceShared extends VmScheduler { public class VmSchedulerSpaceShared extends VmScheduler {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -10,7 +18,14 @@ import org.cloudbus.cloudsim.lists.PeList; ...@@ -10,7 +18,14 @@ import org.cloudbus.cloudsim.lists.PeList;
import org.cloudbus.cloudsim.provisioners.PeProvisioner; import org.cloudbus.cloudsim.provisioners.PeProvisioner;
/** /**
* The Class VmSchedulerTimeShared. * VmSchedulerTimeShared is a VMM allocation policy that
* allocates one or more Pe to a VM, and allows sharing
* of PEs by multiple VMs. This class also implements
* 10% performance degration due to VM migration.
*
* @author Rodrigo N. Calheiros
* @author Anton Beloglazov
* @since CloudSim Toolkit 1.0
*/ */
public class VmSchedulerTimeShared extends VmScheduler { public class VmSchedulerTimeShared extends VmScheduler {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import java.util.HashMap; import java.util.HashMap;
...@@ -15,7 +13,6 @@ import java.util.LinkedList; ...@@ -15,7 +13,6 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* VmSchedulerTimeSharedWithPriority is a VMM allocation policy that * VmSchedulerTimeSharedWithPriority is a VMM allocation policy that
* allows sharing of PEs among virtual machines. CPU Share of each VM can be * allows sharing of PEs among virtual machines. CPU Share of each VM can be
...@@ -24,9 +21,8 @@ import java.util.Map; ...@@ -24,9 +21,8 @@ import java.util.Map;
* one machine runs faster than the other. E.g.: if a VM A has priority * one machine runs faster than the other. E.g.: if a VM A has priority
* 1 and a VM B has a priority 2, B will run twice as faster as A. * 1 and a VM B has a priority 2, B will run twice as faster as A.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 Beta * @since CloudSim Toolkit 1.0
* @invariant $none
*/ */
public class VmSchedulerTimeSharedWithPriority extends VmScheduler { public class VmSchedulerTimeSharedWithPriority extends VmScheduler {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* $Id: CloudInformationService.java,v 1.2 2008/09/15 08:34:29 marcosd Exp $ * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.core; package org.cloudbus.cloudsim.core;
...@@ -32,13 +31,9 @@ import org.cloudbus.cloudsim.Log; ...@@ -32,13 +31,9 @@ import org.cloudbus.cloudsim.Log;
* Hence, do not need to worry about creating an object of this class. * Hence, do not need to worry about creating an object of this class.
* <p> * <p>
* *
* @author Manzur Murshed and Rajkumar Buyya * @author Manzur Murshed
* @since CloudSim Toolkit 1.0 * @author Rajkumar Buyya
* @invariant $none * @since CloudSim Toolkit 1.0
* @see CloudSimTags.CloudSimTags
* @see CloudSimShutdown.CloudSimShutdown
* @see gridsim.CloudSim#init(int, Calendar, boolean)
* @see gridsim.CloudResource#startEntity()
*/ */
public class CloudInformationService extends SimEntity { public class CloudInformationService extends SimEntity {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.core; package org.cloudbus.cloudsim.core;
...@@ -32,9 +31,9 @@ import org.cloudbus.cloudsim.core.predicates.PredicateNone; ...@@ -32,9 +31,9 @@ import org.cloudbus.cloudsim.core.predicates.PredicateNone;
* model are added to the messages send through CloudSim. Messages using the old * model are added to the messages send through CloudSim. Messages using the old
* model are converted to the apropriate methods with the correct parameters. * model are converted to the apropriate methods with the correct parameters.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 1.0 * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class CloudSim { public class CloudSim {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* $Id: CloudSimShutdown.java,v 1.1 2008/09/13 03:54:45 marcosd Exp $ * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.core; package org.cloudbus.cloudsim.core;
...@@ -22,14 +21,13 @@ import java.util.Calendar; ...@@ -22,14 +21,13 @@ import java.util.Calendar;
* This object signals the end of simulation to CloudInformationService (GIS) * This object signals the end of simulation to CloudInformationService (GIS)
* entity. * entity.
* *
* @author Manzur Murshed and Rajkumar Buyya * @author Manzur Murshed
* @since CloudSim Toolkit 1.0 * @author Rajkumar Buyya
* @invariant $none * @since CloudSim Toolkit 1.0
*
* @see gridsim.CloudSim#init(int, Calendar, boolean)
*/ */
public class CloudSimShutdown extends SimEntity public class CloudSimShutdown extends SimEntity {
{
/** The num user. */
private int numUser; private int numUser;
/** /**
...@@ -68,11 +66,13 @@ public class CloudSimShutdown extends SimEntity ...@@ -68,11 +66,13 @@ public class CloudSimShutdown extends SimEntity
* the Constructor. * the Constructor.
* <br> * <br>
* <b>NOTE:</b> This method shuts down grid hostList and GIS entities * <b>NOTE:</b> This method shuts down grid hostList and GIS entities
* either <tt>AFTER</tt> all grid users have been shut down or * either <tt>AFTER</tt> all grid users have been shut down or
* an entity requires an abrupt end of the whole simulation. * an entity requires an abrupt end of the whole simulation.
* In the first case, the number of grid users given in the * In the first case, the number of grid users given in the
* Constructor <tt>must</tt> be correct. Otherwise, CloudSim * Constructor <tt>must</tt> be correct. Otherwise, CloudSim
* package hangs forever or it does not terminate properly. * package hangs forever or it does not terminate properly.
*
* @param ev the ev
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
...@@ -84,16 +84,20 @@ public class CloudSimShutdown extends SimEntity ...@@ -84,16 +84,20 @@ public class CloudSimShutdown extends SimEntity
} }
} }
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.core.SimEntity#startEntity()
*/
@Override @Override
public void startEntity() { public void startEntity() {
// do nothing // do nothing
} }
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.core.SimEntity#shutdownEntity()
*/
@Override @Override
public void shutdownEntity() { public void shutdownEntity() {
// do nothing // do nothing
} }
/////////////////////// PRIVATE METHODS ////////////////////////// }
} // end class
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2002, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.core; package org.cloudbus.cloudsim.core;
...@@ -16,13 +15,12 @@ package org.cloudbus.cloudsim.core; ...@@ -16,13 +15,12 @@ package org.cloudbus.cloudsim.core;
* <b>NOTE:</b> To avoid conflicts with other tags, CloudSim reserves negative * <b>NOTE:</b> To avoid conflicts with other tags, CloudSim reserves negative
* numbers, 0 - 299, and 9600. * numbers, 0 - 299, and 9600.
* *
* @author Manzur Murshed and Rajkumar Buyya * @author Manzur Murshed
* @author Anthony Sulistio * @author Rajkumar Buyya
* @since CloudSim Toolkit 1.0 * @author Anthony Sulistio
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public final class CloudSimTags public final class CloudSimTags {
{
// starting constant value for cloud-related tags // starting constant value for cloud-related tags
private static final int BASE = 0; private static final int BASE = 0;
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.core; package org.cloudbus.cloudsim.core;
import java.util.Iterator; import java.util.Iterator;
...@@ -9,9 +17,11 @@ import java.util.ListIterator; ...@@ -9,9 +17,11 @@ import java.util.ListIterator;
* This class implements the deferred event queue used by {@link Simulation}. * This class implements the deferred event queue used by {@link Simulation}.
* The event queue uses a linked list to store the events. * The event queue uses a linked list to store the events.
* *
* @see Simulation * @author Marcos Dias de Assuncao
* @see SimEvent * @since CloudSim Toolkit 1.0
* @author Marcos Dias de Assuncao *
* @see Simulation
* @see SimEvent
*/ */
public class DeferredQueue { public class DeferredQueue {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.core; package org.cloudbus.cloudsim.core;
import java.util.Collection; import java.util.Collection;
...@@ -9,9 +17,11 @@ import java.util.TreeSet; ...@@ -9,9 +17,11 @@ import java.util.TreeSet;
* This class implements the future event queue used by {@link Simulation}. * This class implements the future event queue used by {@link Simulation}.
* The event queue uses a {@link TreeSet} in order to store the events. * The event queue uses a {@link TreeSet} in order to store the events.
* *
* @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
*
* @see Simulation * @see Simulation
* @see java.util.TreeSet * @see java.util.TreeSet
* @author Marcos Dias de Assuncao
*/ */
public class FutureQueue { public class FutureQueue {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.core; package org.cloudbus.cloudsim.core;
import org.cloudbus.cloudsim.Log; import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.NetworkTopology; import org.cloudbus.cloudsim.NetworkTopology;
import org.cloudbus.cloudsim.core.predicates.Predicate; import org.cloudbus.cloudsim.core.predicates.Predicate;
/** /**
* This class represents a simulation entity. An entity handles events and can * This class represents a simulation entity. An entity handles events and can
* send events to other entities. When this class is extended, there are a few * send events to other entities. When this class is extended, there are a few
...@@ -21,7 +28,8 @@ import org.cloudbus.cloudsim.core.predicates.Predicate; ...@@ -21,7 +28,8 @@ import org.cloudbus.cloudsim.core.predicates.Predicate;
* in which the corresponding code would be placed. * in which the corresponding code would be placed.
* </ul> * </ul>
* *
* @author Marcos Dias de Assuncao * @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
*/ */
public abstract class SimEntity implements Cloneable { public abstract class SimEntity implements Cloneable {
......
/* Sim_event.java */ /*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.core; package org.cloudbus.cloudsim.core;
/** /**
* This class represents a simulation event which is passed between * This class represents a simulation event which is passed between
* the entities in the simulation. * the entities in the simulation.
* *
* @see Simulation * @author Costas Simatos
* @see SimEntity *
* @see Simulation
* @author Costas Simatos * @see SimEntity
*/ */
public class SimEvent implements Cloneable, Comparable<SimEvent> { public class SimEvent implements Cloneable, Comparable<SimEvent> {
private final int etype; // internal event type private final int etype; // internal event type
...@@ -89,6 +94,7 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> { ...@@ -89,6 +94,7 @@ public class SimEvent implements Cloneable, Comparable<SimEvent> {
/** /**
* @see Comparable#compareTo(Object) * @see Comparable#compareTo(Object)
*/ */
@Override
public int compareTo(SimEvent event) { public int compareTo(SimEvent event) {
if (event == null) { if (event == null) {
return 1; return 1;
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.core.predicates; package org.cloudbus.cloudsim.core.predicates;
import org.cloudbus.cloudsim.core.SimEvent; import org.cloudbus.cloudsim.core.SimEvent;
...@@ -8,12 +16,14 @@ import org.cloudbus.cloudsim.core.SimEvent; ...@@ -8,12 +16,14 @@ import org.cloudbus.cloudsim.core.SimEvent;
* predicate. Some standard predicates are provided.<br> * predicate. Some standard predicates are provided.<br>
* The idea of simulation predicates was copied from SimJava 2. * The idea of simulation predicates was copied from SimJava 2.
* *
* @see PredicateType * @author Marcos Dias de Assuncao
* @see PredicateFrom * @since CloudSim Toolkit 1.0
* @see PredicateAny *
* @see PredicateNone * @see PredicateType
* @see Simulation * @see PredicateFrom
* @author Marcos Dias de Assuncao * @see PredicateAny
* @see PredicateNone
* @see Simulation
*/ */
public abstract class Predicate { public abstract class Predicate {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.core.predicates; package org.cloudbus.cloudsim.core.predicates;
import org.cloudbus.cloudsim.core.SimEvent; import org.cloudbus.cloudsim.core.SimEvent;
...@@ -9,11 +17,12 @@ import org.cloudbus.cloudsim.core.SimEvent; ...@@ -9,11 +17,12 @@ import org.cloudbus.cloudsim.core.SimEvent;
* no new instances need to be created. <br> * no new instances need to be created. <br>
* The idea of simulation predicates was copied from SimJava 2. * The idea of simulation predicates was copied from SimJava 2.
* *
* @see Predicate * @author Marcos Dias de Assuncao
* @see Simulation * @since CloudSim Toolkit 1.0
* @author Marcos Dias de Assuncao *
* @see Predicate
* @see Simulation
*/ */
public class PredicateAny extends Predicate { public class PredicateAny extends Predicate {
/** /**
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.core.predicates; package org.cloudbus.cloudsim.core.predicates;
import org.cloudbus.cloudsim.core.SimEvent; import org.cloudbus.cloudsim.core.SimEvent;
...@@ -6,11 +14,12 @@ import org.cloudbus.cloudsim.core.SimEvent; ...@@ -6,11 +14,12 @@ import org.cloudbus.cloudsim.core.SimEvent;
* A predicate which selects events from specific entities.<br> * A predicate which selects events from specific entities.<br>
* The idea of simulation predicates was copied from SimJava 2. * The idea of simulation predicates was copied from SimJava 2.
* *
* @see PredicateNotFrom * @author Marcos Dias de Assuncao
* @see Predicate * @since CloudSim Toolkit 1.0
* @author Marcos Dias de Assuncao *
* @see PredicateNotFrom
* @see Predicate
*/ */
public class PredicateFrom extends Predicate { public class PredicateFrom extends Predicate {
/** The ids. */ /** The ids. */
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.core.predicates; package org.cloudbus.cloudsim.core.predicates;
import org.cloudbus.cloudsim.core.SimEvent; import org.cloudbus.cloudsim.core.SimEvent;
...@@ -9,11 +17,12 @@ import org.cloudbus.cloudsim.core.SimEvent; ...@@ -9,11 +17,12 @@ import org.cloudbus.cloudsim.core.SimEvent;
* so the user does not need to create any new instances. * so the user does not need to create any new instances.
* The idea of simulation predicates was copied from SimJava 2. * The idea of simulation predicates was copied from SimJava 2.
* *
* @see Predicate * @author Marcos Dias de Assuncao
* @see Simulation * @since CloudSim Toolkit 1.0
* @author Marcos Dias de Assuncao *
* @see Predicate
* @see Simulation
*/ */
public class PredicateNone extends Predicate { public class PredicateNone extends Predicate {
/** /**
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.core.predicates; package org.cloudbus.cloudsim.core.predicates;
import org.cloudbus.cloudsim.core.SimEvent; import org.cloudbus.cloudsim.core.SimEvent;
...@@ -5,11 +13,12 @@ import org.cloudbus.cloudsim.core.SimEvent; ...@@ -5,11 +13,12 @@ import org.cloudbus.cloudsim.core.SimEvent;
/** /**
* A predicate which selects events that have not been sent by specific entities. * A predicate which selects events that have not been sent by specific entities.
* *
* @see PredicateFrom * @author Marcos Dias de Assuncao
* @see Predicate * @since CloudSim Toolkit 1.0
* @author Marcos Dias de Assuncao *
* @see PredicateFrom
* @see Predicate
*/ */
public class PredicateNotFrom extends Predicate { public class PredicateNotFrom extends Predicate {
/** The ids. */ /** The ids. */
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.core.predicates; package org.cloudbus.cloudsim.core.predicates;
import org.cloudbus.cloudsim.core.SimEvent; import org.cloudbus.cloudsim.core.SimEvent;
...@@ -5,11 +13,12 @@ import org.cloudbus.cloudsim.core.SimEvent; ...@@ -5,11 +13,12 @@ import org.cloudbus.cloudsim.core.SimEvent;
/** /**
* A predicate to select events that don't match specific tags. * A predicate to select events that don't match specific tags.
* *
* @see PredicateType * @author Marcos Dias de Assuncao
* @see Predicate * @since CloudSim Toolkit 1.0
* @author Marcos Dias de Assuncao *
* @see PredicateType
* @see Predicate
*/ */
public class PredicateNotType extends Predicate { public class PredicateNotType extends Predicate {
/** The tags. */ /** The tags. */
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.core.predicates; package org.cloudbus.cloudsim.core.predicates;
import org.cloudbus.cloudsim.core.SimEvent; import org.cloudbus.cloudsim.core.SimEvent;
...@@ -5,11 +13,12 @@ import org.cloudbus.cloudsim.core.SimEvent; ...@@ -5,11 +13,12 @@ import org.cloudbus.cloudsim.core.SimEvent;
/** /**
* A predicate to select events with specific tags. * A predicate to select events with specific tags.
* *
* @see PredicateNotType * @author Marcos Dias de Assuncao
* @see Predicate * @since CloudSim Toolkit 1.0
* @author Marcos Dias de Assuncao *
* @see PredicateNotType
* @see Predicate
*/ */
public class PredicateType extends Predicate { public class PredicateType extends Predicate {
/** The tags. */ /** The tags. */
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.distributions; package org.cloudbus.cloudsim.distributions;
/** /**
* Interface to be implemented by a random number generator. * Interface to be implemented by a random number generator.
* *
* @author Marcos Dias de Assuncao * @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
*/ */
public interface ContinuousDistribution { public interface ContinuousDistribution {
/** /**
* Sample the random number generator. * Sample the random number generator.
* @return The sample * @return The sample
*/ */
double sample(); double sample();
} }
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.distributions; package org.cloudbus.cloudsim.distributions;
import java.util.Random; import java.util.Random;
...@@ -5,7 +13,8 @@ import java.util.Random; ...@@ -5,7 +13,8 @@ import java.util.Random;
/** /**
* An exponential number generator. * An exponential number generator.
* *
* @author Marcos Dias de Assuncao * @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
*/ */
public class ExponentialDistr implements ContinuousDistribution { public class ExponentialDistr implements ContinuousDistribution {
...@@ -47,6 +56,7 @@ public class ExponentialDistr implements ContinuousDistribution { ...@@ -47,6 +56,7 @@ public class ExponentialDistr implements ContinuousDistribution {
* *
* @return the next random number in the sequence * @return the next random number in the sequence
*/ */
@Override
public double sample() { public double sample() {
return -mean * Math.log(numGen.nextDouble()); return -mean * Math.log(numGen.nextDouble());
} }
......
/*
* Title: CloudSim Toolkit
* Descripimport java.util.Random;
mulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.distributions; package org.cloudbus.cloudsim.distributions;
import java.util.Random; import java.util.Random;
/** /**
* The Class GammaDistr. * The Class GammaDistr.
*
* @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
*/ */
public class GammaDistr implements ContinuousDistribution { public class GammaDistr implements ContinuousDistribution {
...@@ -56,6 +68,7 @@ public class GammaDistr implements ContinuousDistribution { ...@@ -56,6 +68,7 @@ public class GammaDistr implements ContinuousDistribution {
/* (non-Javadoc) /* (non-Javadoc)
* @see cloudsim.distributions.ContinuousDistribution#sample() * @see cloudsim.distributions.ContinuousDistribution#sample()
*/ */
@Override
public double sample() { public double sample() {
double sum=0.0; double sum=0.0;
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.distributions; package org.cloudbus.cloudsim.distributions;
import java.util.Random; import java.util.Random;
/** /**
* The Class LognormalDistr. * The Class LognormalDistr.
*
* @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
*/ */
public class LognormalDistr implements ContinuousDistribution { public class LognormalDistr implements ContinuousDistribution {
...@@ -56,6 +67,7 @@ public class LognormalDistr implements ContinuousDistribution { ...@@ -56,6 +67,7 @@ public class LognormalDistr implements ContinuousDistribution {
/* (non-Javadoc) /* (non-Javadoc)
* @see cloudsim.distributions.ContinuousDistribution#sample() * @see cloudsim.distributions.ContinuousDistribution#sample()
*/ */
@Override
public double sample() { public double sample() {
//generate a normal variate from a uniform variate //generate a normal variate from a uniform variate
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.distributions; package org.cloudbus.cloudsim.distributions;
import java.util.Random; import java.util.Random;
/** /**
* The Class LomaxDistribution. * The Class LomaxDistribution.
*
* @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
*/ */
public class LomaxDistribution extends ParetoDistr implements ContinuousDistribution { public class LomaxDistribution extends ParetoDistr implements ContinuousDistribution {
......
/*
* Title: CloudSim Toolkit
* Descripimport java.util.Random;
mulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.distributions; package org.cloudbus.cloudsim.distributions;
import java.util.Random; import java.util.Random;
/** /**
* The Class ParetoDistr. * The Class ParetoDistr.
*
* @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
*/ */
public class ParetoDistr implements ContinuousDistribution { public class ParetoDistr implements ContinuousDistribution {
...@@ -56,6 +68,7 @@ public class ParetoDistr implements ContinuousDistribution { ...@@ -56,6 +68,7 @@ public class ParetoDistr implements ContinuousDistribution {
/* (non-Javadoc) /* (non-Javadoc)
* @see cloudsim.distributions.ContinuousDistribution#sample() * @see cloudsim.distributions.ContinuousDistribution#sample()
*/ */
@Override
public double sample() { public double sample() {
return location/Math.pow(numGen.nextDouble(),1/shape); return location/Math.pow(numGen.nextDouble(),1/shape);
} }
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.distributions; package org.cloudbus.cloudsim.distributions;
import java.util.Random; import java.util.Random;
...@@ -5,7 +13,8 @@ import java.util.Random; ...@@ -5,7 +13,8 @@ import java.util.Random;
/** /**
* A random number generator based on the Uniform distribution. * A random number generator based on the Uniform distribution.
* *
* @author Marcos Dias de Assuncao * @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
*/ */
public class UniformDistr implements ContinuousDistribution { public class UniformDistr implements ContinuousDistribution {
...@@ -52,6 +61,7 @@ public class UniformDistr implements ContinuousDistribution { ...@@ -52,6 +61,7 @@ public class UniformDistr implements ContinuousDistribution {
* *
* @return the next random number in the sequence * @return the next random number in the sequence
*/ */
@Override
public double sample() { public double sample() {
return (numGen.nextDouble() * (mag)) + min; return (numGen.nextDouble() * (mag)) + min;
} }
......
/*
* Title: CloudSim Toolkit
* Descripimport java.util.Random;
mulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.distributions; package org.cloudbus.cloudsim.distributions;
import java.util.Random; import java.util.Random;
/** /**
* The Class WeibullDistr. * The Class WeibullDistr.
*
* @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
*/ */
public class WeibullDistr implements ContinuousDistribution { public class WeibullDistr implements ContinuousDistribution {
...@@ -56,6 +68,7 @@ public class WeibullDistr implements ContinuousDistribution { ...@@ -56,6 +68,7 @@ public class WeibullDistr implements ContinuousDistribution {
/* (non-Javadoc) /* (non-Javadoc)
* @see cloudsim.distributions.ContinuousDistribution#sample() * @see cloudsim.distributions.ContinuousDistribution#sample()
*/ */
@Override
public double sample() { public double sample() {
return beta*Math.pow(-Math.log(numGen.nextDouble()),1/alpha); return beta*Math.pow(-Math.log(numGen.nextDouble()),1/alpha);
} }
......
/*
* Title: CloudSim Toolkit
* Descripimport java.util.Random;
mulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.distributions; package org.cloudbus.cloudsim.distributions;
import java.util.Random; import java.util.Random;
/** /**
* The Class ZipfDistr. * The Class ZipfDistr.
*
* @author Marcos Dias de Assuncao
* @since CloudSim Toolkit 1.0
*/ */
public class ZipfDistr implements ContinuousDistribution { public class ZipfDistr implements ContinuousDistribution {
...@@ -53,6 +65,7 @@ public class ZipfDistr implements ContinuousDistribution { ...@@ -53,6 +65,7 @@ public class ZipfDistr implements ContinuousDistribution {
* *
* @return the next random number in the sequence * @return the next random number in the sequence
*/ */
@Override
public double sample() { public double sample() {
double variate = numGen.nextDouble(); double variate = numGen.nextDouble();
double num=1; double num=1;
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.lists; package org.cloudbus.cloudsim.lists;
...@@ -16,14 +15,13 @@ import java.util.List; ...@@ -16,14 +15,13 @@ import java.util.List;
import org.cloudbus.cloudsim.Cloudlet; import org.cloudbus.cloudsim.Cloudlet;
/** /**
* CloudletList is a link to store Cloudlets. * CloudletList is a collection of operations on lists of Cloudlets.
* *
* @author Rodrigo N. Calheiros * @author Anton Beloglazov
* @since CloudSim Toolkit 1.0 Beta * @since CloudSim Toolkit 2.0
* @invariant $none
*/ */
public class CloudletList { public class CloudletList {
/** /**
* Gets the by id. * Gets the by id.
* *
...@@ -70,7 +68,8 @@ public class CloudletList { ...@@ -70,7 +68,8 @@ public class CloudletList {
* @pre b != null * @pre b != null
* @post $none * @post $none
*/ */
public int compare(T a, T b) throws ClassCastException { @Override
public int compare(T a, T b) throws ClassCastException {
Double cla = Double.valueOf(a.getCloudletTotalLength()); Double cla = Double.valueOf(a.getCloudletTotalLength());
Double clb = Double.valueOf(b.getCloudletTotalLength()); Double clb = Double.valueOf(b.getCloudletTotalLength());
return cla.compareTo(clb); return cla.compareTo(clb);
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2002, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.lists; package org.cloudbus.cloudsim.lists;
...@@ -15,14 +14,10 @@ import org.cloudbus.cloudsim.Host; ...@@ -15,14 +14,10 @@ import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Pe; import org.cloudbus.cloudsim.Pe;
/** /**
* CloudSim HostList simulates a collection of machines. It is up to the * HostList is a collection of operations on lists of hosts.
* CloudSim users to define the connectivity among the machines in a collection.
* Therefore, this class can be instantiated to model a simple LAN to cluster
* to WAN.
* *
* @author Manzur Murshed and Rajkumar Buyya * @author Anton Beloglazov
* @since CloudSim Toolkit 1.0 * @since CloudSim Toolkit 2.0
* @invariant $none
*/ */
public class HostList { public class HostList {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2002, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.lists; package org.cloudbus.cloudsim.lists;
...@@ -16,23 +15,21 @@ import org.cloudbus.cloudsim.Pe; ...@@ -16,23 +15,21 @@ import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Vm; import org.cloudbus.cloudsim.Vm;
/** /**
* CloudSim PeList maintains a list of PEs (Processing Elements) that make up * PeList is a collection of operations on lists of PEs.
* a machine. *
* * @author Anton Beloglazov
* @author Manzur Murshed and Rajkumar Buyya * @since CloudSim Toolkit 2.0
* @since CloudSim Toolkit 1.0
* @invariant $none
*/ */
public class PeList { public class PeList {
/** /**
* Gets MIPS Rating for a specified Pe ID. * Gets MIPS Rating for a specified Pe ID.
* *
* @param id the Pe ID * @param id the Pe ID
* @param peList the pe list * @param peList the pe list
* *
* @return the MIPS rating if exists, otherwise returns -1 * @return the MIPS rating if exists, otherwise returns -1
* *
* @pre id >= 0 * @pre id >= 0
* @post $none * @post $none
*/ */
...@@ -44,15 +41,15 @@ public class PeList { ...@@ -44,15 +41,15 @@ public class PeList {
} }
return null; return null;
} }
/** /**
* Gets MIPS Rating for a specified Pe ID. * Gets MIPS Rating for a specified Pe ID.
* *
* @param id the Pe ID * @param id the Pe ID
* @param peList the pe list * @param peList the pe list
* *
* @return the MIPS rating if exists, otherwise returns -1 * @return the MIPS rating if exists, otherwise returns -1
* *
* @pre id >= 0 * @pre id >= 0
* @post $none * @post $none
*/ */
...@@ -63,31 +60,31 @@ public class PeList { ...@@ -63,31 +60,31 @@ public class PeList {
} }
return -1; return -1;
} }
/** /**
* Gets total MIPS Rating for all PEs. * Gets total MIPS Rating for all PEs.
* *
* @param peList the pe list * @param peList the pe list
* *
* @return the total MIPS Rating * @return the total MIPS Rating
* *
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
public static <T extends Pe> int getTotalMips(List<Pe> peList) { public static <T extends Pe> int getTotalMips(List<Pe> peList) {
int totalMips = 0; int totalMips = 0;
for (Pe pe : peList) { for (Pe pe : peList) {
totalMips += pe.getMips(); totalMips += pe.getMips();
} }
return totalMips; return totalMips;
} }
/** /**
* Gets the max utilization among by all PEs. * Gets the max utilization among by all PEs.
* *
* @param peList the pe list * @param peList the pe list
* *
* @return the utilization * @return the utilization
*/ */
public static <T extends Pe> double getMaxUtilization(List<Pe> peList) { public static <T extends Pe> double getMaxUtilization(List<Pe> peList) {
...@@ -96,18 +93,18 @@ public class PeList { ...@@ -96,18 +93,18 @@ public class PeList {
double utilization = pe.getPeProvisioner().getUtilization(); double utilization = pe.getPeProvisioner().getUtilization();
if (utilization > maxUtilization) { if (utilization > maxUtilization) {
maxUtilization = utilization; maxUtilization = utilization;
} }
} }
return maxUtilization; return maxUtilization;
} }
/** /**
* 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
* @param peList the pe list * @param peList the pe list
* *
* @return the utilization * @return the utilization
*/ */
public static <T extends Pe> double getMaxUtilizationAmongVmsPes(List<Pe> peList, Vm vm) { public static <T extends Pe> double getMaxUtilizationAmongVmsPes(List<Pe> peList, Vm vm) {
...@@ -119,18 +116,18 @@ public class PeList { ...@@ -119,18 +116,18 @@ public class PeList {
double utilization = pe.getPeProvisioner().getUtilization(); double utilization = pe.getPeProvisioner().getUtilization();
if (utilization > maxUtilization) { if (utilization > maxUtilization) {
maxUtilization = utilization; maxUtilization = utilization;
} }
} }
return maxUtilization; return maxUtilization;
} }
/** /**
* Gets a Pe ID which is FREE. * Gets a Pe ID which is FREE.
* *
* @param peList the pe list * @param peList the pe list
* *
* @return a Pe ID if it is FREE, otherwise returns -1 * @return a Pe ID if it is FREE, otherwise returns -1
* *
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
...@@ -145,11 +142,11 @@ public class PeList { ...@@ -145,11 +142,11 @@ public class PeList {
/** /**
* Gets the number of <tt>FREE</tt> or non-busy Pe. * Gets the number of <tt>FREE</tt> or non-busy Pe.
* *
* @param peList the pe list * @param peList the pe list
* *
* @return number of Pe * @return number of Pe
* *
* @pre $none * @pre $none
* @post $result >= 0 * @post $result >= 0
*/ */
...@@ -165,14 +162,14 @@ public class PeList { ...@@ -165,14 +162,14 @@ public class PeList {
/** /**
* Sets the Pe status. * Sets the Pe status.
* *
* @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 id the id * @param id the id
* @param peList the pe list * @param peList the pe list
* *
* @return <tt>true</tt> if the Pe status has been changed, <tt>false</tt> * @return <tt>true</tt> if the Pe status has been changed, <tt>false</tt>
* otherwise (Pe id might not be exist) * otherwise (Pe id might not be exist)
* *
* @pre peID >= 0 * @pre peID >= 0
* @post $none * @post $none
*/ */
...@@ -187,11 +184,11 @@ public class PeList { ...@@ -187,11 +184,11 @@ public class PeList {
/** /**
* Gets the number of <tt>BUSY</tt> Pe. * Gets the number of <tt>BUSY</tt> Pe.
* *
* @param peList the pe list * @param peList the pe list
* *
* @return number of Pe * @return number of Pe
* *
* @pre $none * @pre $none
* @post $result >= 0 * @post $result >= 0
*/ */
...@@ -207,14 +204,14 @@ public class PeList { ...@@ -207,14 +204,14 @@ public class PeList {
/** /**
* Gets the byte size of PeList internal data members. * Gets the byte size of PeList internal data members.
* *
* @param peList the pe list * @param peList the pe list
* @param resName the res name * @param resName the res name
* @param hostId the host id * @param hostId the host id
* @param failed the failed * @param failed the failed
* *
* @return the byte size * @return the byte size
* *
* @pre $none * @pre $none
* @post $result >= 0 * @post $result >= 0
*/ */
...@@ -229,7 +226,7 @@ public class PeList { ...@@ -229,7 +226,7 @@ public class PeList {
* purposes, which is <b>ON</b> by default. * purposes, which is <b>ON</b> by default.
* Use {@link #setStatusFailed(boolean)} if you do not want * Use {@link #setStatusFailed(boolean)} if you do not want
* this information. * this information.
* *
* @param resName the name of the resource * @param resName the name of the resource
* @param hostId the id of this machine * @param hostId the id of this machine
* @param failed the new value for the "failed" parameter * @param failed the new value for the "failed" parameter
...@@ -249,7 +246,7 @@ public class PeList { ...@@ -249,7 +246,7 @@ public class PeList {
/** /**
* Sets the status of PEs of this machine to FAILED. * Sets the status of PEs of this machine to FAILED.
* *
* @param failed the new value for the "failed" parameter * @param failed the new value for the "failed" parameter
* @param peList the pe list * @param peList the pe list
*/ */
...@@ -260,8 +257,8 @@ public class PeList { ...@@ -260,8 +257,8 @@ public class PeList {
pe.setStatus(Pe.FAILED); pe.setStatus(Pe.FAILED);
} else { } else {
pe.setStatus(Pe.FREE); pe.setStatus(Pe.FREE);
} }
} }
} }
} }
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2002, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.lists; package org.cloudbus.cloudsim.lists;
...@@ -14,11 +13,10 @@ import java.util.List; ...@@ -14,11 +13,10 @@ import java.util.List;
import org.cloudbus.cloudsim.ResCloudlet; import org.cloudbus.cloudsim.ResCloudlet;
/** /**
* CloudSim ResCloudletList maintains a linked-list of Cloudlet. * ResCloudletList is a collection of operations on lists of ResCloudlets.
* *
* @author Manzur Murshed and Rajkumar Buyya * @author Anton Beloglazov
* @since CloudSim Toolkit 1.0 * @since CloudSim Toolkit 2.0
* @invariant $none
*/ */
public class ResCloudletList { public class ResCloudletList {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2009, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.lists; package org.cloudbus.cloudsim.lists;
...@@ -14,22 +13,21 @@ import java.util.List; ...@@ -14,22 +13,21 @@ import java.util.List;
import org.cloudbus.cloudsim.Vm; import org.cloudbus.cloudsim.Vm;
/** /**
* VmList is a list to store virtual machines. * VmList is a collection of operations on lists of VMs.
* *
* @author Rodrigo N. Calheiros * @author Anton Beloglazov
* @since CloudSim Toolkit 1.0 Beta * @since CloudSim Toolkit 2.0
* @invariant $none
*/ */
public class VmList { public class VmList {
/** /**
* Return a reference to a Vm object from its ID. * Return a reference to a Vm object from its ID.
* *
* @param id ID of required VM * @param id ID of required VM
* @param vmList the vm list * @param vmList the vm list
* *
* @return Vm with the given ID, $null if not found * @return Vm with the given ID, $null if not found
* *
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
...@@ -44,13 +42,13 @@ public class VmList { ...@@ -44,13 +42,13 @@ public class VmList {
/** /**
* Return a reference to a Vm object from its ID and user ID. * Return a reference to a Vm object from its ID and user ID.
* *
* @param id ID of required VM * @param id ID of required VM
* @param userId the user ID * @param userId the user ID
* @param vmList the vm list * @param vmList the vm list
* *
* @return Vm with the given ID, $null if not found * @return Vm with the given ID, $null if not found
* *
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.network; package org.cloudbus.cloudsim.network;
import java.util.Iterator; import java.util.Iterator;
/** /**
* this class represents an delay-topology * This class represents an delay-topology
* storing every distance between connected nodes * storing every distance between connected nodes
* *
* @author Thomas Hohnstein * @author Thomas Hohnstein
* * @since CloudSim Toolkit 1.0
*/ */
public class DelayMatrix_Float { public class DelayMatrix_Float {
......
/* /*
* @(#)FloydWarshall.java ver 1.2 6/20/2005 * @(#)FloydWarshall.java ver 1.2 6/20/2005
* *
* Modified by Weishuai Yang (wyang@cs.binghamton.edu). * Modified by Weishuai Yang (wyang@cs.binghamton.edu).
* Originally written by Rahul Simha * Originally written by Rahul Simha
* *
*/ */
package org.cloudbus.cloudsim.network; package org.cloudbus.cloudsim.network;
/** /**
* FloydWarshall algorithm to calculate all pairs delay and predecessor matrix. * FloydWarshall algorithm to calculate all pairs delay and predecessor matrix.
* *
* Modified by Weishuai Yang * @author Rahul Simha
* Originally written by Rahul Simha * @author Weishuai Yang
* @version 1.2, 6/20/2005 * @version 1.2, 6/20/2005
* @since CloudSim Toolkit 1.0
*/ */
public class FloydWarshall_Float { public class FloydWarshall_Float {
/** /**
* Number of vertices (when initialized) * Number of vertices (when initialized)
*/ */
private int numVertices; private int numVertices;
// /** // /**
// * The adjacency matrix (given as input), // * The adjacency matrix (given as input),
// * here I use float rather than double to save memory, // * here I use float rather than double to save memory,
// * since there won't be a lot of spilting for delay, // * since there won't be a lot of spilting for delay,
// * and float is accurate enough. // * and float is accurate enough.
// */ // */
// private float[][] adjMatrix; // private float[][] adjMatrix;
/** /**
* Matrices used in dynamic programming * Matrices used in dynamic programming
*/ */
private float[][] Dk, Dk_minus_one; private float[][] Dk, Dk_minus_one;
/** /**
* Matrices used in dynamic programming * Matrices used in dynamic programming
*/ */
private int[][] Pk, Pk_minus_one; private int[][] Pk, Pk_minus_one;
/** /**
* initialization matrix * initialization matrix
...@@ -55,7 +54,7 @@ public class FloydWarshall_Float { ...@@ -55,7 +54,7 @@ public class FloydWarshall_Float {
Dk[i] = new float [numVertices]; Dk[i] = new float [numVertices];
Dk_minus_one[i] = new float [numVertices]; Dk_minus_one[i] = new float [numVertices];
} }
// Initialize Pk matrices. // Initialize Pk matrices.
Pk = new int [numVertices][]; Pk = new int [numVertices][];
Pk_minus_one = new int [numVertices][]; Pk_minus_one = new int [numVertices][];
...@@ -63,7 +62,7 @@ public class FloydWarshall_Float { ...@@ -63,7 +62,7 @@ public class FloydWarshall_Float {
Pk[i] = new int [numVertices]; Pk[i] = new int [numVertices];
Pk_minus_one[i] = new int [numVertices]; Pk_minus_one[i] = new int [numVertices];
} }
} }
/** /**
...@@ -88,7 +87,7 @@ public class FloydWarshall_Float { ...@@ -88,7 +87,7 @@ public class FloydWarshall_Float {
// this to avoid a comparison. // this to avoid a comparison.
} }
} }
// Now iterate over k. // Now iterate over k.
for (int k=0; k<numVertices; k++) { for (int k=0; k<numVertices; k++) {
...@@ -108,9 +107,9 @@ public class FloydWarshall_Float { ...@@ -108,9 +107,9 @@ public class FloydWarshall_Float {
Dk[i][j] = Dk_minus_one[i][k] + Dk_minus_one[k][j]; Dk[i][j] = Dk_minus_one[i][k] + Dk_minus_one[k][j];
Pk[i][j] = Pk_minus_one[k][j]; Pk[i][j] = Pk_minus_one[k][j];
} }
} } else {
else Pk[i][j] = -1;
Pk[i][j] = -1; }
} }
} }
...@@ -142,7 +141,7 @@ public class FloydWarshall_Float { ...@@ -142,7 +141,7 @@ public class FloydWarshall_Float {
public static void main (String[] argv) public static void main (String[] argv)
{ {
// A test case. // A test case.
* *
double[][] adjMatrix = { double[][] adjMatrix = {
{0, 1, 0, 0, 1}, {0, 1, 0, 0, 1},
{1, 0, 1, 3, 0}, {1, 0, 1, 3, 0},
...@@ -156,7 +155,7 @@ public class FloydWarshall_Float { ...@@ -156,7 +155,7 @@ public class FloydWarshall_Float {
FloydWarshall fwAlg = new FloydWarshall (); FloydWarshall fwAlg = new FloydWarshall ();
fwAlg.initialize (n); fwAlg.initialize (n);
adjMatrix=fwAlg.allPairsShortestPaths (adjMatrix); adjMatrix=fwAlg.allPairsShortestPaths (adjMatrix);
//debug begin //debug begin
StringBuffer s0=new StringBuffer("Delay Information before floydwarshall:\n"); StringBuffer s0=new StringBuffer("Delay Information before floydwarshall:\n");
for(int i=0;i<n;i++){ for(int i=0;i<n;i++){
...@@ -168,15 +167,15 @@ public class FloydWarshall_Float { ...@@ -168,15 +167,15 @@ public class FloydWarshall_Float {
s0.append("\n"); s0.append("\n");
} }
Log.printLine(""+s0); Log.printLine(""+s0);
int[][] Pk=fwAlg.getPK(); int[][] Pk=fwAlg.getPK();
Log.printLine("Path information"); Log.printLine("Path information");
for(int i=0;i<n;i++){ for(int i=0;i<n;i++){
for(int j=0;j<n;j++){ for(int j=0;j<n;j++){
Log.print("From "+i+" to "+j+": "); Log.print("From "+i+" to "+j+": ");
int pre=Pk[i][j]; int pre=Pk[i][j];
while((pre!=-1)&&(pre!=i)){ while((pre!=-1)&&(pre!=i)){
Log.print(" <- "+ pre); Log.print(" <- "+ pre);
...@@ -187,7 +186,7 @@ public class FloydWarshall_Float { ...@@ -187,7 +186,7 @@ public class FloydWarshall_Float {
Log.printLine("\n"); Log.printLine("\n");
} }
} }
} }
*/ */
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.network; package org.cloudbus.cloudsim.network;
import java.io.BufferedReader; import java.io.BufferedReader;
...@@ -6,7 +14,7 @@ import java.io.IOException; ...@@ -6,7 +14,7 @@ import java.io.IOException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
/** /**
* this class is just an file-reader for the special brite-format! * This class is just an file-reader for the special brite-format!
* *
* the brite-file is structured as followed: * the brite-file is structured as followed:
* Node-section: * Node-section:
...@@ -15,8 +23,8 @@ import java.util.StringTokenizer; ...@@ -15,8 +23,8 @@ import java.util.StringTokenizer;
* Edge-section: * Edge-section:
* EdgeID, fromNode, toNode, euclideanLength, linkDelay, linkBandwith, AS_from, AS_to, type * EdgeID, fromNode, toNode, euclideanLength, linkDelay, linkBandwith, AS_from, AS_to, type
* *
* @author Thomas Hohnstein * @author Thomas Hohnstein
* * @since CloudSim Toolkit 1.0
*/ */
public class GraphReaderBrite implements GraphReaderIF { public class GraphReaderBrite implements GraphReaderIF {
...@@ -36,6 +44,7 @@ public class GraphReaderBrite implements GraphReaderIF { ...@@ -36,6 +44,7 @@ public class GraphReaderBrite implements GraphReaderIF {
* @return created TopologicalGraph * @return created TopologicalGraph
* @throws IOException * @throws IOException
*/ */
@Override
public TopologicalGraph readGraphFile(String filename) throws IOException{ public TopologicalGraph readGraphFile(String filename) throws IOException{
graph = new TopologicalGraph(); graph = new TopologicalGraph();
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.network; package org.cloudbus.cloudsim.network;
import java.io.IOException; import java.io.IOException;
/** /**
* this interface abstracts an reader for different graph-file-formats * This interface abstracts an reader for different graph-file-formats
*
* @author Thomas Hohnstein
* *
* @author Thomas Hohnstein
* @since CloudSim Toolkit 1.0
*/ */
public interface GraphReaderIF { public interface GraphReaderIF {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.network; package org.cloudbus.cloudsim.network;
import java.util.Iterator; import java.util.Iterator;
...@@ -5,15 +13,15 @@ import java.util.LinkedList; ...@@ -5,15 +13,15 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
/** /**
* this class represents an graph containing nodes and edges, * This class represents an graph containing nodes and edges,
* used for input with an network-layer * used for input with an network-layer
* *
* Graphical-Output Restricions! * Graphical-Output Restricions!
* EdgeColors: GraphicalProperties.getColorEdge * EdgeColors: GraphicalProperties.getColorEdge
* NodeColors: GraphicalProperties.getColorNode * NodeColors: GraphicalProperties.getColorNode
* *
* @author Thomas Hohnstein * @author Thomas Hohnstein
* * @since CloudSim Toolkit 1.0
*/ */
public class TopologicalGraph { public class TopologicalGraph {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.network; package org.cloudbus.cloudsim.network;
/** /**
* this class represents an link (edge) from an graph * This class represents an link (edge) from an graph
*
* @author Thomas Hohnstein
* *
* @author Thomas Hohnstein
* @since CloudSim Toolkit 1.0
*/ */
public class TopologicalLink { public class TopologicalLink {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.network; package org.cloudbus.cloudsim.network;
/** /**
* just represents an topological network node * Just represents an topological network node
* retrieves its information from an topological-generated file * retrieves its information from an topological-generated file
* (eg. topology-generator) * (eg. topology-generator)
* *
* @author Thomas Hohnstein * @author Thomas Hohnstein
* * @since CloudSim Toolkit 1.0
*/ */
public class TopologicalNode { public class TopologicalNode {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2008, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.power; package org.cloudbus.cloudsim.power;
...@@ -27,16 +26,10 @@ import org.cloudbus.cloudsim.core.SimEvent; ...@@ -27,16 +26,10 @@ import org.cloudbus.cloudsim.core.SimEvent;
import org.cloudbus.cloudsim.core.predicates.PredicateType; import org.cloudbus.cloudsim.core.predicates.PredicateType;
/** /**
* CloudSim Datacentre class is a CloudResource whose hostList * PowerDatacenter is a class that enables simulation of power-aware data centers.
* are virtualized. It deals with processing of VM queries (i.e., handling
* of VMs) instead of processing Cloudlet-related queries. So, even though an
* AllocPolicy will be instantiated (in the init() method of the superclass,
* it will not be used, as processing of cloudlets are handled by the CloudletScheduler
* and processing of VirtualMachines are handled by the VMAllocationPolicy.
* *
* @author Rodrigo N. Calheiros * @author Anton Beloglazov
* @since CloudSim Toolkit 4.3 * @since CloudSim Toolkit 2.0
* @invariant $none
*/ */
public class PowerDatacenter extends Datacenter { public class PowerDatacenter extends Datacenter {
...@@ -110,9 +103,7 @@ public class PowerDatacenter extends Datacenter { ...@@ -110,9 +103,7 @@ public class PowerDatacenter extends Datacenter {
for (PowerHost host : this.<PowerHost>getHostList()) { for (PowerHost host : this.<PowerHost>getHostList()) {
if (!Log.isDisabled()) { Log.formatLine("%.2f: Host #%d", CloudSim.clock(), host.getId());
Log.print(String.format("%.2f: Host #%d\n", CloudSim.clock(), host.getId()));
}
double hostPower = 0.0; double hostPower = 0.0;
...@@ -125,31 +116,23 @@ public class PowerDatacenter extends Datacenter { ...@@ -125,31 +116,23 @@ public class PowerDatacenter extends Datacenter {
} }
} }
if (!Log.isDisabled()) { Log.formatLine("%.2f: Host #%d utilization is %.2f%%", CloudSim.clock(), host.getId(), host.getUtilizationOfCpu() * 100);
Log.print(String.format("%.2f: Host #%d utilization is %.2f%%\n", CloudSim.clock(), host.getId(), host.getUtilizationOfCpu() * 100)); Log.formatLine("%.2f: Host #%d energy is %.2f W*sec", CloudSim.clock(), host.getId(), hostPower);
Log.print(String.format("%.2f: Host #%d energy is %.2f W*sec\n", CloudSim.clock(), host.getId(), hostPower));
}
} }
if (!Log.isDisabled()) { Log.formatLine("\n%.2f: Consumed energy is %.2f W*sec\n", CloudSim.clock(), timeframePower);
Log.print(String.format("\n%.2f: Consumed energy is %.2f W*sec\n\n", CloudSim.clock(), timeframePower));
}
Log.printLine("\n\n--------------------------------------------------------------\n\n"); Log.printLine("\n\n--------------------------------------------------------------\n\n");
for (PowerHost host : this.<PowerHost>getHostList()) { for (PowerHost host : this.<PowerHost>getHostList()) {
if (!Log.isDisabled()) { Log.formatLine("\n%.2f: Host #%d", CloudSim.clock(), host.getId());
Log.print(String.format("\n%.2f: Host #%d\n", CloudSim.clock(), host.getId()));
}
double time = host.updateVmsProcessing(currentTime); // inform VMs to update processing double time = host.updateVmsProcessing(currentTime); // inform VMs to update processing
if (time < minTime) { if (time < minTime) {
minTime = time; minTime = time;
} }
if (!Log.isDisabled()) { Log.formatLine("%.2f: Host #%d utilization is %.2f%%", CloudSim.clock(), host.getId(), host.getUtilizationOfCpu() * 100);
Log.print(String.format("%.2f: Host #%d utilization is %.2f%%\n", CloudSim.clock(), host.getId(), host.getUtilizationOfCpu() * 100));
}
} }
setPower(getPower() + timeframePower); setPower(getPower() + timeframePower);
...@@ -179,13 +162,11 @@ public class PowerDatacenter extends Datacenter { ...@@ -179,13 +162,11 @@ public class PowerDatacenter extends Datacenter {
Log.printLine("problem"); Log.printLine("problem");
} }
if (!Log.isDisabled()) { if (oldHost == null) {
if (oldHost == null) { Log.formatLine("%.2f: Migration of VM #%d to Host #%d is started", CloudSim.clock(), vm.getId(), targetHost.getId());
Log.print(String.format("%.2f: Migration of VM #%d to Host #%d is started\n", CloudSim.clock(), vm.getId(), targetHost.getId())); } else {
} else { Log.formatLine("%.2f: Migration of VM #%d from Host #%d to Host #%d is started", CloudSim.clock(), vm.getId(), oldHost.getId(), targetHost.getId());
Log.print(String.format("%.2f: Migration of VM #%d from Host #%d to Host #%d is started\n", CloudSim.clock(), vm.getId(), oldHost.getId(), targetHost.getId())); //oldHost.vmDestroy(vm);
//oldHost.vmDestroy(vm);
}
} }
incrementMigrationCount(); incrementMigrationCount();
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2008, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.power; package org.cloudbus.cloudsim.power;
...@@ -22,16 +21,11 @@ import org.cloudbus.cloudsim.core.CloudSimTags; ...@@ -22,16 +21,11 @@ import org.cloudbus.cloudsim.core.CloudSimTags;
import org.cloudbus.cloudsim.core.predicates.PredicateType; import org.cloudbus.cloudsim.core.predicates.PredicateType;
/** /**
* CloudSim Datacentre class is a CloudResource whose hostList * PowerDatacenterNonPowerAware is a class that represents a non-power aware data center
* are virtualized. It deals with processing of VM queries (i.e., handling * in the context of power-aware simulations.
* of VMs) instead of processing Cloudlet-related queries. So, even though an
* AllocPolicy will be instantiated (in the init() method of the superclass,
* it will not be used, as processing of cloudlets are handled by the CloudletScheduler
* and processing of VirtualMachines are handled by the VMAllocationPolicy.
* *
* @author Rodrigo N. Calheiros * @author Anton Beloglazov
* @since CloudSim Toolkit 4.3 * @since CloudSim Toolkit 2.0
* @invariant $none
*/ */
public class PowerDatacenterNonPowerAware extends PowerDatacenter { public class PowerDatacenterNonPowerAware extends PowerDatacenter {
...@@ -86,9 +80,7 @@ public class PowerDatacenterNonPowerAware extends PowerDatacenter { ...@@ -86,9 +80,7 @@ public class PowerDatacenterNonPowerAware extends PowerDatacenter {
Log.printLine("\n"); Log.printLine("\n");
for (PowerHost host : this.<PowerHost>getHostList()) { for (PowerHost host : this.<PowerHost>getHostList()) {
if (!Log.isDisabled()) { Log.formatLine("%.2f: Host #%d", CloudSim.clock(), host.getId());
Log.print(String.format("%.2f: Host #%d\n", CloudSim.clock(), host.getId()));
}
double hostPower = 0.0; double hostPower = 0.0;
...@@ -100,22 +92,16 @@ public class PowerDatacenterNonPowerAware extends PowerDatacenter { ...@@ -100,22 +92,16 @@ public class PowerDatacenterNonPowerAware extends PowerDatacenter {
e.printStackTrace(); e.printStackTrace();
} }
if (!Log.isDisabled()) { Log.formatLine("%.2f: Host #%d utilization is %.2f%%", CloudSim.clock(), host.getId(), host.getUtilizationOfCpu() * 100);
Log.print(String.format("%.2f: Host #%d utilization is %.2f%%\n", CloudSim.clock(), host.getId(), host.getUtilizationOfCpu() * 100)); Log.formatLine("%.2f: Host #%d energy is %.2f W*sec", CloudSim.clock(), host.getId(), hostPower);
Log.print(String.format("%.2f: Host #%d energy is %.2f W*sec\n", CloudSim.clock(), host.getId(), hostPower));
}
} }
if (!Log.isDisabled()) { Log.formatLine("\n%.2f: Consumed energy is %.2f W*sec\n", CloudSim.clock(), timeframePower);
Log.print(String.format("\n%.2f: Consumed energy is %.2f W*sec\n\n", CloudSim.clock(), timeframePower));
}
Log.printLine("\n\n--------------------------------------------------------------\n\n"); Log.printLine("\n\n--------------------------------------------------------------\n\n");
for (PowerHost host : this.<PowerHost>getHostList()) { for (PowerHost host : this.<PowerHost>getHostList()) {
if (!Log.isDisabled()) { Log.formatLine("\n%.2f: Host #%d", CloudSim.clock(), host.getId());
Log.print(String.format("\n%.2f: Host #%d\n", CloudSim.clock(), host.getId()));
}
double time = host.updateVmsProcessing(currentTime); // inform VMs to update processing double time = host.updateVmsProcessing(currentTime); // inform VMs to update processing
if (time < minTime) { if (time < minTime) {
...@@ -146,12 +132,10 @@ public class PowerDatacenterNonPowerAware extends PowerDatacenter { ...@@ -146,12 +132,10 @@ public class PowerDatacenterNonPowerAware extends PowerDatacenter {
targetHost.addMigratingInVm(vm); targetHost.addMigratingInVm(vm);
if (!Log.isDisabled()) { if (oldHost == null) {
if (oldHost == null) { Log.formatLine("%.2f: Migration of VM #%d to Host #%d is started", CloudSim.clock(), vm.getId(), targetHost.getId());
Log.print(String.format("%.2f: Migration of VM #%d to Host #%d is started\n", CloudSim.clock(), vm.getId(), targetHost.getId())); } else {
} else { Log.formatLine("%.2f: Migration of VM #%d from Host #%d to Host #%d is started", CloudSim.clock(), vm.getId(), oldHost.getId(), targetHost.getId());
Log.print(String.format("%.2f: Migration of VM #%d from Host #%d to Host #%d is started\n", CloudSim.clock(), vm.getId(), oldHost.getId(), targetHost.getId()));
}
} }
incrementMigrationCount(); incrementMigrationCount();
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.power; package org.cloudbus.cloudsim.power;
import java.util.List; import java.util.List;
...@@ -10,7 +18,10 @@ import org.cloudbus.cloudsim.provisioners.BwProvisioner; ...@@ -10,7 +18,10 @@ import org.cloudbus.cloudsim.provisioners.BwProvisioner;
import org.cloudbus.cloudsim.provisioners.RamProvisioner; import org.cloudbus.cloudsim.provisioners.RamProvisioner;
/** /**
* The Class PowerHost. * PowerHost class enables simulation of power-aware hosts.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class PowerHost extends HostDynamicWorkload { public class PowerHost extends HostDynamicWorkload {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.power; package org.cloudbus.cloudsim.power;
import org.cloudbus.cloudsim.Pe; import org.cloudbus.cloudsim.Pe;
...@@ -5,7 +13,10 @@ import org.cloudbus.cloudsim.power.models.PowerModel; ...@@ -5,7 +13,10 @@ import org.cloudbus.cloudsim.power.models.PowerModel;
import org.cloudbus.cloudsim.provisioners.PeProvisioner; import org.cloudbus.cloudsim.provisioners.PeProvisioner;
/** /**
* The Class PowerPe. * PowerPe class enables simulation of power-aware PEs.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class PowerPe extends Pe { public class PowerPe extends Pe {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2008, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.power; package org.cloudbus.cloudsim.power;
...@@ -23,13 +22,11 @@ import org.cloudbus.cloudsim.power.lists.PowerVmList; ...@@ -23,13 +22,11 @@ import org.cloudbus.cloudsim.power.lists.PowerVmList;
/** /**
* PowerVmAllocationPolicySingleThreshold is an VMAllocationPolicy that * PowerVmAllocationPolicySingleThreshold is an VMAllocationPolicy that
* chooses, as the host for a VM, the host with * chooses a host with the least power increase due to utilization increase
* the least power increase due to utilization * caused by the VM allocation.
* increase.
* *
* @author Anton Beloglazov * @author Anton Beloglazov
* @since CloudSim Toolkit 4.3 * @since CloudSim Toolkit 2.0
* @invariant $none
*/ */
public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySimple { public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySimple {
...@@ -122,9 +119,7 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi ...@@ -122,9 +119,7 @@ public class PowerVmAllocationPolicySingleThreshold extends VmAllocationPolicySi
if (result) { //if vm has been succesfully created in the host if (result) { //if vm has been succesfully created in the host
getVmTable().put(vm.getUid(), allocatedHost); getVmTable().put(vm.getUid(), allocatedHost);
if (!Log.isDisabled()) { Log.formatLine("%.2f: VM #" + vm.getId() + " has been sent to the host #" + allocatedHost.getId(), CloudSim.clock());
Log.print(String.format("%.2f: VM #" + vm.getId() + " has been sent to the host #" + allocatedHost.getId() + "\n", CloudSim.clock()));
}
} }
return result; return result;
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2002, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.power.lists; package org.cloudbus.cloudsim.power.lists;
...@@ -15,12 +14,10 @@ import org.cloudbus.cloudsim.lists.PeList; ...@@ -15,12 +14,10 @@ import org.cloudbus.cloudsim.lists.PeList;
import org.cloudbus.cloudsim.power.PowerPe; import org.cloudbus.cloudsim.power.PowerPe;
/** /**
* CloudSim PowerPeList maintains a list of PEs (Processing Elements) that make up * PowerPeList is a collection of operations on lists of Power-enabled PEs.
* a machine.
* *
* @author Manzur Murshed and Rajkumar Buyya * @author Anton Beloglazov
* @since CloudSim Toolkit 1.0 * @since CloudSim Toolkit 2.0
* @invariant $none
*/ */
public class PowerPeList extends PeList { public class PowerPeList extends PeList {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.power.lists; package org.cloudbus.cloudsim.power.lists;
import java.util.Collections; import java.util.Collections;
...@@ -9,7 +17,10 @@ import org.cloudbus.cloudsim.core.CloudSim; ...@@ -9,7 +17,10 @@ import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.lists.VmList; import org.cloudbus.cloudsim.lists.VmList;
/** /**
* The Class PowerVmList. * PowerVmList is a collection of operations on lists of power-enabled VMs.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class PowerVmList extends VmList { public class PowerVmList extends VmList {
...@@ -20,7 +31,8 @@ public class PowerVmList extends VmList { ...@@ -20,7 +31,8 @@ public class PowerVmList extends VmList {
*/ */
public static <T extends Vm> void sortByCpuUtilization(List<T> vmList) { public static <T extends Vm> void sortByCpuUtilization(List<T> vmList) {
Collections.sort(vmList, new Comparator<T>() { Collections.sort(vmList, new Comparator<T>() {
public int compare(T a, T b) throws ClassCastException { @Override
public int compare(T a, T b) throws ClassCastException {
Double aUtilization = a.getTotalUtilizationOfCpuMips(CloudSim.clock()); Double aUtilization = a.getTotalUtilizationOfCpuMips(CloudSim.clock());
Double bUtilization = b.getTotalUtilizationOfCpuMips(CloudSim.clock()); Double bUtilization = b.getTotalUtilizationOfCpuMips(CloudSim.clock());
return bUtilization.compareTo(aUtilization); return bUtilization.compareTo(aUtilization);
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.power.models; package org.cloudbus.cloudsim.power.models;
/** /**
* The Interface PowerModel. * The PowerModel interface needs to be implemented in order to
* provide a model of power consumption depending on utilization
* for system components.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public interface PowerModel { public interface PowerModel {
/** /**
* Get power consumption by the utilization percentage * Get power consumption by the utilization percentage
* according to the power model. * according to the power model.
* *
* @param utilization the utilization * @param utilization the utilization
* *
* @return power consumption * @return power consumption
* *
* @throws Exception the exception * @throws Exception the exception
*/ */
double getPower(double utilization) throws Exception; double getPower(double utilization) throws Exception;
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.power.models; package org.cloudbus.cloudsim.power.models;
/** /**
* The Class PowerModelCubic. * The Class PowerModelCubic.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class PowerModelCubic implements PowerModel { public class PowerModelCubic implements PowerModel {
/** The max power. */ /** The max power. */
private double maxPower; private double maxPower;
/** The constant. */ /** The constant. */
private double constant; private double constant;
/** The static power. */ /** The static power. */
private double staticPower; private double staticPower;
/** /**
* Instantiates a new power model cubic. * Instantiates a new power model cubic.
* *
* @param maxPower the max power * @param maxPower the max power
* @param staticPowerPercent the static power percent * @param staticPowerPercent the static power percent
*/ */
public PowerModelCubic(double maxPower, double staticPowerPercent) { public PowerModelCubic(double maxPower, double staticPowerPercent) {
setMaxPower(maxPower); setMaxPower(maxPower);
setStaticPower(staticPowerPercent * maxPower); setStaticPower(staticPowerPercent * maxPower);
setConstant((maxPower - getStaticPower()) / Math.pow(100, 3)); setConstant((maxPower - getStaticPower()) / Math.pow(100, 3));
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see gridsim.virtualization.power.PowerModel#getPower(double) * @see gridsim.virtualization.power.PowerModel#getPower(double)
*/ */
@Override
public double getPower(double utilization) throws IllegalArgumentException { public double getPower(double utilization) throws IllegalArgumentException {
if (utilization < 0 || utilization > 1) { if (utilization < 0 || utilization > 1) {
throw new IllegalArgumentException("Utilization value must be between 0 and 1"); throw new IllegalArgumentException("Utilization value must be between 0 and 1");
...@@ -41,7 +53,7 @@ public class PowerModelCubic implements PowerModel { ...@@ -41,7 +53,7 @@ public class PowerModelCubic implements PowerModel {
/** /**
* Gets the max power. * Gets the max power.
* *
* @return the max power * @return the max power
*/ */
protected double getMaxPower() { protected double getMaxPower() {
...@@ -50,7 +62,7 @@ public class PowerModelCubic implements PowerModel { ...@@ -50,7 +62,7 @@ public class PowerModelCubic implements PowerModel {
/** /**
* Sets the max power. * Sets the max power.
* *
* @param maxPower the new max power * @param maxPower the new max power
*/ */
protected void setMaxPower(double maxPower) { protected void setMaxPower(double maxPower) {
...@@ -59,7 +71,7 @@ public class PowerModelCubic implements PowerModel { ...@@ -59,7 +71,7 @@ public class PowerModelCubic implements PowerModel {
/** /**
* Gets the constant. * Gets the constant.
* *
* @return the constant * @return the constant
*/ */
protected double getConstant() { protected double getConstant() {
...@@ -68,7 +80,7 @@ public class PowerModelCubic implements PowerModel { ...@@ -68,7 +80,7 @@ public class PowerModelCubic implements PowerModel {
/** /**
* Sets the constant. * Sets the constant.
* *
* @param constant the new constant * @param constant the new constant
*/ */
protected void setConstant(double constant) { protected void setConstant(double constant) {
...@@ -77,7 +89,7 @@ public class PowerModelCubic implements PowerModel { ...@@ -77,7 +89,7 @@ public class PowerModelCubic implements PowerModel {
/** /**
* Gets the static power. * Gets the static power.
* *
* @return the static power * @return the static power
*/ */
protected double getStaticPower() { protected double getStaticPower() {
...@@ -86,7 +98,7 @@ public class PowerModelCubic implements PowerModel { ...@@ -86,7 +98,7 @@ public class PowerModelCubic implements PowerModel {
/** /**
* Sets the static power. * Sets the static power.
* *
* @param staticPower the new static power * @param staticPower the new static power
*/ */
protected void setStaticPower(double staticPower) { protected void setStaticPower(double staticPower) {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.power.models; package org.cloudbus.cloudsim.power.models;
/** /**
* The Class PowerModelLinear. * The Class PowerModelLinear.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class PowerModelLinear implements PowerModel { public class PowerModelLinear implements PowerModel {
/** The max power. */ /** The max power. */
private double maxPower; private double maxPower;
/** The constant. */ /** The constant. */
private double constant; private double constant;
/** The static power. */ /** The static power. */
private double staticPower; private double staticPower;
/** /**
* Instantiates a new linear power model. * Instantiates a new linear power model.
* *
* @param maxPower the max power * @param maxPower the max power
* @param staticPowerPercent the static power percent * @param staticPowerPercent the static power percent
*/ */
public PowerModelLinear(double maxPower, double staticPowerPercent) { public PowerModelLinear(double maxPower, double staticPowerPercent) {
setMaxPower(maxPower); setMaxPower(maxPower);
setStaticPower(staticPowerPercent * maxPower); setStaticPower(staticPowerPercent * maxPower);
setConstant((maxPower - getStaticPower()) / 100); setConstant((maxPower - getStaticPower()) / 100);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see cloudsim.power.PowerModel#getPower(double) * @see cloudsim.power.PowerModel#getPower(double)
*/ */
@Override
public double getPower(double utilization) throws IllegalArgumentException { public double getPower(double utilization) throws IllegalArgumentException {
if (utilization < 0 || utilization > 1) { if (utilization < 0 || utilization > 1) {
throw new IllegalArgumentException("Utilization value must be between 0 and 1"); throw new IllegalArgumentException("Utilization value must be between 0 and 1");
...@@ -41,7 +53,7 @@ public class PowerModelLinear implements PowerModel { ...@@ -41,7 +53,7 @@ public class PowerModelLinear implements PowerModel {
/** /**
* Gets the max power. * Gets the max power.
* *
* @return the max power * @return the max power
*/ */
protected double getMaxPower() { protected double getMaxPower() {
...@@ -50,7 +62,7 @@ public class PowerModelLinear implements PowerModel { ...@@ -50,7 +62,7 @@ public class PowerModelLinear implements PowerModel {
/** /**
* Sets the max power. * Sets the max power.
* *
* @param maxPower the new max power * @param maxPower the new max power
*/ */
protected void setMaxPower(double maxPower) { protected void setMaxPower(double maxPower) {
...@@ -59,7 +71,7 @@ public class PowerModelLinear implements PowerModel { ...@@ -59,7 +71,7 @@ public class PowerModelLinear implements PowerModel {
/** /**
* Gets the constant. * Gets the constant.
* *
* @return the constant * @return the constant
*/ */
protected double getConstant() { protected double getConstant() {
...@@ -68,7 +80,7 @@ public class PowerModelLinear implements PowerModel { ...@@ -68,7 +80,7 @@ public class PowerModelLinear implements PowerModel {
/** /**
* Sets the constant. * Sets the constant.
* *
* @param constant the new constant * @param constant the new constant
*/ */
protected void setConstant(double constant) { protected void setConstant(double constant) {
...@@ -77,7 +89,7 @@ public class PowerModelLinear implements PowerModel { ...@@ -77,7 +89,7 @@ public class PowerModelLinear implements PowerModel {
/** /**
* Gets the static power. * Gets the static power.
* *
* @return the static power * @return the static power
*/ */
protected double getStaticPower() { protected double getStaticPower() {
...@@ -86,7 +98,7 @@ public class PowerModelLinear implements PowerModel { ...@@ -86,7 +98,7 @@ public class PowerModelLinear implements PowerModel {
/** /**
* Sets the static power. * Sets the static power.
* *
* @param staticPower the new static power * @param staticPower the new static power
*/ */
protected void setStaticPower(double staticPower) { protected void setStaticPower(double staticPower) {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.power.models; package org.cloudbus.cloudsim.power.models;
/** /**
* The Class PowerModelSqrt. * The Class PowerModelSqrt.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class PowerModelSqrt implements PowerModel { public class PowerModelSqrt implements PowerModel {
/** The max power. */ /** The max power. */
private double maxPower; private double maxPower;
/** The constant. */ /** The constant. */
private double constant; private double constant;
/** The static power. */ /** The static power. */
private double staticPower; private double staticPower;
/** /**
* Instantiates a new power model sqrt. * Instantiates a new power model sqrt.
* *
* @param maxPower the max power * @param maxPower the max power
* @param staticPowerPercent the static power percent * @param staticPowerPercent the static power percent
*/ */
public PowerModelSqrt(double maxPower, double staticPowerPercent) { public PowerModelSqrt(double maxPower, double staticPowerPercent) {
setMaxPower(maxPower); setMaxPower(maxPower);
setStaticPower(staticPowerPercent * maxPower); setStaticPower(staticPowerPercent * maxPower);
setConstant((maxPower - getStaticPower()) / Math.sqrt(100)); setConstant((maxPower - getStaticPower()) / Math.sqrt(100));
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see cloudsim.power.PowerModel#getPower(double) * @see cloudsim.power.PowerModel#getPower(double)
*/ */
@Override
public double getPower(double utilization) throws IllegalArgumentException { public double getPower(double utilization) throws IllegalArgumentException {
if (utilization < 0 || utilization > 1) { if (utilization < 0 || utilization > 1) {
throw new IllegalArgumentException("Utilization value must be between 0 and 1"); throw new IllegalArgumentException("Utilization value must be between 0 and 1");
...@@ -41,7 +53,7 @@ public class PowerModelSqrt implements PowerModel { ...@@ -41,7 +53,7 @@ public class PowerModelSqrt implements PowerModel {
/** /**
* Gets the max power. * Gets the max power.
* *
* @return the max power * @return the max power
*/ */
protected double getMaxPower() { protected double getMaxPower() {
...@@ -50,7 +62,7 @@ public class PowerModelSqrt implements PowerModel { ...@@ -50,7 +62,7 @@ public class PowerModelSqrt implements PowerModel {
/** /**
* Sets the max power. * Sets the max power.
* *
* @param maxPower the new max power * @param maxPower the new max power
*/ */
protected void setMaxPower(double maxPower) { protected void setMaxPower(double maxPower) {
...@@ -59,7 +71,7 @@ public class PowerModelSqrt implements PowerModel { ...@@ -59,7 +71,7 @@ public class PowerModelSqrt implements PowerModel {
/** /**
* Gets the constant. * Gets the constant.
* *
* @return the constant * @return the constant
*/ */
protected double getConstant() { protected double getConstant() {
...@@ -68,7 +80,7 @@ public class PowerModelSqrt implements PowerModel { ...@@ -68,7 +80,7 @@ public class PowerModelSqrt implements PowerModel {
/** /**
* Sets the constant. * Sets the constant.
* *
* @param constant the new constant * @param constant the new constant
*/ */
protected void setConstant(double constant) { protected void setConstant(double constant) {
...@@ -77,7 +89,7 @@ public class PowerModelSqrt implements PowerModel { ...@@ -77,7 +89,7 @@ public class PowerModelSqrt implements PowerModel {
/** /**
* Gets the static power. * Gets the static power.
* *
* @return the static power * @return the static power
*/ */
protected double getStaticPower() { protected double getStaticPower() {
...@@ -86,7 +98,7 @@ public class PowerModelSqrt implements PowerModel { ...@@ -86,7 +98,7 @@ public class PowerModelSqrt implements PowerModel {
/** /**
* Sets the static power. * Sets the static power.
* *
* @param staticPower the new static power * @param staticPower the new static power
*/ */
protected void setStaticPower(double staticPower) { protected void setStaticPower(double staticPower) {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.power.models; package org.cloudbus.cloudsim.power.models;
/** /**
* The Class PowerModelSquare. * The Class PowerModelSquare.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class PowerModelSquare implements PowerModel { public class PowerModelSquare implements PowerModel {
/** The max power. */ /** The max power. */
private double maxPower; private double maxPower;
/** The constant. */ /** The constant. */
private double constant; private double constant;
/** The static power. */ /** The static power. */
private double staticPower; private double staticPower;
/** /**
* Instantiates a new power model square. * Instantiates a new power model square.
* *
* @param maxPower the max power * @param maxPower the max power
* @param staticPowerPercent the static power percent * @param staticPowerPercent the static power percent
*/ */
public PowerModelSquare(double maxPower, double staticPowerPercent) { public PowerModelSquare(double maxPower, double staticPowerPercent) {
setMaxPower(maxPower); setMaxPower(maxPower);
setStaticPower(staticPowerPercent * maxPower); setStaticPower(staticPowerPercent * maxPower);
setConstant((maxPower - getStaticPower()) / Math.pow(100, 2)); setConstant((maxPower - getStaticPower()) / Math.pow(100, 2));
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see gridsim.virtualization.power.PowerModel#getPower(double) * @see gridsim.virtualization.power.PowerModel#getPower(double)
*/ */
@Override
public double getPower(double utilization) throws IllegalArgumentException { public double getPower(double utilization) throws IllegalArgumentException {
if (utilization < 0 || utilization > 1) { if (utilization < 0 || utilization > 1) {
throw new IllegalArgumentException("Utilization value must be between 0 and 1"); throw new IllegalArgumentException("Utilization value must be between 0 and 1");
...@@ -41,7 +53,7 @@ public class PowerModelSquare implements PowerModel { ...@@ -41,7 +53,7 @@ public class PowerModelSquare implements PowerModel {
/** /**
* Gets the max power. * Gets the max power.
* *
* @return the max power * @return the max power
*/ */
protected double getMaxPower() { protected double getMaxPower() {
...@@ -50,7 +62,7 @@ public class PowerModelSquare implements PowerModel { ...@@ -50,7 +62,7 @@ public class PowerModelSquare implements PowerModel {
/** /**
* Sets the max power. * Sets the max power.
* *
* @param maxPower the new max power * @param maxPower the new max power
*/ */
protected void setMaxPower(double maxPower) { protected void setMaxPower(double maxPower) {
...@@ -59,7 +71,7 @@ public class PowerModelSquare implements PowerModel { ...@@ -59,7 +71,7 @@ public class PowerModelSquare implements PowerModel {
/** /**
* Gets the constant. * Gets the constant.
* *
* @return the constant * @return the constant
*/ */
protected double getConstant() { protected double getConstant() {
...@@ -68,7 +80,7 @@ public class PowerModelSquare implements PowerModel { ...@@ -68,7 +80,7 @@ public class PowerModelSquare implements PowerModel {
/** /**
* Sets the constant. * Sets the constant.
* *
* @param constant the new constant * @param constant the new constant
*/ */
protected void setConstant(double constant) { protected void setConstant(double constant) {
...@@ -77,7 +89,7 @@ public class PowerModelSquare implements PowerModel { ...@@ -77,7 +89,7 @@ public class PowerModelSquare implements PowerModel {
/** /**
* Gets the static power. * Gets the static power.
* *
* @return the static power * @return the static power
*/ */
protected double getStaticPower() { protected double getStaticPower() {
...@@ -86,7 +98,7 @@ public class PowerModelSquare implements PowerModel { ...@@ -86,7 +98,7 @@ public class PowerModelSquare implements PowerModel {
/** /**
* Sets the static power. * Sets the static power.
* *
* @param staticPower the new static power * @param staticPower the new static power
*/ */
protected void setStaticPower(double staticPower) { protected void setStaticPower(double staticPower) {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2008, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.provisioners; package org.cloudbus.cloudsim.provisioners;
...@@ -18,9 +17,9 @@ import org.cloudbus.cloudsim.Vm; ...@@ -18,9 +17,9 @@ import org.cloudbus.cloudsim.Vm;
* will always contain the amount of free bandwidth available for future * will always contain the amount of free bandwidth available for future
* allocations. * allocations.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 4.3 * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public abstract class BwProvisioner { public abstract class BwProvisioner {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2008, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.provisioners; package org.cloudbus.cloudsim.provisioners;
...@@ -19,9 +18,9 @@ import org.cloudbus.cloudsim.Vm; ...@@ -19,9 +18,9 @@ import org.cloudbus.cloudsim.Vm;
* effort allocation policy: if there is bw available to request, it allocates; * effort allocation policy: if there is bw available to request, it allocates;
* otherwise, it fails. * otherwise, it fails.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 4.3 * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class BwProvisionerSimple extends BwProvisioner { public class BwProvisionerSimple extends BwProvisioner {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim.provisioners; package org.cloudbus.cloudsim.provisioners;
import java.util.List; import java.util.List;
...@@ -6,6 +14,9 @@ import org.cloudbus.cloudsim.Vm; ...@@ -6,6 +14,9 @@ import org.cloudbus.cloudsim.Vm;
/** /**
* The Class PeProvisioner. * The Class PeProvisioner.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public abstract class PeProvisioner { public abstract class PeProvisioner {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2008, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.provisioners; package org.cloudbus.cloudsim.provisioners;
...@@ -18,6 +17,9 @@ import org.cloudbus.cloudsim.Vm; ...@@ -18,6 +17,9 @@ import org.cloudbus.cloudsim.Vm;
/** /**
* The Class PeProvisionerSimple. * The Class PeProvisionerSimple.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/ */
public class PeProvisionerSimple extends PeProvisioner { public class PeProvisionerSimple extends PeProvisioner {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2008, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.provisioners; package org.cloudbus.cloudsim.provisioners;
import org.cloudbus.cloudsim.Vm; import org.cloudbus.cloudsim.Vm;
...@@ -19,9 +17,9 @@ import org.cloudbus.cloudsim.Vm; ...@@ -19,9 +17,9 @@ import org.cloudbus.cloudsim.Vm;
* will always contain the amount of free memory available for future * will always contain the amount of free memory available for future
* allocations. * allocations.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 4.3 * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public abstract class RamProvisioner { public abstract class RamProvisioner {
......
/* /*
* Title: CloudSim Toolkit * Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation * Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* of Parallel and Distributed Systems such as Clusters and Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* *
* Copyright (c) 2008, The University of Melbourne, Australia * Copyright (c) 2009-2010, The University of Melbourne, Australia
*/ */
package org.cloudbus.cloudsim.provisioners; package org.cloudbus.cloudsim.provisioners;
...@@ -18,9 +17,9 @@ import org.cloudbus.cloudsim.Vm; ...@@ -18,9 +17,9 @@ import org.cloudbus.cloudsim.Vm;
* RamProvisionerSimple is an extension of RamProvisioner * RamProvisionerSimple is an extension of RamProvisioner
* which uses a best-effort policy to allocate memory to a VM. * which uses a best-effort policy to allocate memory to a VM.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @since CloudSim Toolkit 4.3 * @author Anton Beloglazov
* @invariant $none * @since CloudSim Toolkit 1.0
*/ */
public class RamProvisionerSimple extends RamProvisioner { public class RamProvisionerSimple extends RamProvisioner {
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import static org.easymock.EasyMock.createMock; import static org.easymock.EasyMock.createMock;
...@@ -17,6 +25,10 @@ import java.util.Map; ...@@ -17,6 +25,10 @@ import java.util.Map;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
/**
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/
public class CloudletSchedulerSingleServiceTest { public class CloudletSchedulerSingleServiceTest {
private static final long CLOUDLET_LENGTH = 1000; private static final long CLOUDLET_LENGTH = 1000;
......
/*
* Title: CloudSim Toolkiimport static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import java.util.LinkedList;
import org.junit.Before;
import org.junit.Test;
c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
...@@ -8,6 +19,10 @@ import java.util.LinkedList; ...@@ -8,6 +19,10 @@ import java.util.LinkedList;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
/**
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/
public class CloudletTest { public class CloudletTest {
private static final long CLOUDLET_LENGTH = 1000; private static final long CLOUDLET_LENGTH = 1000;
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
...@@ -14,6 +22,10 @@ import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple; ...@@ -14,6 +22,10 @@ import org.cloudbus.cloudsim.provisioners.RamProvisionerSimple;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
/**
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/
public class HostDynamicWorkloadTest { public class HostDynamicWorkloadTest {
private static final int ID = 0; private static final int ID = 0;
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim; package org.cloudbus.cloudsim;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
...@@ -18,6 +26,10 @@ import org.junit.Before; ...@@ -18,6 +26,10 @@ import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
/**
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/
public class HostTest { public class HostTest {
private static final int ID = 0; private static final int ID = 0;
......
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
/**
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/
public class LogTest {
private static final ByteArrayOutputStream OUTPUT = new ByteArrayOutputStream();
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
@Before
public void setUp() throws Exception {
Log.setOutput(OUTPUT);
}
@Test
public void testPrint() throws IOException {
Log.print("test test");
assertEquals("test test", OUTPUT.toString());
OUTPUT.reset();
Log.print(123);
assertEquals("123", OUTPUT.toString());
OUTPUT.reset();
Log.print(123L);
assertEquals("123", OUTPUT.toString());
OUTPUT.reset();
Log.print(123.0);
assertEquals("123.0", OUTPUT.toString());
OUTPUT.reset();
}
@Test
public void testPrintLine() throws IOException {
Log.printLine("test test");
assertEquals("test test" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
Log.printLine(123);
assertEquals("123" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
Log.printLine(123L);
assertEquals("123" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
Log.printLine(123.0);
assertEquals("123.0" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
}
@Test
public void testFormat() throws IOException {
Log.format("test %s test", "test");
assertEquals("test test test", OUTPUT.toString());
OUTPUT.reset();
Log.format("%d", 123);
assertEquals("123", OUTPUT.toString());
OUTPUT.reset();
Log.format("%d", 123L);
assertEquals("123", OUTPUT.toString());
OUTPUT.reset();
Log.format("%.2f", 123.01);
assertEquals("123.01", OUTPUT.toString());
OUTPUT.reset();
}
@Test
public void testFormatLine() throws IOException {
Log.formatLine("test %s test", "test");
assertEquals("test test test" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
Log.formatLine("%d", 123);
assertEquals("123" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
Log.formatLine("%d", 123L);
assertEquals("123" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
Log.formatLine("%.2f", 123.01);
assertEquals("123.01" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
}
@Test
public void testDisable() throws IOException {
assertFalse(Log.isDisabled());
Log.print("test test");
assertEquals("test test", OUTPUT.toString());
OUTPUT.reset();
Log.printLine("test test");
assertEquals("test test" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
Log.format("test %s test", "test");
assertEquals("test test test", OUTPUT.toString());
OUTPUT.reset();
Log.formatLine("test %s test", "test");
assertEquals("test test test" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
Log.disable();
assertTrue(Log.isDisabled());
Log.print("test test");
assertEquals("", OUTPUT.toString());
OUTPUT.reset();
Log.printLine("test test");
assertEquals("", OUTPUT.toString());
OUTPUT.reset();
Log.format("test %s test", "test");
assertEquals("", OUTPUT.toString());
OUTPUT.reset();
Log.formatLine("test %s test", "test");
assertEquals("", OUTPUT.toString());
OUTPUT.reset();
Log.enable();
assertFalse(Log.isDisabled());
Log.print("test test");
assertEquals("test test", OUTPUT.toString());
OUTPUT.reset();
Log.printLine("test test");
assertEquals("test test" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
Log.format("test %s test", "test");
assertEquals("test test test", OUTPUT.toString());
OUTPUT.reset();
Log.formatLine("test %s test", "test");
assertEquals("test test test" + LINE_SEPARATOR, OUTPUT.toString());
OUTPUT.reset();
}
}
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