/** {@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 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; } }
/** {@inheritDoc} */ @Override public long localSizeLong(int part, CachePeekMode[] peekModes) throws IgniteCheckedException { PeekModes modes = parsePeekModes(peekModes, true); long size = 0; if (modes.near) size += nearSize(); // Swap and offheap are disabled for near cache. if (modes.offheap) { AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); IgniteCacheOffheapManager offheap = ctx.offheap(); if (ctx.affinity().primaryByPartition(ctx.localNode(), part, topVer) && modes.primary || ctx.affinity().backupByPartition(ctx.localNode(), part, topVer) && modes.backup) size += offheap.cacheEntriesCount(ctx.cacheId(), part); } return size; }
/** {@inheritDoc} */ @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException { PeekModes modes = parsePeekModes(peekModes, true); long size = 0; if (modes.near) size += nearSize(); // Swap and offheap are disabled for near cache. if (modes.primary || modes.backup) { AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); IgniteCacheOffheapManager offheap = ctx.offheap(); if (modes.offheap) size += offheap.cacheEntriesCount(ctx.cacheId(), modes.primary, modes.backup, topVer); else if (modes.heap) { for (GridDhtLocalPartition locPart : ctx.topology().currentLocalPartitions()) { if ((modes.primary && locPart.primary(topVer)) || (modes.backup && locPart.backup(topVer))) size += locPart.publicSize(ctx.cacheId()); } } } return size; }
/** * @param nodeIdx Node index. * @param part Cache partition. * @return Tuple with number of primary and backup keys (one or both will be zero). */ private T2<Integer, Integer> offheapKeysCount(int nodeIdx, int part) throws IgniteCheckedException { GridCacheContext ctx = ((IgniteEx)ignite(nodeIdx)).context().cache().internalCache(DEFAULT_CACHE_NAME).context(); // Swap and offheap are disabled for near cache. IgniteCacheOffheapManager offheapManager = ctx.isNear() ? ctx.near().dht().context().offheap() : ctx.offheap(); //First count entries... int cnt = (int)offheapManager.cacheEntriesCount(ctx.cacheId(), part); GridCacheAffinityManager affinity = ctx.affinity(); AffinityTopologyVersion topVer = affinity.affinityTopologyVersion(); //And then find out whether they are primary or backup ones. int primaryCnt = 0; int backupCnt = 0; if (affinity.primaryByPartition(ctx.localNode(), part, topVer)) primaryCnt = cnt; else if (affinity.backupByPartition(ctx.localNode(), part, topVer)) backupCnt = cnt; return new T2<>(primaryCnt, backupCnt); }
long offHeapPrimaryEntriesCount = cctx.offheap().cacheEntriesCount(cctx.cacheId(), true, false, cctx.affinity().affinityTopologyVersion()); long offHeapBackupEntriesCount = cctx.offheap().cacheEntriesCount(cctx.cacheId(), false, true,
/** {@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 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; } }
/** {@inheritDoc} */ @Override public long localSizeLong(int part, CachePeekMode[] peekModes) throws IgniteCheckedException { PeekModes modes = parsePeekModes(peekModes, true); long size = 0; if (modes.near) size += nearSize(); // Swap and offheap are disabled for near cache. if (modes.offheap) { AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); IgniteCacheOffheapManager offheap = ctx.offheap(); if (ctx.affinity().primaryByPartition(ctx.localNode(), part, topVer) && modes.primary || ctx.affinity().backupByPartition(ctx.localNode(), part, topVer) && modes.backup) size += offheap.cacheEntriesCount(ctx.cacheId(), part); } return size; }
/** {@inheritDoc} */ @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException { PeekModes modes = parsePeekModes(peekModes, true); long size = 0; if (modes.near) size += nearSize(); // Swap and offheap are disabled for near cache. if (modes.primary || modes.backup) { AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); IgniteCacheOffheapManager offheap = ctx.offheap(); if (modes.offheap) size += offheap.cacheEntriesCount(ctx.cacheId(), modes.primary, modes.backup, topVer); else if (modes.heap) { for (GridDhtLocalPartition locPart : ctx.topology().currentLocalPartitions()) { if ((modes.primary && locPart.primary(topVer)) || (modes.backup && locPart.backup(topVer))) size += locPart.publicSize(ctx.cacheId()); } } } return size; }