use of org.apache.ignite.internal.pagemem.store.PageStore in project ignite by apache.
the class FilePageStoreManager method onPartitionDestroyed.
/**
* {@inheritDoc}
*/
@Override
public void onPartitionDestroyed(int grpId, int partId, int tag) throws IgniteCheckedException {
assert partId <= PageIdAllocator.MAX_PARTITION_ID;
PageStore store = getStore(grpId, partId);
assert store instanceof FilePageStore : store;
((FilePageStore) store).truncate(tag);
}
use of org.apache.ignite.internal.pagemem.store.PageStore in project ignite by apache.
the class GridCacheDatabaseSharedManager method finalizeCheckpointOnRecovery.
/**
* @throws IgniteCheckedException If failed.
*/
private void finalizeCheckpointOnRecovery(long cpTs, UUID cpId, WALPointer walPtr) throws IgniteCheckedException {
assert cpTs != 0;
ByteBuffer tmpWriteBuf = ByteBuffer.allocateDirect(pageSize());
long start = System.currentTimeMillis();
Collection<DataRegion> memPolicies = context().database().dataRegions();
List<IgniteBiTuple<PageMemory, Collection<FullPageId>>> cpEntities = new ArrayList<>(memPolicies.size());
for (DataRegion memPlc : memPolicies) {
if (memPlc.config().isPersistenceEnabled()) {
PageMemoryEx pageMem = (PageMemoryEx) memPlc.pageMemory();
cpEntities.add(new IgniteBiTuple<PageMemory, Collection<FullPageId>>(pageMem, (pageMem).beginCheckpoint()));
}
}
tmpWriteBuf.order(ByteOrder.nativeOrder());
// Identity stores set.
Collection<PageStore> updStores = new HashSet<>();
int cpPagesCnt = 0;
for (IgniteBiTuple<PageMemory, Collection<FullPageId>> e : cpEntities) {
PageMemoryEx pageMem = (PageMemoryEx) e.get1();
Collection<FullPageId> cpPages = e.get2();
cpPagesCnt += cpPages.size();
for (FullPageId fullId : cpPages) {
tmpWriteBuf.rewind();
Integer tag = pageMem.getForCheckpoint(fullId, tmpWriteBuf, null);
if (tag != null) {
tmpWriteBuf.rewind();
PageStore store = storeMgr.writeInternal(fullId.groupId(), fullId.pageId(), tmpWriteBuf, tag, true);
tmpWriteBuf.rewind();
updStores.add(store);
}
}
}
long written = U.currentTimeMillis();
for (PageStore updStore : updStores) updStore.sync();
long fsync = U.currentTimeMillis();
for (IgniteBiTuple<PageMemory, Collection<FullPageId>> e : cpEntities) ((PageMemoryEx) e.get1()).finishCheckpoint();
writeCheckpointEntry(tmpWriteBuf, cpTs, cpId, walPtr, null, CheckpointEntryType.END);
cctx.pageStore().finishRecover();
if (log.isInfoEnabled())
log.info(String.format("Checkpoint finished [cpId=%s, pages=%d, markPos=%s, " + "pagesWrite=%dms, fsync=%dms, total=%dms]", cpId, cpPagesCnt, walPtr, written - start, fsync - written, fsync - start));
}
use of org.apache.ignite.internal.pagemem.store.PageStore in project ignite by apache.
the class GridCacheDatabaseSharedManager method forGroupPageStores.
/**
* @param gctx Group context.
* @param f Consumer.
* @return Accumulated result for all page stores.
*/
public long forGroupPageStores(CacheGroupContext gctx, ToLongFunction<PageStore> f) {
int groupId = gctx.groupId();
long res = 0;
try {
Collection<PageStore> stores = storeMgr.getStores(groupId);
if (stores != null) {
for (PageStore store : stores) res += f.applyAsLong(store);
}
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
return res;
}
use of org.apache.ignite.internal.pagemem.store.PageStore in project ignite by apache.
the class GridCacheOffheapManager method forGroupPageStores.
/**
* @param gctx Group context.
* @param f Consumer.
* @return Accumulated result for all page stores.
*/
private long forGroupPageStores(CacheGroupContext gctx, ToLongFunction<PageStore> f) {
int groupId = gctx.groupId();
long res = 0;
try {
Collection<PageStore> stores = ((FilePageStoreManager) ctx.cache().context().pageStore()).getStores(groupId);
if (stores != null) {
for (PageStore store : stores) res += f.applyAsLong(store);
}
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
return res;
}
use of org.apache.ignite.internal.pagemem.store.PageStore in project ignite by apache.
the class CacheDataTree method scanDataPages.
/**
* @param rowData Required row data.
* @param c Optional MVCC closure.
* @return Cache row cursor.
* @throws IgniteCheckedException If failed.
*/
private GridCursor<CacheDataRow> scanDataPages(CacheDataRowAdapter.RowData rowData, MvccDataPageClosure c) throws IgniteCheckedException {
lastFindWithDataPageScan = TRUE;
checkDestroyed();
assert rowData != null;
assert grp.persistenceEnabled();
int partId = rowStore.getPartitionId();
GridCacheSharedContext shared = grp.shared();
GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager) shared.database();
PageStore pageStore = db.getPageStore(grpId, partId);
boolean mvccEnabled = grp.mvccEnabled();
int pageSize = pageSize();
long startPageId = ((PageMemoryEx) pageMem).partitionMetaPageId(grp.groupId(), partId);
/**
*/
final class DataPageScanCursor implements GridCursor<CacheDataRow> {
/**
*/
int pagesCnt = pageStore.pages();
/**
*/
int curPage = -1;
/**
*/
CacheDataRow[] rows = EMPTY_ROWS;
/**
*/
int curRow = -1;
/**
* {@inheritDoc}
*/
@Override
public boolean next() throws IgniteCheckedException {
if (rows == null)
return false;
if (++curRow < rows.length && rows[curRow] != null)
return true;
return readNextDataPage();
}
/**
* @return {@code true} If new rows were fetched.
* @throws IgniteCheckedException If failed.
*/
private boolean readNextDataPage() throws IgniteCheckedException {
checkDestroyed();
for (; ; ) {
if (++curPage >= pagesCnt) {
// Reread number of pages when we reach it (it may grow).
int newPagesCnt = pageStore.pages();
if (newPagesCnt <= pagesCnt) {
rows = null;
return false;
}
pagesCnt = newPagesCnt;
}
long pageId = startPageId + curPage;
long page = pageMem.acquirePage(grpId, pageId);
try {
boolean skipVer = CacheDataRowStore.getSkipVersion();
long pageAddr = ((PageMemoryEx) pageMem).readLock(page, pageId, true, false);
try {
// Here we should also exclude fragmented pages that don't contain the head of the entry.
if (PageIO.getType(pageAddr) != T_DATA)
// Not a data page.
continue;
DataPageIO io = PageIO.getPageIO(T_DATA, PageIO.getVersion(pageAddr));
int rowsCnt = io.getRowsCount(pageAddr);
if (rowsCnt == 0)
// Empty page.
continue;
if (rowsCnt > rows.length)
rows = new CacheDataRow[rowsCnt];
else
clearTail(rows, rowsCnt);
int r = 0;
for (int i = 0; i < rowsCnt; i++) {
if (c == null || c.applyMvcc(io, pageAddr, i, pageSize)) {
DataRow row = mvccEnabled ? new MvccDataRow() : new DataRow();
row.initFromDataPage(io, pageAddr, i, grp, shared, pageMem, rowData, skipVer);
rows[r++] = row;
}
}
if (r == 0)
// No rows fetched in this page.
continue;
curRow = 0;
return true;
} finally {
pageMem.readUnlock(grpId, pageId, page);
}
} finally {
pageMem.releasePage(grpId, pageId, page);
}
}
}
/**
* {@inheritDoc}
*/
@Override
public CacheDataRow get() {
return rows[curRow];
}
}
return new DataPageScanCursor();
}
Aggregations