-
Notifications
You must be signed in to change notification settings - Fork 183
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
[FEATURE] Introduce new OpenSearchTransport based on Apache HttpClient 5 #281
Conversation
@dblock @dlvenable the PoC for getting rid of the dependency on OpenSearch core, basically more or less the amount of code we would need to copy / paste from core (I think I could reduce it a bit but that would not be a game changer there). It should help us to assess the go / no-go decision. |
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 love it. It's a lot smaller than I thought it would be and it's mostly boilerplate (+ tests?).
Sure, a few sketches needed to make it compete and testable (just wanted to hear your opinion first), I'll wrap it up shortly. |
25b97c0
to
9364982
Compare
@dblock @VachaShah got stuck on this one #47 :( |
I love this as well. Removing the dependency on core clearly outweighs any downside to code duplication, in my opinion. |
e0cf2c2
to
051b2b1
Compare
@dblock @andrross @VachaShah I think the POC is ready |
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.
This is real progress!
What's the path to delete https://github.com/opensearch-project/opensearch-java/blob/f1fbe833d7cd925018b7ed3f9cd1c0684e25b993/java-client/build.gradle.kts#LL149C5-L149?
import org.opensearch.client.transport.Version; | ||
|
||
public class ApacheHttpClient5Options implements TransportOptions { | ||
private static final String USER_AGENT = "User-Agent"; |
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 found it interesting that the client does not declare things like user-agent as constants. Since this is only used once, maybe we should too? I noticed you don't for "Accept" :)
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 have largely copied it from RestClientOptions
, we probably should have constants, I agree
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.
Done
String ua = String.format( | ||
Locale.ROOT, | ||
"opensearch-java/%s (Java/%s)", | ||
Version.VERSION == null ? "Unknown" : Version.VERSION.toString(), |
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.
Nit: should never be null
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.
@dblock you will be surprised but [1]:
/**
* This library's version, read from the classpath. Can be {@code null} if the version resource could not be read.
*/
@Nullable
public static final Version VERSION;
Thanks @dblock ! This is what we have discussed here [1], basically easy steps:
|
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'm good to merge this or wait to get the actual cut-off done on main.
java-client/src/main/java/org/opensearch/client/transport/httpclient5/DeadHostState.java
Outdated
Show resolved
Hide resolved
I may be confused, but that's the plan for removing the legacy rest client from OpenSearch right? Why can't we remove the dependency on OpenSearch from opensearch-java right now? |
That would be hard breaking change: since we never deprecated |
Thanks @reta @andrross and @dlvenable! Let's talk about what we want to merge. I think we should
|
This is not really possible, the Apache HttpClient 4 and Apache HttpClient 5 are very different: we could hide some (like fe |
d593b64
to
b557835
Compare
Makes sense. I'm slowly getting up to speed here :) So HttpClient 4 and 5 are actually distinct packages that can exists side-by-side ( |
That's right.
This is true. There are no concerns regarding breaking change, my concern is "new dependencies are going to be introduced", it may be very surprising to see that within minor version update (may be I am overly cautious). |
The tl;dr is that this PR will add a new dependency (Apache HttpClient 5) and create a new |
Please note that right now Apache HttpClient 5 comes with OpenSearch core 3.0.0, nothing is added to |
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
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.
Thanks @reta, this looks good to me!
I believe the remaining open question is whether to backport this to 2.x (with a slight change to explicitly declare the HttpClient5 dependencies) or instead introduce an ApacheHttpClient4Transport. In either case this change will be needed on main.
@reta , I did not actually see a dependency change in this PR (no modification to the build file). It seems that we are pulling in Apache HTTP Client 5 via a transitive dependency. We may want to explicitly add this dependency now that the project itself depends on it.
Is this dependency already in the 2.x line? If so, we are not adding a new dependency. If not, we can make this optional at runtime to address the concern of adding new dependencies. End users would need to add it to their build files to use the transport. |
In my opinion, this is not breaking since it is compatible with HttpClient4. If we really want, it is possible to make this an optional dependency on 2.x using feature variants. End users would have to add this dependency or get a runtime error. |
@dlvenable We are getting HttpClient5 on the main branch via a transitive dependency. For the 2.x branch it would have to be added a new dependency. |
I merged it. @reta backport or not? |
…earch-project#281) Signed-off-by: Andriy Redko <andriy.redko@aiven.io> Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
…earch-project#281) Signed-off-by: Andriy Redko <andriy.redko@aiven.io> Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
…earch-project#281) Signed-off-by: Andriy Redko <andriy.redko@aiven.io> Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
Signed-off-by: Andriy Redko andriy.redko@aiven.io
Description
Get rid of the dependency on OpenSearch core. Introducing new
OpenSearchTransport
based on Apache HttpClient 5, with no dependencies on OpenSearch's coreRestClient
.Issues Resolved
PoC for #262
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.