use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.
the class ServerImpl method nodeAlive.
/**
* Checks whether a node is alive or not.
*
* @param nodeId Node ID.
* @return {@code True} if node is in the ring and is not being removed from.
*/
private boolean nodeAlive(UUID nodeId) {
// Is node alive or about to be removed from the ring?
TcpDiscoveryNode node = ring.node(nodeId);
boolean nodeAlive = node != null && node.visible();
if (nodeAlive) {
synchronized (mux) {
nodeAlive = !F.transform(failedNodes.keySet(), F.node2id()).contains(nodeId) && !F.transform(leavingNodes, F.node2id()).contains(nodeId);
}
}
return nodeAlive;
}
use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.
the class ServerImpl method prepareNodeAddedMessage.
/**
* @param msg Message to prepare.
* @param destNodeId Destination node ID.
* @param msgs Messages to include.
* @param discardMsgId Discarded message ID.
*/
private void prepareNodeAddedMessage(TcpDiscoveryAbstractMessage msg, UUID destNodeId, @Nullable Collection<PendingMessage> msgs, @Nullable IgniteUuid discardMsgId, @Nullable IgniteUuid discardCustomMsgId) {
assert destNodeId != null;
if (msg instanceof TcpDiscoveryNodeAddedMessage) {
TcpDiscoveryNodeAddedMessage nodeAddedMsg = (TcpDiscoveryNodeAddedMessage) msg;
TcpDiscoveryNode node = nodeAddedMsg.node();
if (node.id().equals(destNodeId)) {
Collection<TcpDiscoveryNode> allNodes = ring.allNodes();
Collection<TcpDiscoveryNode> topToSnd = new ArrayList<>(allNodes.size());
for (TcpDiscoveryNode n0 : allNodes) {
assert n0.internalOrder() != 0 : n0;
// internal order.
if (n0.internalOrder() < nodeAddedMsg.node().internalOrder())
topToSnd.add(n0);
}
nodeAddedMsg.topology(topToSnd);
Collection<TcpDiscoveryAbstractMessage> msgs0 = null;
if (msgs != null) {
msgs0 = new ArrayList<>(msgs.size());
for (PendingMessage pendingMsg : msgs) {
if (pendingMsg.msg != null)
msgs0.add(pendingMsg.msg);
}
}
nodeAddedMsg.messages(msgs0, discardMsgId, discardCustomMsgId);
Map<Long, Collection<ClusterNode>> hist;
synchronized (mux) {
hist = new TreeMap<>(topHist);
}
nodeAddedMsg.topologyHistory(hist);
}
}
}
use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.
the class ServerImpl method dumpDebugInfo.
/** {@inheritDoc} */
@Override
public void dumpDebugInfo(IgniteLogger log) {
if (!debugMode) {
U.quietAndWarn(log, "Failed to dump debug info (discovery SPI was not configured " + "in debug mode, consider setting 'debugMode' configuration property to 'true').");
return;
}
assert log.isInfoEnabled();
synchronized (mux) {
StringBuilder b = new StringBuilder(U.nl());
b.append(">>>").append(U.nl());
b.append(">>>").append("Dumping discovery SPI debug info.").append(U.nl());
b.append(">>>").append(U.nl());
b.append("Local node ID: ").append(getLocalNodeId()).append(U.nl()).append(U.nl());
b.append("Local node: ").append(locNode).append(U.nl()).append(U.nl());
b.append("SPI state: ").append(spiState).append(U.nl()).append(U.nl());
b.append("Internal threads: ").append(U.nl());
b.append(" Message worker: ").append(threadStatus(msgWorker)).append(U.nl());
b.append(" IP finder cleaner: ").append(threadStatus(ipFinderCleaner)).append(U.nl());
b.append(" Stats printer: ").append(threadStatus(statsPrinter)).append(U.nl());
b.append(U.nl());
b.append("Socket readers: ").append(U.nl());
for (SocketReader rdr : readers) b.append(" ").append(rdr).append(U.nl());
b.append(U.nl());
b.append("In-memory log messages: ").append(U.nl());
for (String msg : debugLogQ) b.append(" ").append(msg).append(U.nl());
b.append(U.nl());
b.append("Leaving nodes: ").append(U.nl());
for (TcpDiscoveryNode node : leavingNodes) b.append(" ").append(node.id()).append(U.nl());
b.append(U.nl());
b.append("Failed nodes: ").append(U.nl());
for (TcpDiscoveryNode node : failedNodes.keySet()) b.append(" ").append(node.id()).append(U.nl());
b.append(U.nl());
b.append("Stats: ").append(spi.stats).append(U.nl());
U.quietAndInfo(log, b.toString());
}
}
use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.
the class ServerImpl method processMessageFailedNodes.
/**
* Adds failed nodes specified in the received message to the local failed nodes list.
*
* @param msg Message.
*/
private void processMessageFailedNodes(TcpDiscoveryAbstractMessage msg) {
if (msg.failedNodes() != null) {
for (UUID nodeId : msg.failedNodes()) {
TcpDiscoveryNode failedNode = ring.node(nodeId);
if (failedNode != null) {
if (!failedNode.isLocal()) {
boolean added = false;
synchronized (mux) {
if (!failedNodes.containsKey(failedNode)) {
failedNodes.put(failedNode, msg.senderNodeId() != null ? msg.senderNodeId() : getLocalNodeId());
added = true;
}
}
if (added && log.isDebugEnabled())
log.debug("Added node to failed nodes list [node=" + failedNode + ", msg=" + msg + ']');
}
}
}
}
}
use of org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode in project ignite by apache.
the class GridTcpSpiForwardingSelfTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings({ "IfMayBeConditional", "deprecation" })
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
if (ipFinderUseLocPorts)
ipFinder.setAddresses(Arrays.asList("127.0.0.1:" + locPort1, "127.0.0.1:" + locPort2));
else
ipFinder.setAddresses(Arrays.asList("127.0.0.1:" + extPort1, "127.0.0.1:" + extPort2));
TcpDiscoverySpi spi = new TcpDiscoverySpi();
final int locPort;
final int commLocPort;
if (getTestIgniteInstanceName(0).equals(igniteInstanceName)) {
locPort = locPort1;
commLocPort = commLocPort1;
} else if (getTestIgniteInstanceName(1).equals(igniteInstanceName)) {
locPort = locPort2;
commLocPort = commLocPort2;
} else
throw new IllegalArgumentException("Unknown Ignite instance name");
spi.setIpFinder(ipFinder);
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
spi.setLocalPort(locPort);
spi.setLocalPortRange(1);
cfg.setDiscoverySpi(spi);
cfg.setLocalHost("127.0.0.1");
cfg.setConnectorConfiguration(null);
TcpCommunicationSpi commSpi = new TcpCommunicationSpi() {
@Override
protected GridCommunicationClient createTcpClient(ClusterNode node, int connIdx) throws IgniteCheckedException {
Map<String, Object> attrs = new HashMap<>(node.attributes());
attrs.remove(createSpiAttributeName(ATTR_PORT));
((TcpDiscoveryNode) node).setAttributes(attrs);
return super.createTcpClient(node, connIdx);
}
};
commSpi.setLocalAddress("127.0.0.1");
commSpi.setLocalPort(commLocPort);
commSpi.setLocalPortRange(1);
commSpi.setSharedMemoryPort(-1);
commSpi.setConnectionsPerNode(1);
cfg.setCommunicationSpi(commSpi);
assert rslvr != null;
cfg.setAddressResolver(rslvr);
return cfg;
}
Aggregations