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);
}
}
}
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;
}
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;
}
Aggregations