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

Fixes #12266 - InvocationType improvements and cleanups. #12273

Closed

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented Sep 13, 2024

  • 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.

* 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]>
@sbordet sbordet linked an issue Sep 13, 2024 that may be closed by this pull request
Copy link
Contributor

@gregw gregw left a 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()
{
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @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();
Copy link
Contributor

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

Suggested change
private final Callback fillableCallback = new FillableCallback();
private final Callback _fillableCallback = new FillableCallback();

Comment on lines +64 to +70
* <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
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* <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

Comment on lines +72 to +78
* <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>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* <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>
`

Copy link
Contributor

@lorban lorban left a 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);
Copy link
Contributor

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.

@sbordet
Copy link
Contributor Author

sbordet commented Sep 23, 2024

Closing in favor of #12299.

@sbordet sbordet closed this Sep 23, 2024
@sbordet sbordet deleted the fix/jetty-12.0.x/12266/invocationtype-cleanups branch September 23, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

InvocationType improvements and cleanups
3 participants