class VespaModelUtil {

    public static List<HostName> getClusterControllerInstancesInOrder(ApplicationInstance application,
                                                                          ClusterId contentClusterId)
    {
        Set<ServiceCluster> controllerClusters = getClusterControllerServiceClusters(application);

        Collection<ServiceCluster> controllerClustersForContentCluster = filter(controllerClusters, contentClusterId);

        Set<ServiceInstance> clusterControllerInstances;
        if (controllerClustersForContentCluster.size() == 1) {
            clusterControllerInstances = first(controllerClustersForContentCluster).serviceInstances();
        } else if (controllerClusters.size() == 1) {
            ServiceCluster cluster = first(controllerClusters);
            log.warning("No cluster controller cluster for content cluster " + contentClusterId
                    + ", using the only cluster controller cluster available: " + cluster.clusterId());

            clusterControllerInstances = cluster.serviceInstances();
        } else {
            throw new RuntimeException("Failed getting cluster controller for content cluster " + contentClusterId +
                    ". Available clusters = " + controllerClusters +
                    ", matching clusters = " + controllerClustersForContentCluster);
        }

        return clusterControllerInstances.stream()
                .sorted(CLUSTER_CONTROLLER_INDEX_COMPARATOR)
                .map(serviceInstance -> serviceInstance.hostName())
                .collect(Collectors.toList());
    }

}