use of org.apache.ignite.internal.pagemem.store.PageStore in project ignite by apache.
the class CheckpointPagesWriter method createPageStoreWriter.
/**
* Factory method for create {@link PageStoreWriter}.
*
* @param pageMemEx
* @param pagesToRetry List pages for retry.
* @return Checkpoint page write context.
*/
private PageStoreWriter createPageStoreWriter(PageMemoryEx pageMemEx, Map<PageMemoryEx, List<FullPageId>> pagesToRetry) {
return new PageStoreWriter() {
/**
* {@inheritDoc}
*/
@Override
public void writePage(FullPageId fullPageId, ByteBuffer buf, int tag) throws IgniteCheckedException {
if (tag == PageMemoryImpl.TRY_AGAIN_TAG) {
pagesToRetry.computeIfAbsent(pageMemEx, k -> new ArrayList<>()).add(fullPageId);
return;
}
int groupId = fullPageId.groupId();
long pageId = fullPageId.pageId();
assert getType(buf) != 0 : "Invalid state. Type is 0! pageId = " + hexLong(pageId);
assert getVersion(buf) != 0 : "Invalid state. Version is 0! pageId = " + hexLong(pageId);
if (persStoreMetrics.metricsEnabled()) {
int pageType = getType(buf);
if (PageIO.isDataPageType(pageType))
tracker.onDataPageWritten();
}
curCpProgress.updateWrittenPages(1);
PageStore store = pageWriter.write(pageMemEx, fullPageId, buf, tag);
updStores.computeIfAbsent(store, k -> new LongAdder()).increment();
}
};
}
use of org.apache.ignite.internal.pagemem.store.PageStore in project ignite by apache.
the class CheckpointWorkflow method finalizeCheckpointOnRecovery.
/**
* This method makes sense if node was stopped during the checkpoint(Start marker was written to disk while end
* marker are not). It is able to write all pages to disk and create end marker.
*
* @throws IgniteCheckedException If failed.
*/
public void finalizeCheckpointOnRecovery(long cpTs, UUID cpId, WALPointer walPtr, StripedExecutor exec, CheckpointPagesWriterFactory checkpointPagesWriterFactory) throws IgniteCheckedException {
assert cpTs != 0;
long start = System.currentTimeMillis();
Collection<DataRegion> regions = dataRegions.get();
CheckpointPagesInfoHolder cpPagesHolder = beginAllCheckpoints(regions, new GridFinishedFuture<>());
// Sort and split all dirty pages set to several stripes.
GridConcurrentMultiPairQueue<PageMemoryEx, FullPageId> pages = splitAndSortCpPagesIfNeeded(cpPagesHolder);
// Identity stores set for future fsync.
Collection<PageStore> updStores = new GridConcurrentHashSet<>();
AtomicInteger cpPagesCnt = new AtomicInteger();
// Shared refernce for tracking exception during write pages.
AtomicReference<Throwable> writePagesError = new AtomicReference<>();
for (int stripeIdx = 0; stripeIdx < exec.stripesCount(); stripeIdx++) exec.execute(stripeIdx, checkpointPagesWriterFactory.buildRecovery(pages, updStores, writePagesError, cpPagesCnt));
// Await completion all write tasks.
awaitApplyComplete(exec, writePagesError);
long written = U.currentTimeMillis();
// Fsync all touched stores.
for (PageStore updStore : updStores) updStore.sync();
long fsync = U.currentTimeMillis();
for (DataRegion memPlc : regions) {
if (memPlc.config().isPersistenceEnabled())
((PageMemoryEx) memPlc.pageMemory()).finishCheckpoint();
}
checkpointMarkersStorage.writeCheckpointEntry(cpTs, cpId, walPtr, null, CheckpointEntryType.END, skipSync);
if (log.isInfoEnabled())
log.info(String.format("Checkpoint finished [cpId=%s, pages=%d, markPos=%s, " + "pagesWrite=%dms, fsync=%dms, total=%dms]", cpId, cpPagesCnt.get(), walPtr, written - start, fsync - written, fsync - start));
}
Aggregations