Package org.cloudbus.cloudsim.resources
Class SanStorage
java.lang.Object
org.cloudbus.cloudsim.resources.HarddriveStorage
org.cloudbus.cloudsim.resources.SanStorage
- All Implemented Interfaces:
FileStorage
,Resource
,ResourceCapacity
SanStorage represents a Storage Area Network (SAN) composed of a set of
hard disks 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.
- Since:
- CloudSim Toolkit 1.0 TODO See the warning in class documentation.
- Author:
- Rodrigo N. Calheiros, 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
ConstructorDescriptionSanStorage
(long capacity, double bandwidth, double networkLatency) Creates a new SAN with a given capacity, latency, and bandwidth of the network connection.SanStorage
(String name, long capacity, double bandwidth, double networkLatency) Creates a new SAN with a given capacity, latency, and bandwidth of the network connection and with a specific name. -
Method Summary
Modifier and TypeMethodDescriptiondouble
Adds a set of files to the storage.double
Adds a file to the storage.double
addReservedFile
(File file) Adds a file for which the space has already been reserved.boolean
Checks whether a file exists in the storage or not.boolean
Checks whether a file is stored in the storage or not.deleteFile
(String fileName) Removes a file from the storage.double
deleteFile
(File file) Removes a file from the storage.double
Gets the bandwidth of the SAN network (in Megabits/s).Gets the file with the specified name.Gets a read-only list with all files stored on the device.Gets a read-only list with the names of all files stored on the device.double
Gets the SAN's network latency (in seconds).int
Gets the number of files stored on this device.double
getTransferTime
(int fileSize) Gets the transfer time of a given file.double
getTransferTime
(String fileName) Gets the transfer time of a given file.double
getTransferTime
(File file) Gets the transfer time of a given file.boolean
Checks if the storage device has a specific file.boolean
hasPotentialAvailableSpace
(long fileSize) Checks whether there is enough space on the storage for a certain fileboolean
renameFile
(File file, String newName) Renames a file on the storage.boolean
reserveSpace
(int fileSize) Makes reservation of space on the storage to store a file.final void
setBandwidth
(double bandwidth) Sets the bandwidth of the SAN network (in Megabits/s).final void
setNetworkLatency
(double networkLatency) Sets the latency of the SAN network (in seconds).toString()
Methods inherited from class org.cloudbus.cloudsim.resources.HarddriveStorage
getAllocatedResource, getAvailableResource, getAvgSeekTime, getCapacity, getLatency, getMaxTransferRate, getName, getSeekTime, getStorage, getTransferTime, getUnit, isAmountAvailable, isAmountAvailable, isFull, setAvgSeekTime, setAvgSeekTime, setLatency, setMaxTransferRate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.cloudbus.cloudsim.resources.Resource
getPercentUtilization, isAmountAvailable, isSubClassOf
-
Field Details
-
FILE_NOT_FOUND
public static final double FILE_NOT_FOUND- See Also:
-
-
Constructor Details
-
SanStorage
public SanStorage(long capacity, double bandwidth, double networkLatency) throws IllegalArgumentException Creates a new SAN with a given capacity, latency, and bandwidth of the network connection.- Parameters:
capacity
- Total storage capacity of the SANbandwidth
- Network bandwidth (in Megabits/s)networkLatency
- Network latency (in seconds)- Throws:
IllegalArgumentException
- when the name and the capacity are not valid
-
SanStorage
Creates a new SAN with a given capacity, latency, and bandwidth of the network connection and with a specific name.- Parameters:
name
- the name of the new storage devicecapacity
- Storage device capacitybandwidth
- Network bandwidth (in Megabits/s)networkLatency
- Network latency (in seconds)- Throws:
IllegalArgumentException
- when the name and the capacity are not valid
-
-
Method Details
-
addReservedFile
Adds a file for which the space has already been reserved. The time taken (in seconds) for adding the specified file can also be found usingFile.getTransactionTime()
.- Parameters:
file
- the file to be added- Returns:
- the time (in seconds) required to add the file
-
addFile
Adds a set of files to the storage. The time taken (in seconds) for adding each file can also be found usingFile.getTransactionTime()
.- Parameters:
list
- the files to be added- Returns:
- the time taken (in seconds) for adding the specified file or zero if the file is invalid or there isn't available storage space.
-
addFile
Adds a file to the storage. The time taken (in seconds) for adding the specified file can also be found usingFile.getTransactionTime()
.- Parameters:
file
- the file to be added- Returns:
- the time taken (in seconds) for adding the specified file or zero if there isn't available storage space.
-
getBandwidth
public double getBandwidth()Gets the bandwidth of the SAN network (in Megabits/s).- Returns:
- the bandwidth (in Megabits/s)
-
setBandwidth
public final void setBandwidth(double bandwidth) Sets the bandwidth of the SAN network (in Megabits/s).- Parameters:
bandwidth
- the bandwidth to set (in Megabits/s)- Throws:
IllegalArgumentException
- when the bandwidth is lower or equal to zero
-
getNetworkLatency
public double getNetworkLatency()Gets the SAN's network latency (in seconds).- Returns:
- the SAN's network latency (in seconds)
-
setNetworkLatency
public final void setNetworkLatency(double networkLatency) Sets the latency of the SAN network (in seconds).- Parameters:
networkLatency
- the latency to set (in seconds)- Throws:
IllegalArgumentException
- when the latency is lower or equal to zero
-
toString
-
getNumStoredFile
public int getNumStoredFile()Gets the number of files stored on this device.- Returns:
- the number of stored files
-
reserveSpace
public boolean reserveSpace(int fileSize) Makes reservation of space on the storage to store a file.- Parameters:
fileSize
- the size to be reserved (in MByte)- Returns:
- true if reservation succeeded, false otherwise
-
hasPotentialAvailableSpace
public boolean hasPotentialAvailableSpace(long fileSize) Checks whether there is enough space on the storage for a certain file- Parameters:
fileSize
- size of the file intended to be stored on the device (in MByte)- Returns:
- true if enough space available, false otherwise
-
hasFile
Checks if the storage device has a specific file.- Parameters:
fileName
- the name of the file to check if it's contained in this storage device.- Returns:
- true if the storage device has the file, false otherwise.
-
getFile
Gets the file with the specified name. The time taken (in seconds) for getting the specified file can also be found usingFile.getTransactionTime()
.- Parameters:
fileName
- the name of the needed file- Returns:
- an
Optional
containing the file if it was found; an empty Optional otherwise
-
getFileNameList
Gets a read-only list with the names of all files stored on the device.- Returns:
- a List of file names
-
getFileList
Gets a read-only list with all files stored on the device.- Returns:
- a List of files
-
getTransferTime
Gets the transfer time of a given file.- Parameters:
file
- the file to compute the transfer time (where its size is defined in MByte)- Returns:
- the transfer time in seconds
-
getTransferTime
public double getTransferTime(int fileSize) Gets the transfer time of a given file. The network latency is added to the transfer time.- Specified by:
getTransferTime
in interfaceFileStorage
- Overrides:
getTransferTime
in classHarddriveStorage
- Parameters:
fileSize
- the size of the file to compute the transfer time (in MByte)- Returns:
- the transfer time in seconds
-
getTransferTime
Gets the transfer time of a given file.- Parameters:
fileName
- the name of the file to compute the transfer time (where its size is defined in MByte)- Returns:
- the transfer time in seconds or
FILE_NOT_FOUND
if the file was not found in this storage device
-
deleteFile
Removes a file from the storage. The time taken (in seconds) for deleting the specified file can be found usingFile.getTransactionTime()
.- Parameters:
fileName
- the name of the file to be removed- Returns:
- an
Optional
containing the deleted file if it is found; an empty Optional otherwise.
-
deleteFile
Removes a file from the storage. The time taken (in seconds) for deleting the specified file can also be found usingFile.getTransactionTime()
.- Parameters:
file
- the file to be removed- Returns:
- the time taken (in seconds) for deleting the specified file
-
contains
Checks whether a file is stored in the storage or not.- Parameters:
file
- the file we are looking for- Returns:
- true if the file is in the storage, false otherwise
-
contains
Checks whether a file exists in the storage or not.- Parameters:
fileName
- the name of the file we are looking for- Returns:
- true if the file is in the storage, false otherwise
-
renameFile
Renames a file on the storage. The time taken (in seconds) for renaming the specified file can also be found usingFile.getTransactionTime()
.- Parameters:
file
- the file we would like to renamenewName
- the new name of the file- Returns:
- true if the renaming succeeded, false otherwise
-