NIFI-3295 - ensures node is disconnected before trying to remove it. This closes #1444

This commit is contained in:
Pierre Villard 2017-01-25 16:08:52 +01:00 committed by Matt Gilman
parent e113511fef
commit 1a6802a016
1 changed files with 6 additions and 0 deletions

View File

@ -49,6 +49,7 @@ import org.apache.nifi.cluster.coordination.node.DisconnectionCode;
import org.apache.nifi.cluster.coordination.node.NodeConnectionState;
import org.apache.nifi.cluster.coordination.node.NodeConnectionStatus;
import org.apache.nifi.cluster.event.NodeEvent;
import org.apache.nifi.cluster.manager.exception.IllegalNodeDeletionException;
import org.apache.nifi.cluster.manager.exception.UnknownNodeException;
import org.apache.nifi.cluster.protocol.NodeIdentifier;
import org.apache.nifi.components.PropertyDescriptor;
@ -3335,6 +3336,11 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
throw new UnknownNodeException("Cannot remove Node with ID " + nodeId + " because it is not part of the cluster");
}
final NodeConnectionStatus nodeConnectionStatus = clusterCoordinator.getConnectionStatus(nodeIdentifier);
if (!nodeConnectionStatus.getState().equals(NodeConnectionState.DISCONNECTED)) {
throw new IllegalNodeDeletionException("Cannot remove Node with ID " + nodeId + " because it is not disconnected, current state = " + nodeConnectionStatus.getState());
}
clusterCoordinator.removeNode(nodeIdentifier, userDn);
heartbeatMonitor.removeHeartbeat(nodeIdentifier);
}