/** * @param nodeId Sender node ID. * @param msg Activation message response. */ public void onResponse(UUID nodeId, GridChangeGlobalStateMessageResponse msg) { assert msg != null; if (isDone()) return; boolean allReceived = false; synchronized (mux) { if (remaining.remove(nodeId)) allReceived = remaining.isEmpty(); responses.put(nodeId, msg); } if (allReceived) onAllReceived(); }
/** * */ private void onAllReceived() { IgniteCheckedException e = new IgniteCheckedException(); boolean fail = false; for (Map.Entry<UUID, GridChangeGlobalStateMessageResponse> entry : responses.entrySet()) { GridChangeGlobalStateMessageResponse r = entry.getValue(); if (r.getError() != null) { fail = true; e.addSuppressed(r.getError()); } } if (fail) onDone(e); else onDone(); }
/** * @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.onDone(concurrentStateChangeError(msg.activate())); fut.onDone(e); fut.setRemaining(nodeIds, topVer.nextMinorVersion()); stateFut.onDone();
while (fut == null || fut.isDone()) { fut = new GridChangeGlobalStateFuture(UUID.randomUUID(), activate, ctx); U.error(log, "Failed to read stored cache configurations: " + e, e); startedFut.onDone(e); startedFut.onDone(new IgniteCheckedException("Failed to execute " + prettyStr(activate) + " request, " + "node is stopping.")); U.error(log, "Failed to send global state change request: " + activate, e); startedFut.onDone(e);
e.addSuppressed(entry.getValue()); fut.onDone(e);
/** * @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); } }); } }); } } }
/** * */ private void onAllReceived() { IgniteCheckedException e = new IgniteCheckedException(); boolean fail = false; for (Map.Entry<UUID, GridChangeGlobalStateMessageResponse> entry : responses.entrySet()) { GridChangeGlobalStateMessageResponse r = entry.getValue(); if (r.getError() != null) { fail = true; e.addSuppressed(r.getError()); } } if (fail) onDone(e); else onDone(); }
/** * @param nodeId Sender node ID. * @param msg Activation message response. */ public void onResponse(UUID nodeId, GridChangeGlobalStateMessageResponse msg) { assert msg != null; if (isDone()) return; boolean allReceived = false; synchronized (mux) { if (remaining.remove(nodeId)) allReceived = remaining.isEmpty(); responses.put(nodeId, msg); } if (allReceived) onAllReceived(); }
/** * @param event Event. */ void onNodeLeft(DiscoveryEvent event) { assert event != null; if (isDone()) return; boolean allReceived = false; synchronized (mux) { if (remaining.remove(event.eventNode().id())) allReceived = remaining.isEmpty(); } if (allReceived) onAllReceived(); }
/** {@inheritDoc} */ @Override public void stop(boolean cancel) throws IgniteCheckedException { super.stop(cancel); if (sharedCtx != null) sharedCtx.io().removeHandler(false, 0, GridChangeGlobalStateMessageResponse.class); ctx.event().removeLocalEventListener(lsr, EVT_NODE_LEFT, EVT_NODE_FAILED); IgniteCheckedException stopErr = new IgniteCheckedException( "Node is stopping: " + ctx.igniteInstanceName()); GridChangeGlobalStateFuture f = stateChangeFut.get(); if (f != null) f.onDone(stopErr); }
/** {@inheritDoc} */ @Override public void onKernalStop(boolean cancel) { GridChangeGlobalStateFuture fut = this.stateChangeFut.get(); if (fut != null) fut.onDone(new IgniteCheckedException("Failed to wait for cluster state change, node is stopping.")); super.onKernalStop(cancel); }
fut.onDone(concurrentStateChangeError(msg.activate())); fut.onDone(e); fut.setRemaining(nodeIds, topVer.nextMinorVersion()); stateFut.onDone();
while (fut == null || fut.isDone()) { fut = new GridChangeGlobalStateFuture(UUID.randomUUID(), activate, ctx); U.error(log, "Failed to read stored cache configurations: " + e, e); startedFut.onDone(e); String errMsg = "Failed to execute " + prettyStr(activate) + " request, node is stopping."; startedFut.onDone(new IgniteCheckedException(errMsg)); U.error(log, "Failed to send global state change request: " + activate, e); startedFut.onDone(e);
e.addSuppressed(entry.getValue()); fut.onDone(e);
/** * @param event Event. */ void onNodeLeft(DiscoveryEvent event) { assert event != null; if (isDone()) return; boolean allReceived = false; synchronized (mux) { if (remaining.remove(event.eventNode().id())) allReceived = remaining.isEmpty(); } if (allReceived) onAllReceived(); }
/** {@inheritDoc} */ @Override public void onKernalStop(boolean cancel) { GridChangeGlobalStateFuture fut = this.stateChangeFut.get(); if (fut != null) fut.onDone(new IgniteCheckedException("Failed to wait for cluster state change, node is stopping.")); super.onKernalStop(cancel); }
/** {@inheritDoc} */ @Override public void stop(boolean cancel) throws IgniteCheckedException { super.stop(cancel); if (sharedCtx != null) sharedCtx.io().removeHandler(false, 0, GridChangeGlobalStateMessageResponse.class); ctx.event().removeLocalEventListener(lsr, EVT_NODE_LEFT, EVT_NODE_FAILED); IgniteCheckedException stopErr = new IgniteCheckedException( "Node is stopping: " + ctx.igniteInstanceName()); GridChangeGlobalStateFuture f = stateChangeFut.get(); if (f != null) f.onDone(stopErr); }