Choose a server in a round robin fashion after the predicate filters a list of servers. Load balancer key
is presumed to be null.
501126
public Optional<Server> chooseRoundRobinAfterFiltering(List<Server> servers) {
        List<Server> eligible = getEligibleServers(servers);
        if (eligible.size() == 0) {
            return Optional.absent();
        }
        return Optional.of(eligible.get(incrementAndGetModulo(eligible.size())));
    }
37924
protected Server getServer(final Settings settings, final String serverId) {
		if (settings == null)
			return null;
		List<Server> servers = settings.getServers();
		if (servers == null || servers.isEmpty())
			return null;

		for (Server server : servers)
			if (serverId.equals(server.getId()))
				return server;
		return null;
	}
1351299
public static server[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception{
		server obj = new server();
		options option = new options();
		option.set_filter(filter);
		server[] response = (server[]) obj.getfiltered(service, option);
		return response;
	}
706545
function getServer(localPath) {
        var provider, server, i;

        for (i = 0; i < _serverProviders.length; i++) {
            provider = _serverProviders[i];
            server = provider.create();

            if (server.canServe(localPath)) {
                return server;
            }
        }

        return null;
    }
100110
static public <E> LoadBalancedList<E> synchronizedList(LoadBalancedList<E> list) {
        return new ConcurrentLoadBalancedList<E>(list);
    }
569641
public OperationFuture<List<LoadBalancer>> update(
            LoadBalancerFilter loadBalancerFilter,
            LoadBalancerConfig config
    ) {
        checkNotNull(loadBalancerFilter, "Load balancer filter must be not null");

        List<LoadBalancer> loadBalancerList = findLazy(loadBalancerFilter)
                .map(metadata -> LoadBalancer.refById(
                    metadata.getId(),
                    DataCenter.refById(metadata.getDataCenterId())
                ))
                .collect(toList());

        return update(loadBalancerList, config);
    }
554820
public void removeServerFromCache(long serverId) {
        servers.computeIfPresent(serverId, (key, server) -> {
            ((Cleanupable) server).cleanup();
            return null;
        });
        nonReadyServers.computeIfPresent(serverId, (key, server) -> {
            ((Cleanupable) server).cleanup();
            return null;
        });
    }
830790
public LoadBalancerPoolFilter loadBalancerPools(LoadBalancerPool... loadBalancerPools) {
        predicate = predicate.and(Filter.or(
                Streams.map(loadBalancerPools, LoadBalancerPool::asFilter)
        ).getPredicate());

        return this;
    }
515759
public void setServerList(java.util.Collection<Server> serverList) {
        if (serverList == null) {
            this.serverList = null;
            return;
        }

        this.serverList = new java.util.ArrayList<Server>(serverList);
    }
845058
def select_host(self, metric):
        
        key = self.keyfunc(metric)
        nodes = []
        servers = set()
        for node in self.hash_ring.get_nodes(key):
            server, instance = node
            if server in servers:
                continue
            servers.add(server)
            nodes.append(node)
            if len(servers) >= self.replication_factor:
                break
        available = [n for n in nodes if self.is_available(n)]
        return random.choice(available or nodes)
416313
public ServiceInstance choose(String serviceId, Object hint) {
		Server server = getServer(getLoadBalancer(serviceId), hint);
		if (server == null) {
			return null;
		}
		return new RibbonServer(serviceId, server, isSecure(server, serviceId),
				serverIntrospector(serviceId).getMetadata(server));
	}
830889
def has_known_servers(self):
        """"""
        return any(s for s in self._server_descriptions.values()
                   if s.is_server_type_known)
99091
private ServerPod []buildServers(int serverCount)
  {
    ArrayList<ServerPod> serversPod = new ArrayList<>();

    for (int i = 0; i < serverCount; i++) {
      //ServerPod serverPod = new ServerPod(i);
      
      //serversPod.add(serverPod);
      
      if (i < _serverList.size()) {
        serversPod.add(_serverList.get(i));
      }
      else {
        serversPod.add(new ServerPod(i));
      }
      
      /*        ServerPod serverHint = _serverList.get(i);
        
        serverPod.setHint(serverHint.getHint());

        if (server == null) {
        }
        else if (server.startsWith("127")) {
          int p = server.indexOf(':');
          int port = Integer.parseInt(server.substring(p + 1));
          
          serverPod.setHintPort(port);
        }
        else {
          serverPod.setHintServerId(server);
        }
        
        ServerBartender server = _cluster.findServerByName(serverHint.getServerId());
        System.out.println("BS22: " + server + " " + serverHint + " " + serverHint.getServerId() + " " + serverHint.getHint());
        serverPod.setServer(server);
      }
        */
    }
    
    ServerPod []serverArray = new ServerPod[serverCount];
    for (int i = 0; i < serverCount; i++) {
      serverArray[i] = serversPod.get(i);
    }
    
    return serverArray;
  }
121252
private boolean getGoodNode(Set<Node> candidateNodes,
                              boolean considerLoad,
                              long blockSize,
                              List<DatanodeDescriptor> results) {
    List<DatanodeDescriptor> sorted = new ArrayList<DatanodeDescriptor>();
    for (Node n : candidateNodes) {
      sorted.add((DatanodeDescriptor)n);
    }
    final long blocksize = blockSize;
    Collections.sort(sorted, new Comparator<DatanodeDescriptor>() {
      public int compare(DatanodeDescriptor n1, DatanodeDescriptor n2) {
        long ret = (n2.getRemaining() - (n2.getBlocksScheduled() * blocksize)) -
                   (n1.getRemaining() - (n1.getBlocksScheduled() * blocksize));
        return ret == 0 ? 0 : (ret > 0) ? 1 : -1;
      }
    });
    // Also, add some randomness. We are doing so because it seems
    // that if there are many copies scheduled at the same time, namenode
    // does not have the uptodate information. So, we need to add some
    // randomness so that there is not a lot of copies targeted to
    // the same node, which will overload the hosts and may lead to
    // timeouts.
    int count = sorted.size() / 2;
    Collections.shuffle(sorted.subList(0, count));
    for (DatanodeDescriptor n : sorted) {
      if (this.isGoodTarget((DatanodeDescriptor)n,
                            blocksize,
                            1, // MaxTargerPerLoc (per rack)
                            considerLoad,
                            results)) {
        results.add((DatanodeDescriptor)n);
        return true;
      }
    }
    return false;
  }
427650
def set_server(self, server_pos, key, value):
        """"""
        self._server_list[server_pos][key] = value
704742
public Optional<Server> chooseRandomlyAfterFiltering(List<Server> servers) {
        List<Server> eligible = getEligibleServers(servers);
        if (eligible.size() == 0) {
            return Optional.absent();
        }
        return Optional.of(eligible.get(random.nextInt(eligible.size())));
    }
336259
public void addScannerServers(final int query_index, final int id, 
      final Set<String> servers) {
    Map<Integer, Set<String>> query_servers = scanner_servers.get(query_index);
    if (query_servers == null) {
      query_servers = new ConcurrentHashMap<Integer, Set<String>>(
          Const.SALT_WIDTH() > 0 ? Const.SALT_BUCKETS() : 1);
      scanner_servers.put(query_index, query_servers);
    }
    query_servers.put(id, servers);
  }