/** * Gets affinity ready future, a future that will be completed after affinity with given * topology version is calculated. * * @param topVer Topology version to wait. * @return Affinity ready future. */ public IgniteInternalFuture<AffinityTopologyVersion> affinityReadyFuture(long topVer) { return affinityReadyFuture(new AffinityTopologyVersion(topVer)); }
/** * @param setId Set ID. * @param topVer Topology version. * @throws IgniteCheckedException If failed. */ private void removeSetData(IgniteUuid setId, AffinityTopologyVersion topVer) throws IgniteCheckedException { boolean loc = cctx.isLocal(); GridCacheAffinityManager aff = cctx.affinity(); if (!loc) { aff.affinityReadyFuture(topVer).get(); cctx.preloader().syncFuture().get(); } IgniteInternalCache<?, ?> cache = cctx.cache(); final int BATCH_SIZE = 100; Collection<SetItemKey> keys = new ArrayList<>(BATCH_SIZE); for (Cache.Entry entry : cache.localEntries(new CachePeekMode[] {CachePeekMode.PRIMARY})) { Object obj = entry.getKey(); if (!(obj instanceof SetItemKey && setId.equals(((SetItemKey)obj).setId()))) continue; keys.add((SetItemKey)obj); if (keys.size() == BATCH_SIZE) { retryRemoveAll(cache, keys); keys.clear(); } } if (!keys.isEmpty()) retryRemoveAll(cache, keys); }
/** {@inheritDoc} */ @Override public GridTuple3<GridAffinityMessage, GridAffinityMessage, GridAffinityAssignment> call() throws Exception { assert ignite != null; assert log != null; IgniteKernal kernal = ((IgniteKernal) ignite); GridCacheContext<Object, Object> cctx = kernal.internalCache(cacheName).context(); assert cctx != null; GridKernalContext ctx = kernal.context(); cctx.affinity().affinityReadyFuture(topVer).get(); AffinityAssignment assign0 = cctx.affinity().assignment(topVer); //using legacy GridAffinityAssignment for compatibility. return F.t( affinityMessage(ctx, cctx.config().getAffinity()), affinityMessage(ctx, cctx.config().getAffinityMapper()), new GridAffinityAssignment(topVer, assign0.assignment(), assign0.idealAssignment()) ); }
IgniteInternalFuture<AffinityTopologyVersion> verFut = cctx.affinity().affinityReadyFuture(topVer);
/** * Gets affinity ready future, a future that will be completed after affinity with given * topology version is calculated. * * @param topVer Topology version to wait. * @return Affinity ready future. */ public IgniteInternalFuture<AffinityTopologyVersion> affinityReadyFuture(long topVer) { return affinityReadyFuture(new AffinityTopologyVersion(topVer)); }
/** * @param setId Set ID. * @param topVer Topology version. * @throws IgniteCheckedException If failed. */ @SuppressWarnings("unchecked") private void removeSetData(IgniteUuid setId, AffinityTopologyVersion topVer) throws IgniteCheckedException { boolean loc = cctx.isLocal(); GridCacheAffinityManager aff = cctx.affinity(); if (!loc) { aff.affinityReadyFuture(topVer).get(); cctx.preloader().syncFuture().get(); } IgniteInternalCache<?, ?> cache = cctx.cache(); final int BATCH_SIZE = 100; Collection<SetItemKey> keys = new ArrayList<>(BATCH_SIZE); for (Cache.Entry entry : cache.localEntries(new CachePeekMode[] {CachePeekMode.PRIMARY})) { Object obj = entry.getKey(); if (!(obj instanceof SetItemKey && setId.equals(((SetItemKey)obj).setId()))) continue; keys.add((SetItemKey)obj); if (keys.size() == BATCH_SIZE) { retryRemoveAll(cache, keys); keys.clear(); } } if (!keys.isEmpty()) retryRemoveAll(cache, keys); }
/** {@inheritDoc} */ @Override public GridTuple3<GridAffinityMessage, GridAffinityMessage, GridAffinityAssignment> call() throws Exception { assert ignite != null; assert log != null; IgniteKernal kernal = ((IgniteKernal) ignite); GridCacheContext<Object, Object> cctx = kernal.internalCache(cacheName).context(); assert cctx != null; GridKernalContext ctx = kernal.context(); cctx.affinity().affinityReadyFuture(topVer).get(); AffinityAssignment assign0 = cctx.affinity().assignment(topVer); GridAffinityAssignment assign = assign0 instanceof GridAffinityAssignment ? (GridAffinityAssignment)assign0 : new GridAffinityAssignment(topVer, assign0.assignment(), assign0.idealAssignment(), assign0.mvccCoordinator()); return F.t( affinityMessage(ctx, cctx.config().getAffinity()), affinityMessage(ctx, cctx.config().getAffinityMapper()), assign); }