|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectstorage.primitiveStorage.PrimitiveStorageManager
This class is used to manage the operatios of a primitive storage component. The primitive storage component controls the access to secundary storage manager (using chunks) and the intermediate memory (using a buffer). In the primitive storage component the page is the minimum storage unit.
Nested Class Summary | |
class |
PrimitiveStorageManager.Chunk
A chunks is a part of secundary storage. |
class |
PrimitiveStorageManager.ChunkNumberIterator
This class is used to retrieve the used chunk numbers. |
class |
PrimitiveStorageManager.ChunksTable
This class represents the chunk's table, i.e. a set of number-chunk pairs. |
class |
PrimitiveStorageManager.FixedChunk
Fixed chunks are used to storage information in files which size is considered fixed. |
class |
PrimitiveStorageManager.FlexibleChunk
Flexible chunks are used to storage information in files which size can grow or decrease. |
Field Summary | |
static int |
CLOCK_ALGORITHM
Represents the Clock or LRU with second chance replace algorithm. |
static int |
DEFAULT_PAGE_SIZE
The default page size if other is not specified. |
static int |
FIFO_ALGORITHM
Represents the FIFO (First In First Out) replace algorithm. |
static int |
LIFO_ALGORITHM
Represents the LIFO (Last In First Out) replace algorithm. |
static int |
LRU_ALGORITHM
Represents the LRU (Least Recent Used) replace algorithm. |
static long |
MAX_CHUNK_NUMBER
The maximum number which a chunk can be associated. |
static long |
MAX_CHUNK_SIZE
The maximum size of a chunk. |
static int |
MIN_PAGE_SIZE
The manimum size of a page. |
static int |
MRU_ALGORITHM
Represents the MRU (Most Recent Used) replace algorithm. |
Constructor Summary | |
PrimitiveStorageManager()
Constructs a primitive storage manager with the default page size and with no actived buffer. |
|
PrimitiveStorageManager(int pageSize)
Constructs a primitive storage manager with a specific page size (in bytes) and with no actived buffer. |
|
PrimitiveStorageManager(int pageSize,
int bufferSize)
Constructs a primitive storage manager with a specific page size (in bytes), a specific buffer size (in bytes) and the LRU replace algorithm. |
|
PrimitiveStorageManager(int pageSize,
int bufferSize,
int replaceAlgorithm)
Constructs a primitive storage manager with a specific page size (in bytes), a specific buffer size (in bytes) and a specific replace algorithm. |
Method Summary | |
void |
activeBuffer()
Actives the buffer. |
void |
closeAll()
Closes all files used in this component. |
void |
deactiveBuffer()
Deactives the buffer. |
PrimitiveStorageManager.Chunk |
getChunk(int chunkNumber)
Returns the chunk with the specified number. |
PrimitiveStorageManager.ChunkNumberIterator |
getChunkNumbers()
Returns the sequence of used chunk numbers. |
int |
getPageSize()
Return the used page size (in bytes). |
void |
loadFixedChunk(int chunkNumber,
java.io.File fileName,
long offset,
long maxSize)
Load a fixed chunk with a specified chunk number. |
void |
loadFlexibleChunk(int chunkNumber,
java.io.File fileName)
Load a flexible chunk with a specified chunk number, the default maximum size and keeping the previous file's content. |
void |
loadFlexibleChunk(int chunkNumber,
java.io.File fileName,
boolean overwrite)
Load a flexible chunk with a specified chunk number and the default maximum size. |
void |
loadFlexibleChunk(int chunkNumber,
java.io.File fileName,
long maxSize,
boolean overwrite)
Load a flexible chunk with a specified chunk number. |
void |
readPage(int chunkNumber,
long pageNumber,
byte[] b)
Read a specified page in a specified chunk and copies its content in an array. |
void |
removeChunk(int chunkNumber)
Removes the chunk with the specified number. |
void |
show()
Shows information about this component. |
void |
transferAndClearBuffer()
Copies the buffer's content to the secundary storage and clean the buffer. |
void |
transferBuffer()
Copies the buffer's content to the secundary storage. |
void |
writePage(int chunkNumber,
long pageNumber,
byte[] b)
Write a specified page in a specified chunk and copies its content from an array. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final long MAX_CHUNK_SIZE
public static final int MIN_PAGE_SIZE
public static final long MAX_CHUNK_NUMBER
public static final int DEFAULT_PAGE_SIZE
public static final int LRU_ALGORITHM
public static final int CLOCK_ALGORITHM
public static final int FIFO_ALGORITHM
public static final int MRU_ALGORITHM
public static final int LIFO_ALGORITHM
Constructor Detail |
public PrimitiveStorageManager(int pageSize, int bufferSize, int replaceAlgorithm) throws InvalidPageSizeException, InvalidBufferCapacityException
public PrimitiveStorageManager(int pageSize, int bufferSize) throws InvalidPageSizeException, InvalidBufferCapacityException
public PrimitiveStorageManager(int pageSize) throws InvalidPageSizeException
public PrimitiveStorageManager()
Method Detail |
public void activeBuffer()
public void deactiveBuffer() throws java.io.IOException
java.io.IOException
public void loadFixedChunk(int chunkNumber, java.io.File fileName, long offset, long maxSize) throws InvalidChunkNumberException, AlreadyExistingChunkNumberException, InvalidChunkSizeException, InvalidChunkOffsetException, UnaddressableChunkException, java.io.FileNotFoundException
chunkNumber
- The number which the chunk will be identified.fileName
- The file to be used by the chunk.offset
- The offset in the file when the chunk starts.maxSize
- The maximun size that the chunk can occup.
InvalidChunkNumberException
AlreadyExistingChunkNumberException
InvalidChunkSizeException
InvalidChunkOffsetException
UnaddressableChunkException
java.io.FileNotFoundException
public void loadFlexibleChunk(int chunkNumber, java.io.File fileName, long maxSize, boolean overwrite) throws InvalidChunkNumberException, AlreadyExistingChunkNumberException, java.io.FileNotFoundException, InvalidChunkSizeException, java.io.IOException
chunkNumber
- The number which the chunk will be identified.fileName
- The file to be used by the chunk.maxSize
- The maximun size that the chunk can grow.overwrite
- If it is false
the files's content will not be changed,
if it is true
the files's content will be erased.
InvalidChunkNumberException
AlreadyExistingChunkNumberException
java.io.FileNotFoundException
InvalidChunkSizeException
java.io.IOException
public void loadFlexibleChunk(int chunkNumber, java.io.File fileName, boolean overwrite) throws InvalidChunkNumberException, AlreadyExistingChunkNumberException, java.io.FileNotFoundException, java.io.IOException
chunkNumber
- The number which the chunk will be identified.fileName
- The file to be used by the chunk.overwrite
- If it is false
the files's content will not be changed,
if it is true
the files's content will be erased.
InvalidChunkNumberException
AlreadyExistingChunkNumberException
java.io.FileNotFoundException
java.io.IOException
public void loadFlexibleChunk(int chunkNumber, java.io.File fileName) throws InvalidChunkNumberException, AlreadyExistingChunkNumberException, java.io.FileNotFoundException
chunkNumber
- The number which the chunk will be identified.fileName
- The file to be used by the chunk.
InvalidChunkNumberException
AlreadyExistingChunkNumberException
java.io.FileNotFoundException
public void removeChunk(int chunkNumber) throws NotExistingChunkNumberException
chunkNumber
- The number of the chunk to be removed.
NotExistingChunkNumberException
public PrimitiveStorageManager.Chunk getChunk(int chunkNumber)
chunkNumber
- The number of the chunk to be retrieved.
Chunk
object requested.public void transferBuffer() throws java.io.IOException
java.io.IOException
public void transferAndClearBuffer() throws java.io.IOException
java.io.IOException
public void readPage(int chunkNumber, long pageNumber, byte[] b) throws NotExistingChunkNumberException, PageNumberOutOfRangeException, java.io.IOException
chunkNumber
- The chunk number in which the page is.pageNumber
- The number of the page inside the chunk.b
- The byte array in which the page's content will be copied.
NotExistingChunkNumberException
PageNumberOutOfRangeException
java.io.IOException
public void writePage(int chunkNumber, long pageNumber, byte[] b) throws NotExistingChunkNumberException, PageNumberOutOfRangeException, java.io.IOException
chunkNumber
- The chunk number in which the page is.pageNumber
- The number of the page inside the chunk.b
- The byte array from which the page's content will be copied.
NotExistingChunkNumberException
PageNumberOutOfRangeException
java.io.IOException
public int getPageSize()
public PrimitiveStorageManager.ChunkNumberIterator getChunkNumbers()
public void closeAll()
public void show() throws java.io.IOException
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |