Package org.cloudbus.cloudsim.resources
Interface FileStorage
- All Superinterfaces:
Resource
,ResourceCapacity
- All Known Implementing Classes:
HarddriveStorage
,SanStorage
public interface FileStorage extends Resource
An interface which defines the desired functionality of a storage system in a Data Cloud
that performs operations on a file system, such as file inclusion, exclusion
and renaming.
Classes that implement this interface should simulate the characteristics of different storage
systems by setting the capacity of the storage and the maximum transfer rate. The transfer rate
defines the time required to execute some common operations on the storage, e.g. storing a file,
getting a file and deleting a file.
- Author:
- Uros Cibej, Anthony Sulistio, Manoel Campos da Silva Filho
-
Field Summary
Fields Modifier and Type Field Description static int
FILE_NOT_FOUND
-
Method Summary
Modifier and Type Method Description double
addFile(List<File> list)
Adds a set of files to the storage.double
addFile(File file)
Adds a file to the storage.double
addReservedFile(File file)
Adds a file for which the space has already been reserved.boolean
contains(String fileName)
Checks whether a file exists in the storage or not.boolean
contains(File file)
Checks whether a file is stored in the storage or not.File
deleteFile(String fileName)
Removes a file from the storage.double
deleteFile(File file)
Removes a file from the storage.File
getFile(String fileName)
Gets the file with the specified name.List<File>
getFileList()
Gets a read-only list with all files stored on the device.List<String>
getFileNameList()
Gets a read-only list with the names of all files stored on the device.double
getLatency()
Gets the latency of this hard drive in seconds.double
getMaxTransferRate()
Gets the maximum local transfer rate of the storage in Mega-bits/sec, i.e., the physical device reading speed.String
getName()
int
getNumStoredFile()
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
hasFile(String fileName)
Checks if the storage device has a specific file.boolean
hasPotentialAvailableSpace(int 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.void
setLatency(double latency)
Sets the latency of this hard drive in seconds.void
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 interface org.cloudbus.cloudsim.resources.Resource
getAllocatedResource, getAvailableResource, getPercentUtilization, isAmountAvailable, isAmountAvailable, isAmountAvailable, isFull, isSubClassOf
Methods inherited from interface org.cloudbus.cloudsim.resources.ResourceCapacity
getCapacity
-
Field Details
-
FILE_NOT_FOUND
static final int FILE_NOT_FOUND- See Also:
- Constant Field Values
-
-
Method Details
-
getName
String getName()- Returns:
- the name of the storage device
-
getMaxTransferRate
double getMaxTransferRate()Gets the maximum local transfer rate of the storage in Mega-bits/sec, i.e., the physical device reading speed.- Returns:
- the maximum transfer rate in Mega-bits/sec
- See Also:
setMaxTransferRate(double)
-
setMaxTransferRate
void setMaxTransferRate(double maxTransferRate)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.- Parameters:
maxTransferRate
- the maximum transfer rate in Mbits/sec- Throws:
IllegalArgumentException
- if the value is lower than 1
-
setLatency
void setLatency(double latency)Sets the latency of this hard drive in seconds.- Parameters:
latency
- the new latency in seconds- Throws:
IllegalArgumentException
- if the value is lower than 0
-
getLatency
double getLatency()Gets the latency of this hard drive in seconds.- Returns:
- the latency in seconds
-
getNumStoredFile
int getNumStoredFile()Gets the number of files stored on this device.- Returns:
- the number of stored files
-
reserveSpace
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
-
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
-
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:
- the file with the specified filename; null if not found
-
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:
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
-
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
double getTransferTime(int fileSize)Gets the transfer time of a given file.- Parameters:
fileSize
- the size of the file to compute the transfer time (in MByte)- Returns:
- the transfer time in seconds
-
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.
-
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.
-
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:
- the deleted file.
-
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 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
-
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
-
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
-
hasPotentialAvailableSpace
boolean hasPotentialAvailableSpace(int 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.
-