use of org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore in project ignite by apache.
the class IndexPagesMetricsPageDisplacementTest method getIdxPagesOnDisk.
/**
* Returns IDs of index pages currently residing in the storage.
*/
private List<Long> getIdxPagesOnDisk(int grpId) throws IgniteCheckedException {
FilePageStoreManager pageStoreMgr = (FilePageStoreManager) grid.context().cache().context().pageStore();
FilePageStore pageStore = (FilePageStore) pageStoreMgr.getStore(grpId, PageIdAllocator.INDEX_PARTITION);
List<Long> result = new ArrayList<>();
ByteBuffer buf = ByteBuffer.allocateDirect(pageStore.getPageSize()).order(ByteOrder.nativeOrder());
// Page Store contains a one-page header
long numPages = pageStore.size() / pageStore.getPageSize() - 1;
for (int i = 0; i < numPages; i++) {
long pageId = PageIdUtils.pageId(PageIdAllocator.INDEX_PARTITION, (byte) 0, i);
try {
pageStore.read(pageId, buf, false);
} catch (IgniteDataIntegrityViolationException ignored) {
// sometimes we try to access an invalid page, in which case this exception will be thrown.
// We simply ignore it and try to access other pages.
}
if (PageIO.isIndexPage(PageIO.getType(buf)))
result.add(PageIO.getPageId(buf));
buf.clear();
}
return result;
}
Aggregations