/** {@inheritDoc} */ @Override public void apply(T t) { try { applyx(t); } catch (IgniteCheckedException e) { throw F.wrap(e); } }
fetchFut.listen(new IgniteInClosureX<IgniteInternalFuture<GridDhtAffinityAssignmentResponse>>() { @Override public void applyx(IgniteInternalFuture<GridDhtAffinityAssignmentResponse> fetchFut) throws IgniteCheckedException {
/** * @param crd Coordinator flag. * @param c Closure. */ private void forAllCacheGroups(boolean crd, IgniteInClosureX<GridAffinityAssignmentCache> c) { if (crd) { for (CacheGroupHolder grp : grpHolders.values()) c.apply(grp.affinity()); } else { for (CacheGroupContext grp : cctx.kernalContext().cache().cacheGroups()) { if (grp.isLocal()) continue; c.apply(grp.affinity()); } } }
fetchFut.listen(new IgniteInClosureX<IgniteInternalFuture<GridDhtAffinityAssignmentResponse>>() { @Override public void applyx(IgniteInternalFuture<GridDhtAffinityAssignmentResponse> fetchFut) throws IgniteCheckedException {
/** * @param newIdx Index. * @param newItem Item. * @param maxIdxDiff Max difference in indexes. * @param c Closure applied on evicted object before eviction. * @return Evicted value on success or {@code null} if update failed. * @throws InterruptedException If interrupted. * @throws IgniteCheckedException If closure throws exception. */ @Nullable synchronized V update(long newIdx, V newItem, long maxIdxDiff, @Nullable IgniteInClosureX<V> c) throws InterruptedException, IgniteCheckedException { assert newIdx >= 0; // Thread should wait and allow previous update to finish. while (newIdx - idx > maxIdxDiff) wait(); idx = newIdx; // Index should be updated even if closure fails. if (c != null && item != null) c.applyx(item); V old = item; item = newItem; notifyAll(); return old; }
/** * Execute closure inside cache transaction. * * @param cache Cache. * @param concurrency Concurrency. * @param isolation Isolation. * @param clo Closure. * @throws IgniteCheckedException If failed. */ public static <K, V> void inTx(IgniteInternalCache<K, V> cache, TransactionConcurrency concurrency, TransactionIsolation isolation, IgniteInClosureX<IgniteInternalCache<K ,V>> clo) throws IgniteCheckedException { try (GridNearTxLocal tx = cache.txStartEx(concurrency, isolation)) { clo.applyx(cache); tx.commit(); } }
/** * @param c Cache closure. */ private void forAllRegisteredCacheGroups(IgniteInClosureX<CacheGroupDescriptor> c) { Collection<CacheGroupDescriptor> affinityCaches = cachesRegistry.allGroups().values().stream() .filter(desc -> desc.config().getCacheMode() != LOCAL) .collect(Collectors.toList()); try { U.doInParallel(cctx.kernalContext().getSystemExecutorService(), affinityCaches, t -> { c.applyx(t); return null; }); } catch (IgniteCheckedException e) { throw new IgniteException("Failed to execute affinity operation on cache groups", e); } }
/** * Execute closure inside cache transaction. * * @param cache Cache. * @param concurrency Concurrency. * @param isolation Isolation. * @param clo Closure. * @throws IgniteCheckedException If failed. */ public static <K, V> void inTx(Ignite ignite, IgniteCache<K, V> cache, TransactionConcurrency concurrency, TransactionIsolation isolation, IgniteInClosureX<IgniteCache<K ,V>> clo) throws IgniteCheckedException { try (Transaction tx = ignite.transactions().txStart(concurrency, isolation)) { clo.applyx(cache); tx.commit(); } }
/** * @param crd Coordinator flag. * @param c Closure. */ private void forAllCacheGroups(boolean crd, IgniteInClosureX<GridAffinityAssignmentCache> c) { Collection<GridAffinityAssignmentCache> affinityCaches; if (crd) { affinityCaches = grpHolders.values().stream() .map(CacheGroupHolder::affinity) .collect(Collectors.toList()); } else { affinityCaches = cctx.kernalContext().cache().cacheGroups().stream() .filter(grp -> !grp.isLocal()) .filter(grp -> !grp.isRecoveryMode()) .map(CacheGroupContext::affinity) .collect(Collectors.toList()); } try { U.doInParallel(cctx.kernalContext().getSystemExecutorService(), affinityCaches, t -> { c.applyx(t); return null; }); } catch (IgniteCheckedException e) { throw new IgniteException("Failed to execute affinity operation on cache groups", e); } }
afterRmv.applyx(null);
/** * Execute certain logic for all nodes. * * @param task Task. * @throws Exception If failed. */ protected void forAllNodes(IgniteInClosureX<Ignite> task) throws Exception { for (Ignite node : Ignition.allGrids()) { try { info(""); info(">>> Executing test on node: " + node.name()); task.applyx(node); } finally { for (Ignite node0 : Ignition.allGrids()) { Collection<String> cacheNames = node0.cacheNames(); for (String cacheName : cacheNames) destroyCache(node0, cacheName); } } } }
/** {@inheritDoc} */ @Override public void apply(T t) { try { applyx(t); } catch (IgniteCheckedException e) { throw F.wrap(e); } }
/** * @param newIdx Index. * @param newItem Item. * @param maxIdxDiff Max difference in indexes. * @param c Closure applied on evicted object before eviction. * @return Evicted value on success or {@code null} if update failed. * @throws InterruptedException If interrupted. * @throws IgniteCheckedException If closure throws exception. */ @Nullable synchronized V update(long newIdx, V newItem, long maxIdxDiff, @Nullable IgniteInClosureX<V> c) throws InterruptedException, IgniteCheckedException { assert newIdx >= 0; // Thread should wait and allow previous update to finish. while (newIdx - idx > maxIdxDiff) wait(); idx = newIdx; // Index should be updated even if closure fails. if (c != null && item != null) c.applyx(item); V old = item; item = newItem; notifyAll(); return old; }
/** * @param c Cache closure. * @throws IgniteCheckedException If failed */ private void forAllRegisteredCacheGroups(IgniteInClosureX<CacheGroupDescriptor> c) throws IgniteCheckedException { for (CacheGroupDescriptor cacheDesc : cachesRegistry.allGroups().values()) { if (cacheDesc.config().getCacheMode() == LOCAL) continue; c.applyx(cacheDesc); } }
/** * Execute closure inside cache transaction. * * @param cache Cache. * @param concurrency Concurrency. * @param isolation Isolation. * @param clo Closure. * @throws IgniteCheckedException If failed. */ public static <K, V> void inTx(IgniteInternalCache<K, V> cache, TransactionConcurrency concurrency, TransactionIsolation isolation, IgniteInClosureX<IgniteInternalCache<K ,V>> clo) throws IgniteCheckedException { try (GridNearTxLocal tx = cache.txStartEx(concurrency, isolation)) { clo.applyx(cache); tx.commit(); } }
/** * Execute closure inside cache transaction. * * @param cache Cache. * @param concurrency Concurrency. * @param isolation Isolation. * @param clo Closure. * @throws IgniteCheckedException If failed. */ public static <K, V> void inTx(Ignite ignite, IgniteCache<K, V> cache, TransactionConcurrency concurrency, TransactionIsolation isolation, IgniteInClosureX<IgniteCache<K ,V>> clo) throws IgniteCheckedException { try (Transaction tx = ignite.transactions().txStart(concurrency, isolation)) { clo.applyx(cache); tx.commit(); } }
afterRmv.applyx(null);