@Beta public class JCloudsStorageModule extends Object implements IStorageModule
| Modifier and Type | Field and Description |
|---|---|
static int |
BLOCK_IN_CLUSTER
Number of Blocks in one Cluster.
|
static String |
CONTAINERNAME |
static int |
SIZE_PER_BUCKET
Number of Bytes in Bucket.
|
VIRTUAL_BLOCK_SIZE| Constructor and Description |
|---|
JCloudsStorageModule(long pSizeInBlocks,
File pFile)
Creates a new
JCloudsStorageModule backed by the specified file. |
| Modifier and Type | Method and Description |
|---|---|
int |
checkBounds(long logicalBlockAddress,
int transferLengthInBlocks)
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()
Closing the storage.
|
long |
getSizeInBlocks()
Returns the storage space size in bytes divided by the block size in bytes (rounded down).
|
void |
read(byte[] bytes,
long storageIndex)
Copies bytes from storage to the passed byte array.
|
void |
write(byte[] bytes,
long storageIndex)
Saves part of the passed byte array's content.
|
public static final int BLOCK_IN_CLUSTER
public static final int SIZE_PER_BUCKET
public static final String CONTAINERNAME
public JCloudsStorageModule(long pSizeInBlocks,
File pFile)
JCloudsStorageModule backed by the specified file. If no such file exists, a
FileNotFoundException will be thrown.pSizeInBlocks - blocksize for this modulepFile - local storage, not used over herepublic 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 read(byte[] bytes,
long storageIndex)
throws IOException
read in interface IStorageModulebytes - the array into which the data will be copied will be filled with data from storagestorageIndex - the position of the first byte to be copiedIOExceptionpublic void write(byte[] bytes,
long storageIndex)
throws IOException
write in interface IStorageModulebytes - the source of the data to be storedstorageIndex - byte offset in the storage areaExceptionIOExceptionpublic void close()
throws IOException
close in interface IStorageModuleIOException - to be closedCopyright © 2013 University of Konstanz, Distributed Systems Group. All Rights Reserved.