rkhachatryan commented on code in PR #24904:
URL: https://github.com/apache/flink/pull/24904#discussion_r1629515119
##########
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:
To me, the name is misleading: according to this flag, the mail won't be
picked up in some cases.
Whether the processing can be interrupted is defined by the logic inside the
mail, right?
##########
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 {
Review Comment:
Why is it an interface and not a class?
##########
flink-streaming-java/src/main/java/org/apache/flink/streaming/runtime/tasks/mailbox/Mail.java:
##########
@@ -58,11 +62,13 @@ public Mail(
}
public Mail(
+ MailboxExecutor.MailOptions mailOptions,
ThrowingRunnable<? extends Exception> runnable,
int priority,
StreamTaskActionExecutor actionExecutor,
String descriptionFormat,
Object... descriptionArgs) {
+ this.mailOptions = (MailOptionsImpl) mailOptions;
Review Comment:
Can we remove this cast?
I guess it won't be necessary after 1 or 2 resolved).
##########
flink-core/src/main/java/org/apache/flink/api/common/operators/MailOptionsImpl.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.api.common.operators;
+
+import org.apache.flink.annotation.Internal;
+
+/** Options to configure behaviour of executing mailbox mails. */
+@Internal
+public class MailOptionsImpl implements MailboxExecutor.MailOptions {
+ private boolean interruptible;
+
+ @Override
+ public MailboxExecutor.MailOptions setInterruptible() {
+ this.interruptible = true;
+ return this;
+ }
+
+ public boolean isInterruptible() {
Review Comment:
Why is this method defined in class and not in (super) interface?
##########
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:
If the class would be immutable then we could use constants here to avoid
objects creation/gc.
##########
flink-core/src/main/java/org/apache/flink/api/common/operators/MailOptionsImpl.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.api.common.operators;
+
+import org.apache.flink.annotation.Internal;
+
+/** Options to configure behaviour of executing mailbox mails. */
+@Internal
+public class MailOptionsImpl implements MailboxExecutor.MailOptions {
+ private boolean interruptible;
Review Comment:
I'd prefer this flag to be immutable, that would be a bit more clear IMO and
would allow to reuse the options.
--
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]