@Deprecated public class FileStorageModule extends Object implements IStorageModule
VIRTUAL_BLOCK_SIZE| Constructor and Description |
|---|
FileStorageModule(String pBaseDir,
long pStorageSize,
int pFileSize)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
int |
checkBounds(long logicalBlockAddress,
int transferLengthInBlocks)
Deprecated.
This method can be used for checking if a (series of) I/O operations will result in an
IOException due to
trying to access blocks outside the medium's boundaries. |
void |
close()
Deprecated.
Closing the storage.
|
long |
getSizeInBlocks()
Deprecated.
Returns the storage space size in bytes divided by the block size in bytes (rounded down).
|
void |
read(byte[] bytes,
long storageIndex)
Deprecated.
Reading bytes from file
|
void |
write(byte[] bytes,
long storageIndex)
Deprecated.
Writing into a file.
|
public FileStorageModule(String pBaseDir, long pStorageSize, int pFileSize) throws IOException
pBaseDir - - The root directory for the filestorage (will be created if not exists)pStorageSize - - The size of the storagepFileSize - - The size of each fileIOExceptionpublic void read(byte[] bytes,
long storageIndex)
throws IOException
read in interface IStorageModulebytes - storageIndex - IOExceptionpublic void write(byte[] bytes,
long storageIndex)
throws IOException
write in interface IStorageModulebytes - storageIndex - IOExceptionpublic int checkBounds(long logicalBlockAddress,
int transferLengthInBlocks)
IOException due to
trying to access blocks outside the medium's boundaries.
The SCSI standard requires checking for these boundary violations right after receiving a read or write command, so that an appropriate error message can be returned to the initiator. Therefore this method must be called prior to each read or write sequence.
The values returned by this method and their meaning with regard to the interval [0, IStorageModule.getSizeInBlocks() -
1] are shown in the following table:
| Return Value | Meaning |
|---|---|
| 0 | no boundaries are violated |
| 1 | the logicalBlockAddress parameter lies outside of the interval |
| 2 | the interval [logicalBlockAddress, logicalBlockAddress + transferLengthInBlocks] lies outside of the interval, or transferLengthInBlocks is negative |
Note that the parameters of this method are referring to blocks, not to byte indices.
checkBounds in interface IStorageModulelogicalBlockAddress - the index of the first block of data to be read or writtentransferLengthInBlocks - the total number of consecutive blocks about to be read or writtenpublic long getSizeInBlocks()
getSizeInBlocks in interface IStorageModulepublic void close()
throws IOException
close in interface IStorageModuleIOException - to be closedCopyright © 2013 University of Konstanz, Distributed Systems Group. All Rights Reserved.