-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Experiment with IteratingCallback #12040
Experiment with IteratingCallback #12040
Conversation
The previous semantic of `onCompleteFailure` has been renamed to `onFailure(Throwable)`, which is called immediately (but serialized) on either an abort or a failure. A new `onCompleteFailure(Throwable)` method has been added that is called only after a `failed(throwable)` or a `abort(Throwable)` followed by `succeeded()` or `failed(Throwable)`` No usage has yet been made of the new `onCompleteFailure`, but the ICB implementation has been completely replaced by the one developed in #11876
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.
IMHO the onCompleteXyz
trio should be improved to leave no trace to confusion in the API. Otherwise LGTM.
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java
Show resolved
Hide resolved
The previous semantic of `onCompleteFailure` has been renamed to `onFailure(Throwable)`, which is called immediately (but serialized) on either an abort or a failure. A new `onCompleteFailure(Throwable)` method has been added that is called only after a `failed(throwable)` or a `abort(Throwable)` followed by `succeeded()` or `failed(Throwable)`` No usage has yet been made of the new `onCompleteFailure`, but the ICB implementation has been completely replaced by the one developed in #11876
The previous semantic of `onCompleteFailure` has been renamed to `onFailure(Throwable)`, which is called immediately (but serialized) on either an abort or a failure. A new `onCompleteFailure(Throwable)` method has been added that is called only after a `failed(throwable)` or a `abort(Throwable)` followed by `succeeded()` or `failed(Throwable)`` No usage has yet been made of the new `onCompleteFailure`, but the ICB implementation has been completely replaced by the one developed in #11876
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java
Outdated
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.
I think this is way too fine-grained.
I would be fine to "delay" the call to onCompleteFailure()
until completeness (rather than early failure), and that's it.
The new methods introduced are currently not used, and will be APIs that we need to maintain and carefully document about what can and cannot be done in them, which I think is a big effort not worth it.
Their semantic is delicate and we got it mostly wrong in this PR (e.g. calling release from onFailure()).
So I'd revert to minimal changes, i.e. just "delay" properly the call to onCompleteFailure()
, and all the rest should just be correct as it is.
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java
Show resolved
Hide resolved
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java
Show resolved
Hide resolved
jetty-core/jetty-util/src/main/java/org/eclipse/jetty/util/IteratingCallback.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This is necessary to avoid confusion, for example class A_ICB extending ICB and overriding onCompleted() without calling super, and class B_ICB extending A_ICB and overriding onCompleteSuccess() which would be never called. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@gregw I think it is mandatory that "release" operations in case of failure become in fact "remove" operations, when dealing with buffers, because it is always possible that the failure is asynchronous, and the buffer is being utilized by the async operation while the release is trying to put it back into the pool for reuse. Therefore, rather than splitting the "fail" and "release" operations, the former in Which then begs the question if we need to have the additional methods introduced in this PR especially regarding abort/failure. So the idea is to have Or, we bit the bullet, change the behavior in 12.1.x, introduce the new methods, possibly break existing code, but avoid the split of my experiment PR by introducing "remove" semantic to RBB. |
Dismissing after additional discussions with @lorban.
…lback # Conflicts: # jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipResponseAndCallback.java
@lorban can you take this one on? |
@gregw a note to self/team about failures in case of non termination. The practical example would be a write that is TCP congested, and a timeout happening.
|
@sbordet ... and further to that example, we have two strategies to deal with the scenario: a) in The buffer is held in memory in both a) and b), so there is no memory saving in either. In a) we potentially free a slot in the buffer pool making for better pooling for other requests, but only a very marginal gain. So the choice between a) and b) really should be based on code clarity and what other events might be triggered by |
…gCallback-SplitRelease' into experiment/jetty-12.1.x/IteratingCallback # Conflicts: # documentation/jetty-documentation/src/main/java/org/eclipse/jetty/docs/programming/ContentDocs.java # jetty-core/jetty-http2/jetty-http2-common/src/main/java/org/eclipse/jetty/http2/internal/HTTP2Flusher.java # jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/gzip/GzipResponseAndCallback.java # jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/HttpOutput.java # jetty-ee11/jetty-ee11-servlet/src/main/java/org/eclipse/jetty/ee11/servlet/HttpOutput.java # jetty-ee9/jetty-ee9-nested/src/main/java/org/eclipse/jetty/ee9/nested/HttpOutput.java
...ules/code/examples/src/main/java/org/eclipse/jetty/docs/programming/SelectorManagerDocs.java
Outdated
Show resolved
Hide resolved
...odules/code/examples/src/main/java/org/eclipse/jetty/docs/programming/server/ServerDocs.java
Outdated
Show resolved
Hide resolved
...odules/code/examples/src/main/java/org/eclipse/jetty/docs/programming/server/ServerDocs.java
Outdated
Show resolved
Hide resolved
documentation/jetty/modules/programming-guide/pages/arch/io.adoc
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferPool.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/internal/ContentCopier.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/internal/ContentCopier.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/Content.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBuffer.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java
Outdated
Show resolved
Hide resolved
...etty/modules/code/examples/src/main/java/org/eclipse/jetty/docs/programming/ContentDocs.java
Outdated
Show resolved
Hide resolved
...tty-client/src/main/java/org/eclipse/jetty/client/transport/internal/HttpSenderOverHTTP.java
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBuffer.java
Outdated
Show resolved
Hide resolved
jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/RetainableByteBuffer.java
Outdated
Show resolved
Hide resolved
FYI |
…lback # Conflicts: # jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/HttpOutput.java # jetty-ee11/jetty-ee11-servlet/src/main/java/org/eclipse/jetty/ee11/servlet/HttpOutput.java
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
…tty-12.1.x/IteratingCallback
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…tty-12.1.x/IteratingCallback
…tty-12.1.x/IteratingCallback
@gregw I'm ok to merge this. |
The QoSHandler CI failures appear to be a problem in head, so merging this without a green build. |
The previous semantic of
onCompleteFailure
has been renamed toonFailure(Throwable)
, which is called immediately (but serialized) on either an abort or a failure. A newonCompleteFailure(Throwable)
method has been added that is called only after afailed(throwable)
or aabort(Throwable)
followed bysucceeded()
or `failed(Throwable)``No usage has yet been made of the new
onCompleteFailure
, but the ICB implementation has been completely replaced by the one developed in #11876