Apache Solr open-source search software
SOLR-17066: Switch ConcurrentSolrClients away from core URLs (#2254)
Jason Gerlowski6afbc20ee061
diff --git a/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.java b/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.javaindex e53797ee21f..51381f4a582 100644--- a/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.java+++ b/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.java@@ -158,6 +158,13 @@ class ErrorReportingConcurrentUpdateSolrClient extends ConcurrentUpdateHttp2Solrprotected SolrCmdDistributor.Req req;protected List<SolrError> errors;+ /**+ * @param baseSolrUrl the base URL of a Solr node. Should <em>not</em> contain a collection or+ * core name+ * @param client the client to use in making requests+ * @param req the command distributor request object for this client+ * @param errors a collector for any errors+ */public Builder(String baseSolrUrl,Http2SolrClient client,diff --git a/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.java b/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.javaindex 20965ef6cb6..b10f72152e1 100644--- a/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.java+++ b/solr/core/src/test/org/apache/solr/client/solrj/impl/ConnectionReuseTest.java@@ -83,7 +83,8 @@ public class ConnectionReuseTest extends SolrCloudTestCase {switch (random().nextInt(3)) {case 0:// currently, only testing with 1 thread- return new ConcurrentUpdateSolrClient.Builder(url.toString() + "/" + COLLECTION)+ return new ConcurrentUpdateSolrClient.Builder(url.toString())+ .withDefaultCollection(COLLECTION).withHttpClient(httpClient).withQueueSize(6).withThreadCount(1)diff --git a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.javaindex 5f0a86b0822..318a28a289f 100644--- a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java@@ -812,8 +812,8 @@ public class FullSolrCloudDistribCmdsTest extends SolrCloudTestCase {final int numDocs = atLeast(50);final JettySolrRunner nodeToUpdate = cluster.getRandomJetty(random());try (ConcurrentUpdateSolrClient indexClient =- new ConcurrentUpdateSolrClient.Builder(- nodeToUpdate.getProxyBaseUrl() + "/" + collectionName)+ new ConcurrentUpdateSolrClient.Builder(nodeToUpdate.getProxyBaseUrl().toString())+ .withDefaultCollection(collectionName).withQueueSize(10).withThreadCount(2).build()) {diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.javaindex 24d7edc175e..b60a5b77b0f 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java@@ -149,9 +149,6 @@ public class LBHttpSolrClient extends LBSolrClient {.withResponseParser(parser).withConnectionTimeout(connectionTimeoutMillis, TimeUnit.MILLISECONDS).withSocketTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS);-- // Note that this may override the value extracted from the base URL..should we log a warning- // here?if (defaultCollection != null) {clientBuilder.withDefaultCollection(defaultCollection);}diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.javaindex cbab498a9ac..f2ca853005f 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.java@@ -37,7 +37,7 @@ public class SolrExampleStreamingBinaryHttp2Test extends SolrExampleStreamingHtt@Overridepublic SolrClient createNewSolrClient() {- String url = getCoreUrl();+ String url = getBaseUrl();// smaller queue size hits locks more oftenHttp2SolrClient solrClient =new Http2SolrClient.Builder()@@ -46,6 +46,7 @@ public class SolrExampleStreamingBinaryHttp2Test extends SolrExampleStreamingHtt.build();ConcurrentUpdateHttp2SolrClient concurrentClient =new ErrorTrackingConcurrentUpdateSolrClient.Builder(url, solrClient)+ .withDefaultCollection(DEFAULT_TEST_CORENAME).withQueueSize(2).withThreadCount(5).build();diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.javaindex ec326f61858..1610760a84f 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java@@ -36,7 +36,8 @@ public class SolrExampleStreamingBinaryTest extends SolrExampleStreamingTest {public SolrClient createNewSolrClient() {SolrClient client =- new ErrorTrackingConcurrentUpdateSolrClient.Builder(getCoreUrl())+ new ErrorTrackingConcurrentUpdateSolrClient.Builder(getBaseUrl())+ .withDefaultCollection(DEFAULT_TEST_CORENAME).withQueueSize(2).withThreadCount(5).withResponseParser(new BinaryResponseParser())diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingHttp2Test.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingHttp2Test.javaindex 1584fc87cf1..7c20c53254f 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingHttp2Test.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingHttp2Test.java@@ -45,7 +45,7 @@ public class SolrExampleStreamingHttp2Test extends SolrExampleTests {@Overridepublic SolrClient createNewSolrClient() {- String url = getCoreUrl();+ String url = getBaseUrl();// smaller queue size hits locks more oftenHttp2SolrClient solrClient =new Http2SolrClient.Builder()@@ -54,6 +54,7 @@ public class SolrExampleStreamingHttp2Test extends SolrExampleTests {.build();ConcurrentUpdateHttp2SolrClient concurrentClient =new ErrorTrackingConcurrentUpdateSolrClient.Builder(url, solrClient)+ .withDefaultCollection(DEFAULT_TEST_CORENAME).withQueueSize(2).withThreadCount(5).build();@@ -63,10 +64,11 @@ public class SolrExampleStreamingHttp2Test extends SolrExampleTests {public void testWaitOptions() throws Exception {// SOLR-3903final List<Throwable> failures = new ArrayList<>();- final String serverUrl = getCoreUrl();+ final String serverUrl = getBaseUrl();try (Http2SolrClient http2Client = new Http2SolrClient.Builder().build();ConcurrentUpdateHttp2SolrClient concurrentClient =new FailureRecordingConcurrentUpdateSolrClient.Builder(serverUrl, http2Client)+ .withDefaultCollection(DEFAULT_TEST_CORENAME).withQueueSize(2).withThreadCount(2).build()) {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.javaindex 6aa438e0339..616782a10ea 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingTest.java@@ -44,7 +44,8 @@ public class SolrExampleStreamingTest extends SolrExampleTests {@Overridepublic SolrClient createNewSolrClient() {// smaller queue size hits locks more often- return new ErrorTrackingConcurrentUpdateSolrClient.Builder(getCoreUrl())+ return new ErrorTrackingConcurrentUpdateSolrClient.Builder(getBaseUrl())+ .withDefaultCollection(DEFAULT_TEST_CORENAME).withQueueSize(2).withThreadCount(5).withResponseParser(new XMLResponseParser())diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientBadInputTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientBadInputTest.javaindex 552a48c379b..8ca9d6b938d 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientBadInputTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientBadInputTest.java@@ -45,8 +45,8 @@ public class ConcurrentUpdateHttp2SolrClientBadInputTest extends SolrJettyTestBatry (Http2SolrClient http2Client = new Http2SolrClient.Builder().build();SolrClient client =- new ConcurrentUpdateHttp2SolrClient.Builder(- getBaseUrl() + "/" + ANY_COLLECTION, http2Client)+ new ConcurrentUpdateHttp2SolrClient.Builder(getBaseUrl(), http2Client)+ .withDefaultCollection(ANY_COLLECTION).withQueueSize(ANY_QUEUE_SIZE).withThreadCount(ANY_MAX_NUM_THREADS).build()) {@@ -78,8 +78,8 @@ public class ConcurrentUpdateHttp2SolrClientBadInputTest extends SolrJettyTestBatry (Http2SolrClient http2Client = new Http2SolrClient.Builder().build();SolrClient client =- new ConcurrentUpdateHttp2SolrClient.Builder(- getBaseUrl() + "/" + ANY_COLLECTION, http2Client)+ new ConcurrentUpdateHttp2SolrClient.Builder(getBaseUrl(), http2Client)+ .withDefaultCollection(ANY_COLLECTION).withQueueSize(ANY_QUEUE_SIZE).withThreadCount(ANY_MAX_NUM_THREADS).build()) {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientTest.javaindex 70804ff2654..713ee22a926 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClientTest.java@@ -146,7 +146,8 @@ public class ConcurrentUpdateHttp2SolrClientTest extends SolrJettyTestBase {try (Http2SolrClient http2Client = new Http2SolrClient.Builder().build();ConcurrentUpdateHttp2SolrClient concurrentClient =- new ConcurrentUpdateHttp2SolrClient.Builder(getCoreUrl(), http2Client)+ new ConcurrentUpdateHttp2SolrClient.Builder(getBaseUrl(), http2Client)+ .withDefaultCollection(DEFAULT_TEST_CORENAME).withQueueSize(cussQueueSize).withThreadCount(cussThreadCount).build()) {@@ -205,7 +206,8 @@ public class ConcurrentUpdateHttp2SolrClientTest extends SolrJettyTestBase {try (Http2SolrClient http2Client = new Http2SolrClient.Builder().build();ConcurrentUpdateHttp2SolrClient concurrentClient =- new ConcurrentUpdateHttp2SolrClient.Builder(getCoreUrl(), http2Client)+ new ConcurrentUpdateHttp2SolrClient.Builder(getBaseUrl(), http2Client)+ .withDefaultCollection(DEFAULT_TEST_CORENAME).withQueueSize(cussQueueSize).withThreadCount(cussThreadCount).build()) {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBadInputTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBadInputTest.javaindex 17e74924a47..45520dd49c4 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBadInputTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBadInputTest.java@@ -43,7 +43,8 @@ public class ConcurrentUpdateSolrClientBadInputTest extends SolrJettyTestBase {@Testpublic void testDeleteByIdReportsInvalidIdLists() throws Exception {try (SolrClient client =- new ConcurrentUpdateSolrClient.Builder(getBaseUrl() + "/" + ANY_COLLECTION)+ new ConcurrentUpdateSolrClient.Builder(getBaseUrl())+ .withDefaultCollection(ANY_COLLECTION).withQueueSize(ANY_QUEUE_SIZE).withThreadCount(ANY_MAX_NUM_THREADS).build()) {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBuilderTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBuilderTest.javaindex c6cd4779f96..d2c5686d6bb 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBuilderTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientBuilderTest.java@@ -31,6 +31,8 @@ import org.junit.Test;/** Unit tests for {@link Builder}. */public class ConcurrentUpdateSolrClientBuilderTest extends SolrTestCase {+ private static final String ANY_BASE_URL = "http://localhost:8983/solr";+@Test(expected = IllegalArgumentException.class)public void testRejectsMissingBaseSolrUrl() {new Builder(null).build();@@ -39,7 +41,7 @@ public class ConcurrentUpdateSolrClientBuilderTest extends SolrTestCase {@Test@SuppressWarnings({"try"})public void testMissingQueueSize() {- try (ConcurrentUpdateSolrClient client = new Builder("someurl").build()) {+ try (ConcurrentUpdateSolrClient client = new Builder(ANY_BASE_URL).build()) {// Do nothing as we just need to test that the only mandatory parameter for building the// client is the baseSolrUrl}@@ -76,7 +78,7 @@ public class ConcurrentUpdateSolrClientBuilderTest extends SolrTestCase {@Testpublic void testDefaultCollectionPassedFromBuilderToClient() throws IOException {try (SolrClient createdClient =- new ConcurrentUpdateSolrClient.Builder("someurl")+ new ConcurrentUpdateSolrClient.Builder(ANY_BASE_URL).withDefaultCollection("aCollection").build()) {assertEquals("aCollection", createdClient.getDefaultCollection());diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.javaindex 6cff2257f8d..28052321a69 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClientTest.java@@ -227,7 +227,8 @@ public class ConcurrentUpdateSolrClientTest extends SolrJettyTestBase {}try (ConcurrentUpdateSolrClient concurrentClient =- (new ConcurrentUpdateSolrClient.Builder(getCoreUrl()))+ (new ConcurrentUpdateSolrClient.Builder(getBaseUrl()))+ .withDefaultCollection(DEFAULT_TEST_CORENAME).withQueueSize(cussQueueSize).withThreadCount(cussThreadCount).build()) {@@ -283,7 +284,8 @@ public class ConcurrentUpdateSolrClientTest extends SolrJettyTestBase {}try (ConcurrentUpdateSolrClient concurrentClient =- (new ConcurrentUpdateSolrClient.Builder(getCoreUrl()))+ (new ConcurrentUpdateSolrClient.Builder(getBaseUrl()))+ .withDefaultCollection(DEFAULT_TEST_CORENAME).withQueueSize(cussQueueSize).withThreadCount(cussThreadCount).build()) {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientConPoolTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientConPoolTest.javaindex c169faab0e7..e3c589dae6b 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientConPoolTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientConPoolTest.java@@ -49,6 +49,7 @@ public class HttpSolrClientConPoolTest extends SolrJettyTestBase {public static void beforeTest() throws Exception {createAndStartJetty(legacyExampleCollection1SolrHome());fooUrl = getBaseUrl();+secondJetty.startSolr(Path.of(legacyExampleCollection1SolrHome()));barUrl = secondJetty.getBaseUrl();}diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/FullThrottleStoppableIndexingThread.java b/solr/test-framework/src/java/org/apache/solr/cloud/FullThrottleStoppableIndexingThread.javaindex 79413ed51e8..23846f0fff2 100644--- a/solr/test-framework/src/java/org/apache/solr/cloud/FullThrottleStoppableIndexingThread.java+++ b/solr/test-framework/src/java/org/apache/solr/cloud/FullThrottleStoppableIndexingThread.java@@ -63,6 +63,7 @@ class FullThrottleStoppableIndexingThread extends StoppableIndexingThread {cusc =new ErrorLoggingConcurrentUpdateSolrClient.Builder(((HttpSolrClient) clients.get(0)).getBaseURL())+ .withDefaultCollection(clients.get(0).getDefaultCollection()).withHttpClient(httpClient).withQueueSize(8).withThreadCount(2)@@ -127,6 +128,7 @@ class FullThrottleStoppableIndexingThread extends StoppableIndexingThread {cusc =new ErrorLoggingConcurrentUpdateSolrClient.Builder(((HttpSolrClient) clients.get(clientIndex)).getBaseURL())+ .withDefaultCollection(clients.get(clientIndex).getDefaultCollection()).withHttpClient(httpClient).withQueueSize(30).withThreadCount(3)