jdyer1 commented on code in PR #2899:
URL: https://github.com/apache/solr/pull/2899#discussion_r1878873445
##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java:
##########
@@ -94,35 +97,74 @@
*
* @since solr 8.0
*/
-public class LBHttp2SolrClient<C extends HttpSolrClientBase> extends
LBSolrClient {
+public class LBHttp2SolrClient<B extends HttpSolrClientBuilderBase<?, ?>>
extends LBSolrClient {
- protected final C solrClient;
+ private final Map<String, HttpSolrClientBase> urlToClient;
+ private final Set<String> urlParamNames;
+
+ private final HttpSolrClientBuilderBase<?, ?> solrClientBuilder;
@SuppressWarnings("unchecked")
private LBHttp2SolrClient(Builder<?> builder) {
super(Arrays.asList(builder.solrEndpoints));
- this.solrClient = (C) builder.solrClient;
+ this.solrClientBuilder = builder.solrClientBuilder;
+
+ this.urlToClient = new ConcurrentHashMap<>();
+ for (LBSolrClient.Endpoint endpoint : builder.solrEndpoints) {
+ buildClient(endpoint);
+ }
+
this.aliveCheckIntervalMillis = builder.aliveCheckIntervalMillis;
this.defaultCollection = builder.defaultCollection;
+
+ if (builder.solrClientBuilder.urlParamNames == null) {
+ this.urlParamNames = Collections.emptySet();
+ } else {
+ this.urlParamNames =
Collections.unmodifiableSet(builder.solrClientBuilder.urlParamNames);
+ }
+ }
+
+ private synchronized HttpSolrClientBase buildClient(Endpoint endpoint) {
Review Comment:
The `synchronized` keyword was to prevent multiple threads from adding
clients for the same Base Url. However, in taking your advice to use
`computeIfAbsent` this removes the need.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]