private static <T> String createSpec(List<T> servers,
                                         Function<T, String> hostnameGetter,
                                         Function<T, Integer> portGetter,
                                         boolean localhostAffinity) {
        String thisServer = HostName.getLocalhost();
        StringBuilder connectionSpec = new StringBuilder();
        for (var server : servers) {
            if (localhostAffinity && !thisServer.equals(hostnameGetter.apply(server))) continue;
            connectionSpec.append(hostnameGetter.apply(server));
            connectionSpec.append(':');
            connectionSpec.append(portGetter.apply(server));
            connectionSpec.append(',');
        }
        if (localhostAffinity && connectionSpec.length() == 0) {
            throw new IllegalArgumentException("Unable to create connect string to localhost: " +
                                               "There is no localhost server specified in config");
        }
        if (connectionSpec.length() > 0) {
            connectionSpec.setLength(connectionSpec.length() - 1); // Remove trailing comma
        }
        return connectionSpec.toString();
    }
Returns the number of servers in the ensemble
zkfacade/src/main/java/com/yahoo/vespa/curator/ConnectionSpec.java