/** {@inheritDoc} */ @Override public void listen(final IgniteInClosure lsnr) { fut.listen(new IgniteInClosure<IgniteInternalFuture>() { private static final long serialVersionUID = 0L; @Override public void apply(IgniteInternalFuture fut0) { lsnr.apply(ComputeConvertingFuture.this); } }); }
/** * @param fut ResultSet future. */ public void register(IgniteInternalFuture<?> fut) { fut.listen(this); }
@Override public void run() { storeBlocksAsync(blocks).listen(new CI1<IgniteInternalFuture<?>>() { @Override public void apply(IgniteInternalFuture<?> fut) { try { fut.get(); completionFut.onWriteAck(nodeId, batchId); } catch (IgniteCheckedException e) { completionFut.onError(nodeId, e); } } }); } });
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public void listen(final IgniteBiInClosure<Object, Throwable> lsnr) { fut.listen(new IgniteInClosure<IgniteInternalFuture>() { private static final long serialVersionUID = 0L; @Override public void apply(IgniteInternalFuture fut0) { try { lsnr.apply(fut0.get(), null); } catch (Throwable err) { lsnr.apply(null, err); } } }); }
/** * @param <T> Type of command result. * @param fut Future to add. * @return Future for command. */ @SuppressWarnings("unchecked") private <T> Future<T> addFuture(IgniteInternalFuture<T> fut) { synchronized (mux) { if (!fut.isDone()) { fut.listen(lsnr); futs.add(fut); } return new TaskFutureWrapper<>(fut); } }
/** * @param jobId Job id. * @param c Closure of operation. */ private void transform(HadoopJobId jobId, EntryProcessor<HadoopJobId, HadoopJobMetadata, Void> c) { jobMetaCache().invokeAsync(jobId, c).listen(failsLog); }
/** * Future wrapper which ignores any underlying future errors. * * @param f Underlying future. * @return Future wrapper which ignore any underlying future errors. */ private IgniteInternalFuture ignoreErrors(IgniteInternalFuture<?> f) { GridFutureAdapter<?> wrapper = new GridFutureAdapter(); f.listen(future -> wrapper.onDone()); return wrapper; }
/** {@inheritDoc} */ @Override public void listen(IgniteInClosure<? super IgniteFuture<V>> lsnr) { A.notNull(lsnr, "lsnr"); fut.listen(new InternalFutureListener(lsnr)); }
/** * Map operation handling. */ @SuppressWarnings("unchecked") public void start() { worker.start(); synchronized (mux) { worker.future().listen(new IgniteInClosure<IgniteInternalFuture>() { @Override public void apply(IgniteInternalFuture fut) { onLocalNodeFinished(fut); } }); } }
/** * @param op Operation closure. * @return Future. */ private <T> IgniteInternalFuture<T> asyncOp(final CO<IgniteInternalFuture<T>> op) { IgniteInternalFuture<T> fail = asyncOpAcquire(/*retry*/false); if (fail != null) return fail; IgniteInternalFuture<T> f = op.apply(); f.listen(new CI1<IgniteInternalFuture<?>>() { @Override public void apply(IgniteInternalFuture<?> f) { asyncOpRelease(/*retry*/false); } }); return f; }
/** * @param ctx Grid context. * @param lsnr Optional listener (used in test). */ public void send(GridKernalContext ctx, @Nullable IgniteInClosure<IgniteInternalFuture<String>> lsnr) { for (Map.Entry<UUID, CompoundInfoClosure> entry : cls.entrySet()) { UUID rmtNodeId = entry.getKey(); CompoundInfoClosure c = entry.getValue(); IgniteInternalFuture<String> fut = ctx.cluster().requestDiagnosticInfo(rmtNodeId, c, c.message()); if (lsnr != null) fut.listen(lsnr); listenAndLog(ctx.cluster().diagnosticLog(), fut); } }
@Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> t) { IgniteInternalFuture<Boolean> fut0 = ctx.exchange().forceRebalance(exchFut.exchangeId()); fut0.listen(new IgniteInClosure<IgniteInternalFuture<Boolean>>() { @Override public void apply(IgniteInternalFuture<Boolean> future) { try { fut.onDone(future.get()); } catch (Exception e) { fut.onDone(e); } } }); } });
/** * @param op Operation closure. * @return Future. */ @SuppressWarnings("unchecked") private IgniteInternalFuture asyncOp(final Callable<?> op) { IgniteInternalFuture fail = asyncOpAcquire(/*retry*/false); if (fail != null) return fail; IgniteInternalFuture f = ctx.closures().callLocalSafe(op); f.listen(new CI1<IgniteInternalFuture<?>>() { @Override public void apply(IgniteInternalFuture<?> f) { asyncOpRelease(false); } }); return f; }
/** * @param key Key to remove. * @param filter Optional filter. * @return Putx operation future. */ public IgniteInternalFuture<Boolean> removeAsync(final K key, @Nullable final CacheEntryPredicate filter) { final boolean statsEnabled = ctx.statisticsEnabled(); final long start = statsEnabled ? System.nanoTime() : 0L; A.notNull(key, "key"); if (keyCheck) validateCacheKey(key); IgniteInternalFuture<Boolean> fut = removeAsync0(key, filter); if (statsEnabled) fut.listen(new UpdateRemoveTimeStatClosure<Boolean>(metrics0(), start)); return fut; }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<V> getAndRemoveAsync(final K key) { final boolean statsEnabled = ctx.statisticsEnabled(); final long start = statsEnabled ? System.nanoTime() : 0L; A.notNull(key, "key"); if (keyCheck) validateCacheKey(key); IgniteInternalFuture<V> fut = getAndRemoveAsync0(key); if (statsEnabled) fut.listen(new UpdateRemoveTimeStatClosure<V>(metrics0(), start)); return fut; }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> removeAllAsync(@Nullable final Collection<? extends K> keys) { if (F.isEmpty(keys)) return new GridFinishedFuture<Object>(); final boolean statsEnabled = ctx.statisticsEnabled(); final long start = statsEnabled ? System.nanoTime() : 0L; if (keyCheck) validateCacheKeys(keys); IgniteInternalFuture<Object> fut = removeAllAsync0(keys); if (statsEnabled) fut.listen(new UpdateRemoveTimeStatClosure<>(metrics0(), start)); return fut; }
/** {@inheritDoc} */ @Override public void listenAsync(IgniteInClosure<? super IgniteFuture<V>> lsnr, Executor exec) { A.notNull(lsnr, "lsnr"); A.notNull(exec, "exec"); fut.listen(new InternalFutureListener(new AsyncFutureListener<>(lsnr, exec))); }
/** * @param topVer Topology version. */ private void awaitVersionAndRemap(AffinityTopologyVersion topVer){ IgniteInternalFuture<AffinityTopologyVersion> awaitTopologyVersionFuture = cctx.shared().exchange().affinityReadyFuture(topVer); awaitTopologyVersionFuture.listen(f -> { try { remap(f.get()); } catch (IgniteCheckedException e) { onDone(e); } }); }
/** * @param node Node originated request. * @param msg Force keys message. */ protected final void processForceKeysRequest(final ClusterNode node, final GridDhtForceKeysRequest msg) { IgniteInternalFuture<?> fut = ctx.mvcc().finishKeys(msg.keys(), msg.cacheId(), msg.topologyVersion()); if (fut.isDone()) processForceKeysRequest0(node, msg); else fut.listen(new CI1<IgniteInternalFuture<?>>() { @Override public void apply(IgniteInternalFuture<?> t) { processForceKeysRequest0(node, msg); } }); }
/** */ private void onFinishFutureDone(IgniteInternalFuture<IgniteInternalTx> fut) { GridNearTxLocal tx = tx(); Throwable err = fut.error(); if (tx.state() == TransactionState.COMMITTED) tx.context().coordinators().ackTxCommit(tx.mvccSnapshot()) .listen(fut0 -> onDone(tx, addSuppressed(err, fut0.error()))); else { tx.context().coordinators().ackTxRollback(tx.mvccSnapshot()); onDone(tx, err); } }