Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.solr.common.AlreadyClosedException;
import org.apache.solr.common.util.IOUtils;
import org.apache.solr.common.util.URLUtil;
import org.apache.solr.client.solrj.impl.CloudHttp2SolrClient;

/** The SolrClientCache caches SolrClients, so they can be reused by different TupleStreams. */
public class SolrClientCache implements Closeable {
Expand Down Expand Up @@ -136,7 +137,22 @@ public synchronized SolrClient getHttpSolrClient(String baseUrl) {
ensureOpen();
Objects.requireNonNull(baseUrl, "Url cannot be null!");
return httpSolrClients.computeIfAbsent(
baseUrl, url -> newHttpSolrClientBuilder(url, httpSolrClient).build());
baseUrl,
url -> {
// Find an existing Cloud Client connection
HttpSolrClient sharedEngine = this.httpSolrClient;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe called it sharedClient?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Affirmative 😊


if (sharedEngine == null && !cloudSolClients.isEmpty()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was cloudSolClients spelled wrong?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently? Should i refactor it?

// Get first available active Cloud client connection
CloudSolrClient firstCloudClient = cloudSolClients.values().iterator().next();
if (firstCloudClient instanceof CloudHttp2SolrClient) {
sharedEngine = ((CloudHttp2SolrClient) firstCloudClient).getHttpClient();
}
}

// Build the client using the shared engine if found one
return newHttpSolrClientBuilder(url, sharedEngine).build();
});
}

@SuppressWarnings({"unchecked", "rawtypes"})
Expand Down
Loading