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