public static ClickHouseCluster of(String cluster, Collection<ClickHouseNode> nodes) {
        if (nodes == null || nodes.isEmpty() || nodes.iterator().next() == null) {
            throw new IllegalArgumentException("At least one non-null node is required");
        }

        boolean autoDiscovery = false;
        String clusterName = cluster;
        int size = nodes.size();
        List<ClickHouseNode> list = new ArrayList<>(size);
        for (ClickHouseNode n : nodes) {
            if (n == null) {
                continue;
            }
            autoDiscovery = autoDiscovery || n.config.getBoolOption(ClickHouseClientOption.AUTO_DISCOVERY);
            String name = n.getCluster();
            if (!ClickHouseChecker.isNullOrEmpty(name)) {
                if (ClickHouseChecker.isNullOrEmpty(clusterName)) {
                    clusterName = name;
                } else if (!name.equals(clusterName)) {
                    throw new IllegalArgumentException(
                            ClickHouseUtils.format(
                                    "Cluster name should be [%s] for all %d node(s), but it's [%s] for %s", clusterName,
                                    size, name, n));
                }
            }
        }
        if (autoDiscovery && ClickHouseChecker.isNullOrEmpty(clusterName)) {
            throw new IllegalArgumentException("Please specify non-empty cluster name in order to use auto discovery");
        }
        for (ClickHouseNode n : nodes) {
            if (n == null) {
                continue;
            }

            n = clusterName.equals(n.getCluster()) ? n : ClickHouseNode.builder(n).cluster(clusterName).build();
            if (!list.contains(n)) {
                list.add(n);
            }
        }
        return new ClickHouseCluster(clusterName, list);
    }
Creates cluster object from list of nodes.

@param cluster cluster name
@param node    first node
@param more    more nodes if any
@return cluster object
clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseCluster.java