Package org.apache.solr.client.solrj.impl

# Class ConcurrentUpdateBaseSolrClient.Builder

java.lang.Object
org.apache.solr.client.solrj.impl.ConcurrentUpdateBaseSolrClient.Builder

Enclosing class:
  `ConcurrentUpdateBaseSolrClient`

public abstract static class ConcurrentUpdateBaseSolrClient.Builder extends Object
Constructs `ConcurrentUpdateBaseSolrClient` instances from provided configuration.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected String`
`baseSolrUrl`
`protected HttpSolrClientBase`
`client`
`protected boolean`
`closeHttpClient`
`protected String`
`defaultCollection`
`protected ExecutorService`
`executorService`
`protected long`
`idleTimeoutMillis`
`protected long`
`pollQueueTimeMillis`
`protected int`
`queueSize`
`protected boolean`
`streamDeletes`
`protected int`
`threadCount`

## Constructor Summary

Constructors
Constructor
Description
`Builder(String baseSolrUrl, HttpSolrClientBase client)`
Initialize a Builder object, based on the provided URL and client.
`Builder(String baseSolrUrl, HttpSolrClientBase client, boolean closeHttpClient)`
Initialize a Builder object, based on the provided arguments.

## Method Summary

Modifier and Type
Method
Description
`ConcurrentUpdateBaseSolrClient.Builder`
`alwaysStreamDeletes()`
Configures created clients to always stream delete requests.
`abstract ConcurrentUpdateBaseSolrClient`
`build()`
Create a `ConcurrentUpdateBaseSolrClient` based on the provided configuration options.
`HttpSolrClientBase`
`getClient()`
`ConcurrentUpdateBaseSolrClient.Builder`
`neverStreamDeletes()`
Configures created clients to not stream delete requests.
`ConcurrentUpdateBaseSolrClient.Builder`
`setPollQueueTime(long pollQueueTime, TimeUnit unit)`
`ConcurrentUpdateBaseSolrClient.Builder`
`withDefaultCollection(String defaultCoreOrCollection)`
Sets a default for core or collection based requests.
`ConcurrentUpdateBaseSolrClient.Builder`
`withExecutorService(ExecutorService executorService)`
Provides the `ExecutorService` for the created client to use when servicing the update-request queue.
`ConcurrentUpdateBaseSolrClient.Builder`
`withQueueSize(int queueSize)`
The maximum number of requests buffered by the SolrClient's internal queue before being processed by background threads.
`ConcurrentUpdateBaseSolrClient.Builder`
`withThreadCount(int threadCount)`
The maximum number of threads used to empty `ConcurrentUpdateBaseSolrClient`s queue.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### idleTimeoutMillis

protected long idleTimeoutMillis

### client

protected HttpSolrClientBase 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

### closeHttpClient

protected boolean closeHttpClient

### pollQueueTimeMillis

protected long pollQueueTimeMillis

## Constructor Details

### Builder

public Builder(String baseSolrUrl, HttpSolrClientBase client)
Initialize a Builder object, based on the provided URL and client.

The provided URL must point to the root Solr path (i.e. "/solr"), for example:

       SolrClient client = new ConcurrentUpdateJettySolrClient.Builder("http://my-solr-server:8983/solr", http2Client)
           .withDefaultCollection("core1")
           .build();
       QueryResponse resp = client.query(new SolrQuery("*:*"));

Parameters:
  `baseSolrUrl` - a URL pointing to the root Solr path, typically of the form "http[s]://host:port/solr"
  `client` - a client for this ConcurrentUpdateJettySolrClient to use for all requests internally. Callers are responsible for closing the provided client (after closing any clients created by this builder)

### Builder

public Builder(String baseSolrUrl, HttpSolrClientBase client, boolean closeHttpClient)
Initialize a Builder object, based on the provided arguments.

The provided URL must point to the root Solr path (i.e. "/solr"), for example:

       SolrClient client = new ConcurrentUpdateJettySolrClient.Builder("http://my-solr-server:8983/solr", http2Client)
           .withDefaultCollection("core1")
           .build();
       QueryResponse resp = client.query(new SolrQuery("*:*"));

Parameters:
  `baseSolrUrl` - a URL pointing to the root Solr path, typically of the form "http[s]://host:port/solr"
  `client` - a client for this ConcurrentUpdateJettySolrClient to use for all requests internally.
  `closeHttpClient` - a boolean flag indicating whether the created ConcurrentUpdateBaseSolrClient should assume responsibility for closing the provided 'client'

## Method Details

### withQueueSize

public ConcurrentUpdateBaseSolrClient.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 ConcurrentUpdateBaseSolrClient.Builder withThreadCount(int threadCount)
The maximum number of threads used to empty `ConcurrentUpdateBaseSolrClient`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 ConcurrentUpdateBaseSolrClient.Builder withExecutorService(ExecutorService executorService)
Provides the `ExecutorService` for the created client to use when servicing the update-request queue.

### alwaysStreamDeletes

public ConcurrentUpdateBaseSolrClient.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 ConcurrentUpdateBaseSolrClient.Builder neverStreamDeletes()
Configures created clients to not stream delete requests.

With this option set when the created ConcurrentUpdateBaseSolrClient sends 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 ConcurrentUpdateBaseSolrClient.Builder withDefaultCollection(String defaultCoreOrCollection)
Sets a default for core or collection based requests.

### setPollQueueTime

public ConcurrentUpdateBaseSolrClient.Builder setPollQueueTime(long pollQueueTime, TimeUnit unit)

Parameters:
  `pollQueueTime` - time for an open connection to wait for updates when the queue is empty.

### build

public abstract ConcurrentUpdateBaseSolrClient build()
Create a `ConcurrentUpdateBaseSolrClient` based on the provided configuration options.

### getClient

public HttpSolrClientBase getClient()