Search in sources :

Example 1 with DisconnectMessage

use of org.apache.nifi.cluster.protocol.message.DisconnectMessage in project nifi by apache.

the class NodeClusterCoordinator method requestNodeDisconnect.

@Override
public void requestNodeDisconnect(final NodeIdentifier nodeId, final DisconnectionCode disconnectionCode, final String explanation) {
    final Set<NodeIdentifier> connectedNodeIds = getNodeIdentifiers(NodeConnectionState.CONNECTED);
    if (connectedNodeIds.size() == 1 && connectedNodeIds.contains(nodeId)) {
        throw new IllegalNodeDisconnectionException("Cannot disconnect node " + nodeId + " because it is the only node currently connected");
    }
    logger.info("Requesting that {} disconnect due to {}", nodeId, explanation == null ? disconnectionCode : explanation);
    updateNodeStatus(new NodeConnectionStatus(nodeId, disconnectionCode, explanation));
    // shutdown, as we will not be able to connect to the node anyway.
    if (disconnectionCode == DisconnectionCode.NODE_SHUTDOWN) {
        return;
    }
    final DisconnectMessage request = new DisconnectMessage();
    request.setNodeId(nodeId);
    request.setExplanation(explanation);
    addNodeEvent(nodeId, "Disconnection requested due to " + explanation);
    disconnectAsynchronously(request, 10, 5);
}
Also used : DisconnectMessage(org.apache.nifi.cluster.protocol.message.DisconnectMessage) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) IllegalNodeDisconnectionException(org.apache.nifi.cluster.manager.exception.IllegalNodeDisconnectionException)

Aggregations

IllegalNodeDisconnectionException (org.apache.nifi.cluster.manager.exception.IllegalNodeDisconnectionException)1 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)1 DisconnectMessage (org.apache.nifi.cluster.protocol.message.DisconnectMessage)1