Class CloudSolrClient.Builder

java.lang.Object
org.apache.solr.client.solrj.impl.CloudSolrClient.Builder
Enclosing class:
CloudSolrClient

public static class CloudSolrClient.Builder extends Object
Constructs CloudSolrClient instances from provided configuration. It will use a Jetty based HttpClient if available, or will otherwise use the JDK.
  • Field Details

    • zkHosts

      protected Collection<String> zkHosts
    • solrUrls

      protected List<String> solrUrls
    • zkChroot

      protected String zkChroot
    • httpClient

      protected HttpSolrClientBase httpClient
    • shardLeadersOnly

      protected boolean shardLeadersOnly
    • directUpdatesToLeadersOnly

      protected boolean directUpdatesToLeadersOnly
    • parallelUpdates

      protected boolean parallelUpdates
    • stateProvider

      protected ClusterStateProvider stateProvider
    • internalClientBuilder

      protected HttpSolrClientBuilderBase<?,?> internalClientBuilder
    • requestWriter

      protected RequestWriter requestWriter
    • responseParser

      protected ResponseParser responseParser
    • retryExpiryTimeNano

      protected long retryExpiryTimeNano
    • defaultCollection

      protected String defaultCollection
    • timeToLiveSeconds

      protected long timeToLiveSeconds
    • parallelCacheRefreshesLocks

      protected int parallelCacheRefreshesLocks
    • zkConnectTimeout

      protected int zkConnectTimeout
    • zkClientTimeout

      protected int zkClientTimeout
    • canUseZkACLs

      protected boolean canUseZkACLs
  • Constructor Details

    • Builder

      public Builder(List<String> solrUrls)
      Provide a series of Solr URLs to be used when configuring CloudSolrClient instances. The solr client will use these urls to understand the cluster topology, which solr nodes are active etc.

      Provided Solr URLs are expected to point to the root Solr path ("http://hostname:8983/solr"); they should not include any collections, cores, or other path components.

      Usage example:

         final List<String> solrBaseUrls = new ArrayList<String>();
         solrBaseUrls.add("http://solr1:8983/solr"); solrBaseUrls.add("http://solr2:8983/solr"); solrBaseUrls.add("http://solr3:8983/solr");
         final SolrClient client = new CloudSolrClient.Builder(solrBaseUrls).build();
       
    • Builder

      public Builder(List<String> zkHosts, Optional<String> zkChroot)
      Provide a series of ZK hosts which will be used when configuring CloudSolrClient instances.

      Usage example when Solr stores data at the ZooKeeper root ('/'):

         final List<String> zkServers = new ArrayList<String>();
         zkServers.add("zookeeper1:2181"); zkServers.add("zookeeper2:2181"); zkServers.add("zookeeper3:2181");
         final SolrClient client = new CloudSolrClient.Builder(zkServers, Optional.empty()).build();
       
      Usage example when Solr data is stored in a ZooKeeper chroot:
          final List<String> zkServers = new ArrayList<String>();
          zkServers.add("zookeeper1:2181"); zkServers.add("zookeeper2:2181"); zkServers.add("zookeeper3:2181");
          final SolrClient client = new CloudSolrClient.Builder(zkServers, Optional.of("/solr")).build();
        
      Parameters:
      zkHosts - a List of at least one ZooKeeper host and port (e.g. "zookeeper1:2181")
      zkChroot - the path to the root ZooKeeper node containing Solr data. Provide java.util.Optional.empty() if no ZK chroot is used.
    • Builder

      public Builder(ClusterStateProvider stateProvider)
      for an expert use-case
  • Method Details