Skip to content

Conversation

@jdyer1
Copy link
Contributor

@jdyer1 jdyer1 commented Oct 15, 2025

This includes changes to CloudHttp2SolrClient to allow it to delegate to any instance of HttpSolrClientBase or HttpSolrClientBuilderBase.

This removes a redundant Builder inner class of CloudSolrclient and migrates usages to CloudHttp2SolrClient.Builder.

A few classes geared for internal server use will now throw IllegalArgumentException if passed a CSC that does not delegate to the Jetty client.

This PR also fixes a bug in HttpjdkSolrClient in that it could not work in some situations for updates to multiple base urls.

This PR is geared for main/10x only. The fix for HttpjdkSolrClient could be backported to 9.x. Also it may be necessary to deprecate the removed CloudSolrclient.Builder class in 9.x.

@jdyer1 jdyer1 requested a review from mlbiscoc October 15, 2025 19:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Introduces broader HTTP client delegation in CloudHttp2SolrClient (supporting Http2SolrClient or HttpJdkSolrClient) and removes the deprecated CloudSolrClient.Builder, updating tests and internal server utilities accordingly. Key changes include refactoring builder usages to CloudHttp2SolrClient.Builder, revising HEAD request logic in HttpJdkSolrClient, and tightening internal APIs to require Jetty-based clients where needed.

  • Replaces CloudSolrClient.Builder usage across tests and examples with CloudHttp2SolrClient.Builder
  • Modifies HttpJdkSolrClient HEAD request caching to be per-base URI (but with an implementation flaw)
  • Adjusts internal server-only classes to validate delegate HTTP client type (Jetty-based)

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
AbstractFullDistribZkTestBase.java Javadoc updated to reference new builder class.
HttpJdkSolrClientTest.java Tests adapted to new HEAD tracking map API.
HttpClusterStateSSLTest.java Switched to CloudHttp2SolrClient builder.
CloudSolrClientMultiConstructorTest.java Builder migration to CloudHttp2SolrClient.
CloudSolrClientBuilderTest.java All builder usages updated.
CloudHttp2SolrClientTest.java Expanded test coverage for multiple delegate clients.
CloudHttp2SolrClientRetryTest.java Randomized delegate client selection added.
CloudHttp2SolrClientBuilderTest.java Added tests for Jetty/JDK builders and external clients.
HttpJdkSolrClient.java Reworked HEAD request logic to per-URI map; potential logical flaw.
CloudSolrClient.java Removed inner Builder class (API cleanup).
CloudHttp2SolrClient.java Generalized to HttpSolrClientBase; dynamic client selection.
SolrClientNodeStateProvider.java Enforces Jetty-based delegate; adjusted request paths.
NodeValueFetcher.java Updated to use narrowed client accessor.
UsingSolrJRefGuideExamplesTest.java Examples updated to new builder class.
KafkaCrossDcConsumer.java Internal client creation migrated to new builder.
RunExampleTool.java Cloud client construction updated.
libs.versions.toml Reordered one dependency entry (no functional change).

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@jdyer1 jdyer1 requested a review from Copilot October 16, 2025 00:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

} else if (builder.internalClientBuilder != null) {
return builder.internalClientBuilder.build();
} else {
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this logic should be done in a static initializer initializing a boolean constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great idea.

return maybeTryHeadRequestSync(uriNoQueryParams);
}

protected final Map<URI, Boolean> headSucceededByBaseUri =
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really need to differentiate by base URI? Meaning, in practice, is that really a concern?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CloudHttp2SolrClientTest fails without this. It is not that one shard is http/1 and the other is http/2, it is that it seems the JDK code also is tracking which hosts it knows for sure using http/2. So we were sending the HEAD request to the first shard and the JDK knew that shard was http/2, but for the second shard, it would still be sending a jetty-incompatible upgrade request. This change sends the HEAD request once to every shard and then all the components are happy.

private Map<String, Map> nodeVsTags = new HashMap<>();

public SolrClientNodeStateProvider(CloudHttp2SolrClient solrClient) {
if (!(solrClient.getHttpClient() instanceof Http2SolrClient)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why bother insisting on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these call the very special "requestwithbaseUrl" method on the jetty client. I was unable to quickly create a common api for this with both clients so I decided for now we just need to enforce the jetty client. In practice, I would think these are only used internally so nothing is going to pass the jdk client here.

} else {
try {
Class.forName("org.eclipse.jetty.client.HttpClient");
} catch (ClassNotFoundException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

have you tried if this actually works? You'd need to attempt on some other project. Recently I used the Solr MCP project for a similar test to see if excluding Apache HttpClient works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I manually tested that it correctly picks the jdk client when jetty is absent. I also added a unit test for the case where jetty is present. I wasn't brave enough to try and write the unit test with jetty absent.

jdyer1 and others added 3 commits October 16, 2025 14:52
…olrClient.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- decide default delegate client class in static intalizer (suggested by dsmiley)
- add unit test for the cae where jetty client shuld be default delegat client (cannot be tested so easy for djdk client)
Copy link
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

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

Overall looks good to me!
It'd be good to get this into Solr 10. Maybe 9?


/**
* Set the internal {@link Http2SolrClient}.
* Set the internal client Solr HTTP client.
Copy link
Contributor

Choose a reason for hiding this comment

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

That sounds clumsy to me. Maybe just refer to the type -- HttpSolrClientBase?

jdyer1 and others added 2 commits October 17, 2025 10:37
…p2SolrClient.java

Co-authored-by: David Smiley <dsmiley@apache.org>
@jdyer1 jdyer1 merged commit aad0c4b into apache:main Oct 17, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants