@Override public void onEvent(Event evt) { assert evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT : "Unexpected event: " + evt; UUID id = ((DiscoveryEvent)evt).eventNode().id(); if (log.isDebugEnabled()) log.debug("Processing node departure: " + id); for (Map.Entry<IgniteUuid, CachedDeploymentInfo<K, V>> entry : deps.entrySet()) { CachedDeploymentInfo<K, V> d = entry.getValue(); if (log.isDebugEnabled()) log.debug("Examining cached info: " + d); if (d.senderId().equals(id) || d.removeParticipant(id)) { deps.remove(entry.getKey(), d); if (log.isDebugEnabled()) log.debug("Removed cached info [d=" + d + ", deps=" + deps + ']'); } } allParticipants.remove(id); } };
/** {@inheritDoc} */ @Override public void onConnectionLost(HadoopProcessDescriptor desc) { if (log.isDebugEnabled()) log.debug("Lost connection with remote process: " + desc); if (desc == null) U.warn(log, "Handshake failed."); else if (desc.processId().equals(nodeDesc.processId())) { log.warning("Child process lost connection with parent node (will terminate child process)."); shutdown(); terminate(); } } }
/** * @param nodeId Left node ID * @return {@code True} if node was in the list. */ @Override public synchronized boolean onNodeLeft(UUID nodeId) { for (IgniteInternalFuture<?> fut : futures()) { MiniFuture f = (MiniFuture)fut; if (f.node.id().equals(nodeId)) { if (log.isDebugEnabled()) log.debug("Found mini-future for left node [nodeId=" + nodeId + ", mini=" + f + ", fut=" + this + ']'); return f.onResult(null, newTopologyException(nodeId)); } } if (log.isDebugEnabled()) log.debug("Future does not have mapping for left node (ignoring) [nodeId=" + nodeId + ", fut=" + this + ']'); return false; }
/** {@inheritDoc} */ @Override public void onDisconnected(IgniteFuture<?> reconnectFut) { cancelFutures(new IgniteClientDisconnectedCheckedException(reconnectFut, "Client node disconnected.")); if (log.isDebugEnabled()) { log.debug("onDisconnected [rmtInfos=" + rmtInfos + ", locInfos=" + locInfos + ", clientInfos=" + clientInfos + ']'); } for (Map.Entry<UUID, RemoteRoutineInfo> e : rmtInfos.entrySet()) { RemoteRoutineInfo info = e.getValue(); if (!ctx.localNodeId().equals(info.nodeId) || info.autoUnsubscribe) unregisterRemote(e.getKey()); } for (LocalRoutineInfo routine : locInfos.values()) routine.hnd.onClientDisconnected(); rmtInfos.clear(); clientInfos.clear(); if (discoProtoVer == 2) routinesInfo.onClientDisconnected(locInfos.keySet()); if (log.isDebugEnabled()) { log.debug("after onDisconnected [rmtInfos=" + rmtInfos + ", locInfos=" + locInfos + ", clientInfos=" + clientInfos + ']'); } }
/** * @param nodeId Sender. * @param res Result. */ private boolean onResult0(UUID nodeId, GridNearLockResponse res) { if (log.isDebugEnabled()) log.debug("Received lock response from node [nodeId=" + nodeId + ", res=" + res + ", fut=" + this + ']'); MiniFuture mini = miniFuture(res.miniId()); if (mini != null) { assert mini.node().id().equals(nodeId); if (log.isDebugEnabled()) log.debug("Found mini future for response [mini=" + mini + ", res=" + res + ']'); mini.onResult(res); if (log.isDebugEnabled()) log.debug("Future after processed lock response [fut=" + this + ", mini=" + mini + ", res=" + res + ']'); return true; } U.warn(log, "Failed to find mini future for response (perhaps due to stale message) [res=" + res + ", fut=" + this + ']'); return false; }
/** {@inheritDoc} */ @Override @Nullable protected IgniteInternalFuture<Boolean> addReader(long msgId, GridDhtCacheEntry cached, IgniteTxEntry entry, AffinityTopologyVersion topVer) { // Don't add local node as reader. if (entry.addReader() && !cctx.localNodeId().equals(nearNodeId)) { GridCacheContext cacheCtx = cached.context(); while (true) { try { return cached.addReader(nearNodeId, msgId, topVer); } catch (GridCacheEntryRemovedException ignore) { if (log.isDebugEnabled()) log.debug("Got removed entry when adding to DHT local transaction: " + cached); cached = cacheCtx.dht().entryExx(entry.key(), topVer); } } } return null; }
/** * @param nodeId Left node ID * @return {@code True} if node was in the list. */ @Override public boolean onNodeLeft(UUID nodeId) { boolean found = false; for (IgniteInternalFuture<?> fut : futures()) { if (isMini(fut)) { MiniFuture f = (MiniFuture)fut; if (f.node().id().equals(nodeId)) { if (log.isDebugEnabled()) log.debug("Found mini-future for left node [nodeId=" + nodeId + ", mini=" + f + ", fut=" + this + ']'); f.onResult(newTopologyException(null, nodeId)); found = true; } } } if (!found) { if (log.isDebugEnabled()) log.debug("Near lock future does not have mapping for left node (ignoring) [nodeId=" + nodeId + ", fut=" + this + ']'); } return found; }
/** * @param desc Process descriptor. * @return Client. * @throws IgniteCheckedException If failed. */ @Nullable protected HadoopCommunicationClient createNioClient(HadoopProcessDescriptor desc) throws IgniteCheckedException { assert desc != null; int shmemPort = desc.sharedMemoryPort(); // If remote node has shared memory server enabled and has the same set of MACs // then we are likely to run on the same host and shared memory communication could be tried. if (shmemPort != -1 && locProcDesc.parentNodeId().equals(desc.parentNodeId())) { try { return createShmemClient(desc, shmemPort); } catch (IgniteCheckedException e) { if (e.hasCause(IpcOutOfSystemResourcesException.class)) // Has cause or is itself the IpcOutOfSystemResourcesException. LT.warn(log, OUT_OF_RESOURCES_TCP_MSG); else if (log.isDebugEnabled()) log.debug("Failed to establish shared memory connection with local hadoop process: " + desc); } } return createTcpClient(desc); }
/** * Finds node by id. Returns null in case of absence of specified id in request topology. * * @param top Topology for current request. * @param foundNodeId Node id. * @return Found node or null in case of absence of specified id in request topology. */ private static ClusterNode findNodeById(Iterable<ClusterNode> top, UUID foundNodeId) { for (ClusterNode node : top) if (foundNodeId.equals(node.id())) return node; return null; }
/** {@inheritDoc} */ @Override public boolean onNodeLeft(UUID nodeId) { if (topVer == null) return false; // Local query, do nothing. for (IgniteInternalFuture<?> fut : futures()) { NodeFuture f = (NodeFuture)fut; if (f.node.id().equals(nodeId)) { if (log.isDebugEnabled()) log.debug("Found mini-future for left node [nodeId=" + nodeId + ", mini=" + f + ", fut=" + this + ']'); ClusterTopologyCheckedException topEx = new ClusterTopologyCheckedException("Failed to enlist keys " + "(primary node left grid, retry transaction if possible) [node=" + nodeId + ']'); topEx.retryReadyFuture(cctx.shared().nextAffinityReadyFuture(topVer)); return f.onResult(0, false, topEx); } } if (log.isDebugEnabled()) log.debug("Future does not have mapping for left node (ignoring) [nodeId=" + nodeId + ", fut=" + this + ']'); return false; }
/** * @param reqId Request ID. * @param initNodeId Initialize node id. * @param ex Exception. */ private void sendChangeGlobalStateResponse(UUID reqId, UUID initNodeId, Exception ex) { assert reqId != null; assert initNodeId != null; GridChangeGlobalStateMessageResponse res = new GridChangeGlobalStateMessageResponse(reqId, ex); try { if (log.isDebugEnabled()) log.debug("Sending global state change response [nodeId=" + ctx.localNodeId() + ", topVer=" + ctx.discovery().topologyVersionEx() + ", res=" + res + "]"); if (ctx.localNodeId().equals(initNodeId)) processChangeGlobalStateResponse(ctx.localNodeId(), res); else sharedCtx.io().send(initNodeId, res, SYSTEM_POOL); } catch (ClusterTopologyCheckedException e) { if (log.isDebugEnabled()) { log.debug("Failed to send change global state response, node left [node=" + initNodeId + ", res=" + res + ']'); } } catch (IgniteCheckedException e) { U.error(log, "Failed to send change global state response [node=" + initNodeId + ", res=" + res + ']', e); } }
/** * @param nodeId Left node ID * @return {@code True} if node was in the list. */ @Override public boolean onNodeLeft(UUID nodeId) { boolean found = false; for (IgniteInternalFuture<?> fut : futures()) { if (isMini(fut)) { MiniFuture f = (MiniFuture)fut; if (f.node().id().equals(nodeId)) { f.onResult(newTopologyException(null, nodeId)); found = true; } } } if (log.isDebugEnabled()) log.debug("Near lock future does not have mapping for left node (ignoring) [nodeId=" + nodeId + ", fut=" + this + ']'); return found; }
@Override public void run() { boolean ping = node.id().equals(err0.nodeId()) ? pingNode(node) : pingNode(err0.nodeId()); if (!ping) { if (log.isDebugEnabled()) log.debug("Conflicting node has already left, need to wait for event. " + "Will ignore join request for now since it will be recent [req=" + msg + ", err=" + err0.message() + ']'); // Ignore join request. return; } LT.warn(log, err0.message()); // Always output in debug. if (log.isDebugEnabled()) log.debug(err0.message()); try { trySendMessageDirectly(node, new TcpDiscoveryCheckFailedMessage(err0.nodeId(), err0.sendMessage())); } catch (IgniteSpiException e) { if (log.isDebugEnabled()) log.debug("Failed to send hash ID resolver validation failed message to node " + "[node=" + node + ", err=" + e.getMessage() + ']'); onException("Failed to send hash ID resolver validation failed message to node " + "[node=" + node + ", err=" + e.getMessage() + ']', e); } } }
/** {@inheritDoc} */ @Override public void onResult(UUID nodeId, GridNearTxPrepareResponse res) { if (!isDone()) { MiniFuture mini = miniFuture(res.miniId()); if (mini != null) { assert mini.node().id().equals(nodeId); mini.onResult(res); } else { if (msgLog.isDebugEnabled()) { msgLog.debug("Near optimistic prepare fut, failed to find mini future [txId=" + tx.nearXidVersion() + ", node=" + nodeId + ", res=" + res + ", fut=" + this + ']'); } } } else { if (msgLog.isDebugEnabled()) { msgLog.debug("Near optimistic prepare fut, response for finished future [txId=" + tx.nearXidVersion() + ", node=" + nodeId + ", res=" + res + ", fut=" + this + ']'); } } }