Search in sources :

Example 1 with IgniteCacheOffheapManager

use of org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager in project ignite by apache.

the class GridDistributedCacheAdapter method localSizeLong.

/** {@inheritDoc} */
@Override
public long localSizeLong(int partition, 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(), partition, topVer) && modes.primary || ctx.affinity().backupByPartition(ctx.localNode(), partition, topVer) && modes.backup)
            size += offheap.entriesCount(partition);
    }
    return size;
}
Also used : IgniteCacheOffheapManager(org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)

Example 2 with IgniteCacheOffheapManager

use of org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager in project ignite by apache.

the class GridDistributedCacheAdapter method localSizeLong.

/** {@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.entriesCount(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();
            }
        }
    }
    return size;
}
Also used : IgniteCacheOffheapManager(org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition)

Aggregations

AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)2 IgniteCacheOffheapManager (org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager)2 GridDhtLocalPartition (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition)1