/** * */ void waitPreviousReconnect() { if (curReconnectFut != null && !curReconnectFut.isDone()) { assert reconnectDone != null; curReconnectFut.onDone(STOP_RECONNECT); try { reconnectDone.get(); } catch (IgniteCheckedException ignote) { // No-op. } } }
/** {@inheritDoc} */ @Override public String toString() { return S.toString(GridCompoundFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error(), "futs", F.viewReadOnly(futures(), new C1<IgniteInternalFuture<T>, String>() { @Override public String apply(IgniteInternalFuture<T> f) { return Boolean.toString(f.isDone()); } }) ); } }
/** * @throws Exception If failed. */ @Test public void testCompleteOnReducer() throws Exception { GridCompoundFuture<Boolean, Boolean> fut = new GridCompoundFuture<>(CU.boolReducer()); List<GridFutureAdapter<Boolean>> futs = new ArrayList<>(5); for (int i = 0; i < 5; i++) { GridFutureAdapter<Boolean> part = new GridFutureAdapter<>(); fut.add(part); futs.add(part); } fut.markInitialized(); assertFalse(fut.isDone()); assertFalse(fut.isCancelled()); for (int i = 0; i < 3; i++) { futs.get(i).onDone(true); assertFalse(fut.isDone()); } futs.get(3).onDone(false); assertTrue(fut.isDone()); }
/** * @throws Exception If failed. */ @Test public void testCompleteOnException() throws Exception { GridCompoundFuture<Boolean, Boolean> fut = new GridCompoundFuture<>(CU.boolReducer()); List<GridFutureAdapter<Boolean>> futs = new ArrayList<>(5); for (int i = 0; i < 5; i++) { GridFutureAdapter<Boolean> part = new GridFutureAdapter<>(); fut.add(part); futs.add(part); } fut.markInitialized(); assertFalse(fut.isDone()); assertFalse(fut.isCancelled()); for (int i = 0; i < 3; i++) { futs.get(i).onDone(true); assertFalse(fut.isDone()); } futs.get(3).onDone(new IgniteCheckedException("Test message")); assertTrue(fut.isDone()); }
/** * @throws Exception If failed. */ @Test public void testMarkInitialized() throws Exception { GridCompoundFuture<Boolean, Boolean> fut = new GridCompoundFuture<>(); for (int i = 0; i < 5; i++) { IgniteInternalFuture<Boolean> part = new GridFinishedFuture<>(true); fut.add(part); } assertFalse(fut.isDone()); assertFalse(fut.isCancelled()); fut.markInitialized(); assertTrue(fut.isDone()); }
/** * Check completeness of the future. */ private void checkComplete() { if (initialized() && !isDone() && lsnrCalls == futuresCount()) { try { onDone(rdc != null ? rdc.reduce() : null); } catch (RuntimeException e) { logError(logger(), "Failed to execute compound future reducer: " + this, e); onDone(e); } catch (AssertionError e) { logError(logger(), "Failed to execute compound future reducer: " + this, e); onDone(e); throw e; } } }
if (asyncRunFut != null && !asyncRunFut.isDone()) { stop.set(true);
if (txFut == null || txFut.isDone()) { fut = cache().getDhtAllAsync( keys.keySet(),
/** * @throws Exception If failed. */ @Test public void testConcurrentCompletion() throws Exception { GridCompoundFuture<Boolean, Boolean> fut = new GridCompoundFuture<>(CU.boolReducer()); final ConcurrentLinkedDeque<GridFutureAdapter<Boolean>> futs = new ConcurrentLinkedDeque<>(); for (int i = 0; i < 1000; i++) { GridFutureAdapter<Boolean> part = new GridFutureAdapter<>(); fut.add(part); futs.add(part); } fut.markInitialized(); IgniteInternalFuture<?> complete = multithreadedAsync(new Runnable() { @Override public void run() { GridFutureAdapter<Boolean> part; while ((part = futs.poll()) != null) part.onDone(true); } }, 20); complete.get(); assertTrue(fut.isDone()); }
assertTrue(fut.isDone());
assertFalse(fut.isDone());
/** * */ void waitPreviousReconnect() { if (curReconnectFut != null && !curReconnectFut.isDone()) { assert reconnectDone != null; curReconnectFut.onDone(STOP_RECONNECT); try { reconnectDone.get(); } catch (IgniteCheckedException ignote) { // No-op. } } }
/** {@inheritDoc} */ @Override public String toString() { return S.toString(GridCompoundFuture.class, this, "done", isDone(), "cancelled", isCancelled(), "err", error(), "futs", F.viewReadOnly(futures(), new C1<IgniteInternalFuture<T>, String>() { @Override public String apply(IgniteInternalFuture<T> f) { return Boolean.toString(f.isDone()); } }) ); } }
resFut.markInitialized(); if (resFut == null || resFut.isDone()) sendFutureResponse(nodeId, msg); else {
/** * Check completeness of the future. */ private void checkComplete() { if (initialized() && !isDone() && lsnrCalls == futuresCount()) { try { onDone(rdc != null ? rdc.reduce() : null); } catch (RuntimeException e) { logError(logger(), "Failed to execute compound future reducer: " + this, e); onDone(e); } catch (AssertionError e) { logError(logger(), "Failed to execute compound future reducer: " + this, e); onDone(e); throw e; } } }
if (txFut == null || txFut.isDone()) { fut = cache().getDhtAllAsync( keys.keySet(),