@InterfaceAudience.Private public class FileIOEngine extends PersistentIOEngine
Modifier and Type | Class and Description |
---|---|
private static interface |
FileIOEngine.FileAccessor |
private static class |
FileIOEngine.FileReadAccessor |
private static class |
FileIOEngine.FileWriteAccessor |
Modifier and Type | Field and Description |
---|---|
private long |
capacity |
private ReentrantLock[] |
channelLocks |
static String |
FILE_DELIMITER |
private FileChannel[] |
fileChannels |
private static org.slf4j.Logger |
LOG |
private RandomAccessFile[] |
rafs |
private FileIOEngine.FileReadAccessor |
readAccessor |
private long |
sizePerFile |
private FileIOEngine.FileWriteAccessor |
writeAccessor |
filePaths
Constructor and Description |
---|
FileIOEngine(long capacity,
boolean maintainPersistence,
String... filePaths) |
Modifier and Type | Method and Description |
---|---|
private void |
accessFile(FileIOEngine.FileAccessor accessor,
ByteBuff buff,
long globalOffset) |
(package private) void |
closeFileChannels() |
private long |
getAbsoluteOffsetInFile(int fileNum,
long globalOffset)
Get the absolute offset in given file with the relative global offset.
|
(package private) FileChannel[] |
getFileChannels() |
private int |
getFileNum(long offset) |
boolean |
isPersistent()
File IO engine is always able to support persistent storage for the cache n
|
Cacheable |
read(BucketEntry be)
Transfers data from file to the given byte buffer
|
(package private) void |
refreshFileConnection(int accessFileNum,
IOException ioe) |
void |
shutdown()
Close the file
|
void |
sync()
Sync the data to file after writing n
|
String |
toString() |
void |
write(ByteBuffer srcBuffer,
long offset)
Transfers data from the given byte buffer to file
|
void |
write(ByteBuff srcBuff,
long offset)
Transfers the data from the given MultiByteBuffer to IOEngine
|
calculateChecksum, verifyFileIntegrity
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
usesSharedMemory
private static final org.slf4j.Logger LOG
public static final String FILE_DELIMITER
private final FileChannel[] fileChannels
private final RandomAccessFile[] rafs
private final ReentrantLock[] channelLocks
private final long sizePerFile
private final long capacity
private FileIOEngine.FileReadAccessor readAccessor
private FileIOEngine.FileWriteAccessor writeAccessor
public FileIOEngine(long capacity, boolean maintainPersistence, String... filePaths) throws IOException
IOException
public boolean isPersistent()
public Cacheable read(BucketEntry be) throws IOException
be
- an BucketEntry
which maintains an (offset, len, refCnt)Cacheable
with block data inside.IOException
- if any IO error happen.void closeFileChannels()
public void write(ByteBuffer srcBuffer, long offset) throws IOException
srcBuffer
- the given byte buffer from which bytes are to be readoffset
- The offset in the file where the first byte to be written nIOException
public void sync() throws IOException
IOException
public void shutdown()
public void write(ByteBuff srcBuff, long offset) throws IOException
IOEngine
srcBuff
- the given MultiBytebufffers from which bytes are to be readoffset
- the offset in the IO engine where the first byte to be written nIOException
private void accessFile(FileIOEngine.FileAccessor accessor, ByteBuff buff, long globalOffset) throws IOException
IOException
private long getAbsoluteOffsetInFile(int fileNum, long globalOffset)
private int getFileNum(long offset)
FileChannel[] getFileChannels()
void refreshFileConnection(int accessFileNum, IOException ioe) throws IOException
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.