/** * @param fut Completed future to finish this process with. */ private void onResult(IgniteInternalFuture<Map<KeyCacheObject, EntryGetResult>> fut) { assert fut.isDone(); if (fut.error() != null) onDone(fut.error()); else { try { onDone(toEntryInfo(fut.get())); } catch (IgniteCheckedException ignored) { assert false; // Should never happen. } } }
/** {@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 <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); } }
@Override public void apply(IgniteInternalFuture<IgniteBiTuple<Process, HadoopProcessDescriptor>> f) { try { // Make sure there were no exceptions. f.get(); prepareForJob(proc, job, plan); } catch (IgniteCheckedException ignore) { // Exception is printed in future's onDone() method. } } });
/** * @return {@code True} if data is ready to be read. */ public boolean ready() { return readFut.isDone(); }
/** * Interrupt the operation started in {@link BackgroundOperation#start()} method and join interrupted thread. */ void stop() throws Exception { if (fut == null) return; try { fut.get(stopTimeout()); } catch (IgniteFutureTimeoutCheckedException e) { fut.cancel(); fut.get(); } finally { fut = null; } } }
/** * @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); } }); }
/** {@inheritDoc} */ @Override protected void cancelQuery() throws IgniteCheckedException { if (fut != null) fut.cancel(); }
/** * Adds a future to this compound future. * * @param fut Future to add. */ public final void add(IgniteInternalFuture<T> fut) { assert fut != null; synchronized (this) { if (futs == null) futs = fut; else if (futs instanceof IgniteInternalFuture) { Collection<IgniteInternalFuture> futs0 = new ArrayList<>(4); futs0.add((IgniteInternalFuture)futs); futs0.add(fut); futs = futs0; } else ((Collection<IgniteInternalFuture>)futs).add(fut); } fut.listen(this); if (isCancelled()) { try { fut.cancel(); } catch (IgniteCheckedException e) { onDone(e); } } }
/** */ 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); } }
/** {@inheritDoc} */ @Override public Throwable error() { return fut.error(); }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> putAllAsync0(Map<? extends K, ? extends V> m) { return updateAllAsync0(m, null, null, false, false, null).chain(RET2NULL); }
@Override public GridCacheReturn applyx(IgniteInternalFuture<Void> f) throws IgniteCheckedException { f.get(); return ret; } }));
@Override public String apply(IgniteInternalFuture<?> f) { return "[node=" + ((MiniFuture)f).nodeId + ", done=" + f.isDone() + "]"; } });