Class EncryptedFileIO
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.persistence.file.EncryptedFileIO
-
- All Implemented Interfaces:
AutoCloseable,FileIO
public class EncryptedFileIO extends Object implements FileIO
Implementation ofFileIOthat supports encryption(decryption) of pages written(readed) to(from) file.- See Also:
EncryptedFileIOFactory
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Truncates current file to zero length and resets current file position to zero.voidclose()Closes current file.voidforce()Forces any updates of this file to be written to the storage device that contains it.voidforce(boolean withMetadata)Forces any updates of this file to be written to the storage device that contains it.intgetFileSystemBlockSize()longgetSparseSize()MappedByteBuffermap(int sizeBytes)Allocates memory mapped buffer for this file with given size.longposition()Returns current file position.voidposition(long newPosition)Sets new current file position.intpunchHole(long position, int len)intread(byte[] buf, int off, int len)Reads a up tolengthbytes from this file into thebuffer.intread(ByteBuffer destBuf)Reads a sequence of bytes from this file into thedestinationBuffer.intread(ByteBuffer destBuf, long position)Reads a sequence of bytes from this file into thedestinationBufferstarting from specified fileposition.intreadFully(byte[] buf, int off, int len)Reads a up tolengthbytes from this file into thebuffer.intreadFully(ByteBuffer destBuf)Reads a sequence of bytes from this file into thedestinationBuffer.intreadFully(ByteBuffer destBuf, long position)Reads a sequence of bytes from this file into thedestinationBufferstarting from specified fileposition.longsize()Returns current file size in bytes.intwrite(byte[] buf, int off, int len)Writeslengthbytes from thebufferstarting at offsetoffto this file.intwrite(ByteBuffer srcBuf)Writes a sequence of bytes to this file from thesourceBuffer.intwrite(ByteBuffer srcBuf, long position)Writes a sequence of bytes to this file from thesourceBufferstarting from specified filepositionintwriteFully(byte[] buf, int off, int len)Writeslengthbytes from thebufferstarting at offsetoffto this file.intwriteFully(ByteBuffer srcBuf)Writes a sequence of bytes to this file from thesourceBuffer.intwriteFully(ByteBuffer srcBuf, long position)Writes a sequence of bytes to this file from thesourceBufferstarting from specified fileposition-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.ignite.internal.processors.cache.persistence.file.FileIO
transferFrom, transferTo
-
-
-
-
Method Detail
-
getFileSystemBlockSize
public int getFileSystemBlockSize()
- Specified by:
getFileSystemBlockSizein interfaceFileIO- Returns:
- File system block size or negative value if unknown.
-
getSparseSize
public long getSparseSize()
- Specified by:
getSparseSizein interfaceFileIO- Returns:
- Approximate system dependent size of the storage or negative value if not supported.
- See Also:
FileIO.punchHole(long, int)
-
punchHole
public int punchHole(long position, int len)
-
position
public long position() throws IOExceptionReturns current file position.- Specified by:
positionin interfaceFileIO- Returns:
- Current file position, a non-negative integer counting the number of bytes from the beginning of the file to the current position.
- Throws:
IOException- If some I/O error occurs.
-
position
public void position(long newPosition) throws IOExceptionSets new current file position.- Specified by:
positionin interfaceFileIO- Parameters:
newPosition- The new position, a non-negative integer counting the number of bytes from the beginning of the file.- Throws:
IOException- If some I/O error occurs.
-
read
public int read(ByteBuffer destBuf) throws IOException
Reads a sequence of bytes from this file into thedestinationBuffer.- Specified by:
readin interfaceFileIO- Parameters:
destBuf- Destination byte buffer.- Returns:
- Number of read bytes, or -1 if the given position is greater than or equal to the file's current size
- Throws:
IOException- If some I/O error occurs.
-
readFully
public int readFully(ByteBuffer destBuf) throws IOException
Reads a sequence of bytes from this file into thedestinationBuffer.- Specified by:
readFullyin interfaceFileIO- Parameters:
destBuf- Destination byte buffer.- Returns:
- Number of written bytes.
- Throws:
IOException- If some I/O error occurs.
-
read
public int read(ByteBuffer destBuf, long position) throws IOException
Reads a sequence of bytes from this file into thedestinationBufferstarting from specified fileposition.- Specified by:
readin interfaceFileIO- Parameters:
destBuf- Destination byte buffer.position- Starting position of file.- Returns:
- Number of read bytes, possibly zero, or -1 if the given position is greater than or equal to the file's current size
- Throws:
IOException- If some I/O error occurs.
-
readFully
public int readFully(ByteBuffer destBuf, long position) throws IOException
Reads a sequence of bytes from this file into thedestinationBufferstarting from specified fileposition.- Specified by:
readFullyin interfaceFileIO- Parameters:
destBuf- Destination byte buffer.position- Starting position of file.- Returns:
- Number of written bytes.
- Throws:
IOException- If some I/O error occurs.
-
read
public int read(byte[] buf, int off, int len) throws IOExceptionReads a up tolengthbytes from this file into thebuffer.- Specified by:
readin interfaceFileIO- Parameters:
buf- Destination byte array.off- The start offset in arraybat which the data is written.len- Maximum number of bytes read.- Returns:
- Number of read bytes.
- Throws:
IOException- If some I/O error occurs.
-
readFully
public int readFully(byte[] buf, int off, int len) throws IOExceptionReads a up tolengthbytes from this file into thebuffer.- Specified by:
readFullyin interfaceFileIO- Parameters:
buf- Destination byte array.off- The start offset in arraybat which the data is written.len- Number of bytes read.- Returns:
- Number of written bytes.
- Throws:
IOException- If some I/O error occurs.
-
write
public int write(ByteBuffer srcBuf) throws IOException
Writes a sequence of bytes to this file from thesourceBuffer.- Specified by:
writein interfaceFileIO- Parameters:
srcBuf- Source buffer.- Returns:
- Number of written bytes.
- Throws:
IOException- If some I/O error occurs.
-
writeFully
public int writeFully(ByteBuffer srcBuf) throws IOException
Writes a sequence of bytes to this file from thesourceBuffer.- Specified by:
writeFullyin interfaceFileIO- Parameters:
srcBuf- Source buffer.- Returns:
- Number of written bytes.
- Throws:
IOException- If some I/O error occurs.
-
write
public int write(ByteBuffer srcBuf, long position) throws IOException
Writes a sequence of bytes to this file from thesourceBufferstarting from specified fileposition- Specified by:
writein interfaceFileIO- Parameters:
srcBuf- Source buffer.position- Starting file position.- Returns:
- Number of written bytes.
- Throws:
IOException- If some I/O error occurs.
-
writeFully
public int writeFully(ByteBuffer srcBuf, long position) throws IOException
Writes a sequence of bytes to this file from thesourceBufferstarting from specified fileposition- Specified by:
writeFullyin interfaceFileIO- Parameters:
srcBuf- Source buffer.position- Starting file position.- Returns:
- Number of written bytes.
- Throws:
IOException- If some I/O error occurs.
-
write
public int write(byte[] buf, int off, int len) throws IOExceptionWriteslengthbytes from thebufferstarting at offsetoffto this file.- Specified by:
writein interfaceFileIO- Parameters:
buf- Source byte array.off- Start offset in thebuffer.len- Number of bytes to write.- Returns:
- Number of written bytes.
- Throws:
IOException- If some I/O error occurs.
-
writeFully
public int writeFully(byte[] buf, int off, int len) throws IOExceptionWriteslengthbytes from thebufferstarting at offsetoffto this file.- Specified by:
writeFullyin interfaceFileIO- Parameters:
buf- Source byte array.off- Start offset in thebuffer.len- Number of bytes to write.- Returns:
- Number of written bytes.
- Throws:
IOException- If some I/O error occurs.
-
map
public MappedByteBuffer map(int sizeBytes) throws IOException
Allocates memory mapped buffer for this file with given size.- Specified by:
mapin interfaceFileIO- Parameters:
sizeBytes- Size of buffer.- Returns:
- Instance of mapped byte buffer.
- Throws:
IOException- If some I/O error occurs.
-
force
public void force() throws IOExceptionForces any updates of this file to be written to the storage device that contains it.- Specified by:
forcein interfaceFileIO- Throws:
IOException- If some I/O error occurs.
-
force
public void force(boolean withMetadata) throws IOExceptionForces any updates of this file to be written to the storage device that contains it.- Specified by:
forcein interfaceFileIO- Parameters:
withMetadata- Iftrueforce also file metadata.- Throws:
IOException- If some I/O error occurs.
-
size
public long size() throws IOExceptionReturns current file size in bytes.- Specified by:
sizein interfaceFileIO- Returns:
- File size.
- Throws:
IOException- If some I/O error occurs.
-
clear
public void clear() throws IOExceptionTruncates current file to zero length and resets current file position to zero.- Specified by:
clearin interfaceFileIO- Throws:
IOException- If some I/O error occurs.
-
close
public void close() throws IOExceptionCloses current file.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceFileIO- Throws:
IOException- If some I/O error occurs.
-
-