/** {@inheritDoc} */ @Override public boolean localPreloadPartition(int part) throws IgniteCheckedException { ctx.offheap().preloadPartition(part); return true; } }
/** {@inheritDoc} */ @Override public long offHeapAllocatedSize() { IgniteCacheOffheapManager mgr = ctx.offheap(); return mgr != null ? mgr.offHeapAllocatedSize() : -1; }
/** {@inheritDoc} */ @Override public void preloadPartition(int part) throws IgniteCheckedException { ctx.offheap().preloadPartition(part); }
/** * @return The size of pending entries. * @throws IgniteCheckedException If failed. */ public long pendingSize() throws IgniteCheckedException { return (pendingEntries != null ? pendingEntries.sizex() : 0) + cctx.offheap().expiredSize(); }
/** * @param segIdx Segment index. * @return RootPage for meta page. * @throws IgniteCheckedException If failed. */ private RootPage getMetaPage(int segIdx) throws IgniteCheckedException { return cctx.offheap().rootPageForIndex(cctx.cacheId(), treeName, segIdx); }
/** * @param segIdx Segment index. * @throws IgniteCheckedException If failed. */ private void dropMetaPage(int segIdx) throws IgniteCheckedException { cctx.offheap().dropRootPageForIndex(cctx.cacheId(), treeName, segIdx); }
/** * Removes value from offheap. * * @throws IgniteCheckedException If failed. */ protected void removeValue() throws IgniteCheckedException { assert lock.isHeldByCurrentThread(); cctx.offheap().remove(cctx, key, partition(), localPartition()); }
/** {@inheritDoc} */ @Override public void removeAll() throws IgniteCheckedException { assert ctx.isLocal(); // We do batch and recreate cursor because removing using a single cursor // will cause it to reinitialize on each merged page. List<K> keys = new ArrayList<>(Math.min(REMOVE_ALL_KEYS_BATCH, size())); do { Iterator<CacheDataRow> it = ctx.offheap().cacheIterator(ctx.cacheId(), true, true, null, null, null); while (it.hasNext() && keys.size() < REMOVE_ALL_KEYS_BATCH) keys.add((K)it.next().key()); removeAll(keys); keys.clear(); } while (!isEmpty()); }
/** {@inheritDoc} */ @Nullable @Override public CacheObject mvccPeek(boolean onheapOnly) throws GridCacheEntryRemovedException, IgniteCheckedException { if (onheapOnly) return null; lockEntry(); try { checkObsolete(); CacheDataRow row = cctx.offheap().mvccRead(cctx, key, MVCC_MAX_SNAPSHOT); return row != null ? row.value() : null; } finally { unlockEntry(); } }
/** {@inheritDoc} */ @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException { PeekModes modes = parsePeekModes(peekModes, true); modes.primary = true; modes.backup = true; if (modes.offheap) return ctx.offheap().cacheEntriesCount(ctx.cacheId()); else if (modes.heap) return size(); else return 0; }
/** {@inheritDoc} */ @Override public void run() { for (GridCacheEntryEx gridCacheEntryEx : cache.entries()) clearEntry(gridCacheEntryEx); if (!ctx.isNear()) { if (id == 0) ctx.offheap().clearCache(ctx, readers); } }
/** {@inheritDoc} */ @Override public void preloadPartition(int part) throws IgniteCheckedException { if (isLocal()) ctx.offheap().preloadPartition(part); else executePreloadTask(part).get(); }
/** {@inheritDoc} */ @Override public long offHeapEntriesCount() { try { IgniteCacheOffheapManager mgr = ctx.offheap(); return mgr != null ? mgr.cacheEntriesCount(ctx.cacheId(), true, true, ctx.affinity().affinityTopologyVersion()) : -1; } catch (IgniteCheckedException ignore) { return 0; } }
/** */ private static Optional<IgniteCacheOffheapManager.CacheDataStore> dataStore( GridCacheContext<?, ?> cctx, Object key) { int p = cctx.affinity().partition(key); return StreamSupport.stream(cctx.offheap().cacheDataStores().spliterator(), false) .filter(ds -> ds.partId() == p) .findFirst(); }
/** */ private static Optional<IgniteCacheOffheapManager.CacheDataStore> dataStore( GridCacheContext<?, ?> cctx, Object key) { int p = cctx.affinity().partition(key); IgniteCacheOffheapManager offheap = cctx.offheap(); return StreamSupport.stream(offheap.cacheDataStores().spliterator(), false) .filter(ds -> ds.partId() == p) .findFirst(); } }
/** */ private static Optional<IgniteCacheOffheapManager.CacheDataStore> dataStore( GridCacheContext<?, ?> cctx, Object key) { int p = cctx.affinity().partition(key); return StreamSupport.stream(cctx.offheap().cacheDataStores().spliterator(), false) .filter(ds -> ds.partId() == p) .findFirst(); } }
/** {@inheritDoc} */ @Override public void run() { IgniteInternalCache cache = ignite.context().cache().cache(name); try { cache.context().offheap().preloadPartition(part); } catch (IgniteCheckedException e) { log.error("Failed to preload the partition [cache=" + name + ", partition=" + part + ']', e); throw new IgniteException(e); } } }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> preloadPartitionAsync(int part) throws IgniteCheckedException { if (isLocal()) { return ctx.kernalContext().closure().runLocalSafe(() -> { try { ctx.offheap().preloadPartition(part); } catch (IgniteCheckedException e) { throw new IgniteException(e); } }); } else return executePreloadTask(part); }
@Override public boolean apply() { try { GridCacheContext cctx = node.context().cache().context().cacheContext(CU.cacheId(DEFAULT_CACHE_NAME)); KeyCacheObject key = cctx.toCacheKeyObject(1); return cctx.offheap().read(cctx, key) == null; } catch (Exception e) { fail(); return false; } } }, 5000));
/** */ private void checkAllVersionsHints(IgniteCache cache) throws IgniteCheckedException { IgniteCacheProxy cache0 = (IgniteCacheProxy)cache; GridCacheContext cctx = cache0.context(); assert cctx.mvccEnabled(); for (Object e : cache) { IgniteBiTuple entry = (IgniteBiTuple)e; KeyCacheObject key = cctx.toCacheKeyObject(entry.getKey()); GridCursor<CacheDataRow> cur = cctx.offheap().mvccAllVersionsCursor(cctx, key, CacheDataRowAdapter.RowData.LINK_WITH_HEADER); while (cur.next()) { CacheDataRow row = cur.get(); assertTrue(row.mvccTxState() != 0); } } }