This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new c04430bd4b7 SOLR-10462: migrate to using the Builder setting the
pollQueueTime (#1219)
c04430bd4b7 is described below
commit c04430bd4b755761193598784cbe7d8c15ba935e
Author: Eric Pugh <[email protected]>
AuthorDate: Thu Dec 22 13:31:16 2022 -0500
SOLR-10462: migrate to using the Builder setting the pollQueueTime (#1219)
Deprecate the method on the ConcurrentUpdateHttp2SolrClient client.
---
solr/CHANGES.txt | 3 +++
.../org/apache/solr/update/StreamingSolrClients.java | 3 ++-
.../solrj/impl/ConcurrentUpdateHttp2SolrClient.java | 20 ++++++++++++++++++++
.../impl/ConcurrentUpdateHttp2SolrClientTest.java | 4 ++--
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 3940d4569ce..01eb61d6a2d 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -72,6 +72,9 @@ Improvements
* SOLR-10461: Introduce Builder setter for aliveCheckInterval on load balanced
SolrClients. Deprecated
direct 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.java
index 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.java
index 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
*/
+ @Deprecated
public 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.java
index 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 yet
concurrentClient.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 yet
concurrentClient.blockUntilFinished();