static Map<Integer, ClusterControllerStateRestAPI.Socket> getClusterControllerSockets(ClusterInfoConfig config) {
        Map<Integer, ClusterControllerStateRestAPI.Socket> result = new TreeMap<>();
        for (ClusterInfoConfig.Services service : config.services()) {
            for (ClusterInfoConfig.Services.Ports port : service.ports()) {
                Set<String> tags = parseTags(port.tags());
                if (tags.contains("http") && tags.contains("state")) {
                    result.put(service.index(), new ClusterControllerStateRestAPI.Socket(service.hostname(), port.number()));
                    break;
                }
            }
        }
        if (result.isEmpty()) {
            log.warning("Found no cluster controller in model config");
        } else if (log.isLoggable(Level.FINE)) {
            StringBuilder sb = new StringBuilder();
            sb.append("Found ").append(result.size()).append(" cluster controllers in model config:");
            for (Map.Entry<Integer, ClusterControllerStateRestAPI.Socket> e : result.entrySet()) {
                sb.append("\n  ").append(e.getKey()).append(" -> ").append(e.getValue());
            }
            log.fine(sb.toString());
        }
        return result;
    }
@Test
    void testMappingOfIndexToClusterControllers() {
        ClusterInfoConfig.Builder builder = new ClusterInfoConfig.Builder()
                .clusterId("cluster-id")
                .nodeCount(1)
                .services(new ClusterInfoConfig.Services.Builder()
                        .index(1)
                        .hostname("host-1")
                        .ports(new ClusterInfoConfig.Services.Ports.Builder().number(80).tags("state http"))
                        .ports(new ClusterInfoConfig.Services.Ports.Builder().number(81).tags("ignored port http")))
                .services(new ClusterInfoConfig.Services.Builder()
                        .index(3)
                        .hostname("host-3")
                        .ports(new ClusterInfoConfig.Services.Ports.Builder().number(85).tags("state http"))
                        .ports(new ClusterInfoConfig.Services.Ports.Builder().number(86).tags("foo http bar state")));

        ClusterInfoConfig config = new ClusterInfoConfig(builder);
        Map<Integer, ClusterControllerStateRestAPI.Socket> mapping = StateRestApiV2Handler.getClusterControllerSockets(config);
        Map<Integer, ClusterControllerStateRestAPI.Socket> expected = new TreeMap<>();

        expected.put(1, new ClusterControllerStateRestAPI.Socket("host-1", 80));
        expected.put(3, new ClusterControllerStateRestAPI.Socket("host-3", 85));

        assertEquals(expected, mapping);
    }