public class OpenFileCache extends Object
Constructor and Description |
---|
OpenFileCache(int maxOpenFiles)
Construct an LRU cache for managing open files
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close all open files in this storage system.
|
void |
close(FileCacheKey key)
Close the file associated with this cache key if it is open
|
boolean |
existsOnFileSystem(FileCacheKey key)
Check if the the File exists on the file system.
|
void |
flush()
Flush all buffered data to the file system
|
int |
readBlock(FileCacheKey key,
ByteBuffer buffer,
long offset)
Read a block from the provided file cache key
|
void |
readBlockFully(FileCacheKey key,
ByteBuffer buffer,
long offset)
Fully read a block from the provided file cache key
|
long |
size(FileCacheKey key)
Get the size of the file referred to by key on disk
|
int |
writeBlock(FileCacheKey key,
ByteBuffer buffer,
long offset)
Write a block to the provided file cache key
|
int |
writeBlock(FileCacheKey key,
ByteBufferView buffer,
long offset)
Write a block to the provided file cache key
|
void |
writeBlockFully(FileCacheKey key,
ByteBuffer buffer,
long offset)
Fully write a block from the provided file cache key
|
void |
writeBlockFully(FileCacheKey key,
ByteBufferView buffer,
long offset)
Fully write a block from the provided file cache key
|
public OpenFileCache(int maxOpenFiles)
maxOpenFiles
- the max number of permitted open filespublic int readBlock(FileCacheKey key, ByteBuffer buffer, long offset)
key
- the key that references the files to read the block forbuffer
- the buffer to read the block intooffset
- the offset of the blockpublic void readBlockFully(FileCacheKey key, ByteBuffer buffer, long offset)
key
- the key that references the files to read the block forbuffer
- the buffer to read the block intooffset
- the offset of the blockpublic int writeBlock(FileCacheKey key, ByteBuffer buffer, long offset)
key
- the key that references the files to write the block forbuffer
- the buffer to write the block intooffset
- the offset of the blockpublic void writeBlockFully(FileCacheKey key, ByteBuffer buffer, long offset)
key
- the key that references the files to write the block forbuffer
- the buffer to write the block intooffset
- the offset of the blockpublic int writeBlock(FileCacheKey key, ByteBufferView buffer, long offset)
key
- the key that references the files to write the block forbuffer
- the buffer to write the block intooffset
- the offset of the blockpublic void writeBlockFully(FileCacheKey key, ByteBufferView buffer, long offset)
key
- the key that references the files to write the block forbuffer
- the buffer to write the block intooffset
- the offset of the blockpublic long size(FileCacheKey key)
key
- the key of the filepublic void flush()
public boolean existsOnFileSystem(FileCacheKey key)
key
- the key to check whether exists on the file systempublic void close(FileCacheKey key) throws IOException
key
- the key of the file to closeIOException
- on failure to closepublic void close() throws IOException
IOException
- on failure to close fileCopyright © 2016–2021. All rights reserved.