/** * @return Data region. */ public DataRegion dataRegion() { return grp.dataRegion(); }
/** * Creates Group metrics MBean. * * @param ctx Cache group context. */ public CacheGroupMetricsMXBeanImpl(CacheGroupContext ctx) { this.ctx = ctx; DataRegion region = ctx.dataRegion(); // On client node, region is null. if (region != null) { DataRegionMetricsImpl dataRegionMetrics = ctx.dataRegion().memoryMetrics(); this.groupPageAllocationTracker = dataRegionMetrics.getOrAllocateGroupPageAllocationTracker(ctx.groupId()); } else this.groupPageAllocationTracker = new GroupAllocationTracker(AllocatedPageTracker.NO_OP); }
/** * @param grp Cache group. * @param freeList Free list. */ public RowStore(CacheGroupContext grp, FreeList freeList) { assert grp != null; assert freeList != null; this.freeList = freeList; ctx = grp.shared(); coctx = grp.cacheObjectContext(); pageMem = grp.dataRegion().pageMemory(); persistenceEnabled = grp.dataRegion().config().isPersistenceEnabled(); }
/** * Read row from data pages. * * @param grp Cache group. * @param rowData Required row data. * @param skipVer Whether version read should be skipped. * @throws IgniteCheckedException If failed. */ public final void initFromLink(CacheGroupContext grp, RowData rowData, boolean skipVer) throws IgniteCheckedException { initFromLink(grp, grp.shared(), grp.dataRegion().pageMemory(), rowData, skipVer); }
/** * @param row Row. * @param key Key. * @throws IgniteCheckedException If failed. */ private void afterRowFound(@Nullable CacheDataRow row, KeyCacheObject key) throws IgniteCheckedException { if (row != null) { row.key(key); grp.dataRegion().evictionTracker().touchPage(row.link()); } }
/** {@inheritDoc} */ @Override public long getTotalAllocatedSize() { return getTotalAllocatedPages() * ctx.dataRegion().pageMemory().pageSize(); }
ByteBuffer buf = ByteBuffer.allocateDirect(grpCtx.dataRegion().pageMemory().pageSize());
/** * @return Page ID. * @throws IgniteCheckedException If failed. */ private long allocateForTree() throws IgniteCheckedException { ReuseList reuseList = grp.reuseList(); long pageId; if (reuseList == null || (pageId = reuseList.takeRecycledPage()) == 0L) pageId = grp.dataRegion().pageMemory().allocatePage(grp.groupId(), INDEX_PARTITION, FLAG_IDX); return pageId; }
@Override public Long apply() { long freeSpace = 0L; for (CacheGroupContext grpCtx : cctx.cache().cacheGroups()) { if (!grpCtx.dataRegion().config().getName().equals(dataRegName)) continue; assert grpCtx.offheap() instanceof GridCacheOffheapManager; freeSpace += ((GridCacheOffheapManager)grpCtx.offheap()).freeSpace(); } return freeSpace; } };
/** {@inheritDoc} */ @Override public void onMarkCheckpointBegin(Context ctx) throws IgniteCheckedException { assert grp.dataRegion().pageMemory() instanceof PageMemoryEx; Executor execSvc = ctx.executor(); boolean needSnapshot = ctx.nextSnapshot() && ctx.needToSnapshot(grp.cacheOrGroupName()); if (needSnapshot) { if (execSvc == null) updateSnapshotTag(ctx); else { execSvc.execute(() -> { try { updateSnapshotTag(ctx); } catch (IgniteCheckedException e) { throw new IgniteException(e); } }); } } syncMetadata(execSvc, ctx, needSnapshot); }
/** * Update page * * @param link Link. * @throws IgniteCheckedException On error. */ private void touch(long link) throws IgniteCheckedException { PageMemory mem = grpCtx.dataRegion().pageMemory(); int grpId = grpCtx.groupId(); final long pageId = PageIdUtils.pageId(link); final long page = mem.acquirePage(grpId, pageId); try { // Touch page timestamp mem.readLock(grpId, pageId, page); mem.readUnlock(grpId, pageId, page); } finally { mem.releasePage(grpId, pageId, page); } } }
super(name, grp.groupId(), grp.dataRegion().pageMemory(), grp.dataRegion().config().isPersistenceEnabled() ? grp.shared().wal() : null, grp.offheap().globalRemoveId(), metaPageId, this.grp = grp; assert !grp.dataRegion().config().isPersistenceEnabled() || grp.shared().database().checkpointLockIsHeldByThread();
/** * Invalidates page memory for given partition. Destroys partition store. * <b>NOTE:</b> This method can be invoked only within checkpoint lock or checkpointer thread. * * @param grpId Group ID. * @param partId Partition ID. * * @throws IgniteCheckedException If destroy has failed. */ public void destroyPartitionStore(int grpId, int partId) throws IgniteCheckedException { PageMemoryEx pageMemory = (PageMemoryEx)grp.dataRegion().pageMemory(); int tag = pageMemory.invalidate(grp.groupId(), partId); if (grp.walEnabled()) ctx.wal().log(new PartitionDestroyRecord(grp.groupId(), partId)); ctx.pageStore().onPartitionDestroyed(grpId, partId, tag); }
/** * @param cctx Cache context. * @throws IgniteCheckedException If failed. */ protected void initPendingTree(GridCacheContext cctx) throws IgniteCheckedException { assert !cctx.group().persistenceEnabled(); if (cctx.affinityNode() && cctx.ttl().eagerTtlEnabled() && pendingEntries == null) { String name = "PendingEntries"; long rootPage = allocateForTree(); pendingEntries = new PendingEntriesTree( grp, name, grp.dataRegion().pageMemory(), rootPage, grp.reuseList(), true); } }
/** {@inheritDoc} */ @Override public Boolean run(int cacheId, long pageId, long page, long pageAddr, PageIO io, Boolean walPlc, MvccVersion newVer, int itemId, IoStatisticsHolder statHolder) throws IgniteCheckedException { assert grp.mvccEnabled(); DataPageIO iox = (DataPageIO)io; int off = iox.getPayloadOffset(pageAddr, itemId, grp.dataRegion().pageMemory().realPageSize(grp.groupId()), MVCC_INFO_SIZE); long newCrd = iox.newMvccCoordinator(pageAddr, off); long newCntr = iox.newMvccCounter(pageAddr, off); int newOpCntr = iox.newMvccOperationCounter(pageAddr, off); assert newCrd == MVCC_CRD_COUNTER_NA || state(grp, newCrd, newCntr, newOpCntr) == TxState.ABORTED; iox.updateNewVersion(pageAddr, off, newVer, TxState.NA); if (isWalDeltaRecordNeeded(grp.dataRegion().pageMemory(), cacheId, pageId, page, ctx.wal(), walPlc)) ctx.wal().log(new DataPageMvccMarkUpdatedRecord(cacheId, pageId, itemId, newVer.coordinatorVersion(), newVer.counter(), newVer.operationCounter())); return TRUE; } }
cctx.cacheContext(CU.cacheId(cacheName)).group().dataRegion().config().getName();
/** {@inheritDoc} */ @Override protected void initDataStructures() throws IgniteCheckedException { assert ctx.database().checkpointLockIsHeldByThread(); Metas metas = getOrAllocateCacheMetas(); RootPage reuseListRoot = metas.reuseListRoot; reuseList = new ReuseListImpl(grp.groupId(), grp.cacheOrGroupName(), grp.dataRegion().pageMemory(), ctx.wal(), reuseListRoot.pageId().pageId(), reuseListRoot.isAllocated()); RootPage metastoreRoot = metas.treeRoot; indexStorage = new IndexStorageImpl(grp.dataRegion().pageMemory(), ctx.wal(), globalRemoveId(), grp.groupId(), grp.sharedGroup(), PageIdAllocator.INDEX_PARTITION, PageIdAllocator.FLAG_IDX, reuseList, metastoreRoot.pageId().pageId(), metastoreRoot.isAllocated(), ctx.kernalContext().failure()); ((GridCacheDatabaseSharedManager)ctx.database()).addCheckpointListener(this); }
/** * Test for check checkpoint size metric. * * @throws Exception If failed. */ @Test public void testCheckpointBufferSize() throws Exception { IgniteEx ig = startGrid(0); ig.cluster().active(true); DataRegionMetricsImpl regionMetrics = ig.cachex(DEFAULT_CACHE_NAME) .context().group().dataRegion().memoryMetrics(); Assert.assertTrue(regionMetrics.getCheckpointBufferSize() != 0); Assert.assertTrue(regionMetrics.getCheckpointBufferSize() <= MAX_REGION_SIZE); }
PageMemoryEx pageMemory = (PageMemoryEx)grpCtx.dataRegion().pageMemory();
/** * Test for check used checkpoint size metric. * * @throws Exception If failed. */ @Test public void testUsedCheckpointBuffer() throws Exception { IgniteEx ig = startGrid(0); ig.cluster().active(true); final DataRegionMetricsImpl regionMetrics = ig.cachex(DEFAULT_CACHE_NAME) .context().group().dataRegion().memoryMetrics(); Assert.assertEquals(0, regionMetrics.getUsedCheckpointBufferPages()); Assert.assertEquals(0, regionMetrics.getUsedCheckpointBufferSize()); load(ig); GridCacheDatabaseSharedManager psMgr = (GridCacheDatabaseSharedManager)ig.context().cache().context().database(); GridFutureAdapter<T2<Long, Long>> metricsResult = new GridFutureAdapter<>(); IgniteInternalFuture chpBeginFut = psMgr.wakeupForCheckpoint(null); chpBeginFut.listen((f) -> { load(ig); metricsResult.onDone(new T2<>( regionMetrics.getUsedCheckpointBufferPages(), regionMetrics.getUsedCheckpointBufferSize() )); }); metricsResult.get(); Assert.assertTrue(metricsResult.get().get1() > 0); Assert.assertTrue(metricsResult.get().get2() > 0); }