/** * Ctor. * * @param fut Future to wrap. */ public ComputeConvertingFuture(ComputeTaskFuture fut) { this.fut = ((IgniteFutureImpl)fut).internalFuture(); }
/** {@inheritDoc} */ @Override public void onReconnected() { if (state.compareAndSet(GridKernalState.DISCONNECTED, GridKernalState.STARTED)) ((GridFutureAdapter<?>)reconnectFut.internalFuture()).onDone(); }
/** * Task map callback. */ public void onMapped() { ((GridFutureAdapter)mapFut.internalFuture()).onDone(); }
/** * Finish task callback. */ public void onDone() { ((GridFutureAdapter)mapFut.internalFuture()).onDone(); }
/** {@inheritDoc} */ @Override public void setState(GridKernalState state) { assert state != null; // NOTE: this method should always be called within write lock. this.state.set(state); if (reconnectFut != null) ((GridFutureAdapter<?>)reconnectFut.internalFuture()).onDone(new IgniteCheckedException("Node stopped.")); }
/** {@inheritDoc} */ @Override public GridFutureAdapter<?> onDisconnected() { if (state.get() == GridKernalState.DISCONNECTED) { assert reconnectFut != null; return (GridFutureAdapter<?>)reconnectFut.internalFuture(); } GridFutureAdapter<?> fut = new GridFutureAdapter<>(); reconnectFut = new IgniteFutureImpl<>(fut); if (!state.compareAndSet(GridKernalState.STARTED, GridKernalState.DISCONNECTED)) { ((GridFutureAdapter<?>)reconnectFut.internalFuture()).onDone(new IgniteCheckedException("Node stopped.")); return null; } return fut; }
/** * @param fut Future. * @return Internal future. */ private static IgniteInternalFuture internalFuture(IgniteFuture fut) { assertTrue(fut.toString(), fut instanceof IgniteFutureImpl); return ((IgniteFutureImpl) fut).internalFuture(); }
/** {@inheritDoc} */ @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer, ? extends String>> evts) { (((GridFutureAdapter)((IgniteFutureImpl)res).internalFuture())).onDone("by listener"); } }
@Override public void run() { String v; while (!Thread.currentThread().isInterrupted()) { v = cache.get(key); if (v == null) doSleep(100); else { log.info("Completed by async mvcc get: " + id); (((GridFutureAdapter)((IgniteFutureImpl)promise).internalFuture())).onDone("by get"); break; } } } });
@Override public void apply(IgniteFuture<String> f) { String val = f.get(); if (val != null) { log.info("Completed by get: " + id); (((GridFutureAdapter)((IgniteFutureImpl)promise).internalFuture())).onDone("by async get"); } } });
/** * Performs an operation with transaction with retries. * * @param cache Cache to do the transaction on. * @param clo Closure. * @return Result of closure execution. * @throws IgniteCheckedException If failed. */ public static <T> T doInTransactionWithRetries(IgniteInternalCache cache, IgniteOutClosureX<T> clo) throws IgniteCheckedException { assert cache != null; int attempts = 0; while (attempts < MAX_CACHE_TX_RETRIES) { try (Transaction tx = cache.txStart(PESSIMISTIC, REPEATABLE_READ)) { T res = clo.applyx(); tx.commit(); return res; } catch (IgniteException | IgniteCheckedException e) { ClusterTopologyException cte = X.cause(e, ClusterTopologyException.class); if (cte != null) ((IgniteFutureImpl)cte.retryReadyFuture()).internalFuture().getUninterruptibly(); else throw U.cast(e); } attempts++; } throw new IgniteCheckedException("Failed to perform operation since max number of attempts " + "exceeded. [maxAttempts=" + MAX_CACHE_TX_RETRIES + ']'); }
if (curFut != null && curFut.internalFuture() == reconnectFut) userFut = curFut; else {
/** * Ctor. * * @param fut Future to wrap. */ public ComputeConvertingFuture(ComputeTaskFuture fut) { this.fut = ((IgniteFutureImpl)fut).internalFuture(); }
/** * Task map callback. */ public void onMapped() { ((GridFutureAdapter)mapFut.internalFuture()).onDone(); }
/** * Finish task callback. */ public void onDone() { ((GridFutureAdapter)mapFut.internalFuture()).onDone(); }
/** {@inheritDoc} */ @Override public void onReconnected() { if (state.compareAndSet(GridKernalState.DISCONNECTED, GridKernalState.STARTED)) ((GridFutureAdapter<?>)reconnectFut.internalFuture()).onDone(); }
/** {@inheritDoc} */ @Override public void setState(GridKernalState state) { assert state != null; // NOTE: this method should always be called within write lock. this.state.set(state); if (reconnectFut != null) ((GridFutureAdapter<?>)reconnectFut.internalFuture()).onDone(new IgniteCheckedException("Node stopped.")); }
/** {@inheritDoc} */ @Override public GridFutureAdapter<?> onDisconnected() { if (state.get() == GridKernalState.DISCONNECTED) { assert reconnectFut != null; return (GridFutureAdapter<?>)reconnectFut.internalFuture(); } GridFutureAdapter<?> fut = new GridFutureAdapter<>(); reconnectFut = new IgniteFutureImpl<>(fut); if (!state.compareAndSet(GridKernalState.STARTED, GridKernalState.DISCONNECTED)) { ((GridFutureAdapter<?>)reconnectFut.internalFuture()).onDone(new IgniteCheckedException("Node stopped.")); return null; } return fut; }
((IgniteFutureImpl)cte.retryReadyFuture()).internalFuture().getUninterruptibly(); else throw U.cast(e);
if (curFut != null && curFut.internalFuture() == reconnectFut) userFut = curFut; else {