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