use of org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method sendAllPartitions.
/**
* @param fullMsg Message to send.
* @param nodes Target Nodes.
* @param mergedJoinExchMsgs Messages received from merged 'join node' exchanges.
* @param affinityForJoinedNodes Affinity if was requested by some nodes.
*/
private void sendAllPartitions(GridDhtPartitionsFullMessage fullMsg, Collection<ClusterNode> nodes, Map<UUID, GridDhtPartitionsSingleMessage> mergedJoinExchMsgs, Map<Integer, CacheGroupAffinityMessage> affinityForJoinedNodes) {
assert !nodes.contains(cctx.localNode());
if (log.isTraceEnabled()) {
log.trace("Sending full partition map [nodeIds=" + F.viewReadOnly(nodes, F.node2id()) + ", exchId=" + exchId + ", msg=" + fullMsg + ']');
}
// Find any single message with affinity request. This request exists only for newly joined nodes.
Optional<GridDhtPartitionsSingleMessage> singleMsgWithAffinityReq = nodes.stream().flatMap(node -> Optional.ofNullable(msgs.get(node.id())).filter(singleMsg -> singleMsg.cacheGroupsAffinityRequest() != null).map(Stream::of).orElse(Stream.empty())).findAny();
// Prepare full message for newly joined nodes with affinity request.
final GridDhtPartitionsFullMessage fullMsgWithAffinity = singleMsgWithAffinityReq.filter(singleMessage -> affinityForJoinedNodes != null).map(singleMessage -> fullMsg.copy().joinedNodeAffinity(affinityForJoinedNodes)).orElse(null);
// Prepare and send full messages for given nodes.
nodes.stream().map(node -> {
// No joined nodes, just send a regular full message.
if (fullMsgWithAffinity == null)
return new T2<>(node, fullMsg);
return new T2<>(node, // If single message contains affinity request, use special full message for such single messages.
Optional.ofNullable(msgs.get(node.id())).filter(singleMsg -> singleMsg.cacheGroupsAffinityRequest() != null).map(singleMsg -> fullMsgWithAffinity).orElse(fullMsg));
}).map(nodeAndMsg -> {
ClusterNode node = nodeAndMsg.get1();
GridDhtPartitionsFullMessage fullMsgToSend = nodeAndMsg.get2();
// If exchange has merged, use merged version of exchange id.
GridDhtPartitionExchangeId sndExchId = mergedJoinExchMsgs != null ? Optional.ofNullable(mergedJoinExchMsgs.get(node.id())).map(GridDhtPartitionsAbstractMessage::exchangeId).orElse(exchangeId()) : exchangeId();
if (sndExchId != null && !sndExchId.equals(exchangeId())) {
GridDhtPartitionsFullMessage fullMsgWithUpdatedExchangeId = fullMsgToSend.copy();
fullMsgWithUpdatedExchangeId.exchangeId(sndExchId);
return new T2<>(node, fullMsgWithUpdatedExchangeId);
}
return new T2<>(node, fullMsgToSend);
}).forEach(nodeAndMsg -> {
ClusterNode node = nodeAndMsg.get1();
GridDhtPartitionsFullMessage fullMsgToSend = nodeAndMsg.get2();
try {
cctx.io().send(node, fullMsgToSend, SYSTEM_POOL);
} catch (ClusterTopologyCheckedException e) {
if (log.isDebugEnabled())
log.debug("Failed to send partitions, node failed: " + node);
} catch (IgniteCheckedException e) {
U.error(log, "Failed to send partitions [node=" + node + ']', e);
}
});
}
Aggregations