Class ShardHandler

java.lang.Object
org.apache.solr.handler.component.ShardHandler
Direct Known Subclasses:
HttpShardHandler

public abstract class ShardHandler extends Object
Executes, tracks, and awaits all shard-requests made in the course of a distributed request.

New ShardHandler instances are created for each individual distributed request, and should not be assumed to be thread-safe.

  • Constructor Details

    • ShardHandler

      public ShardHandler()
  • Method Details

    • prepDistributed

      public abstract void prepDistributed(ResponseBuilder rb)
      Bootstraps any data structures needed by the ShardHandler to execute or track outgoing requests.
      Parameters:
      rb - provides access to request and response state.
    • submit

      public abstract void submit(ShardRequest sreq, String shard, org.apache.solr.common.params.ModifiableSolrParams params)
      Sends a request (represented by sreq) to the specified shard.

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

      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
    • takeCompletedIncludingErrors

      public abstract ShardResponse takeCompletedIncludingErrors()
      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.
    • takeCompletedOrError

      public abstract ShardResponse takeCompletedOrError()
      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.
    • cancelAll

      public abstract void cancelAll()
      Cancels all uncompleted requests managed by this instance
    • getShardHandlerFactory

      public abstract ShardHandlerFactory getShardHandlerFactory()
    • setShardAttributesToParams

      public static void setShardAttributesToParams(org.apache.solr.common.params.ModifiableSolrParams params, int purpose)