Sort partitions by client count.

@param clusterNodes
@return List containing {@link RedisClusterNode}s ordered by client count
190647
public static List<RedisClusterNode> sortByClientCount(Iterable<RedisClusterNode> clusterNodes) {

        LettuceAssert.notNull(clusterNodes, "Cluster nodes must not be null");

        List<RedisClusterNode> ordered = LettuceLists.newList(clusterNodes);
        ordered.sort(ClientCountComparator.INSTANCE);
        return ordered;
    }
1062590
int createUserIndexForClusters() {
		if (m_clusterIndices == null) {
			m_clusterIndices = new ArrayList<AttributeStreamOfInt32>(3);
		}

		AttributeStreamOfInt32 new_stream = new AttributeStreamOfInt32(
				m_clusterData.capacity(), -1);
		for (int i = 0, n = m_clusterIndices.size(); i < n; i++) {
			if (m_clusterIndices.get(i) == null) {
				m_clusterIndices.set(i, new_stream);
				return i;
			}
		}
		m_clusterIndices.add(new_stream);
		return m_clusterIndices.size() - 1;
	}
412917
public void setClusters(java.util.Collection<String> clusters) {
        if (clusters == null) {
            this.clusters = null;
            return;
        }

        this.clusters = new java.util.ArrayList<String>(clusters);
    }
557615
public static ns_clusternode[] get_filtered(nitro_service service, String filter) throws Exception
	{
		ns_clusternode obj = new ns_clusternode();
		options option = new options();
		option.set_filter(filter);
		ns_clusternode[] response = (ns_clusternode[]) obj.getfiltered(service, option);
		return response;
	}
237712
private void allClustersEqual(final List<String> clusterUrls) {
        Validate.notEmpty(clusterUrls, "clusterUrls cannot be null");
        // If only one clusterUrl return immediately
        if (clusterUrls.size() == 1)
            return;
        AdminClient adminClientLhs = adminClientPerCluster.get(clusterUrls.get(0));
        Cluster clusterLhs = adminClientLhs.getAdminClientCluster();
        for (int index = 1; index < clusterUrls.size(); index++) {
            AdminClient adminClientRhs = adminClientPerCluster.get(clusterUrls.get(index));
            Cluster clusterRhs = adminClientRhs.getAdminClientCluster();
            if (!areTwoClustersEqual(clusterLhs, clusterRhs))
                throw new VoldemortException("Cluster " + clusterLhs.getName()
                                             + " is not the same as " + clusterRhs.getName());
        }
    }
493569
public static long count(nitro_service service, Long clid) throws Exception{
		clusterinstance_clusternode_binding obj = new clusterinstance_clusternode_binding();
		obj.set_clid(clid);
		options option = new options();
		option.set_count(true);
		clusterinstance_clusternode_binding response[] = (clusterinstance_clusternode_binding[]) obj.get_resources(service,option);
		if (response != null) {
			return response[0].__count;
		}
		return 0;
	}
17089
@SuppressWarnings("WeakerAccess")
  public Cluster resizeCluster(String instanceId, String clusterId, int numServeNodes) {
    return ApiExceptions.callAndTranslateApiException(
        resizeClusterAsync(instanceId, clusterId, numServeNodes));
  }
748975
private ArrayList<String[]> findCluster(Cluster cluster, double cutDist, int minPatternPerCls) {

    ArrayList<String[]> clusterTSIdx = new ArrayList<String[]>();

    if (cluster.getDistance() != null) {
      // if (cluster.getDistance() > cutDist) {
      if (cluster.getDistanceValue() > cutDist) {
        if (cluster.getChildren().size() > 0) {
          clusterTSIdx.addAll(findCluster(cluster.getChildren().get(0), cutDist, minPatternPerCls));
          clusterTSIdx.addAll(findCluster(cluster.getChildren().get(1), cutDist, minPatternPerCls));
        }
      }
      else {
        // String[] idxes = cluster.getName().split("&");
        ArrayList<String> itemsInCluster = getNameInCluster(cluster);
        String[] idxes = itemsInCluster.toArray(new String[itemsInCluster.size()]);
        if (idxes.length > minPatternPerCls) {
          clusterTSIdx.add(idxes);
        }
      }
    }

    return clusterTSIdx;
  }
953219
public Sort sort() {
        SortField[] partitionKeySort = tokenMapper.sortFields();
        SortField[] clusteringKeySort = clusteringKeyMapper.sortFields();
        return new Sort(ArrayUtils.addAll(partitionKeySort, clusteringKeySort));
    }
809294
public java.util.List<Cluster> getClusters() {
        if (clusters == null) {
            clusters = new com.amazonaws.internal.SdkInternalList<Cluster>();
        }
        return clusters;
    }
1194096
public static clusternode[] get(nitro_service service) throws Exception{
		clusternode obj = new clusternode();
		clusternode[] response = (clusternode[])obj.get_resources(service);
		return response;
	}
26740
public static int numPoints(Clustering<? extends MeanModel> clustering) {
    int n = 0;
    for(Cluster<? extends MeanModel> aCluster : clustering.getAllClusters()) {
      n += aCluster.size();
    }
    return n;
  }
1192509
public static clusterinstance[] get(nitro_service service) throws Exception{
		clusterinstance obj = new clusterinstance();
		clusterinstance[] response = (clusterinstance[])obj.get_resources(service);
		return response;
	}
680182
private <K, V> CompletableFuture<StatefulRedisClusterPubSubConnection<K, V>> connectClusterPubSubAsync(
            RedisCodec<K, V> codec) {

        if (partitions == null) {
            return Futures.failed(new IllegalStateException(
                    "Partitions not initialized. Initialize via RedisClusterClient.getPartitions()."));
        }

        activateTopologyRefreshIfNeeded();

        logger.debug("connectClusterPubSub(" + initialUris + ")");

        Mono<SocketAddress> socketAddressSupplier = getSocketAddressSupplier(TopologyComparators::sortByClientCount);

        PubSubClusterEndpoint<K, V> endpoint = new PubSubClusterEndpoint<K, V>(clientOptions, clientResources);
        RedisChannelWriter writer = endpoint;

        if (CommandExpiryWriter.isSupported(clientOptions)) {
            writer = new CommandExpiryWriter(writer, clientOptions, clientResources);
        }

        ClusterDistributionChannelWriter clusterWriter = new ClusterDistributionChannelWriter(clientOptions, writer,
                clusterTopologyRefreshScheduler);

        StatefulRedisClusterPubSubConnectionImpl<K, V> connection = new StatefulRedisClusterPubSubConnectionImpl<>(endpoint,
                clusterWriter, codec, timeout);

        ClusterPubSubConnectionProvider<K, V> pooledClusterConnectionProvider = new ClusterPubSubConnectionProvider<>(this,
                clusterWriter, codec, connection.getUpstreamListener(), clusterTopologyRefreshScheduler);

        clusterWriter.setClusterConnectionProvider(pooledClusterConnectionProvider);
        connection.setPartitions(partitions);

        Supplier<CommandHandler> commandHandlerSupplier = () -> new PubSubCommandHandler<>(clientOptions, clientResources,
                codec, endpoint);

        Mono<StatefulRedisClusterPubSubConnectionImpl<K, V>> connectionMono = Mono.defer(() -> connect(socketAddressSupplier,
                codec, endpoint, connection, commandHandlerSupplier));

        for (int i = 1; i < getConnectionAttempts(); i++) {
            connectionMono = connectionMono.onErrorResume(t -> connect(socketAddressSupplier, codec, endpoint, connection,
                    commandHandlerSupplier));
        }

        return connectionMono
                .flatMap(c -> c.reactive().command().collectList() //
                        .map(CommandDetailParser::parse) //
                                .doOnNext(detail -> c.setState(new RedisState(detail)))
                                .doOnError(e -> c.setState(new RedisState(Collections.emptyList()))).then(Mono.just(c))
                                .onErrorResume(RedisCommandExecutionException.class, e -> Mono.just(c)))
                .doOnNext(
                        c -> connection.registerCloseables(closeableResources, clusterWriter, pooledClusterConnectionProvider))
                .map(it -> (StatefulRedisClusterPubSubConnection<K, V>) it).toFuture();
    }
1014722
public java.util.List<CacheCluster> getCacheClusters() {
        if (cacheClusters == null) {
            cacheClusters = new com.amazonaws.internal.SdkInternalList<CacheCluster>();
        }
        return cacheClusters;
    }
632541
public RemoteFsClusterClient withPartition(Object id, FsClient client) {
		clients.put(id, client);
		aliveClients.put(id, client);
		return this;
	}
279077
public Vertigo deployCluster(String cluster, int nodes) {
    return deployCluster(cluster, null, nodes, null);
  }