@Override
    public DataNodeDto removeNode(String nodeId) throws NodeNotFoundException {
        final DataNodeDto node = nodeService.byNodeId(nodeId);
        if (node.getDataNodeStatus() != DataNodeStatus.AVAILABLE) {
            throw new IllegalArgumentException("Only running data nodes can be removed from the cluster.");
        }
        if (nodeService.allActive().values().stream()
                .filter(n -> n.getDataNodeStatus() == DataNodeStatus.AVAILABLE && n.getActionQueue() == null)
                .count() <= 1) {
            throw new IllegalArgumentException("Cannot remove last data node in the cluster.");
        }
        DataNodeLifecycleTrigger trigger = DataNodeLifecycleTrigger.REMOVE;
        DataNodeStatus lockingStatus = DataNodeStatus.REMOVING;
        addToQueue(node, trigger, lockingStatus);
        return node;
    }
@Test
    public void removeNodesPostsFirstToEventBus() throws NodeNotFoundException {
        String node1 = "node1";
        String node2 = "node2";
        nodeService.registerServer(buildTestNode(node1, DataNodeStatus.AVAILABLE));
        nodeService.registerServer(buildTestNode(node2, DataNodeStatus.AVAILABLE));
        nodeService.registerServer(buildTestNode("node3", DataNodeStatus.AVAILABLE));

        classUnderTest.removeNode(node1);
        verify(clusterEventBus).post(DataNodeLifecycleEvent.create(node1, DataNodeLifecycleTrigger.REMOVE));

        classUnderTest.removeNode(node2);
        verifyNoMoreInteractions(clusterEventBus);

        long removeCount = nodeService.allActive().values().stream()
                .filter(dto -> dto.getActionQueue() == DataNodeLifecycleTrigger.REMOVE)
                .count();

        assertEquals(removeCount, 2);
    }