public class FilePageStore extends Object implements PageStore
Actual read and write operations are performed with FileIO abstract interface,
list of its implementations is a good source of information about functionality in Ignite Native Persistence.
On a physical level each instance of FilePageStore corresponds to a partition file assigned to the local node or to index file of a particular cache if any secondary indexes were created.
Instances of FilePageStore are managed by FilePageStoreManager for regular cache operations like assignment
of new partition to the local node or checkpoint event and by IgniteSnapshotManager during snapshot creation.
| Modifier and Type | Field and Description |
|---|---|
protected FileIO |
fileIO
I/O interface for read/write operations with file
|
static int |
HEADER_SIZE
Allocated field offset.
|
protected int |
pageSize |
static int |
VERSION
File version.
|
| Constructor and Description |
|---|
FilePageStore(byte type,
IgniteOutClosure<Path> pathProvider,
FileIOFactory factory,
int pageSize,
LongConsumer allocatedTracker) |
| Modifier and Type | Method and Description |
|---|---|
void |
addWriteListener(PageWriteListener lsnr) |
long |
allocatePage()
Allocates next page index.
|
void |
beginRecover()
Starts recover process.
|
void |
close() |
void |
ensure() |
boolean |
exists()
Checks if page exists.
|
void |
finishRecover()
Ends recover process.
|
int |
getBlockSize() |
String |
getFileAbsolutePath() |
int |
getPageSize() |
long |
getSparseSize() |
ByteBuffer |
header(byte type,
int pageSize)
Creates header for current version file store.
|
int |
headerSize()
Size of page store header.
|
void |
init() |
long |
pageOffset(long pageId)
Gets page offset within the store file.
|
int |
pages()
Gets number of allocated pages.
|
void |
punchHole(long pageId,
int usefulBytes)
Should free all the extra storage space after the given number of useful bytes in the given page.
|
boolean |
read(long pageId,
ByteBuffer pageBuf,
boolean keepCrc)
Reads a page.
|
boolean |
read(long pageId,
ByteBuffer pageBuf,
boolean checkCrc,
boolean keepCrc) |
void |
readHeader(ByteBuffer buf)
Reads a header.
|
void |
removeWriteListener(PageWriteListener lsnr) |
long |
size() |
void |
stop(boolean delete) |
void |
sync()
Sync method used to ensure that the given pages are guaranteed to be written to the store.
|
void |
truncate(int tag)
Truncates and deletes partition file.
|
int |
version()
Page store version.
|
void |
write(long pageId,
ByteBuffer pageBuf,
int tag,
boolean calculateCrc)
Writes a page.
|
public static final int VERSION
public static final int HEADER_SIZE
protected volatile FileIO fileIO
protected final int pageSize
public FilePageStore(byte type,
IgniteOutClosure<Path> pathProvider,
FileIOFactory factory,
int pageSize,
LongConsumer allocatedTracker)
type - Type of stored pages.pathProvider - Store path.factory - Factory producing an IO accessor.pageSize - Page size.allocatedTracker - Allocation tracker.public void addWriteListener(PageWriteListener lsnr)
addWriteListener in interface PageStorelsnr - Page write listener to set.public void removeWriteListener(PageWriteListener lsnr)
removeWriteListener in interface PageStorelsnr - Page write listener to remove.public int getPageSize()
getPageSize in interface PageStorepublic int getBlockSize()
getBlockSize in interface PageStorepublic long size()
size in interface PageStorePageStore.pages() * PageStore.getPageSize()
due to delayed writes or due to other implementation specific details.public long getSparseSize()
getSparseSize in interface PageStorePageStore.size().PageStore.punchHole(long, int)public void punchHole(long pageId,
int usefulBytes)
public boolean exists()
public int headerSize()
public int version()
public ByteBuffer header(byte type, int pageSize)
type - Type.pageSize - Page size.public void stop(boolean delete)
throws StorageException
stop in interface PageStoredelete - True to delete file.StorageException - If failed.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void truncate(int tag)
throws StorageException
truncate in interface PageStoretag - New partition tag.StorageException - If failed.public void beginRecover()
beginRecover in interface PageStorepublic void finishRecover()
throws StorageException
finishRecover in interface PageStoreStorageException - If failed.public boolean read(long pageId,
ByteBuffer pageBuf,
boolean keepCrc)
throws IgniteCheckedException
read in interface PageStorepageId - Page ID.pageBuf - Page buffer to read into.keepCrc - by default reading zeroes CRC which was on file, but you can keep it in pageBuf if set keepCrctrue if page has been read successfully, false if page hasn't been written yet.IgniteCheckedException - If reading failed (IO error occurred).public boolean read(long pageId,
ByteBuffer pageBuf,
boolean checkCrc,
boolean keepCrc)
throws IgniteCheckedException
pageId - Page ID.pageBuf - Page buffer to read into.checkCrc - Check CRC on page.keepCrc - By default reading zeroes CRC which was on file, but you can keep it in pageBuf if set keepCrctrue if page has been read successfully, false if page hasn't been written yet.IgniteCheckedException - If reading failed (IO error occurred).public void readHeader(ByteBuffer buf) throws IgniteCheckedException
readHeader in interface PageStorebuf - Buffer to write to.IgniteCheckedException - If failed.public void init()
throws StorageException
StorageException - If failed to initialize store file.public void write(long pageId,
ByteBuffer pageBuf,
int tag,
boolean calculateCrc)
throws IgniteCheckedException
write in interface PageStorepageId - Page ID.pageBuf - Page buffer to write.tag - Partition file version, 1-based incrementing counter. For outdated pages tag has lower value,
and write does nothing.calculateCrc - if False crc calculation will be forcibly skipped.IgniteCheckedException - If page writing failed (IO error occurred).public long pageOffset(long pageId)
pageOffset in interface PageStorepageId - Page ID.public void sync()
throws StorageException
sync in interface PageStoreStorageExceptionpublic void ensure()
throws IgniteCheckedException
ensure in interface PageStoreIgniteCheckedException - If sync failed (IO error occurred).public long allocatePage()
throws IgniteCheckedException
allocatePage in interface PageStoreIgniteCheckedException - If failed to allocate.public String getFileAbsolutePath()
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.11.1 Release Date : December 20 2021