Search in sources :

Example 16 with FilePageStore

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;
}
Also used : IgniteDataIntegrityViolationException(org.apache.ignite.internal.processors.cache.persistence.wal.crc.IgniteDataIntegrityViolationException) ArrayList(java.util.ArrayList) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) FilePageStore(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore) ByteBuffer(java.nio.ByteBuffer)

Aggregations

FilePageStore (org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore)16 File (java.io.File)11 ByteBuffer (java.nio.ByteBuffer)11 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)10 ArrayList (java.util.ArrayList)9 IgniteException (org.apache.ignite.IgniteException)8 FilePageStoreManager (org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager)8 IOException (java.io.IOException)7 HashMap (java.util.HashMap)7 List (java.util.List)7 Map (java.util.Map)7 PageIO (org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO)7 Collections (java.util.Collections)6 HashSet (java.util.HashSet)6 Set (java.util.Set)6 IgniteEx (org.apache.ignite.internal.IgniteEx)6 PagePartitionMetaIO (org.apache.ignite.internal.processors.cache.persistence.tree.io.PagePartitionMetaIO)6 F (org.apache.ignite.internal.util.typedef.F)6 Path (java.nio.file.Path)5 Arrays (java.util.Arrays)5