You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ep...@apache.org on 2020/07/13 16:38:12 UTC

[lucene-solr] branch jira/SOLR-14637 created (now af1e724)

This is an automated email from the ASF dual-hosted git repository.

epugh pushed a change to branch jira/SOLR-14637
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git.


      at af1e724  update CloudSolrClient examples to remove deprecated .Builder() method

This branch includes the following new commits:

     new af1e724  update CloudSolrClient examples to remove deprecated .Builder() method

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[lucene-solr] 01/01: update CloudSolrClient examples to remove deprecated .Builder() method

Posted by ep...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

epugh pushed a commit to branch jira/SOLR-14637
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit af1e724225862dcf126c1cae0ac0059ed2f16b38
Author: epugh <ep...@opensourceconnections.com>
AuthorDate: Mon Jul 13 12:37:55 2020 -0400

    update CloudSolrClient examples to remove deprecated .Builder() method
---
 solr/CHANGES.txt                                   |  6 ++--
 solr/solr-ref-guide/src/enabling-ssl.adoc          |  2 +-
 .../src/kerberos-authentication-plugin.adoc        |  3 +-
 solr/solr-ref-guide/src/using-solrj.adoc           | 23 +++++++++++++
 .../UsingSolrJRefGuideExamplesTest.java            | 40 ++++++++++++++++++++++
 5 files changed, 69 insertions(+), 5 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index e795b65..540c16e 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -115,7 +115,7 @@ Improvements
 
 * SOLR-14537: Improve performance of ExportWriter. (ab, Joel Bernstein)
 
-* SOLR-14566: Request ID's ('rid') are now added by default to distributed search requests, and can be used to correlate 
+* SOLR-14566: Request ID's ('rid') are now added by default to distributed search requests, and can be used to correlate
   logs from the receiving coordinator node with those from downstream shard requests.  This can be disabled by providing a
   disableRequestId=true request parameter. (Jason Gerlowski)
 
@@ -142,12 +142,14 @@ Other Changes
 
 * SOLR-14592: Upgrade Zookeeper to 3.6.1. NOTE: this required upgrading netty to 4.1.50 (Erick Erickson)
 
-* SOLR-10742: SolrCores.getNamesForCore is quite inefficient and blocks other core operations. 
+* SOLR-10742: SolrCores.getNamesForCore is quite inefficient and blocks other core operations.
   NOTE: this experimental method has been removed (Erick Erickson)
 
 * SOLR-13939: Extract any non-gradle related patches (deprecations, URL fixes, etc.) from gradle effort. NOTE:
   this will be in several separate commits/pushes. (Erick Erickson)
 
+* SOLR-14637: Update CloudSolrClient examples to remove deprecated method. (Andras Salaman via Eric Pugh)
+
 ==================  8.6.0 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
diff --git a/solr/solr-ref-guide/src/enabling-ssl.adoc b/solr/solr-ref-guide/src/enabling-ssl.adoc
index 4a3db6a..d5cd812 100644
--- a/solr/solr-ref-guide/src/enabling-ssl.adoc
+++ b/solr/solr-ref-guide/src/enabling-ssl.adoc
@@ -404,7 +404,7 @@ System.setProperty("javax.net.ssl.keyStorePassword", "secret");
 System.setProperty("javax.net.ssl.trustStore", "/path/to/solr-ssl.keystore.p12");
 System.setProperty("javax.net.ssl.trustStorePassword", "secret");
 String zkHost = "127.0.0.1:2181";
-CloudSolrClient client = new CloudSolrClient.Builder().withZkHost(zkHost).build();
+CloudSolrClient client = new CloudSolrClient.Builder(Collections.singletonList(zkHost),Optional.empty()).build();
 client.setDefaultCollection("mycollection");
 SolrInputDocument doc = new SolrInputDocument();
 doc.addField("id", "1234");
diff --git a/solr/solr-ref-guide/src/kerberos-authentication-plugin.adoc b/solr/solr-ref-guide/src/kerberos-authentication-plugin.adoc
index d3a7c67..af10d21 100644
--- a/solr/solr-ref-guide/src/kerberos-authentication-plugin.adoc
+++ b/solr/solr-ref-guide/src/kerberos-authentication-plugin.adoc
@@ -373,8 +373,7 @@ To create a `CloudSolrClient` that uses delegation tokens:
 
 [source,java]
 ----
-CloudSolrClient client = new CloudSolrClient.Builder()
-                .withZkHost("localhost:2181")
+CloudSolrClient client = new CloudSolrClient.Builder(Collections.singletonList("localhost:2181"),Optional.empty())
                 .withLBHttpSolrClientBuilder(new LBHttpSolrClient.Builder()
                     .withResponseParser(client.getParser())
                     .withHttpSolrClientBuilder(
diff --git a/solr/solr-ref-guide/src/using-solrj.adoc b/solr/solr-ref-guide/src/using-solrj.adoc
index b7ea385..e371787 100644
--- a/solr/solr-ref-guide/src/using-solrj.adoc
+++ b/solr/solr-ref-guide/src/using-solrj.adoc
@@ -110,6 +110,29 @@ The `Http2SolrClient` manages connections to different nodes efficiently. `Http2
 does not require a `baseUrl`. In case a `baseUrl` is not provided, then `SolrRequest.basePath` must be set, so
 `Http2SolrClient` knows which nodes to send requests to. If not an `IllegalArgumentException` will be thrown.
 
+==== Base URLs of CloudSolrClient
+
+It is also possible to specify base URLs for `CloudSolrClient`, but URLs are expected to point to the root Solr path (e.g., `\http://hostname:8983/solr`). They should not include any collections, cores, or other path components.
+
+[source,java,indent=0]
+----
+include::{example-source-dir}UsingSolrJRefGuideExamplesTest.java[tag=solrj-cloudsolrclient-baseurl]
+----
+
+In case a `baseUrl` is not provided, then a list of ZooKeeper hosts (with ports) and ZooKeeper root must be provided.
+If no ZooKeeper root is used then `java.util.Optional.empty()` has to be provided as part of the method.
+
+[source,java,indent=0]
+----
+include::{example-source-dir}UsingSolrJRefGuideExamplesTest.java[tag=solrj-cloudsolrclient-zookeepernoroot]
+----
+
+[source,java,indent=0]
+----
+include::{example-source-dir}UsingSolrJRefGuideExamplesTest.java[tag=solrj-cloudsolrclient-zookeeperroot]
+----
+
+
 ==== Timeouts
 All `SolrClient` implementations allow users to specify the connection and read timeouts for communicating with Solr.  These are provided at client creation time, as in the example below:
 
diff --git a/solr/solrj/src/test/org/apache/solr/client/ref_guide_examples/UsingSolrJRefGuideExamplesTest.java b/solr/solrj/src/test/org/apache/solr/client/ref_guide_examples/UsingSolrJRefGuideExamplesTest.java
index 5efa215..64f4897 100644
--- a/solr/solrj/src/test/org/apache/solr/client/ref_guide_examples/UsingSolrJRefGuideExamplesTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/ref_guide_examples/UsingSolrJRefGuideExamplesTest.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.Queue;
 import java.util.UUID;
 
@@ -31,6 +32,7 @@ import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrQuery.ORDER;
 import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.client.solrj.beans.Field;
+import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.impl.HttpSolrClient;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.client.solrj.response.CollectionAdminResponse;
@@ -246,6 +248,44 @@ public class UsingSolrJRefGuideExamplesTest extends SolrCloudTestCase {
     // end::solrj-solrclient-timeouts[]
   }
 
+  private SolrClient getBaseURLCloudSolrClient() {
+    // tag::solrj-cloudsolrclient-baseurl[]
+    final List<String> solrUrls = new ArrayList<>();
+    solrUrls.add("http://solr1:8983/solr");
+    solrUrls.add("http://solr2:8983/solr");
+    return new CloudSolrClient.Builder(solrUrls)
+            .withConnectionTimeout(10000)
+            .withSocketTimeout(60000)
+            .build();
+    // end::solrj-cloudsolrclient-baseurl[]
+  }
+
+  private SolrClient getZookeeperNoRootCloudSolrClient() {
+    // tag::solrj-cloudsolrclient-zookeepernoroot[]
+    final List<String> zkServers = new ArrayList<>();
+    zkServers.add("zookeeper1:2181");
+    zkServers.add("zookeeper2:2181");
+    zkServers.add("zookeeper3:2181");
+    return new CloudSolrClient.Builder(zkServers, Optional.empty())
+            .withConnectionTimeout(10000)
+            .withSocketTimeout(60000)
+            .build();
+    // end::solrj-cloudsolrclient-zookeepernoroot[]
+  }
+
+  private SolrClient getZookeeperRootCloudSolrClient() {
+    // tag::solrj-cloudsolrclient-zookeeperroot[]
+    final List<String> zkServers = new ArrayList<>();
+    zkServers.add("zookeeper1:2181");
+    zkServers.add("zookeeper2:2181");
+    zkServers.add("zookeeper3:2181");
+    return new CloudSolrClient.Builder(zkServers, Optional.of("/solr"))
+            .withConnectionTimeout(10000)
+            .withSocketTimeout(60000)
+            .build();
+    // end::solrj-cloudsolrclient-zookeeperroot[]
+  }
+
   private void assertNumDocuments(int expectedNumResults) throws Exception {
     final QueryResponse queryResponse = getSolrClient().query("techproducts", new SolrQuery("*:*"));
     assertEquals(expectedNumResults, queryResponse.getResults().getNumFound());