Search in sources :

Example 6 with PageListMetaResetCountRecord

use of org.apache.ignite.internal.pagemem.wal.record.delta.PageListMetaResetCountRecord in project ignite by apache.

the class PagesList method saveMetadata.

/**
     * @throws IgniteCheckedException If failed.
     */
public void saveMetadata() throws IgniteCheckedException {
    assert metaPageId != 0;
    long curId = 0L;
    long curPage = 0L;
    long curAddr = 0L;
    PagesListMetaIO curIo = null;
    long nextPageId = metaPageId;
    try {
        for (int bucket = 0; bucket < buckets; bucket++) {
            Stripe[] tails = getBucket(bucket);
            if (tails != null) {
                int tailIdx = 0;
                while (tailIdx < tails.length) {
                    int written = curPage != 0L ? curIo.addTails(pageMem.pageSize(), curAddr, bucket, tails, tailIdx) : 0;
                    if (written == 0) {
                        if (nextPageId == 0L) {
                            nextPageId = allocatePageNoReuse();
                            if (curPage != 0L) {
                                curIo.setNextMetaPageId(curAddr, nextPageId);
                                releaseAndClose(curId, curPage, curAddr);
                            }
                            curId = nextPageId;
                            curPage = acquirePage(curId);
                            curAddr = writeLock(curId, curPage);
                            curIo = PagesListMetaIO.VERSIONS.latest();
                            curIo.initNewPage(curAddr, curId, pageSize());
                        } else {
                            releaseAndClose(curId, curPage, curAddr);
                            curId = nextPageId;
                            curPage = acquirePage(curId);
                            curAddr = writeLock(curId, curPage);
                            curIo = PagesListMetaIO.VERSIONS.forPage(curAddr);
                            curIo.resetCount(curAddr);
                        }
                        nextPageId = curIo.getNextMetaPageId(curAddr);
                    } else
                        tailIdx += written;
                }
            }
        }
    } finally {
        releaseAndClose(curId, curPage, curAddr);
    }
    while (nextPageId != 0L) {
        long pageId = nextPageId;
        long page = acquirePage(pageId);
        try {
            long pageAddr = writeLock(pageId, page);
            try {
                PagesListMetaIO io = PagesListMetaIO.VERSIONS.forPage(pageAddr);
                io.resetCount(pageAddr);
                if (needWalDeltaRecord(pageId, page, null))
                    wal.log(new PageListMetaResetCountRecord(cacheId, pageId));
                nextPageId = io.getNextMetaPageId(pageAddr);
            } finally {
                writeUnlock(pageId, page, pageAddr, true);
            }
        } finally {
            releasePage(pageId, page);
        }
    }
}
Also used : PagesListMetaIO(org.apache.ignite.internal.processors.cache.database.freelist.io.PagesListMetaIO) PageListMetaResetCountRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PageListMetaResetCountRecord)

Aggregations

PageListMetaResetCountRecord (org.apache.ignite.internal.pagemem.wal.record.delta.PageListMetaResetCountRecord)6 UUID (java.util.UUID)3 CheckpointRecord (org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord)3 DataRecord (org.apache.ignite.internal.pagemem.wal.record.DataRecord)3 MemoryRecoveryRecord (org.apache.ignite.internal.pagemem.wal.record.MemoryRecoveryRecord)3 MetastoreDataRecord (org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord)3 PageSnapshot (org.apache.ignite.internal.pagemem.wal.record.PageSnapshot)3 DataPageInsertFragmentRecord (org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertFragmentRecord)3 DataPageInsertRecord (org.apache.ignite.internal.pagemem.wal.record.delta.DataPageInsertRecord)3 DataPageRemoveRecord (org.apache.ignite.internal.pagemem.wal.record.delta.DataPageRemoveRecord)3 DataPageSetFreeListPageRecord (org.apache.ignite.internal.pagemem.wal.record.delta.DataPageSetFreeListPageRecord)3 DataPageUpdateRecord (org.apache.ignite.internal.pagemem.wal.record.delta.DataPageUpdateRecord)3 FixCountRecord (org.apache.ignite.internal.pagemem.wal.record.delta.FixCountRecord)3 FixLeftmostChildRecord (org.apache.ignite.internal.pagemem.wal.record.delta.FixLeftmostChildRecord)3 FixRemoveId (org.apache.ignite.internal.pagemem.wal.record.delta.FixRemoveId)3 InitNewPageRecord (org.apache.ignite.internal.pagemem.wal.record.delta.InitNewPageRecord)3 MetaPageAddRootRecord (org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageAddRootRecord)3 MetaPageCutRootRecord (org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageCutRootRecord)3 MetaPageInitRecord (org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRecord)3 MetaPageInitRootInlineRecord (org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRootInlineRecord)3