-
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
Fixes #12266 - InvocationType improvements and cleanups. #12273
Fixes #12266 - InvocationType improvements and cleanups. #12273
Conversation
* Removed usages of `AbstractConnection.getInvocationType()`. * Changed HTTP server-side Connection implementations to use `AbstractConnection.fillInterested(Callback)` with a callback that specifies the `InvocationType`, derived from the `Server`, which derives it from the `Handler` chain. * Changed client-side receivers to use `AbstractConnection.fillInterested(Callback)` with a callback that specifies the `InvocationType`, derived from the `HttpClientTransport`. * Introduced `HttpClientTransport.getInvocationType(Connection)`, so that client applications can specify whether they block or not. * Made sure client-side HTTP/2 and HTTP/3 return tasks with the proper `InvocationType` to be run by the `ExecutionStrategy` when calling application code. * HTTP3StreamConnection now uses an `EITHER` fillable callback to possibly process streams in parallel. * `QuicStreamEndPoint` now uses a task to invoke `FillInterest.fillable()`, rather than invoking it directly, therefore honoring the `InvocationType` of callback set by the `Connection` associated with the `QuicStreamEndPoint`. Signed-off-by: Simone Bordet <[email protected]>
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.
You have some broken tests.
Also... should this be 12.1???
@@ -139,10 +137,21 @@ protected void failedCallback(final Callback callback, final Throwable x) | |||
* @see #onFillable() | |||
*/ | |||
public void fillInterested() | |||
{ |
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.
Should this method be deprecated now, so that we can eventually remove it?
* <p>Registers read interest with the given callback.</p> | ||
* <p>When read readiness is signaled, the callback will be completed.</p> | ||
* | ||
* @param callback the callback to complete when read readiness is signaled |
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.
* @param callback the callback to complete when read readiness is signaled | |
* @param callback the callback to complete when read readiness is signaled or there is a failure |
@@ -88,6 +88,7 @@ public class HttpConnection extends AbstractMetaDataConnection implements Runnab | |||
private static final ThreadLocal<HttpConnection> __currentConnection = new ThreadLocal<>(); | |||
private static final AtomicLong __connectionIdGenerator = new AtomicLong(); | |||
|
|||
private final Callback fillableCallback = new FillableCallback(); |
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.
Please match the naming style of the class
private final Callback fillableCallback = new FillableCallback(); | |
private final Callback _fillableCallback = new FillableCallback(); |
* <p>Invoking the task does not block the invoker thread, | ||
* and the invocation may be performed immediately in the invoker thread.</p> | ||
* <p>The thread that produced the task may dispatch another | ||
* thread to resume production, and then invoke the task, differently | ||
* from {@link #NON_BLOCKING} which does not dispatch production to | ||
* another thread.</p> | ||
* <p>The invocation cannot be deferred to a later time, differently |
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.
* <p>Invoking the task does not block the invoker thread, | |
* and the invocation may be performed immediately in the invoker thread.</p> | |
* <p>The thread that produced the task may dispatch another | |
* thread to resume production, and then invoke the task, differently | |
* from {@link #NON_BLOCKING} which does not dispatch production to | |
* another thread.</p> | |
* <p>The invocation cannot be deferred to a later time, differently | |
* <p>Invoking the {@link Invocable} may block the invoker thread, unless invoked | |
* via {@link #invokeNonBlocking(Runnable)}, in which case it may not block the invoking thread. | |
* The invocation cannot be deferred to a later time, differently |
* <p>A series of {@code NON_BLOCKING} tasks is run sequentially, | ||
* while a series of {@code EITHER} tasks may be run in parallel, | ||
* if there are threads available to resume task production.</p> | ||
* <p>This invocation type is suitable for tasks that | ||
* perform the non-deferrable action in a non-blocking way, | ||
* hinting that may be run in parallel, for example when each task | ||
* processes a different connection or a different stream.</p> |
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.
* <p>A series of {@code NON_BLOCKING} tasks is run sequentially, | |
* while a series of {@code EITHER} tasks may be run in parallel, | |
* if there are threads available to resume task production.</p> | |
* <p>This invocation type is suitable for tasks that | |
* perform the non-deferrable action in a non-blocking way, | |
* hinting that may be run in parallel, for example when each task | |
* processes a different connection or a different stream.</p> | |
* <p>This invocation type is suitable for tasks that | |
* perform the non-deferrable action in a non-blocking way, | |
* hinting that may be run in parallel, for example when each task | |
* processes a different connection or a different stream.</p> | |
* <p>For multiple {@code EITHER} tasks, if there threads available, then | |
* those tasks may be run in parallel as if they are {@code BLOCKING} tasks, otherwise | |
* they should be invoked serially via {@link #invokeNonBlocking(Runnable)} so | |
* they act as {@code NON_BLOCKING}.</p> | |
` |
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.
Looks alright, but why doing this in 12.0 instead of 12.1?
response.write(false, null, Callback.NOOP); | ||
// Wait to force the client to invoke the content | ||
// callback separately from the headers callback. | ||
Thread.sleep(500); |
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.
You could await until queue
contains "-headers"
instead of relying on time.
Closing in favor of #12299. |
AbstractConnection.getInvocationType()
.AbstractConnection.fillInterested(Callback)
with a callback that specifies theInvocationType
, derived from theServer
, which derives it from theHandler
chain.AbstractConnection.fillInterested(Callback)
with a callback that specifies theInvocationType
, derived from theHttpClientTransport
.HttpClientTransport.getInvocationType(Connection)
, so that client applications can specify whether they block or not.InvocationType
to be run by theExecutionStrategy
when calling application code.EITHER
fillable callback to possibly process streams in parallel.QuicStreamEndPoint
now uses a task to invokeFillInterest.fillable()
, rather than invoking it directly, therefore honoring theInvocationType
of callback set by theConnection
associated with theQuicStreamEndPoint
.