Class NumInFlightReqSelector

  • All Implemented Interfaces:
    AdaptiveServerSelector

    public class NumInFlightReqSelector
    extends Object
    implements AdaptiveServerSelector
    The NumInFlightReqSelector is an AdaptiveServerSelector implementation that picks the best server based on the number of in-flight queries being processed by the server. The server with the lowest number of in-flight queries is picked.
    • Method Detail

      • select

        public String select​(List<String> serverCandidates)
        Description copied from interface: AdaptiveServerSelector
        Picks the best server to route a query from the list of candidate servers.
        Specified by:
        select in interface AdaptiveServerSelector
        Parameters:
        serverCandidates - Candidate servers from which the best server should be chosen.
        Returns:
        server identifier
      • fetchAllServerRankingsWithScores

        public List<org.apache.commons.lang3.tuple.Pair<String,​Double>> fetchAllServerRankingsWithScores()
        Description copied from interface: AdaptiveServerSelector
        Returns the ranking of servers ordered from best to worst along with the absolute scores based on which the servers are ranked. Based on the implementation of the interface, the score could refer to different things. For NumInFlightReqSelector, score is the number of inflight requests. For LatencySelector, score is the EMA latency. For HybridSelector, score is the hybridScore which is computed by combining latency and # inflight requests.
        Specified by:
        fetchAllServerRankingsWithScores in interface AdaptiveServerSelector
        Returns:
        List of servers along with their values ranked from best to worst.
      • fetchServerRankingsWithScores

        public List<org.apache.commons.lang3.tuple.Pair<String,​Double>> fetchServerRankingsWithScores​(List<String> serverCandidates)
        Description copied from interface: AdaptiveServerSelector
        Same as above but fetches ranking only for the list of serverCandidates provided in the parameter. If a server doesn't have an entry, it's ranked better than other serverCandidates and a value of -1.0 is returned. With the above "fetchAllServerRankingsWithScores" API, ranking for all the servers are fetched. This can become problematic if a broker is routing to multiple server tenants but a query needs to touch only a single server tenant. This API helps fetch ranking only for a subset of servers.
        Specified by:
        fetchServerRankingsWithScores in interface AdaptiveServerSelector
        Returns:
        List of servers along with their values ranked from best to worst.