Apache Solr open-source search software
SOLR-10462: migrate to using the Builder setting the pollQueueTime (#1219)
Eric Pugh49d77dbb2be2
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex b02f3711262..fd104124821 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -96,6 +96,9 @@ Improvements* SOLR-10461: Introduce Builder setter for aliveCheckInterval on load balanced SolrClients. Deprecateddirect setter setAliveCheckInterval on SolrClients. (Eric Pugh, David Smiley)+* SOLR-10462: Introduce Builder setter for pollQueueTime on ConcurrentUpdateHttp2SolrClient. Deprecated+ direct setter setPollQueueTime on ConcurrentUpdateHttp2SolrClient. (Eric Pugh)+Optimizations---------------------diff --git a/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.java b/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.javaindex 9d55511264a..9294195d4e6 100644--- a/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.java+++ b/solr/core/src/java/org/apache/solr/update/StreamingSolrClients.java@@ -74,8 +74,9 @@ public class StreamingSolrClients {.withThreadCount(runnerCount).withExecutorService(updateExecutor).alwaysStreamDeletes()+ .setPollQueueTime(pollQueueTime) // minimize connections created.build();- client.setPollQueueTime(pollQueueTime); // minimize connections created+solrClients.put(url, client);}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.javaindex 7891a51c710..20b733c2986 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java@@ -149,7 +149,16 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {this.runners = new ArrayDeque<>();this.streamDeletes = builder.streamDeletes;this.basePath = builder.baseSolrUrl;+ this.pollQueueTime = builder.pollQueueTime;this.stallTime = Integer.getInteger("solr.cloud.client.stallTime", 15000);++ // make sure the stall time is larger than the polling time+ // to give a chance for the queue to change+ int minimalStallTime = pollQueueTime * 2;+ if (minimalStallTime > this.stallTime) {+ this.stallTime = minimalStallTime;+ }+if (stallTime < pollQueueTime * 2) {throw new RuntimeException("Invalid stallTime: " + stallTime + "ms, must be 2x > pollQueueTime " + pollQueueTime);@@ -691,7 +700,9 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {/*** @param pollQueueTime time for an open connection to wait for updates when the queue is empty.+ * @deprecated use {@link ConcurrentUpdateHttp2SolrClient.Builder#setPollQueueTime(int)} instead*/+ @Deprecatedpublic void setPollQueueTime(int pollQueueTime) {this.pollQueueTime = pollQueueTime;// make sure the stall time is larger than the polling time@@ -711,6 +722,7 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {protected ExecutorService executorService;protected boolean streamDeletes;protected boolean closeHttp2Client;+ private int pollQueueTime;public Builder(String baseSolrUrl, Http2SolrClient client) {this(baseSolrUrl, client, false);@@ -795,6 +807,14 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {return this;}+ /**+ * @param pollQueueTime time for an open connection to wait for updates when the queue is empty.+ */+ public Builder setPollQueueTime(int pollQueueTime) {+ this.pollQueueTime = pollQueueTime;+ return this;+ }+/*** Create a {@link ConcurrentUpdateHttp2SolrClient} based on the provided configuration options.*/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 900f897d90d..ac26bd9fce4 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@@ -67,8 +67,8 @@ public class ConcurrentUpdateHttp2SolrClientTest extends SolrJettyTestBase {serverUrl, http2Client, successCounter, errorCounter, errors).withQueueSize(cussQueueSize).withThreadCount(cussThreadCount)+ .setPollQueueTime(0).build()) {- concurrentClient.setPollQueueTime(0);// ensure it doesn't block where there's nothing to do yetconcurrentClient.blockUntilFinished();@@ -172,8 +172,8 @@ public class ConcurrentUpdateHttp2SolrClientTest extends SolrJettyTestBase {new ConcurrentUpdateHttp2SolrClient.Builder(jetty.getBaseUrl().toString(), http2Client).withQueueSize(cussQueueSize).withThreadCount(cussThreadCount)+ .setPollQueueTime(0).build()) {- concurrentClient.setPollQueueTime(0);// ensure it doesn't block where there's nothing to do yetconcurrentClient.blockUntilFinished();