GridSim 5.0 beta

gridsim.datagrid.storage
Class TapeStorage

Object
  extended by TapeStorage
All Implemented Interfaces:
Storage

public class TapeStorage
extends Object
implements Storage

An implementation of a tape storage system. It simulates the behaviour of a typical tape storage with the following assumptions:

  1. a constant operation for rewind, access and transfer time
  2. for every operation, the tape needs to be rewinded to the front
  3. a tape is supposed to be for backup purposes, once it is full, individual files can't be deleted unless the tape is cleared

The default values for this storage are those of a HP Ultrium tape with the following parameters:

Since:
GridSim Toolkit 4.0
Author:
Uros Cibej and Anthony Sulistio
See Also:
Storage

Constructor Summary
TapeStorage(double capacity)
          Constructs a new tape storage with a given capacity.
TapeStorage(String name, double capacity)
          Constructs a new tape storage with a given name and capacity.
 
Method Summary
 double addFile(File file)
          Adds a file to the storage.
 double addFile(List 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 certain file is on the storage or not.
 boolean contains(String fileName)
          Checks whether a certain file is on the storage or not.
 double deleteFile(File file)
          Removes a file from the storage -- NOT SUPPORTED.
NOTE: a tape is supposed to be for backup purposes, once it is full, individual files can't be deleted unless the tape is cleared.
 File deleteFile(String fileName)
          Removes a file from the storage -- NOT SUPPORTED.
NOTE: a tape is supposed to be for backup purposes, once it is full, individual files can't be deleted unless the tape is cleared.
 double deleteFile(String fileName, File file)
          Removes a file from the storage -- NOT SUPPORTED.
NOTE: a tape is supposed to be for backup purposes, once it is full, individual files can't be deleted unless the tape is cleared.
 double getAvailableSpace()
          Gets the available space on this storage in MB.
 double getCapacity()
          Gets the total capacity of the storage in MB.
 double getCurrentSize()
          Gets the current size of the stored files in MB.
 File getFile(String fileName)
          Gets the file with the specified name.
 List getFileNameList()
          Gets the list of file names located on this storage.
 double getMaxTransferRate()
          Gets the maximum transfer rate of the storage in MB/sec.
 String getName()
          Gets the name of the storage.
 int getNumStoredFile()
          Gets the number of files stored on this storage.
 int getTotalAccessTime()
          Gets the total access time of this tape drive in seconds.
 int getTotalRewindTime()
          Gets the total rewind time of the tape in seconds.
 boolean hasPotentialAvailableSpace(int fileSize)
          Checks whether there is enough space on the storage for a certain file.
 boolean isFull()
          Checks if the storage is full or not.
 boolean renameFile(File file, String newName)
          Renames a file on the storage.
 boolean reserveSpace(int fileSize)
          Makes a reservation of the space on the storage to store a file.
 boolean setMaxTransferRate(int rate)
          Sets the maximum transfer rate of this storage system in MB/sec.
 boolean setTotalAccessTime(int time)
          Sets the total access time for this tape in seconds.
 boolean setTotalRewindTime(int time)
          Sets the total rewind time of the tape.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TapeStorage

public TapeStorage(String name,
                   double capacity)
            throws ParameterException
Constructs a new tape storage with a given name and capacity.

Parameters:
name - the name of the new tape drive
capacity - the capacity in MB
Throws:
ParameterException - when the name and the capacity are not valid

TapeStorage

public TapeStorage(double capacity)
            throws ParameterException
Constructs a new tape storage with a given capacity. In this case the name of the storage is a default name.

Parameters:
capacity - the capacity in MB
Throws:
ParameterException - when the capacity is not valid
Method Detail

getAvailableSpace

public double getAvailableSpace()
Gets the available space on this storage in MB.

Specified by:
getAvailableSpace in interface Storage
Returns:
the available space in MB

isFull

public boolean isFull()
Checks if the storage is full or not.

Specified by:
isFull in interface Storage
Returns:
true if the storage is full, false otherwise

getNumStoredFile

public int getNumStoredFile()
Gets the number of files stored on this storage.

Specified by:
getNumStoredFile in interface Storage
Returns:
the number of stored files

reserveSpace

public boolean reserveSpace(int fileSize)
Makes a reservation of the space on the storage to store a file.

Specified by:
reserveSpace in interface Storage
Parameters:
fileSize - the size to be reserved in MB
Returns:
true if reservation succeeded, false otherwise

addReservedFile

public double addReservedFile(File file)
Adds a file for which the space has already been reserved. The time taken (in seconds) for adding the file can also be found using File.getTransactionTime().

Specified by:
addReservedFile in interface Storage
Parameters:
file - the file to be added
Returns:
the time (in seconds) required to add the file

hasPotentialAvailableSpace

public boolean hasPotentialAvailableSpace(int fileSize)
Checks whether there is enough space on the storage for a certain file.

Specified by:
hasPotentialAvailableSpace in interface Storage
Parameters:
fileSize - a FileAttribute object to compare to
Returns:
true if enough space available, false otherwise

getCapacity

public double getCapacity()
Gets the total capacity of the storage in MB.

Specified by:
getCapacity in interface Storage
Returns:
the capacity of the storage in MB

getCurrentSize

public double getCurrentSize()
Gets the current size of the stored files in MB.

Specified by:
getCurrentSize in interface Storage
Returns:
the current size of the stored files in MB

getName

public String getName()
Gets the name of the storage.

Specified by:
getName in interface Storage
Returns:
the name of this storage

getTotalAccessTime

public int getTotalAccessTime()
Gets the total access time of this tape drive in seconds.

Returns:
the total access time in seconds

setTotalAccessTime

public boolean setTotalAccessTime(int time)
Sets the total access time for this tape in seconds.

Parameters:
time - the total access time in seconds
Returns:
true if the setting succeeds, false otherwise

getMaxTransferRate

public double getMaxTransferRate()
Gets the maximum transfer rate of the storage in MB/sec.

Specified by:
getMaxTransferRate in interface Storage
Returns:
the maximum transfer rate in MB/sec

setMaxTransferRate

public boolean setMaxTransferRate(int rate)
Sets the maximum transfer rate of this storage system in MB/sec.

Specified by:
setMaxTransferRate in interface Storage
Parameters:
rate - the maximum transfer rate in MB/sec
Returns:
true if the setting succeeded, false otherwise

setTotalRewindTime

public boolean setTotalRewindTime(int time)
Sets the total rewind time of the tape. The total rewind time is the time needed to rewind the tape from the end to the beginning.

Parameters:
time - the total rewind time in seconds
Returns:
true if the setting succeeded, false otherwise

getTotalRewindTime

public int getTotalRewindTime()
Gets the total rewind time of the tape in seconds.

Returns:
the total rewind time in seconds

getFile

public File getFile(String fileName)
Gets the file with the specified name. The time taken (in seconds) for getting the file can also be found using File.getTransactionTime().

Specified by:
getFile in interface Storage
Parameters:
fileName - the name of the needed file
Returns:
the file with the specified filename

getFileNameList

public List getFileNameList()
Gets the list of file names located on this storage.

Specified by:
getFileNameList in interface Storage
Returns:
a LinkedList of file names

addFile

public double addFile(File file)
Adds a file to the storage. First the method checks if there is enough space on the storage, then it checks if the file with the same name is already taken to avoid duplicate filenames.
The time taken (in seconds) for adding the file can also be found using File.getTransactionTime().

Specified by:
addFile in interface Storage
Parameters:
file - the file to be added
Returns:
the time taken (in seconds) for adding the specified file

addFile

public double addFile(List list)
Adds a set of files to the storage. Run through the list of files and save all of them. The time taken (in seconds) for adding each file can also be found using File.getTransactionTime().

Specified by:
addFile in interface Storage
Parameters:
list - the files to be added
Returns:
the time taken (in seconds) for adding the specified files

deleteFile

public File deleteFile(String fileName)
Removes a file from the storage -- NOT SUPPORTED.
NOTE: a tape is supposed to be for backup purposes, once it is full, individual files can't be deleted unless the tape is cleared.

Specified by:
deleteFile in interface Storage
Parameters:
fileName - the name of the file to be removed
Returns:
null

deleteFile

public double deleteFile(String fileName,
                         File file)
Removes a file from the storage -- NOT SUPPORTED.
NOTE: a tape is supposed to be for backup purposes, once it is full, individual files can't be deleted unless the tape is cleared.

Specified by:
deleteFile in interface Storage
Parameters:
fileName - the name of the file to be removed
file - the file which is removed from the storage is returned through this parameter
Returns:
the time taken (in seconds) for deleting the specified file

deleteFile

public double deleteFile(File file)
Removes a file from the storage -- NOT SUPPORTED.
NOTE: a tape is supposed to be for backup purposes, once it is full, individual files can't be deleted unless the tape is cleared.

Specified by:
deleteFile in interface Storage
Parameters:
file - the file which is removed from the storage is returned through this parameter
Returns:
the time taken (in seconds) for deleting the specified file

contains

public boolean contains(String fileName)
Checks whether a certain file is on the storage or not.

Specified by:
contains in interface Storage
Parameters:
fileName - the name of the file we are looking for
Returns:
true if the file is in the storage, false otherwise

contains

public boolean contains(File file)
Checks whether a certain file is on the storage or not.

Specified by:
contains in interface Storage
Parameters:
file - the file we are looking for
Returns:
true if the file is in the storage, false otherwise

renameFile

public boolean renameFile(File file,
                          String newName)
Renames a file on the storage. The time taken (in seconds) for renaming the file can also be found using File.getTransactionTime().

Specified by:
renameFile in interface Storage
Parameters:
file - the file we would like to rename
newName - the new name of the file
Returns:
true if the renaming succeeded, false otherwise

GridSim 5.0 beta

The University of Melbourne, Australia, 2009