Class HttpShardHandler

    • Field Detail

      • ONLY_NRT_REPLICAS

        public static String ONLY_NRT_REPLICAS
        If the request context map has an entry with this key and Boolean.TRUE as value, prepDistributed(ResponseBuilder) will only include Replica.Type.NRT replicas as possible destination of the distributed request (or a leader replica of type Replica.Type.TLOG). This is used by the RealtimeGet handler, since other types of replicas shouldn't respond to RTG requests
      • FUTURE_MAP_LOCK

        protected final Object FUTURE_MAP_LOCK
      • pending

        protected AtomicInteger pending
        The number of pending requests. This must be incremented before a ShardResponse is added to responses, and decremented after a ShardResponse is removed from responses. We can't rely on responseFutureMap.size() because it is an unsynchronized collection updated by multiple threads, and it's internal state including the size field is not volatile/synchronized.
      • lbClient

        protected org.apache.solr.client.solrj.impl.LBHttp2SolrClient lbClient
    • Method Detail

      • getShardsTolerantAsBool

        public static boolean getShardsTolerantAsBool​(SolrQueryRequest req)
        Parse the "shards.tolerant" param from params as a boolean; accepts "requireZkConnected" as a valid value indicating false .

        By default, returns false when "shards.tolerant" is not set in params.

      • submit

        public void submit​(ShardRequest sreq,
                           String shard,
                           org.apache.solr.common.params.ModifiableSolrParams params)
        Description copied from class: ShardHandler
        Sends a request (represented by sreq) to the specified shard.

        The outgoing request may be sent asynchronously. Callers must invoke ShardHandler.takeCompletedIncludingErrors() or ShardHandler.takeCompletedOrError() to inspect the success or failure of requests.

        Specified by:
        submit in class ShardHandler
        Parameters:
        sreq - metadata about the series of sub-requests that the outgoing request belongs to and should be tracked with.
        shard - URLs for replicas of the receiving shard, delimited by '|' (e.g. "http://solr1:8983/solr/foo1|http://solr2:7574/solr/foo2")
        params - query-parameters set on the outgoing request
      • makeShardRequest

        protected void makeShardRequest​(ShardRequest sreq,
                                        String shard,
                                        org.apache.solr.common.params.ModifiableSolrParams params,
                                        org.apache.solr.client.solrj.impl.LBSolrClient.Req lbReq,
                                        HttpShardHandler.SimpleSolrResponse ssr,
                                        ShardResponse srsp,
                                        long startTimeNS)
        Do the actual work of sending a request to a shard and receiving the response
        Parameters:
        sreq - the request to make
        shard - the shard to address
        params - request parameters
        lbReq - the load balanced request suitable for LBHttp2SolrClient
        ssr - the response collector part 1
        srsp - the shard response collector
        startTimeNS - the time at which the request was initiated, likely just prior to calling this method.
      • createQueryRequest

        protected org.apache.solr.client.solrj.request.QueryRequest createQueryRequest​(ShardRequest sreq,
                                                                                       org.apache.solr.common.params.ModifiableSolrParams params,
                                                                                       String shard)
        Subclasses could modify the request based on the shard
      • takeCompletedIncludingErrors

        public ShardResponse takeCompletedIncludingErrors()
        Description copied from class: ShardHandler
        Returns a ShardResponse of the last response correlated with a ShardRequest. This won't return early if it runs into an error. Callers are responsible for ensuring that this can't be called before requests have been submitted with submit.
        Specified by:
        takeCompletedIncludingErrors in class ShardHandler
      • takeCompletedOrError

        public ShardResponse takeCompletedOrError()
        Description copied from class: ShardHandler
        Returns a ShardResponse of the last response correlated with a ShardRequest, or immediately returns a ShardResponse if there was an error detected. Callers are responsible for ensuring that this can't be called before requests have been submitted with submit.
        Specified by:
        takeCompletedOrError in class ShardHandler
      • responsesPending

        protected boolean responsesPending()
      • cancelAll

        public void cancelAll()
        Description copied from class: ShardHandler
        Cancels all uncompleted requests managed by this instance
        Specified by:
        cancelAll in class ShardHandler
      • prepDistributed

        public void prepDistributed​(ResponseBuilder rb)
        Description copied from class: ShardHandler
        Bootstraps any data structures needed by the ShardHandler to execute or track outgoing requests.
        Specified by:
        prepDistributed in class ShardHandler
        Parameters:
        rb - provides access to request and response state.