/** {@inheritDoc} */ @Override public boolean onDone(@Nullable Boolean res, @Nullable Throwable err) { // Make sure to remove future before completion. pendingFuts.remove(id, this); context().exchange().exchangerUpdateHeartbeat(); return super.onDone(res, err); }
/** {@inheritDoc} */ @Override public GridDhtPartitionTopology topology(DiscoCache discoCache) { return cctx.exchange().clientTopology(groupId(), discoCache); } }
/** {@inheritDoc} */ @Override public GridDhtTopologyFuture topologyVersionFuture() { GridDhtTopologyFuture topReadyFut0 = topReadyFut; assert topReadyFut0 != null; if (!topReadyFut0.changedAffinity()) { GridDhtTopologyFuture lastFut = ctx.exchange().lastFinishedFuture(); if (lastFut != null) return lastFut; } return topReadyFut0; }
/** * @param fut Future. * @return {@code True} if rebalance topology version changed by exchange thread or force * reassing exchange occurs, see {@link RebalanceReassignExchangeTask} for details. */ private boolean topologyChanged(RebalanceFuture fut) { return !ctx.exchange().rebalanceTopologyVersion().equals(fut.topVer) || fut != rebalanceFut; // Same topology, but dummy exchange forced because of missing partitions. }
/** * @param sb String builder. * @param ctx Context. */ static void dumpExchangeInfo(StringBuilder sb, GridKernalContext ctx) { GridCachePartitionExchangeManager exchMgr = ctx.cache().context().exchange(); GridDhtTopologyFuture fut = exchMgr.lastTopologyFuture(); sb.append("Partitions exchange info [readyVer=").append(exchMgr.readyAffinityVersion()).append(']').append(U.nl()) .append("Last initialized exchange future: ").append(fut); }
/** {@inheritDoc} */ @Override public void apply(StringBuilder sb, GridKernalContext ctx) { sb.append(U.nl()); List<GridDhtPartitionsExchangeFuture> futs = ctx.cache().context().exchange().exchangeFutures(); for (GridDhtPartitionsExchangeFuture fut : futs) { if (topVer.equals(fut.initialVersion())) { sb.append("Exchange future: ").append(fut); return; } } sb.append("Failed to find exchange future: ").append(topVer); }
/** * @return Ready topology version. */ public AffinityTopologyVersion readyTopologyVersion() { return ctx.cache().context().exchange().readyAffinityVersion(); }
/** * @param cacheName Cache name. * @param keys Keys. * @return Affinity map. * @throws IgniteCheckedException If failed. */ private <K> Map<ClusterNode, Collection<K>> keysToNodes(@Nullable final String cacheName, Collection<? extends K> keys) throws IgniteCheckedException { return keysToNodes(cacheName, keys, ctx.cache().context().exchange().readyAffinityVersion()); }
/** * Get affinity assignment for the given topology version. * * @param topVer Topology version. * @return Affinity assignment. */ public AffinityAssignment assignment(AffinityTopologyVersion topVer) { return assignment(topVer, cctx.shared().exchange().lastAffinityChangedTopologyVersion(topVer)); }
/** * @return Near entries. */ public Set<Cache.Entry<K, V>> nearEntries() { final AffinityTopologyVersion topVer = ctx.shared().exchange().readyAffinityVersion(); return super.entrySet(new CacheEntryPredicateAdapter() { @Override public boolean apply(GridCacheEntryEx entry) { GridNearCacheEntry nearEntry = (GridNearCacheEntry)entry; return !nearEntry.deleted() && nearEntry.visitable(CU.empty0()) && nearEntry.valid(topVer); } }); }
/** {@inheritDoc} */ @Override public void onTimeout() { if (!cctx.kernalContext().isStopping()) cctx.exchange().addCustomTask(this); } }
/** * Get cached affinity for specified topology version. * * @param topVer Topology version. * @return Cached affinity. */ public AffinityAssignment cachedAffinity(AffinityTopologyVersion topVer) { AffinityTopologyVersion lastAffChangeTopVer = ctx.cache().context().exchange().lastAffinityChangedTopologyVersion(topVer); return cachedAffinity(topVer, lastAffChangeTopVer); }
/** * @return Affinity info for current topology version. * @throws IgniteCheckedException If failed. */ private AffinityInfo cache() throws IgniteCheckedException { AffinityInfo aff = affinityCache(cacheName, ctx.cache().context().exchange().readyAffinityVersion()); if (aff == null) throw new IgniteException("Failed to find cache (cache was not started " + "yet or cache was already stopped): " + cacheName); return aff; } }
/** * @param topVer Topology version. * @throws IgniteCheckedException If failed. */ public void awaitForReadyTopologyVersion(AffinityTopologyVersion topVer) throws IgniteCheckedException { IgniteInternalFuture<?> fut = ctx.cache().context().exchange().affinityReadyFuture(topVer); if (fut != null) fut.get(); }
/** * */ private void onLeft() { for (CacheGroupContext grp : cctx.cache().cacheGroups()) { if (grp.isLocal()) continue; grp.preloader().unwindUndeploys(); cctx.exchange().exchangerUpdateHeartbeat(); } }
/** * @param histSize History size. */ private void checkHistorySize(int histSize) { List<Ignite> nodes = G.allGrids(); assertTrue(!nodes.isEmpty()); for (Ignite node : nodes) { List<GridDhtPartitionsExchangeFuture> exchFuts = ((IgniteEx)node).context().cache().context().exchange().exchangeFutures(); assertTrue("Unexpected size: " + exchFuts.size(), !exchFuts.isEmpty() && exchFuts.size() <= histSize); } }
/** * @param readyVer Ready topology version. * * @return {@code true} If pending distributed exchange exists because server topology is changed. */ public boolean serverTopologyChanged(AffinityTopologyVersion readyVer) { GridDhtPartitionsExchangeFuture fut = ctx.cache().context().exchange().lastTopologyFuture(); if (fut.isDone()) return false; AffinityTopologyVersion initVer = fut.initialVersion(); return initVer.compareTo(readyVer) > 0 && !fut.firstEvent().node().isClient(); }
/** * @param node Node. * @param topVer Ready exchange version to wait for before trying to merge exchanges. */ public static void mergeExchangeWaitVersion(Ignite node, long topVer) { ((IgniteEx)node).context().cache().context().exchange().mergeExchangesTestWaitVersion( new AffinityTopologyVersion(topVer, 0), null); }
/** * @param node Node. * @param topVer Ready exchange version to wait for before trying to merge exchanges. */ public static void mergeExchangeWaitVersion(Ignite node, long topVer, List mergedEvts) { ((IgniteEx)node).context().cache().context().exchange().mergeExchangesTestWaitVersion( new AffinityTopologyVersion(topVer, 0), mergedEvts); }
/** * * @param ig Ignite. */ private void awaitExchange(IgniteEx ig) throws IgniteCheckedException { ig.context().cache().context().exchange().lastTopologyFuture().get(); }