Search in sources :

Example 11 with DataPageSetFreeListPageRecord

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

the class PagesList method handlePageFull.

/**
 * @param pageId Page ID.
 * @param page Page pointer.
 * @param pageAddr Page address.
 * @param io IO.
 * @param dataId Data page ID.
 * @param data Data page pointer.
 * @param dataAddr Data page address.
 * @param bucket Bucket index.
 * @param statHolder Statistics holder to track IO operations.
 * @throws IgniteCheckedException If failed.
 */
private void handlePageFull(final long pageId, final long page, final long pageAddr, PagesListNodeIO io, final long dataId, final long data, final long dataAddr, int bucket, IoStatisticsHolder statHolder) throws IgniteCheckedException {
    AbstractDataPageIO dataIO = PageIO.getPageIO(dataAddr);
    // Attempt to add page failed: the node page is full.
    if (isReuseBucket(bucket)) {
        // We can put only empty data pages to reuse bucket.
        assert dataIO.isEmpty(dataAddr);
        // Change page type to index and add it as next node page to this list.
        long newDataId = PageIdUtils.changeType(dataId, FLAG_IDX);
        setupNextPage(io, pageId, pageAddr, newDataId, dataAddr);
        if (needWalDeltaRecord(pageId, page, null))
            wal.log(new PagesListSetNextRecord(grpId, pageId, newDataId));
        if (needWalDeltaRecord(dataId, data, null))
            wal.log(new PagesListInitNewPageRecord(grpId, dataId, io.getType(), io.getVersion(), newDataId, pageId, 0L));
        // In reuse bucket the page itself can be used as a free page.
        incrementBucketSize(bucket);
        updateTail(bucket, pageId, newDataId);
    } else {
        // Just allocate a new node page and add our data page there.
        final long nextId = allocatePage(null);
        final long nextPage = acquirePage(nextId, statHolder);
        try {
            // Newly allocated page.
            long nextPageAddr = writeLock(nextId, nextPage);
            assert nextPageAddr != 0L;
            // Here we should never write full page, because it is known to be new.
            Boolean nextWalPlc = FALSE;
            try {
                setupNextPage(io, pageId, pageAddr, nextId, nextPageAddr);
                if (needWalDeltaRecord(pageId, page, null))
                    wal.log(new PagesListSetNextRecord(grpId, pageId, nextId));
                int idx = io.addPage(nextPageAddr, dataId, pageSize());
                if (needWalDeltaRecord(nextId, nextPage, nextWalPlc))
                    wal.log(new PagesListInitNewPageRecord(grpId, nextId, io.getType(), io.getVersion(), nextId, pageId, dataId));
                assert idx != -1;
                dataIO.setFreeListPageId(dataAddr, nextId);
                if (needWalDeltaRecord(dataId, data, null))
                    wal.log(new DataPageSetFreeListPageRecord(grpId, dataId, nextId));
                incrementBucketSize(bucket);
                updateTail(bucket, pageId, nextId);
            } finally {
                writeUnlock(nextId, nextPage, nextPageAddr, nextWalPlc, true);
            }
        } finally {
            releasePage(nextId, nextPage);
        }
    }
}
Also used : AbstractDataPageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.AbstractDataPageIO) DataPageSetFreeListPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageSetFreeListPageRecord) PagesListSetNextRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListSetNextRecord) PagesListInitNewPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListInitNewPageRecord)

Example 12 with DataPageSetFreeListPageRecord

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

the class PagesList method putDataPage.

/**
 * @param dataId Data page ID.
 * @param dataPage Data page pointer.
 * @param dataAddr Data page address.
 * @param bucket Bucket.
 * @return {@code true} If succeeded.
 * @throws IgniteCheckedException If failed.
 */
private boolean putDataPage(PagesCache pagesCache, final long dataId, final long dataPage, final long dataAddr, int bucket) throws IgniteCheckedException {
    if (pagesCache.add(dataId)) {
        incrementBucketSize(bucket);
        AbstractDataPageIO dataIO = PageIO.getPageIO(dataAddr);
        if (dataIO.getFreeListPageId(dataAddr) != 0L) {
            dataIO.setFreeListPageId(dataAddr, 0L);
            // page memory only at the time of checkpoint, but it doesn't affect recovery guarantees).
            if (needWalDeltaRecord(dataId, dataPage, null))
                wal.log(new DataPageSetFreeListPageRecord(grpId, dataId, 0L));
        }
        pageCacheChanged();
        return true;
    } else
        return false;
}
Also used : AbstractDataPageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.AbstractDataPageIO) DataPageSetFreeListPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageSetFreeListPageRecord)

Example 13 with DataPageSetFreeListPageRecord

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

the class PagesList method putDataPage.

/**
 * @param pageId Page ID.
 * @param page Page pointer.
 * @param pageAddr Page address.
 * @param io IO.
 * @param dataId Data page ID.
 * @param dataPage Data page pointer.
 * @param dataAddr Data page address.
 * @param bucket Bucket.
 * @param statHolder Statistics holder to track IO operations.
 * @return {@code true} If succeeded.
 * @throws IgniteCheckedException If failed.
 */
private boolean putDataPage(final long pageId, final long page, final long pageAddr, PagesListNodeIO io, final long dataId, final long dataPage, final long dataAddr, int bucket, IoStatisticsHolder statHolder) throws IgniteCheckedException {
    if (io.getNextId(pageAddr) != 0L)
        // Splitted.
        return false;
    int idx = io.addPage(pageAddr, dataId, pageSize());
    if (idx == -1)
        handlePageFull(pageId, page, pageAddr, io, dataId, dataPage, dataAddr, bucket, statHolder);
    else {
        incrementBucketSize(bucket);
        if (needWalDeltaRecord(pageId, page, null))
            wal.log(new PagesListAddPageRecord(grpId, pageId, dataId));
        AbstractDataPageIO dataIO = PageIO.getPageIO(dataAddr);
        dataIO.setFreeListPageId(dataAddr, pageId);
        if (needWalDeltaRecord(dataId, dataPage, null))
            wal.log(new DataPageSetFreeListPageRecord(grpId, dataId, pageId));
    }
    return true;
}
Also used : AbstractDataPageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.AbstractDataPageIO) DataPageSetFreeListPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.DataPageSetFreeListPageRecord) PagesListAddPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.PagesListAddPageRecord)

Aggregations

DataPageSetFreeListPageRecord (org.apache.ignite.internal.pagemem.wal.record.delta.DataPageSetFreeListPageRecord)13 PagesListAddPageRecord (org.apache.ignite.internal.pagemem.wal.record.delta.PagesListAddPageRecord)6 PagesListInitNewPageRecord (org.apache.ignite.internal.pagemem.wal.record.delta.PagesListInitNewPageRecord)6 PagesListRemovePageRecord (org.apache.ignite.internal.pagemem.wal.record.delta.PagesListRemovePageRecord)6 PagesListSetNextRecord (org.apache.ignite.internal.pagemem.wal.record.delta.PagesListSetNextRecord)6 AbstractDataPageIO (org.apache.ignite.internal.processors.cache.persistence.tree.io.AbstractDataPageIO)5 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 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