Search in sources :

Example 1 with IllegalNodeDeletionException

use of org.apache.nifi.cluster.manager.exception.IllegalNodeDeletionException in project nifi by apache.

the class StandardNiFiServiceFacade method deleteNode.

@Override
public void deleteNode(final String nodeId) {
    final NiFiUser user = NiFiUserUtils.getNiFiUser();
    if (user == null) {
        throw new WebApplicationException(new Throwable("Unable to access details for current user."));
    }
    final String userDn = user.getIdentity();
    final NodeIdentifier nodeIdentifier = clusterCoordinator.getNodeIdentifier(nodeId);
    if (nodeIdentifier == null) {
        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);
}
Also used : NiFiUser(org.apache.nifi.authorization.user.NiFiUser) WebApplicationException(javax.ws.rs.WebApplicationException) UnknownNodeException(org.apache.nifi.cluster.manager.exception.UnknownNodeException) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) NodeConnectionStatus(org.apache.nifi.cluster.coordination.node.NodeConnectionStatus) IllegalNodeDeletionException(org.apache.nifi.cluster.manager.exception.IllegalNodeDeletionException)

Aggregations

WebApplicationException (javax.ws.rs.WebApplicationException)1 NiFiUser (org.apache.nifi.authorization.user.NiFiUser)1 NodeConnectionStatus (org.apache.nifi.cluster.coordination.node.NodeConnectionStatus)1 IllegalNodeDeletionException (org.apache.nifi.cluster.manager.exception.IllegalNodeDeletionException)1 UnknownNodeException (org.apache.nifi.cluster.manager.exception.UnknownNodeException)1 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)1