Skip to content
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

SOLR-17211: HttpJdkSolrClient Support Async requests #2374

Merged
merged 19 commits into from
Apr 3, 2024

Conversation

jdyer1
Copy link
Contributor

@jdyer1 jdyer1 commented Mar 25, 2024

This PR adds method asyncRequest to abstract supertype HttpSolrClientBase and implements it on HttpJdkSolrClient. Also adds unit tests for normal, exceptional and cancelled asynchronous requests, both for HttpJdkSolrClient and Http2SolrClient. Also includes a few javadoc improvements.

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, you did a thorough job; not much to add beyond what I said in the parent JIRA. I'm hoping you are sympathetic to that other JIRA and its existing PR so we can go a different route instead of cementing further Solr's needless bespoke Async API (AsyncListener & Cancellable).

@@ -136,6 +137,16 @@ private void recordRequest(HttpServletRequest req, HttpServletResponse resp) {
resp.addHeader(h[0], h[1]);
}
}
String qs = req.getQueryString();
Copy link
Contributor

Choose a reason for hiding this comment

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

could use a one-liner comment to explain

}
}

protected DebugAsyncListener testAsyncExceptionBase() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if tests can return non-void. If so, you could just make it public and add @Test and remove the "Base" suffix in the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me clarify why I have been overriding these shared tests. You are right it does work generally on IntelliJ, however, if you want to run only 1 test method and not the whole class, this doesn't seem to work. Even if you run all the tests, then right click to re-run just the individual test method, I am getting an error. This makes it very difficult to debug, which is why I have been using all those 1-line test override methods.

@@ -469,6 +531,23 @@ protected String allProcessorSupportedContentTypesCommaDelimited(
.collect(Collectors.joining(", "));
}

protected static class HttpSolrClientCancellable implements Cancellable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seeing this class, to me, really underscores a mismatch between Solr's needless Async API helper classes (Cancellable is one), and using a CompletableFuture directly. See the parent JIRA issue where I direct you to a previous stalled effort that could be resumed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I fully agree we should deprecate and replace the existing method, but we will need to keep the old API around for 9.x. I am interested in taking a closer look at SOLR-14763 and I appreciate your pointing me to that. But in any case I would like to do that separately from this issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. Note the old API is on exactly one class a user might use; it's being expanded here. But at least it's only other Http subclasses; isn't spreading further. If you can mark these methods Deprecated here (to be replaced by something coming (soon?)), people will be forewarned.

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 do not want to deprecate anything unless there is a replacement. But I hear and share your concern, and would like to make the API change, just not as part of this PR.

- could not use DebugServlet to do a thorough post test, switch to indexing actual solr documents
@jdyer1
Copy link
Contributor Author

jdyer1 commented Apr 2, 2024

Unless there are objections I would like to merge this one soon.

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.

Thanks; merge away

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Apr 3, 2024
@jdyer1 jdyer1 merged commit cc08228 into apache:main Apr 3, 2024
4 checks passed
@jdyer1 jdyer1 deleted the feature/SOLR-17211 branch April 3, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client:solrj documentation Improvements or additions to documentation tests
Projects
None yet
2 participants