Class SolrClientHelper

java.lang.Object
org.apache.tika.pipes.plugin.solr.SolrClientHelper

public final class SolrClientHelper extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    applyClientSettings(org.apache.solr.client.solrj.jetty.HttpJettySolrClient.Builder builder, HttpClientFactory factory)
    Applies authentication, proxy and SSL settings from factory to a HttpJettySolrClient.Builder.
    static org.apache.solr.client.solrj.SolrClient
    buildLbClient(org.apache.solr.client.solrj.jetty.HttpJettySolrClient.Builder builder, List<String> solrUrls)
    Builds a direct-URL (load-balanced) Solr client from a configured builder and the list of base Solr URLs.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • applyClientSettings

      public static void applyClientSettings(org.apache.solr.client.solrj.jetty.HttpJettySolrClient.Builder builder, HttpClientFactory factory) throws TikaConfigException
      Applies authentication, proxy and SSL settings from factory to a HttpJettySolrClient.Builder.
      • Auth: when a username is configured, only the basic scheme is supported; any other scheme throws TikaConfigException. When no username is set, auth is skipped regardless of the configured scheme (matching the original Http2SolrClient code).
      • Proxy: configured only when both a non-blank host and a positive port are present.
      • SSL: verified by default. When factory.isVerifySsl() is false, all certificates are trusted and hostname verification is disabled (opt-in; preserves the pre-Jetty-12 HttpClientFactory behaviour for self-signed Solr endpoints).
      Throws:
      TikaConfigException
    • buildLbClient

      public static org.apache.solr.client.solrj.SolrClient buildLbClient(org.apache.solr.client.solrj.jetty.HttpJettySolrClient.Builder builder, List<String> solrUrls)
      Builds a direct-URL (load-balanced) Solr client from a configured builder and the list of base Solr URLs.

      The returned client closes the underlying HttpJettySolrClient when it is closed. The stock LBJettySolrClient does not own its delegate client (see LBSolrClient.close()), so without this the Jetty thread pool and selectors created by the delegate would leak every time a caller closes the load-balanced client.