@InterfaceAudience.Private public class FileIOEngine extends Object implements PersistentIOEngine
Modifier and Type | Field and Description |
---|---|
static String |
FILE_DELIMITER |
Constructor and Description |
---|
FileIOEngine(long capacity,
String... filePaths) |
Modifier and Type | Method and Description |
---|---|
byte[] |
calculateChecksum(String algorithm)
Using an encryption algorithm to calculate a checksum, the default encryption algorithm is MD5
|
boolean |
isPersistent()
File IO engine is always able to support persistent storage for the cache
|
int |
read(ByteBuffer dstBuffer,
long offset)
Transfers data from file to the given byte buffer
|
void |
shutdown()
Close the file
|
void |
sync()
Sync the data to file after writing
|
String |
toString() |
boolean |
verifyFileIntegrity(byte[] persistentChecksum,
String algorithm)
Verify cache files's integrity
|
void |
write(ByteBuffer srcBuffer,
long offset)
Transfers data from the given byte buffer to file
|
public static final String FILE_DELIMITER
public FileIOEngine(long capacity, String... filePaths) throws IOException
IOException
public boolean verifyFileIntegrity(byte[] persistentChecksum, String algorithm)
PersistentIOEngine
verifyFileIntegrity
in interface PersistentIOEngine
persistentChecksum
- the persistent checksumalgorithm
- which algorithm to calculate checksumpublic boolean isPersistent()
isPersistent
in interface IOEngine
public int read(ByteBuffer dstBuffer, long offset) throws IOException
read
in interface IOEngine
dstBuffer
- the given byte buffer into which bytes are to be writtenoffset
- The offset in the file where the first byte to be readIOException
public void write(ByteBuffer srcBuffer, long offset) throws IOException
write
in interface IOEngine
srcBuffer
- the given byte buffer from which bytes are to be readoffset
- The offset in the file where the first byte to be writtenIOException
public void sync() throws IOException
sync
in interface IOEngine
IOException
public byte[] calculateChecksum(String algorithm)
PersistentIOEngine
calculateChecksum
in interface PersistentIOEngine
algorithm
- which algorithm to calculate checksumCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.