Package org.cloudbus.cloudsim.resources
Class HarddriveStorage
java.lang.Object
org.cloudbus.cloudsim.resources.HarddriveStorage
- All Implemented Interfaces:
FileStorage
,Resource
,ResourceCapacity
- Direct Known Subclasses:
SanStorage
An implementation of a Hard Drive (HD) storage device with a specific capacity (in Megabytes).
It simulates the behavior of a typical hard drive.
The default values for this storage are those of a
"Maxtor DiamondMax 10 ATA"
hard disk with the following parameters:
- latency = 4.17 ms
- avg seek time = 9 m/s
- max transfer rate = 1064 Megabits/sec (133 MBytes/sec)
- Since:
- CloudSim Toolkit 1.0
- Author:
- Uros Cibej, Anthony Sulistio, Manoel Campos da Silva Filho
-
Field Summary
Fields inherited from interface org.cloudbus.cloudsim.resources.FileStorage
DEF_LATENCY_SECS, DEF_MAX_TRANSF_RATE_MBITS_SEC, DEF_SEEK_TIME_SECS, LOGGER, NULL
-
Constructor Summary
ConstructorDescriptionHarddriveStorage
(long capacity) Creates a new hard drive storage with a given capacity.HarddriveStorage
(String name, long capacity) Creates a new hard drive storage with a given name and capacity. -
Method Summary
Modifier and TypeMethodDescriptionlong
Gets the current total amount of allocated resource.long
Gets the amount of the resource that is available (free).double
Gets the average seek time of the hard drive in seconds.long
Gets the total capacity of the resource.double
Gets the rotational latency of this storage in seconds (if any).double
Gets the maximum local transfer rate of the storage in Mega-bits/sec, i.e., the physical device reading speed.getName()
double
getSeekTime
(int fileSize) Get the seek time for a file with the defined size.The internal storage that just manages the HD capacity and used space.double
getTransferTime
(int fileSize) Gets the transfer time of a given file.protected final double
getTransferTime
(int fileSize, double speed) Gets the time to transfer a file (in MBytes) according to a given transfer speed (in Mbits/sec).getUnit()
Gets the measurement unit of this resource.boolean
isAmountAvailable
(double amountToCheck) Checks if there is a specific amount of resource available (free), where such amount is a double value that will be converted to long.boolean
isAmountAvailable
(long amountToCheck) Checks if there is a specific amount of resource available (free).boolean
isFull()
Checks if the resource is full or not.setAvgSeekTime
(double seekTime) Sets the average seek time of the storage in seconds.setAvgSeekTime
(double seekTime, ContinuousDistribution gen) Sets the average seek time and a new generator of seek times in seconds.setLatency
(double latency) Sets the rotational latency of this storage in seconds (if any).setMaxTransferRate
(double maxTransferRate) Sets the maximum transfer rate of this storage system in Mega-bits/sec, i.e., the physical device reading speed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.cloudbus.cloudsim.resources.Resource
getPercentUtilization, isAmountAvailable, isSubClassOf
-
Constructor Details
-
HarddriveStorage
Creates a new hard drive storage with a given name and capacity.- Parameters:
name
- the name of the new hard drive storagecapacity
- the capacity in MByte- Throws:
IllegalArgumentException
- when the name and the capacity are not valid
-
HarddriveStorage
Creates a new hard drive storage with a given capacity. In this case the name of the storage is a default name.- Parameters:
capacity
- the capacity in MByte- Throws:
IllegalArgumentException
- when the name and the capacity are not valid
-
-
Method Details
-
getName
- Returns:
- the name of the storage device
-
getLatency
public double getLatency()Description copied from interface:FileStorage
Gets the rotational latency of this storage in seconds (if any).- Specified by:
getLatency
in interfaceFileStorage
- Returns:
- the read latency in seconds
-
setLatency
Description copied from interface:FileStorage
Sets the rotational latency of this storage in seconds (if any).- Specified by:
setLatency
in interfaceFileStorage
- Parameters:
latency
- the new latency in seconds- Returns:
-
getMaxTransferRate
public double getMaxTransferRate()Description copied from interface:FileStorage
Gets the maximum local transfer rate of the storage in Mega-bits/sec, i.e., the physical device reading speed.- Specified by:
getMaxTransferRate
in interfaceFileStorage
- Returns:
- the maximum transfer rate in Mega-bits/sec
- See Also:
-
setMaxTransferRate
Description copied from interface:FileStorage
Sets the maximum transfer rate of this storage system in Mega-bits/sec, i.e., the physical device reading speed.Despite disk transfer rate is usually defined in MBytes/sec, it's being used Mbits/sec everywhere to avoid confusions, since
Host
,Vm
,Switch
andSanStorage
use such a data unit.- Specified by:
setMaxTransferRate
in interfaceFileStorage
- Parameters:
maxTransferRate
- the maximum transfer rate in Mbits/sec- Returns:
-
setAvgSeekTime
Sets the average seek time of the storage in seconds.- Parameters:
seekTime
- the average seek time in seconds- Returns:
-
setAvgSeekTime
Sets the average seek time and a new generator of seek times in seconds. The generator determines a randomized seek time.- Parameters:
seekTime
- the average seek time in secondsgen
- the ContinuousGenerator which generates seek times- Returns:
-
getAvgSeekTime
public double getAvgSeekTime()Gets the average seek time of the hard drive in seconds.- Returns:
- the average seek time in seconds
-
getSeekTime
public double getSeekTime(int fileSize) Get the seek time for a file with the defined size. Given a file size in MByte, this method returns a seek time for the file in seconds.- Parameters:
fileSize
- the size of a file in MByte- Returns:
- the seek time in seconds
-
getTransferTime
public double getTransferTime(int fileSize) Description copied from interface:FileStorage
Gets the transfer time of a given file.- Specified by:
getTransferTime
in interfaceFileStorage
- Parameters:
fileSize
- the size of the file to compute the transfer time (in MByte)- Returns:
- the transfer time in seconds
-
getTransferTime
protected final double getTransferTime(int fileSize, double speed) Gets the time to transfer a file (in MBytes) according to a given transfer speed (in Mbits/sec).- Parameters:
fileSize
- the size of the file to compute the transfer time (in MBytes)speed
- the speed (in MBits/sec) to compute the time to transfer the file- Returns:
- the transfer time in seconds
-
getCapacity
public long getCapacity()Description copied from interface:ResourceCapacity
Gets the total capacity of the resource.- Specified by:
getCapacity
in interfaceResourceCapacity
- Returns:
- the total resource capacity
-
getAvailableResource
public long getAvailableResource()Description copied from interface:Resource
Gets the amount of the resource that is available (free).- Specified by:
getAvailableResource
in interfaceResource
- Returns:
- the amount of available resource
-
getAllocatedResource
public long getAllocatedResource()Description copied from interface:Resource
Gets the current total amount of allocated resource.- Specified by:
getAllocatedResource
in interfaceResource
- Returns:
- amount of allocated resource
-
isAmountAvailable
public boolean isAmountAvailable(long amountToCheck) Description copied from interface:Resource
Checks if there is a specific amount of resource available (free).- Specified by:
isAmountAvailable
in interfaceResource
- Parameters:
amountToCheck
- the amount of resource to check if is free.- Returns:
- true if the specified amount is free; false otherwise
-
isAmountAvailable
public boolean isAmountAvailable(double amountToCheck) Description copied from interface:Resource
Checks if there is a specific amount of resource available (free), where such amount is a double value that will be converted to long.This method is just a shorthand to avoid explicitly converting a double to long.
- Specified by:
isAmountAvailable
in interfaceResource
- Parameters:
amountToCheck
- the amount of resource to check if is free.- Returns:
- true if the specified amount is free; false otherwise
- See Also:
-
isFull
public boolean isFull()Description copied from interface:Resource
Checks if the resource is full or not. -
getStorage
The internal storage that just manages the HD capacity and used space. TheHarddriveStorage
(HD) does not extends such class to avoid its capacity and available amount of space to be changed indiscriminately. The available space is update according to files added or removed from the HD. -
getUnit
Description copied from interface:Resource
Gets the measurement unit of this resource.
-