-
Notifications
You must be signed in to change notification settings - Fork 809
SOLR-17771: Have a CloudSolrClient that works with HttpJdkSolrClient #3774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… if classpath contans Jetty Http
There was a problem hiding this 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.
solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
Outdated
Show resolved
Hide resolved
solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpJdkSolrClient.java
Show resolved
Hide resolved
solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
Show resolved
Hide resolved
There was a problem hiding this 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.
solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpJdkSolrClient.java
Outdated
Show resolved
Hide resolved
solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
Show resolved
Hide resolved
solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
Show resolved
Hide resolved
solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
Show resolved
Hide resolved
| } else if (builder.internalClientBuilder != null) { | ||
| return builder.internalClientBuilder.build(); | ||
| } else { | ||
| try { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…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)
dsmiley
left a comment
There was a problem hiding this 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?
solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
Outdated
Show resolved
Hide resolved
|
|
||
| /** | ||
| * Set the internal {@link Http2SolrClient}. | ||
| * Set the internal client Solr HTTP client. |
There was a problem hiding this comment.
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?
…p2SolrClient.java Co-authored-by: David Smiley <dsmiley@apache.org>
This includes changes to
CloudHttp2SolrClientto allow it to delegate to any instance ofHttpSolrClientBaseorHttpSolrClientBuilderBase.This removes a redundant
Builderinner class ofCloudSolrclientand migrates usages toCloudHttp2SolrClient.Builder.A few classes geared for internal server use will now throw
IllegalArgumentExceptionif passed a CSC that does not delegate to the Jetty client.This PR also fixes a bug in
HttpjdkSolrClientin 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
HttpjdkSolrClientcould be backported to 9.x. Also it may be necessary to deprecate the removedCloudSolrclient.Builderclass in 9.x.