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

[MRESOLVER-308] HTTP transport showdown. #231

Closed
wants to merge 2 commits into from

Conversation

cstamas
Copy link
Member

@cstamas cstamas commented Dec 22, 2022

Introduces 3 2 new transport: Jetty HttpClient 10.x, OkHttp 4.x and Java 11 HttpClient based ones. These are all HTTP/2 capable transports. 2 out of 3 new ones requires Java 11, hence corresponding modules lavel raised to Java11 and Java 11 is required to build (sniffer removed, using compiler release flag) but the library still remains Java 8!

Also, some reshuffle around HTTP tests, made them reusable to be able to use them in all HTTP based transports.

High level changes:

  • introduced transport-okhttp using OkHttp 4.10.x
  • introduced transport-jetty using Jetty Client 10.x, needs Java 11
  • introduced transport-java11 using Java 11 HttpClient, needs Java 11
  • build required minimal Java upped to Java 11, but project still produces Java 8 binaries (except for 2 new transports)
  • animal-sniffer removed, using compiler release=8 flag (except for 2 new transports) and enforcer byteCode rule adjusted to ignore test scoped dependencies.
  • HTTP test utilities (HTTP Server using EOL Jetty 9.x and other) moved out of transport-http into maven-resolver-test-http module, made it reusable and updated: it is now implemented using Jetty 10.x and is HTTP/2 capable (when TLS enabled). This implies that Java 8 modules uses Java 11 test libraries for testing (the HTTP server), hence the enforcer bytecode rule adjustment.
  • transport specific tests moved in their corresponding UT class that extends the common HTTP test support class. Hence all of HTTP transports run same superset of HTTP tests (from reusable HttpTransporterTestSupport).

Important notes

  • none of the new transports supports the "WebDAV MKCOL dance". This logic originates from Maven 2.x Wagon era, when people used httpd+mod_dav to implement hosted repositories. All new transports assume modern environments, use of proper Maven Repository Managers and not some "home fashioned solutions".
  • all the new transports supports only HTTP Basic authentication, that should be used in combination with HTTPS, just the usual.
  • tested with mvn only. In mvnd these will NOT properly work, as "onSessionClose event" is still missing: clients are created per session, but are NOT stopped when session ends -- hence it works in mvn as process exits on session end, but mvnd does not. All this is resolved with [MRESOLVER-302] Introduce onSessionClose hooks #232
  • and the final notice: not for production use (until it proves otherwise).

For perf tests (kinda) look at related JIRA issue https://issues.apache.org/jira/browse/MRESOLVER-308

New Transports

This PR introduces 3 new transports for resolver:

Java 11 HttpClient transport

Uses Java 11 HttpClient to implement transport, it prefers HTTP/2 and supports HTTP/1.1.

The build produces one 27KB JAR, that can be placed into Maven lib/ext of any Maven version that uses Resolver 1.9.2+. The transport remains dormant when Maven runs on Java 8, while activates (and becomes default) when Java 11+ used to run Maven.

Jetty 10.x Client transport

Uses Jetty 10.x Client to implement transport. When remote repository is HTTPS, it prefers HTTP/2 and supports HTTP/1.1, otherwise speaks HTTP/1.1 only.

The build produces "pgk.zip" classified artifact with transport and all of it's needed dependencies. To use it, unpack the ZIP into Maven lib/ext of any Maven version that uses Resolver 1.9.2+ and use Java 11 or above to run Maven.

OkHttp 4.10.x transport

Uses OkHttp 4.10.x to implement transport. Supports HTTP/2 and HTTP/1.1.

The build produces "pgk.zip" classified artifact with transport and all of it's needed dependencies. To use it, unpack the ZIP into Maven lib/ext of any Maven version that uses Resolver 1.9.2+.

OkHttp transport is about to be dropped.

Note:


https://issues.apache.org/jira/browse/MRESOLVER-308

@cstamas cstamas self-assigned this Dec 22, 2022
@cstamas

This comment was marked as outdated.

@cstamas cstamas added this to the 1.9.3 milestone Dec 22, 2022
Introduces 3 new transport: Jetty HttpClient 10.x, OkHttp 4.x and Java 11 HttpClient based ones.
These are all HTTP/2 capable transports.

Also, some reshuffle around HTTP tests, made them reusable to be able to use them in all
HTTP based transports.

---

https://issues.apache.org/jira/browse/MRESOLVER-308
Copy link
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

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

This should bump the version to 1.10 due to the build requirement change.

@kwin
Copy link
Member

kwin commented Dec 24, 2022

Do we really want to keep maintaining that many resolver transport modules? If there is a clear winner performance wise, why not dropping the other modules? I fail to see the advantage of providing that many options...

@michael-o
Copy link
Member

Do we really want to keep maintaining that many resolver transport modules? If there is a clear winner performance wise, why not dropping the other modules? I fail to see the advantage of providing that many options...

There can never be a clear winner since every client is different and every environment is different. We just need a small decent set.

}
}
}
httpClient.start();
Copy link
Member

Choose a reason for hiding this comment

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

is there any call to stop() to cleanup?
Shouldn't be a problem for mvn as jvm is stopped but for mvnd?
But my understanding of the code there is only one per repo?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, stopping the client is missing, as noted in "Important notes" (3rd bullet). Client is created per-session, per-remote repository.

@kwin
Copy link
Member

kwin commented Dec 27, 2022

We just need a small decent set.

Exactly, for me shipping 5 HTTP transport modules is too much. That also makes the decision for consumers much harder.

@cstamas
Copy link
Member Author

cstamas commented Dec 27, 2022

Just to clear up: the fact we have here 5 (7 to be exact) transports, that does not mean we need to deliver all these with Maven. Or in other words, transport-http, transport-file and transport-classpath was present since day 0 (of resolver existence), but no Maven included it so far. Maven 3.9/4.0 will be the first that will include transport-http.

There are 4 transports already (file, http, wagon, classpath), and this PR adds 3 new modules. But, the thing is, these are all for HTTP protocol (when protocol of remote repository is HTTP/HTTPS). These are the "old" ones:

  • wagon
  • http (aka "native")

While these are new:

  • java11
  • jetty
  • okhttp

New ones are all HTTP/2 capable. Personally, from new ones, I'd remove okhttp (cons: pulls in kotlin runtime and is slowest H2 client). Java11 and Jetty were really close to each other.

In short: the fact a transport is present here, does not mean we must ship it, as the case of transport-classpath and transport-http shows (they were present since day 0 of resolver, but never shipped).

@kwin
Copy link
Member

kwin commented Dec 27, 2022

Whether we ship with Maven or not is completely orthogonal to me. If they are part of resolver releases we should make sure they work properly and I don't see the capacity to maintain that many modules (nor the need TBH)

@rmannibucau
Copy link
Contributor

My 2cts would be that Java 11 HttpClient is really worth it since it will, ultimately, enable to almost drop the resolver transitive stack when we'll be java >= 11 and go reactive (not need 256 threads to download 256 deps at the same time) but for the same reason we don't care anymore of WebDAV we shouldn't care much of http client impls (all but apache one actually?) while we have one impl which works well enough - even if it requires some system properties, we have all we need to make it work - I think it is more than sufficient and will particularly avoid the "don't use in prod until you used it and saw it was working" which does motivate much to use that.

That said, fact it does not work with mvnd should maybe be considered as a blocker - I consider mvnd as a deliverable of maven so anything targetting mvn should also target mvnd IMHO.

@cstamas
Copy link
Member Author

cstamas commented Dec 27, 2022

It does not work currently, but #232 is here to solve that bit as well (naturally, once that is merged, this PR will need changes: to hook into those). also see apache/maven#941

@cstamas
Copy link
Member Author

cstamas commented Dec 28, 2022

This should bump the version to 1.10 due to the build requirement change.

I agree, but let's make it in different change (as we have currently 2 PRs overlapping somewhat, this and onSessionClose). So let's make the 1.10.0 bump change in separate commit (and update JIRA)

@cstamas
Copy link
Member Author

cstamas commented Dec 28, 2022

As nobody objected, I will drop okhttp transport, so lowering this PR to addition of 2 transports (java11 and Jetty).

@cstamas
Copy link
Member Author

cstamas commented Nov 8, 2023

Removed this PR from 2.0.0 milestone, but am keeping it, as while main code is already on master, there may be some test related bits we will need.

@cstamas
Copy link
Member Author

cstamas commented Dec 11, 2023

We are past this, so no reason to keep it anymore, closing it.

@cstamas cstamas closed this Dec 11, 2023
@cstamas cstamas deleted the http2-transports branch December 11, 2023 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants