Get a server by calling {@link AbstractServerPredicate#chooseRandomlyAfterFiltering(java.util.List, Object)}.
The performance for this method is O(n) where n is number of servers to be filtered.
55
@Override
    public Server choose(Object key) {
        ILoadBalancer lb = getLoadBalancer();
        Optional<Server> server = getPredicate().chooseRoundRobinAfterFiltering(lb.getAllServers(), key);
        if (server.isPresent()) {
            return server.get();
        } else {
            return null;
        }       
    }
183125
private Optional<T> getServerIdToTry() {
        if (m_serverIdsToTry.isEmpty()) {
            final Collection<T> moreCandidates = getMoreCandidates();

            if (moreCandidates.isEmpty()) {
                // We were unable to find more candidates. To avoid hammering
                // the service that provides potential candidates, flag that we
                // should sleep for a little while before trying again to get
                // more potential candidates.
                m_sleepBeforeTryingToGetMoreCandidates = true;

                return (new NoneImpl<T>());
            } else {
                // We successfully retrieved more candidates. We clear the
                // flag that prevented requesting more potential candidates,
                // since all is well. Since we have candidates with which to
                // work, we probably will not be hitting the service that
                // provides potential candidates any time soon.
                m_sleepBeforeTryingToGetMoreCandidates = false;

                m_serverIdsToTry.addAll(moreCandidates);

                return (new SomeImpl<T>(m_serverIdsToTry.remove(0)));
            }
        } else {
            // We already have servers to try. Try one of them.
            return (new SomeImpl<T>(m_serverIdsToTry.remove(0)));
        }
    }
703185
public static vpnvserver[] get_filtered(nitro_service service, String filter) throws Exception{
		vpnvserver obj = new vpnvserver();
		options option = new options();
		option.set_filter(filter);
		vpnvserver[] response = (vpnvserver[]) obj.getfiltered(service, option);
		return response;
	}
254651
public Server run() throws Exception {
        if (server == null) {
            server = new Server(port);
            String basePath = "/druid";
            buildSwagger(basePath);
            HandlerList handlers = new HandlerList();
            handlers.addHandler(buildContext(basePath));
            server.setHandler(handlers);
            server.start();
        } else {
            throw new IllegalStateException("Server already running");
        }
        return server;
    }
974812
public static dnsnameserver[] get_filtered(nitro_service service, String filter) throws Exception{
		dnsnameserver obj = new dnsnameserver();
		options option = new options();
		option.set_filter(filter);
		dnsnameserver[] response = (dnsnameserver[]) obj.getfiltered(service, option);
		return response;
	}
200422
@Override
    public T get(int n) {
        checkUnsupportedOperationForIterationOnlyMode("get(int n)");
        
        while ( allResults.size() <= n && nextResultsAvailable() ) {
            moveNextResults(false);
        }

        return allResults.get(n);
    }
1314279
public static location[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception{
		location obj = new location();
		options option = new options();
		option.set_filter(filter);
		location[] response = (location[]) obj.getfiltered(service, option);
		return response;
	}
1077842
@Override
	public ThriftServer getThriftServer(String serverName, int serverPort, TProcessor processor) {
		return new ThreadPoolThriftServerImpl(serverName, serverPort, thriftServerConfiguration, processor);
	}
445084
public static server[] get(nitro_service service) throws Exception{
		server obj = new server();
		server[] response = (server[])obj.get_resources(service);
		return response;
	}
313227
public OperationFuture<List<Server>> archive(GroupFilter groupFilter) {
        return serverService().archive(
            getServerSearchCriteria(groupFilter)
        );
    }
783314
@Override
  public void getServers(
      GetServersRequest request, StreamObserver<GetServersResponse> responseObserver) {
    ServerList servers = channelz.getServers(request.getStartServerId(), maxPageSize);

    GetServersResponse resp;
    try {
      resp = ChannelzProtoUtil.toGetServersResponse(servers);
    } catch (StatusRuntimeException e) {
      responseObserver.onError(e);
      return;
    }

    responseObserver.onNext(resp);
    responseObserver.onCompleted();
  }
1286703
public static server[] get(nitro_service service, server_args args) throws Exception{
		server obj = new server();
		options option = new options();
		option.set_args(nitro_util.object_to_string_withoutquotes(args));
		server[] response = (server[])obj.get_resources(service, option);
		return response;
	}
1200952
public ServerList getServers(long fromId, int maxPageSize) {
    List<InternalInstrumented<ServerStats>> serverList
        = new ArrayList<>(maxPageSize);
    Iterator<InternalInstrumented<ServerStats>> iterator
        = servers.tailMap(fromId).values().iterator();

    while (iterator.hasNext() && serverList.size() < maxPageSize) {
      serverList.add(iterator.next());
    }
    return new ServerList(serverList, !iterator.hasNext());
  }
1099228
public static sslvserver[] get_filtered(nitro_service service, filtervalue[] filter) throws Exception{
		sslvserver obj = new sslvserver();
		options option = new options();
		option.set_filter(filter);
		sslvserver[] response = (sslvserver[]) obj.getfiltered(service, option);
		return response;
	}
855749
def select_server(self,
                      selector,
                      server_selection_timeout=None,
                      address=None):
        """"""
        return random.choice(self.select_servers(selector,
                                                 server_selection_timeout,
                                                 address))
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;
	}
302266
public OperationFuture<List<Server>> removeAutoscalePolicyOnServer(List<Server> serverList) {
        List<JobFuture> jobs = serverList
            .stream()
            .map(server -> removeAutoscalePolicyOnServer(server).jobFuture())
            .collect(toList());

        return
            new OperationFuture<>(
                serverList,
                new ParallelJobsFuture(jobs)
            );
    }