/** * Updates external process map so that shuffle can proceed with sending messages to reducers. * * @param req Update request. */ private void updateTasks(final HadoopJobInfoUpdateRequest req) { initFut.listen(new CI1<IgniteInternalFuture<?>>() { @Override public void apply(IgniteInternalFuture<?> gridFut) { assert initGuard.get(); assert req.jobId().equals(job.id()); if (req.reducersAddresses() != null) { if (shuffleJob.initializeReduceAddresses(req.reducersAddresses())) { shuffleJob.startSending("external", new IgniteInClosure2X<HadoopProcessDescriptor, HadoopMessage>() { @Override public void applyx(HadoopProcessDescriptor dest, HadoopMessage msg) throws IgniteCheckedException { comm.sendMessage(dest, msg); } }); } } } }); }
/** * @param fut Future. * @param doneCb Closure. * @param cbExec Optional executor to run callback. */ ChainFuture( GridFutureAdapter<R> fut, IgniteClosure<? super IgniteInternalFuture<R>, T> doneCb, @Nullable Executor cbExec ) { this.fut = fut; this.doneCb = doneCb; fut.listen(new GridFutureChainListener<>(this, doneCb, cbExec)); }
/** * Creates data load future and register its as active future. * @return Data load future. */ @NotNull protected IgniteCacheFutureImpl createDataLoadFuture() { GridFutureAdapter internalFut0 = new GridFutureAdapter(); IgniteCacheFutureImpl fut = new IgniteCacheFutureImpl(internalFut0); internalFut0.listen(rmvActiveFut); activeFuts.add(internalFut0); return fut; }
/** * Chain the future making sure that operation is completed after local schema is updated. * * @param fut Current future. * @return Chained future. */ @SuppressWarnings("unchecked") private GridFutureAdapter<?> publicFuture(GridFutureAdapter fut) { final GridFutureAdapter<?> chainedFut = new GridFutureAdapter<>(); fut.listen(new IgniteInClosure<IgniteInternalFuture>() { @Override public void apply(IgniteInternalFuture fut) { Exception err = null; try { fut.get(); if (cacheRegistered && !nop) qryProc.onLocalOperationFinished(op, type); } catch (Exception e) { err = e; } finally { chainedFut.onDone(null, err); } } }); return chainedFut; }
@Override public void onEvent(Event evt) { assert evt != null; final DiscoveryEvent e = (DiscoveryEvent)evt; assert e.type() == EVT_NODE_LEFT || e.type() == EVT_NODE_FAILED : this; final GridChangeGlobalStateFuture f = stateChangeFut.get(); if (f != null) { f.initFut.listen(new CI1<IgniteInternalFuture<?>>() { @Override public void apply(IgniteInternalFuture<?> fut) { f.onNodeLeft(e); } }); } } };
/** * * @param task Partition eviction task. */ private synchronized void taskScheduled(PartitionEvictionTask task) { if (shouldStop()) return; taskInProgress++; GridFutureAdapter<?> fut = task.finishFut; int partId = task.part.id(); partIds.remove(partId); partsEvictFutures.put(partId, fut); fut.listen(f -> { synchronized (this) { taskInProgress--; partsEvictFutures.remove(partId, f); if (totalTasks.decrementAndGet() == 0) evictionGroupsMap.remove(grp.groupId()); } }); }
/** * @param node Sender node. * @param msg Full partition info. */ public void onReceiveFullMessage(final ClusterNode node, final GridDhtPartitionsFullMessage msg) { assert msg != null; assert msg.exchangeId() != null : msg; assert !node.isDaemon() : node; initFut.listen(new CI1<IgniteInternalFuture<Boolean>>() { @Override public void apply(IgniteInternalFuture<Boolean> f) { try { if (!f.get()) return; } catch (IgniteCheckedException e) { U.error(log, "Failed to initialize exchange future: " + this, e); return; } processFullMessage(true, node, msg); } }); }
/** {@inheritDoc} */ @Override public void onMessage(UUID nodeId, Object msg, byte plc) { MvccMessage msg0 = (MvccMessage)msg; if (msg0.waitForCoordinatorInit() && !initFut.isDone()) { initFut.listen(new IgniteInClosure<IgniteInternalFuture<Void>>() { @Override public void apply(IgniteInternalFuture<Void> fut) { assert curCrd.local(); processMessage(nodeId, msg); } }); } else processMessage(nodeId, msg); }
/** * Handles received single node services map message. * * @param snd Sender node id. * @param msg Single services map message. */ protected void onReceiveSingleDeploymentsMessage(UUID snd, ServiceSingleNodeDeploymentResultBatch msg) { assert depId.equals(msg.deploymentId()) : "Wrong message's deployment process id, msg=" + msg; initCrdFut.listen((IgniteInClosure<IgniteInternalFuture<?>>)fut -> { if (isCompleted()) return; synchronized (initCrdMux) { if (remaining.remove(snd)) { singleDepsMsgs.put(snd, msg); if (remaining.isEmpty()) onAllReceived(); } else if (log.isDebugEnabled()) log.debug("Unexpected service single deployments received, msg=" + msg); } }); }
/** * @param node Sender node. * @param msg Message with full partition info. */ public void onReceivePartitionRequest(final ClusterNode node, final GridDhtPartitionsSingleRequest msg) { assert !cctx.kernalContext().clientNode() || msg.restoreState(); assert !node.isDaemon() && !node.isClient() : node; initFut.listen(new CI1<IgniteInternalFuture<Boolean>>() { @Override public void apply(IgniteInternalFuture<Boolean> fut) { processSinglePartitionRequest(node, msg); } }); }
initTaskFut.listen((IgniteInClosure<IgniteInternalFuture<?>>)fut -> { if (isCompleted()) return;
/** * @param nodeId Node ID. * @param msg Message. */ private void processChangeGlobalStateResponse(final UUID nodeId, final GridChangeGlobalStateMessageResponse msg) { assert nodeId != null; assert msg != null; if (log.isDebugEnabled()) { log.debug("Received activation response [requestId=" + msg.getRequestId() + ", nodeId=" + nodeId + "]"); } UUID requestId = msg.getRequestId(); final GridChangeGlobalStateFuture fut = stateChangeFut.get(); if (fut != null && requestId.equals(fut.requestId)) { if (fut.initFut.isDone()) fut.onResponse(nodeId, msg); else { fut.initFut.listen(new CI1<IgniteInternalFuture<?>>() { @Override public void apply(IgniteInternalFuture<?> f) { // initFut is completed from discovery thread, process response from other thread. ctx.getSystemExecutorService().execute(new Runnable() { @Override public void run() { fut.onResponse(nodeId, msg); } }); } }); } } }
fut.listen(new CI1<IgniteInternalFuture<String>>() { @Override public void apply(IgniteInternalFuture<String> t) { if (Thread.currentThread() != runThread) fut.listen(new CI1<IgniteInternalFuture<String>>() { @Override public void apply(IgniteInternalFuture<String> t) { if (Thread.currentThread() != runThread)
/** {@inheritDoc} */ @Override protected void notifyListener(UUID sndId, Message msg, IgniteRunnable msgC) { if (msg instanceof GridIoMessage && ((GridIoMessage)msg).message() instanceof GridDhtPartitionSupplyMessage) { GridDhtPartitionSupplyMessage msg0 = (GridDhtPartitionSupplyMessage)((GridIoMessage)msg).message(); CountDownLatch latch = suspendRebalanceInMiddleLatch.get(msg0.groupId()); if (latch != null) { if (latch.getCount() > 0) latch.countDown(); else { resumeRebalanceFutures.get(msg0.groupId()).listen(f -> super.notifyListener(sndId, msg, msgC)); return; } } } super.notifyListener(sndId, msg, msgC); } }
@Override public Object call() throws Exception { Random rnd = new Random(); while (!done) { for (int j = 0; j < rnd.nextInt(10); j++) { GridFutureAdapter<Object> fut = new GridFutureAdapter<>(); futs.add(fut); for (int k = 1; k < rnd.nextInt(3); k++) { fut.listen(new IgniteInClosure<IgniteInternalFuture<Object>>() { @Override public void apply(IgniteInternalFuture<Object> t) { try { t.get(); } catch (IgniteCheckedException e) { e.printStackTrace(); } cnt.increment(); } }); } } GridFutureAdapter<Object> fut; while ((fut = futs.poll()) != null) fut.onDone(); } return null; } });
if (!initFut.isDone()) { initFut.listen(new IgniteInClosure<IgniteInternalFuture>() { @Override public void apply(IgniteInternalFuture fut) { if (forRead)
/** * Constructor. * * @param latchUid Latch uid. * @param participants Participant nodes. */ ServerLatch(CompletableLatchUid latchUid, Collection<ClusterNode> participants) { super(latchUid, participants); this.permits = new AtomicInteger(participants.size()); // Send final acks when latch is completed. this.complete.listen(f -> { for (ClusterNode node : participants) { try { if (discovery.alive(node)) { io.sendToGridTopic(node, GridTopic.TOPIC_EXCHANGE, new LatchAckMessage(id, topVer, true), GridIoPolicy.SYSTEM_POOL); if (log.isDebugEnabled()) log.debug("Final ack has sent [latch=" + latchId() + ", to=" + node.id() + "]"); } } catch (IgniteCheckedException e) { if (log.isDebugEnabled()) log.debug("Failed to send final ack [latch=" + latchId() + ", to=" + node.id() + "]: " + e.getMessage()); } } }); }
log.trace("Received shuffle message [desc=" + desc + ", msg=" + msg + ']'); initFut.listen(new CI1<IgniteInternalFuture<?>>() { @Override public void apply(IgniteInternalFuture<?> f) { try {
fut.listen(new CI1<IgniteInternalFuture<String>>() { @Override public void apply(IgniteInternalFuture<String> t) { assert Thread.currentThread() == runThread; fut.listen(new CI1<IgniteInternalFuture<String>>() { @Override public void apply(IgniteInternalFuture<String> t) { assert Thread.currentThread() == runThread;
ctx.discovery().localJoinFuture().listen(f -> { if (f.error() == null) this.crd = getLatchCoordinator(AffinityTopologyVersion.NONE);