Class HttpShardHandler
java.lang.Object
org.apache.solr.handler.component.ShardHandler
org.apache.solr.handler.component.HttpShardHandler
- Direct Known Subclasses:
ParallelHttpShardHandler
Solr's default
ShardHandler implementation; uses Jetty's async HTTP Client APIs for
sending requests.
Shard-requests triggered by submit(ShardRequest, String, ModifiableSolrParams) will
be sent synchronously (i.e. before 'submit' returns to the caller). Response waiting and parsing
happens asynchronously via HttpShardHandlerFactory.commExecutor. See HttpShardHandlerFactory for details on configuring this executor.
The ideal choice for collections with modest or moderate sharding.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.solr.client.solrj.impl.LBAsyncSolrClientstatic final StringIf the request context map has an entry with this key and Boolean.TRUE as value,prepDistributed(ResponseBuilder)will only includeReplica.Type.NRTreplicas as possible destination of the distributed request (or a leader replica of typeReplica.Type.TLOG).protected final ConcurrentMap<ShardResponse, CompletableFuture<org.apache.solr.client.solrj.impl.LBSolrClient.Rsp>> protected final BlockingQueue<ShardResponse> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCancels all uncompleted requests managed by this instanceprotected org.apache.solr.client.solrj.request.QueryRequestcreateQueryRequest(ShardRequest sreq, org.apache.solr.common.params.ModifiableSolrParams params, String shard) Subclasses could modify the request based on the shardstatic booleanParse the "shards.tolerant" param fromparamsas a boolean; accepts "requireZkConnected" as a valid value indicatingfalse.protected voidmakeShardRequest(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 responsevoidBootstraps any data structures needed by the ShardHandler to execute or track outgoing requests.protected voidrecordShardSubmitError(ShardResponse srsp, org.apache.solr.common.SolrException exception) protected booleanvoidsubmit(ShardRequest sreq, String shard, org.apache.solr.common.params.ModifiableSolrParams params) Sends a request (represented bysreq) to the specified shard.Returns a ShardResponse of the last response correlated with a ShardRequest.Returns a ShardResponse of the last response correlated with a ShardRequest, or immediately returns a ShardResponse if there was an error detected.protected ShardResponsetransformResponse(ShardRequest sreq, ShardResponse rsp, String shard) Subclasses could modify the Response based on the shardMethods inherited from class org.apache.solr.handler.component.ShardHandler
setShardAttributesToParams
-
Field Details
-
ONLY_NRT_REPLICAS
If the request context map has an entry with this key and Boolean.TRUE as value,prepDistributed(ResponseBuilder)will only includeReplica.Type.NRTreplicas as possible destination of the distributed request (or a leader replica of typeReplica.Type.TLOG). This is used by the RealtimeGet handler, since other types of replicas shouldn't respond to RTG requests- See Also:
-
responseFutureMap
protected final ConcurrentMap<ShardResponse,CompletableFuture<org.apache.solr.client.solrj.impl.LBSolrClient.Rsp>> responseFutureMap -
responses
-
lbClient
protected org.apache.solr.client.solrj.impl.LBAsyncSolrClient lbClient
-
-
Constructor Details
-
HttpShardHandler
-
-
Method Details
-
getShardsTolerantAsBool
Parse the "shards.tolerant" param fromparamsas a boolean; accepts "requireZkConnected" as a valid value indicatingfalse.By default, returns
falsewhen "shards.tolerant" is not set inparams. -
recordShardSubmitError
protected void recordShardSubmitError(ShardResponse srsp, org.apache.solr.common.SolrException exception) -
submit
public void submit(ShardRequest sreq, String shard, org.apache.solr.common.params.ModifiableSolrParams params) Description copied from class:ShardHandlerSends a request (represented bysreq) to the specified shard.The outgoing request may be sent asynchronously. Callers must invoke
ShardHandler.takeCompletedIncludingErrors()orShardHandler.takeCompletedOrError()to inspect the success or failure of requests.- Specified by:
submitin classShardHandler- 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 makeshard- the shard to addressparams- request parameterslbReq- the load balanced requestssr- the response collector part 1srsp- the shard response collectorstartTimeNS- 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 -
transformResponse
Subclasses could modify the Response based on the shard -
takeCompletedIncludingErrors
Description copied from class:ShardHandlerReturns 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:
takeCompletedIncludingErrorsin classShardHandler
-
takeCompletedOrError
Description copied from class:ShardHandlerReturns 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:
takeCompletedOrErrorin classShardHandler
-
responsesPending
protected boolean responsesPending() -
cancelAll
public void cancelAll()Description copied from class:ShardHandlerCancels all uncompleted requests managed by this instance- Specified by:
cancelAllin classShardHandler
-
prepDistributed
Description copied from class:ShardHandlerBootstraps any data structures needed by the ShardHandler to execute or track outgoing requests.- Specified by:
prepDistributedin classShardHandler- Parameters:
rb- provides access to request and response state.
-
getShardHandlerFactory
- Specified by:
getShardHandlerFactoryin classShardHandler
-