Class ConcurrentUpdateHttp2SolrClient.Builder
- java.lang.Object
-
- org.apache.solr.client.solrj.impl.ConcurrentUpdateHttp2SolrClient.Builder
-
- Enclosing class:
- ConcurrentUpdateHttp2SolrClient
public static class ConcurrentUpdateHttp2SolrClient.Builder extends Object
ConstructsConcurrentUpdateHttp2SolrClient
instances from provided configuration.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
baseSolrUrl
protected Http2SolrClient
client
protected boolean
closeHttp2Client
protected String
defaultCollection
protected ExecutorService
executorService
protected int
queueSize
protected boolean
streamDeletes
protected int
threadCount
-
Constructor Summary
Constructors Constructor Description Builder(String baseSolrUrl, Http2SolrClient client)
Create a Builder object, based on the provided SolrClient and Solr URL.Builder(String baseSolrUrl, Http2SolrClient client, boolean closeHttp2Client)
Create a Builder object, based on the provided SolrClient and Solr URL.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ConcurrentUpdateHttp2SolrClient.Builder
alwaysStreamDeletes()
Configures created clients to always stream delete requests.ConcurrentUpdateHttp2SolrClient
build()
Create aConcurrentUpdateHttp2SolrClient
based on the provided configuration options.ConcurrentUpdateHttp2SolrClient.Builder
neverStreamDeletes()
Configures created clients to not stream delete requests.ConcurrentUpdateHttp2SolrClient.Builder
setPollQueueTime(int pollQueueTimeMillis)
Deprecated.Please usesetPollQueueTime(long, TimeUnit)
ConcurrentUpdateHttp2SolrClient.Builder
setPollQueueTime(long pollQueueTime, TimeUnit unit)
ConcurrentUpdateHttp2SolrClient.Builder
withDefaultCollection(String defaultCoreOrCollection)
Sets a default for core or collection based requests.ConcurrentUpdateHttp2SolrClient.Builder
withExecutorService(ExecutorService executorService)
Provides theExecutorService
for the created client to use when servicing the update-request queue.ConcurrentUpdateHttp2SolrClient.Builder
withQueueSize(int queueSize)
The maximum number of requests buffered by the SolrClient's internal queue before being processed by background threads.ConcurrentUpdateHttp2SolrClient.Builder
withThreadCount(int threadCount)
The maximum number of threads used to emptyConcurrentUpdateHttp2SolrClient
s queue.
-
-
-
Field Detail
-
client
protected Http2SolrClient client
-
baseSolrUrl
protected String baseSolrUrl
-
defaultCollection
protected String defaultCollection
-
queueSize
protected int queueSize
-
threadCount
protected int threadCount
-
executorService
protected ExecutorService executorService
-
streamDeletes
protected boolean streamDeletes
-
closeHttp2Client
protected boolean closeHttp2Client
-
-
Constructor Detail
-
Builder
public Builder(String baseSolrUrl, Http2SolrClient client)
Create a Builder object, based on the provided SolrClient and Solr URL.Two different paths can be specified as a part of this URL:
1) A path pointing directly at a particular core
SolrClient client = new ConcurrentUpdateHttp2SolrClient.Builder(client, "http://my-solr-server:8983/solr/core1").build(); QueryResponse resp = client.query(new SolrQuery("*:*"));
Note that when a core is provided in the base URL, queries and other requests can be made without mentioning the core explicitly. However, the client can only send requests to that core. Attempts to make core-agnostic requests, or requests for other cores will fail.Use of these core-based URLs is deprecated and will not be supported in Solr 10.0 Users should instead provide base URLs as described below, and provide a "default collection" as desired using
withDefaultCollection(String)
2) The path of the root Solr path ("/solr")
SolrClient client = new ConcurrentUpdateHttp2SolrClient.Builder("http://my-solr-server:8983/solr").build(); QueryResponse resp = client.query("core1", new SolrQuery("*:*"));
In this case the client is more flexible and can be used to send requests to any cores. Users can still provide a "default" collection if desired through use ofwithDefaultCollection(String)
.
-
Builder
public Builder(String baseSolrUrl, Http2SolrClient client, boolean closeHttp2Client)
Create a Builder object, based on the provided SolrClient and Solr URL.Two different paths can be specified as a part of this URL:
1) A path pointing directly at a particular core
SolrClient client = new ConcurrentUpdateHttp2SolrClient.Builder(client, "http://my-solr-server:8983/solr/core1").build(); QueryResponse resp = client.query(new SolrQuery("*:*"));
Note that when a core is provided in the base URL, queries and other requests can be made without mentioning the core explicitly. However, the client can only send requests to that core. Attempts to make core-agnostic requests, or requests for other cores will fail.Use of these core-based URLs is deprecated and will not be supported in Solr 10.0 Users should instead provide base URLs as described below, and provide a "default collection" as desired using
withDefaultCollection(String)
2) The path of the root Solr path ("/solr")
SolrClient client = new ConcurrentUpdateHttp2SolrClient.Builder("http://my-solr-server:8983/solr").build(); QueryResponse resp = client.query("core1", new SolrQuery("*:*"));
In this case the client is more flexible and can be used to send requests to any cores. Users can still provide a "default" collection if desired through use ofwithDefaultCollection(String)
.
-
-
Method Detail
-
withQueueSize
public ConcurrentUpdateHttp2SolrClient.Builder withQueueSize(int queueSize)
The maximum number of requests buffered by the SolrClient's internal queue before being processed by background threads.This value should be carefully paired with the number of queue-consumer threads. A queue with a maximum size set too high may require more memory. A queue with a maximum size set too low may suffer decreased throughput as
SolrClient.request(SolrRequest)
calls block waiting to add requests to the queue.If not set, this defaults to 10.
- See Also:
withThreadCount(int)
-
withThreadCount
public ConcurrentUpdateHttp2SolrClient.Builder withThreadCount(int threadCount)
The maximum number of threads used to emptyConcurrentUpdateHttp2SolrClient
s queue.Threads are created when documents are added to the client's internal queue and exit when no updates remain in the queue.
This value should be carefully paired with the maximum queue capacity. A client with too few threads may suffer decreased throughput as the queue fills up and
SolrClient.request(SolrRequest)
calls block waiting to add requests to the queue.
-
withExecutorService
public ConcurrentUpdateHttp2SolrClient.Builder withExecutorService(ExecutorService executorService)
Provides theExecutorService
for the created client to use when servicing the update-request queue.
-
alwaysStreamDeletes
public ConcurrentUpdateHttp2SolrClient.Builder alwaysStreamDeletes()
Configures created clients to always stream delete requests.Streamed deletes are put into the update-queue and executed like any other update request.
-
neverStreamDeletes
public ConcurrentUpdateHttp2SolrClient.Builder neverStreamDeletes()
Configures created clients to not stream delete requests.With this option set when the created ConcurrentUpdateHttp2SolrClient sents a delete request it will first will lock the queue and block until all queued updates have been sent, and then send the delete request.
-
withDefaultCollection
public ConcurrentUpdateHttp2SolrClient.Builder withDefaultCollection(String defaultCoreOrCollection)
Sets a default for core or collection based requests.This method should not be used if the client is provided a Solr URL which already contains a core or collection name.
-
setPollQueueTime
@Deprecated(since="9.2") public ConcurrentUpdateHttp2SolrClient.Builder setPollQueueTime(int pollQueueTimeMillis)
Deprecated.Please usesetPollQueueTime(long, TimeUnit)
- Parameters:
pollQueueTimeMillis
- time for an open connection to wait for updates when the queue is empty.
-
setPollQueueTime
public ConcurrentUpdateHttp2SolrClient.Builder setPollQueueTime(long pollQueueTime, TimeUnit unit)
- Parameters:
pollQueueTime
- time for an open connection to wait for updates when the queue is empty.
-
build
public ConcurrentUpdateHttp2SolrClient build()
Create aConcurrentUpdateHttp2SolrClient
based on the provided configuration options.
-
-