@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.OFFLOADED) && !nodeConnectionStatus.getState().equals(NodeConnectionState.DISCONNECTED)) { throw new IllegalNodeDeletionException("Cannot remove Node with ID " + nodeId + " because it is not disconnected or offloaded, current state = " + nodeConnectionStatus.getState()); } clusterCoordinator.removeNode(nodeIdentifier, userDn); heartbeatMonitor.removeHeartbeat(nodeIdentifier); }
private ProtocolMessage handleClusterWorkload(final ClusterWorkloadRequestMessage msg) { final ClusterWorkloadResponseMessage response = new ClusterWorkloadResponseMessage(); final Map<NodeIdentifier, NodeWorkload> workloads = new HashMap<>(); getLatestHeartbeats().values().stream() .filter(hb -> NodeConnectionState.CONNECTED.equals(hb.getConnectionStatus().getState())) .forEach(hb -> { NodeWorkload wl = new NodeWorkload(); wl.setReportedTimestamp(hb.getTimestamp()); wl.setSystemStartTime(hb.getSystemStartTime()); wl.setActiveThreadCount(hb.getActiveThreadCount()); wl.setFlowFileCount(hb.getFlowFileCount()); wl.setFlowFileBytes(hb.getFlowFileBytes()); workloads.put(hb.getNodeIdentifier(), wl); }); response.setNodeWorkloads(workloads); return response; }