/** * Gets current topology version. * * @return Topology version. */ private AffinityTopologyVersion topologyVersion() { return cctx.affinity().affinityTopologyVersion(); } }
/** * * @param key Entry key. * @return Entry or <tt>null</tt>. */ @Nullable public final GridCacheEntryEx peekEx(KeyCacheObject key) { return entry0(key, ctx.affinity().affinityTopologyVersion(), false, false); }
/** * @param key Entry key. * @return Entry (never {@code null}). */ public final GridCacheEntryEx entryEx(KeyCacheObject key) { return entryEx(key, ctx.affinity().affinityTopologyVersion()); }
/** * @param primary If {@code true} includes primary entries. * @param backup If {@code true} includes backup entries. * @param keepBinary Keep binary flag. * @return Local entries iterator. */ public Iterator<Cache.Entry<K, V>> localEntriesIterator(final boolean primary, final boolean backup, final boolean keepBinary) { return localEntriesIterator(primary, backup, keepBinary, ctx.affinity().affinityTopologyVersion()); }
/** * * @param key Entry key. * @return Entry or <tt>null</tt>. */ @Nullable public final GridCacheEntryEx peekEx(Object key) { return entry0(ctx.toCacheKeyObject(key), ctx.affinity().affinityTopologyVersion(), false, false); }
/** {@inheritDoc} */ @Override protected void recordNodeId(UUID primaryNodeId, AffinityTopologyVersion topVer) { assert lockedByCurrentThread(); assert topVer.compareTo(cctx.affinity().affinityTopologyVersion()) <= 0 : "Affinity not ready [" + "topVer=" + topVer + ", readyVer=" + cctx.affinity().affinityTopologyVersion() + ", cache=" + cctx.name() + ']'; primaryNode(primaryNodeId, topVer); }
/** * Releases java-level locks on cache entries. * * @param locked Locked entries. */ private void unlockEntries(Iterable<GridCacheEntryEx> locked) { for (GridCacheEntryEx entry : locked) entry.unlockEntry(); AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); for (GridCacheEntryEx entry : locked) entry.touch(); }
/** {@inheritDoc} */ @Nullable @Override public CacheObject peek() throws GridCacheEntryRemovedException, IgniteCheckedException { IgniteInternalTx tx = cctx.tm().localTx(); AffinityTopologyVersion topVer = tx != null ? tx.topologyVersion() : cctx.affinity().affinityTopologyVersion(); return peek(true, false, topVer, null); }
/** {@inheritDoc} */ @Override public boolean apply(K k, V v) { return !filter || ctx.affinity().primaryByKey(ctx.localNode(), k, ctx.affinity().affinityTopologyVersion()); }
/** {@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 IgniteInternalFuture<?> removeAllAsync() { GridFutureAdapter<Void> opFut = new GridFutureAdapter<>(); AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); CacheOperationContext opCtx = ctx.operationContextPerCall(); removeAllAsync(opFut, topVer, opCtx != null && opCtx.skipStore(), opCtx != null && opCtx.isKeepBinary()); return opFut; }
/** * Initialize future. */ public void init() { AffinityTopologyVersion mappingtopVermappingtopVer; if (topVer.topologyVersion() > 0) mappingtopVermappingtopVer = topVer; else { mappingtopVermappingtopVer = canRemap ? cctx.affinity().affinityTopologyVersion() : cctx.shared().exchange().readyAffinityVersion(); } map(mappingtopVermappingtopVer); }
/** {@inheritDoc} */ @Override public long primarySizeLong() { long sum = 0; AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); for (GridDhtLocalPartition p : topology().currentLocalPartitions()) { if (p.primary(topVer)) sum += p.dataStore().cacheSize(ctx.cacheId()); } return sum; }
@Override public boolean apply() { return cache.context().affinity().affinityTopologyVersion().topologyVersion() == topVer; } }, 5000);
/** {@inheritDoc} */ @Override public void unlockAll( Collection<? extends K> keys ) throws IgniteCheckedException { AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); for (K key : keys) { GridLocalCacheEntry entry = peekExx(ctx.toCacheKeyObject(key)); if (entry != null && ctx.isAll(entry, CU.empty0())) { entry.releaseLocal(); entry.touch(); } } }
/** * @param keys Keys to clear. * @param near Near cache flag. * @return Future. */ private IgniteInternalFuture<?> executeClearTask(@Nullable Set<? extends K> keys, boolean near) { Collection<ClusterNode> srvNodes = ctx.grid().cluster().forCacheNodes(name(), !near, near, false).nodes(); if (!srvNodes.isEmpty()) { ctx.kernalContext().task().setThreadContext(TC_SUBGRID, srvNodes); return ctx.kernalContext().task().execute( new ClearTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), keys, near), null); } else return new GridFinishedFuture<>(); }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<Integer> sizeAsync(final CachePeekMode[] peekModes) { assert peekModes != null; PeekModes modes = parsePeekModes(peekModes, true); IgniteClusterEx cluster = ctx.grid().cluster(); ClusterGroup grp = modes.near ? cluster.forCacheNodes(name(), true, true, false) : cluster.forDataNodes(name()); Collection<ClusterNode> nodes = new ArrayList<>(grp.nodes()); if (nodes.isEmpty()) return new GridFinishedFuture<>(0); ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes); return ctx.kernalContext().task().execute( new SizeTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), peekModes), null); }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<Long> sizeLongAsync(final CachePeekMode[] peekModes) { assert peekModes != null; PeekModes modes = parsePeekModes(peekModes, true); IgniteClusterEx cluster = ctx.grid().cluster(); ClusterGroup grp = modes.near ? cluster.forCacheNodes(name(), true, true, false) : cluster.forDataNodes(name()); Collection<ClusterNode> nodes = new ArrayList<>(grp.nodes()); if (nodes.isEmpty()) return new GridFinishedFuture<>(0L); ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes); return ctx.kernalContext().task().execute( new SizeLongTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), peekModes), null); }
/** {@inheritDoc} */ @Override public long getNonHeapMemoryUsed() { Collection<GridCacheAdapter<?, ?>> caches = ctx.cache().internalCaches(); long nonHeapUsed = vmMetrics.getNonHeapMemoryUsed(); for (GridCacheAdapter<?, ?> cache : caches) if (cache.context().statisticsEnabled() && cache.context().started() && cache.context().affinity().affinityTopologyVersion().topologyVersion() > 0) nonHeapUsed += cache.metrics0().getOffHeapAllocatedSize(); return nonHeapUsed; }
/** * @param cctx Cctx. * @return Remote partition. */ private IgniteBiTuple<Integer, UUID> remotePartition(final GridCacheContext cctx) { ClusterNode node = F.first(cctx.kernalContext().grid().cluster().forRemotes().nodes()); GridCacheAffinityManager affMgr = cctx.affinity(); AffinityTopologyVersion topVer = affMgr.affinityTopologyVersion(); Set<Integer> parts = affMgr.primaryPartitions(node.id(), topVer); return new IgniteBiTuple<>(F.first(parts), node.id()); }