private static void setDistributorWantedState(ContentCluster cluster,
                                                  int index,
                                                  NodeState newStorageWantedState,
                                                  NodeListener stateListener,
                                                  boolean probe) {
        Node distributorNode = new Node(NodeType.DISTRIBUTOR, index);
        NodeInfo nodeInfo = cluster.getNodeInfo(distributorNode);
        if (nodeInfo == null)
            throw new IllegalStateException("Missing distributor at index " + distributorNode.getIndex());

        State newState;
        switch (newStorageWantedState.getState()) {
            case MAINTENANCE -> newState = State.DOWN;
            case RETIRED -> newState = State.UP;
            default -> {
                newState = newStorageWantedState.getState();
                if (!newState.validWantedNodeState(distributorNode.getType()))
                    throw new IllegalStateException("Distributor cannot be set to wanted state " + newState);
            }
        }

        NodeState newWantedState = new NodeState(distributorNode.getType(), newState);
        newWantedState.setDescription(newStorageWantedState.getDescription());

        NodeState currentWantedState = nodeInfo.getUserWantedState();
        if (newWantedState.getState() != currentWantedState.getState() ||
                !Objects.equals(newWantedState.getDescription(),
                        currentWantedState.getDescription())) {
            setNewWantedState(nodeInfo, newWantedState, stateListener, probe);
        }
    }
Set the wanted state on the distributor to something appropriate given the storage is being
set to (or is equal to) newStorageWantedState.
clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/restapiv2/requests/SetNodeStateRequest.java