public class SanStorage extends HarddriveStorage
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.
Modifier and Type | Field and Description |
---|---|
static int |
FILE_NOT_FOUND |
DEF_LATENCY_SECS, DEF_MAX_TRANSFER_RATE_MBITS_SEC, DEF_SEEK_TIME_SECS, LOGGER, NULL
Constructor and Description |
---|
SanStorage(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.
|
Modifier and Type | Method and Description |
---|---|
double |
addFile(File file)
Adds a file to the storage.
|
double |
addFile(List<File> list)
Adds a set of files to the storage.
|
double |
addReservedFile(File file)
Adds a file for which the space has already been reserved.
|
boolean |
contains(File file)
Checks whether a file is stored in the storage or not.
|
boolean |
contains(String fileName)
Checks whether a file exists in the storage or not.
|
double |
deleteFile(File file)
Removes a file from the storage.
|
File |
deleteFile(String fileName)
Removes a file from the storage.
|
double |
getBandwidth()
Gets the bandwidth of the SAN network (in Megabits/s).
|
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 |
getNetworkLatency()
Gets the SAN's network latency (in seconds).
|
int |
getNumStoredFile()
Gets the number of files stored on this device.
|
double |
getTransferTime(File file)
Gets the transfer time of a given file.
|
double |
getTransferTime(int fileSize)
Gets the transfer time of a given file.
|
double |
getTransferTime(String fileName)
Gets the transfer time of a given file.
|
boolean |
hasFile(String fileName)
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 file
|
boolean |
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 |
setBandwidth(double bandwidth)
Sets the bandwidth of the SAN network (in Megabits/s).
|
void |
setNetworkLatency(double networkLatency)
Sets the latency of the SAN network (in seconds).
|
String |
toString() |
getAllocatedResource, getAvailableResource, getAvgSeekTime, getCapacity, getLatency, getMaxTransferRate, getName, getSeekTime, getStorage, getTransferTime, getUnit, isAmountAvailable, isAmountAvailable, isFull, setAvgSeekTime, setAvgSeekTime, setLatency, setMaxTransferRate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getPercentUtilization, isAmountAvailable, isSubClassOf
public static final int FILE_NOT_FOUND
public SanStorage(long capacity, double bandwidth, double networkLatency) throws IllegalArgumentException
capacity
- Total storage capacity of the SANbandwidth
- Network bandwidth (in Megabits/s)networkLatency
- Network latency (in seconds)IllegalArgumentException
- when the name and the capacity are not validpublic SanStorage(String name, long capacity, double bandwidth, double networkLatency)
name
- the name of the new storage devicecapacity
- Storage device capacitybandwidth
- Network bandwidth (in Megabits/s)networkLatency
- Network latency (in seconds)IllegalArgumentException
- when the name and the capacity are not validpublic double addReservedFile(File file)
File.getTransactionTime()
.file
- the file to be addedpublic double addFile(File file)
File.getTransactionTime()
.file
- the file to be addedpublic double getTransferTime(int fileSize)
getTransferTime
in interface FileStorage
getTransferTime
in class HarddriveStorage
fileSize
- the size of the file to compute the transfer time (in MByte)public double deleteFile(File file)
File.getTransactionTime()
.file
- the file to be removedpublic double getBandwidth()
public final void setBandwidth(double bandwidth)
bandwidth
- the bandwidth to set (in Megabits/s)IllegalArgumentException
- when the bandwidth is lower or equal to zeropublic double getNetworkLatency()
public final void setNetworkLatency(double networkLatency)
networkLatency
- the latency to set (in seconds)IllegalArgumentException
- when the latency is lower or equal to zeropublic double addFile(List<File> list)
File.getTransactionTime()
.list
- the files to be addedpublic int getNumStoredFile()
public boolean reserveSpace(int fileSize)
fileSize
- the size to be reserved (in MByte)public boolean hasPotentialAvailableSpace(long fileSize)
fileSize
- size of the file intended to be stored on the device (in MByte)public boolean hasFile(String fileName)
fileName
- the name of the file to check if it's contained in this storage device.public File getFile(String fileName)
File.getTransactionTime()
.fileName
- the name of the needed filepublic List<String> getFileNameList()
public List<File> getFileList()
public double getTransferTime(String fileName)
fileName
- the name of the file to compute the transfer time (where its size is defined in MByte)FILE_NOT_FOUND
if the file was not found in this storage devicepublic double getTransferTime(File file)
file
- the file to compute the transfer time (where its size is defined in MByte)public File deleteFile(String fileName)
File.getTransactionTime()
.fileName
- the name of the file to be removedpublic boolean contains(String fileName)
fileName
- the name of the file we are looking forpublic boolean contains(File file)
file
- the file we are looking forpublic boolean renameFile(File file, String newName)
File.getTransactionTime()
.file
- the file we would like to renamenewName
- the new name of the fileCopyright © 2015–2021 Systems, Security and Image Communication Lab - Instituto de Telecomunicações (IT) - Universidade da Beira Interior (UBI) - Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO). All rights reserved.