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

## Class LBHttpSolrClient

- java.lang.Object
- - org.apache.solr.client.solrj.SolrClient
  - - org.apache.solr.client.solrj.impl.LBSolrClient
    - - org.apache.solr.client.solrj.impl.LBHttpSolrClient

All Implemented Interfaces:
  `Closeable`, `Serializable`, `AutoCloseable`

    @Deprecated(since="9.0")
    public class LBHttpSolrClient
    extends LBSolrClient

Deprecated.
Please use `LBHttp2SolrClient`
LBHttpSolrClient or "LoadBalanced HttpSolrClient" is a load balancing wrapper around `HttpSolrClient`. This is useful when you have multiple Solr servers and the requests need to be Load Balanced among them.

Do NOT use this class for indexing in leader/follower scenarios since documents must be sent to the correct leader; no inter-node routing is done.

In SolrCloud (leader/replica) scenarios, it is usually better to use `CloudSolrClient`, but this class may be used for updates because the server will forward them to the appropriate leader.

It offers automatic failover when a server goes down and it detects when the server comes back up.

Load balancing is done using a simple round-robin on the list of servers.

If a request to a server fails by an IOException due to a connection timeout or read timeout then the host is taken off the list of live servers and moved to a 'dead server list' and the request is resent to the next live server. This process is continued till it tries all the live servers. If at least one server is alive, the request succeeds, and if not it fails.

>      SolrClient lbHttpSolrClient = new LBHttpSolrClient("http://host1:8080/solr/", "http://host2:8080/solr", "http://host2:8080/solr");
>      //or if you wish to pass the HttpClient do as follows
>      httpClient httpClient = new HttpClient();
>      SolrClient lbHttpSolrClient = new LBHttpSolrClient(httpClient, "http://host1:8080/solr/", "http://host2:8080/solr", "http://host2:8080/solr");

This detects if a dead server comes alive automatically. The check is done in fixed intervals in a dedicated thread. This interval can be set using `LBHttpSolrClient.Builder.setAliveCheckInterval(int)` , the default is set to one minute.

When to use this?
This can be used as a software load balancer when you do not wish to setup an external load balancer. Alternatives to this code are to use a dedicated hardware load balancer or using Apache httpd with mod_proxy_balancer as a load balancer. See Load balancing on Wikipedia

Since:
  solr 1.4
See Also:
  Serialized Form

### Nested Class Summary

Nested Classes
`static class` `LBHttpSolrClient.Builder` Deprecated. Constructs `LBHttpSolrClient` instances from provided configuration.

### Nested classes/interfaces inherited from class org.apache.solr.client.solrj.impl.LBSolrClient

`LBSolrClient.Endpoint, LBSolrClient.Req, LBSolrClient.Rsp, LBSolrClient.ServerIterator, LBSolrClient.ServerWrapper`

### Field Summary

### Fields inherited from class org.apache.solr.client.solrj.impl.LBSolrClient

`aliveCheckIntervalMillis, parser, requestWriter, RETRY_CODES, zombieServers`

### Fields inherited from class org.apache.solr.client.solrj.SolrClient

`defaultCollection`

### Constructor Summary

Constructors
`protected` `LBHttpSolrClient​(LBHttpSolrClient.Builder builder)` Deprecated. The provided httpClient should use a multi-threaded connection manager

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`void` `addQueryParams​(String urlParamNames)` Deprecated.
`void` `close()` Deprecated.
`protected SolrClient` `getClient​(String baseUrl)` Deprecated. use `getClient(Endpoint)` instead
`protected SolrClient` `getClient​(LBSolrClient.Endpoint endpoint)` Deprecated.
`org.apache.http.client.HttpClient` `getHttpClient()` Deprecated. Return the HttpClient this instance uses.
`Set<String>` `getQueryParams()` Deprecated.
`protected HttpSolrClient` `makeSolrClient​(String server)` Deprecated. use `makeSolrClient(Endpoint)` instead
`protected HttpSolrClient` `makeSolrClient​(LBSolrClient.Endpoint endpoint)` Deprecated.
`String` `removeSolrEndpoint​(LBSolrClient.Endpoint endpoint)` Deprecated.
`String` `removeSolrServer​(String server)` Deprecated. use `removeSolrEndpoint(Endpoint)` instead
`void` `setQueryParams​(Set<String> urlParamNames)` Deprecated.

### Methods inherited from class org.apache.solr.client.solrj.impl.LBSolrClient

`addSolrServer, addSolrServer, addZombie, createServerWrapper, doRequest, getParser, getRequestWriter, normalize, pickServer, request, request, request, setAliveCheckInterval, setParser, setRequestWriter, updateAliveList`

### Methods inherited from class org.apache.solr.client.solrj.SolrClient

`add, add, add, add, add, add, add, add, add, add, addBean, addBean, addBean, addBean, addBeans, addBeans, addBeans, addBeans, addBeans, addBeans, commit, commit, commit, commit, commit, commit, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteByQuery, deleteByQuery, deleteByQuery, deleteByQuery, getBinder, getById, getById, getById, getById, getById, getById, getById, getById, getContext, getDefaultCollection, optimize, optimize, optimize, optimize, optimize, optimize, ping, ping, query, query, query, query, queryAndStreamResponse, queryAndStreamResponse, queryAndStreamResponse, request, rollback, rollback`

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

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

### Constructor Detail

#### LBHttpSolrClient

    protected LBHttpSolrClient​(LBHttpSolrClient.Builder builder)

Deprecated.
The provided httpClient should use a multi-threaded connection manager

### Method Detail

#### makeSolrClient

    protected HttpSolrClient makeSolrClient​(LBSolrClient.Endpoint endpoint)

Deprecated.

#### makeSolrClient

    @Deprecated
    protected HttpSolrClient makeSolrClient​(String server)

Deprecated.
use `makeSolrClient(Endpoint)` instead

#### getClient

    @Deprecated
    protected SolrClient getClient​(String baseUrl)

Deprecated.
use `getClient(Endpoint)` instead

Specified by:
  `getClient` in class `LBSolrClient`

#### getClient

    protected SolrClient getClient​(LBSolrClient.Endpoint endpoint)

Deprecated.

Specified by:
  `getClient` in class `LBSolrClient`

#### removeSolrServer

    @Deprecated
    public String removeSolrServer​(String server)

Deprecated.
use `removeSolrEndpoint(Endpoint)` instead

Overrides:
  `removeSolrServer` in class `LBSolrClient`

#### removeSolrEndpoint

    public String removeSolrEndpoint​(LBSolrClient.Endpoint endpoint)

Deprecated.

Overrides:
  `removeSolrEndpoint` in class `LBSolrClient`

#### close

    public void close()

Deprecated.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Overrides:
  `close` in class `LBSolrClient`

#### getHttpClient

    public org.apache.http.client.HttpClient getHttpClient()

Deprecated.
Return the HttpClient this instance uses.

#### getQueryParams

    @Deprecated
    public Set<String> getQueryParams()

Deprecated.

#### setQueryParams

    @Deprecated
    public void setQueryParams​(Set<String> urlParamNames)

Deprecated.
Expert Method.

Parameters:
  `urlParamNames` - set of param keys to only send via the query string

#### addQueryParams

    @Deprecated
    public void addQueryParams​(String urlParamNames)

Deprecated.