Zakelly commented on code in PR #24904:
URL: https://github.com/apache/flink/pull/24904#discussion_r1630679912
##########
flink-core/src/main/java/org/apache/flink/api/common/operators/MailboxExecutor.java:
##########
@@ -86,6 +87,25 @@ public interface MailboxExecutor {
/** A constant for empty args to save on object allocation. */
Object[] EMPTY_ARGS = new Object[0];
+ /** Extra options to configure enqueued mails. */
+ @Experimental
+ interface MailOptions {
+ static MailOptions options() {
+ return new MailOptionsImpl();
Review Comment:
I'm fine with the full builder pattern, and the caller will have a pre-built
immutable instance. No need to provide constants for each combination.
##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/mailbox/Mail.java:
##########
@@ -71,8 +77,13 @@ public Mail(
this.actionExecutor = actionExecutor;
}
+ public MailboxExecutor.MailOptions getMailOptions() {
+ return mailOptions;
+ }
+
public int getPriority() {
- return priority;
+ /** See {@link MailboxExecutor.MailOptions#setInterruptible()}. */
+ return mailOptions.isInterruptible() ? TaskMailbox.MIN_PRIORITY :
priority;
Review Comment:
I see the `MailboxProcessor#getMainMailboxExecutor` create the
`MailboxExecutorImpl` with `MIN_PRIORITY`, which means for this executor
`#execute` will put mail with `MIN_PRIORITY`. Should this also be changed?
##########
flink-core/src/main/java/org/apache/flink/api/common/operators/MailboxExecutor.java:
##########
@@ -86,6 +87,25 @@ public interface MailboxExecutor {
/** A constant for empty args to save on object allocation. */
Object[] EMPTY_ARGS = new Object[0];
+ /** Extra options to configure enqueued mails. */
+ @Experimental
+ interface MailOptions {
+ static MailOptions options() {
+ return new MailOptionsImpl();
+ }
+
+ /**
+ * Mark this mail as interruptible.
+ *
+ * <p>Interruptible mails, are those that respect {@link
MailboxExecutor#shouldInterrupt()}
+ * flag. Marking mail as interruptible allows {@link MailboxExecutor}
to optimize execution
+ * order. For example interruptible mails are not executed during
{@link #yield()} or {@link
+ * #tryYield()}, to avoid having to immediately interrupt them. This
is done to speed up
+ * checkpointing, by skipping execution of potentially long running
mails.
+ */
+ MailOptions setInterruptible();
Review Comment:
That's a good point. I think maybe `#setDeferrable()` is a better name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]