goutamadwant commented on code in PR #13715:
URL: https://github.com/apache/seatunnel/pull/13715#discussion_r4758024317
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/task/flow/SourceFlowLifeCycle.java:
##########
@@ -209,9 +246,12 @@ public void cancel() {
* <p>Acquires the {@code checkpointLock} (the same monitor that {@link
#triggerBarrier} uses)
* so that flush signals and barriers are strictly serialized — a
FlushSignal either completes
* entirely before a Barrier or queues behind it, never crossing it.
+ *
+ * <p>Admits a tick at its observed time. An admitted tick can finish
after the window ends,
+ * provided the source is still open when it obtains the checkpoint lock.
*/
private void onTimerTick() {
- if (prepareClose) {
+ if (prepareClose || (flushWindow != null &&
!flushWindow.includes(flushClock.instant()))) {
Review Comment:
I added `FlushWindowSkippedTicksTotal` on the source. It increments before
checkpoint-lock handoff when a tick falls outside the window.
`FlushSignalTotal` still counts transmitted signals.
##########
seatunnel-engine/seatunnel-engine-common/src/main/java/org/apache/seatunnel/engine/common/config/TimerFlushWindow.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.seatunnel.engine.common.config;
+
+import org.apache.seatunnel.api.options.EnvCommonOptions;
+
+import java.time.Instant;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.time.format.ResolverStyle;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/** Recurring job-local time window for the Zeta source's flush timer. */
+public final class TimerFlushWindow {
+
+ private static final String KEY = EnvCommonOptions.SINK_FLUSH_WINDOW.key();
+ private static final String START_KEY =
EnvCommonOptions.SINK_FLUSH_WINDOW_START.key();
+ private static final String END_KEY =
EnvCommonOptions.SINK_FLUSH_WINDOW_END.key();
+ private static final String ZONE_KEY =
EnvCommonOptions.SINK_FLUSH_WINDOW_TIMEZONE.key();
+ private static final Object UNSET = new Object();
+ private static final DateTimeFormatter TIME_FORMAT =
+ DateTimeFormatter.ofPattern("HH:mm", Locale.ROOT)
+ .withResolverStyle(ResolverStyle.STRICT);
+ private static final Set<String> ZONE_IDS = ZoneId.getAvailableZoneIds();
+
+ private final LocalTime start;
+ private final LocalTime end;
+ private final ZoneId zone;
+
+ private TimerFlushWindow(LocalTime start, LocalTime end, ZoneId zone) {
+ this.start = start;
+ this.end = end;
+ this.zone = zone;
+ }
+
+ /** Returns null when the job has no window, or rejects a malformed
explicit setting. */
+ public static TimerFlushWindow fromEnv(Map<String, Object> env) {
+ if (env == null) {
+ return null;
+ }
+ Object window = valueAt(env, KEY);
+ if (window != UNSET && !(window instanceof Map)) {
+ throw new IllegalArgumentException(KEY + " must be an object");
+ }
+ Object startValue = valueAt(env, START_KEY);
+ Object endValue = valueAt(env, END_KEY);
+ Object zoneValue = valueAt(env, ZONE_KEY);
+ if (window == UNSET && startValue == UNSET && endValue == UNSET &&
zoneValue == UNSET) {
+ return null;
+ }
+ LocalTime start = parseTime(startValue, START_KEY);
+ LocalTime end = parseTime(endValue, END_KEY);
+ if (start.equals(end)) {
+ throw new IllegalArgumentException(KEY + " start and end must be
different");
+ }
+ if (!(zoneValue instanceof String) || !ZONE_IDS.contains(zoneValue)) {
+ throw new IllegalArgumentException(ZONE_KEY + " must be a valid
IANA zone ID");
+ }
Review Comment:
I kept the timezone explicit for now. Workers with different JVM defaults
could otherwise run the same job on different schedules. Could we keep the IANA
timezone required for this PR, as discussed in #13366?
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CoordinatorService.java:
##########
@@ -1441,6 +1442,18 @@ public PassiveCompletableFuture<Void> submitJob(
try {
JobImmutableInformation
submittedJobImmutableInformation =
deserializeJobImmutableInformation(jobImmutableInformation);
+ try {
Review Comment:
I extracted this into `validateSubmittedTimerOptions()`. Invalid submissions
return before the coordinator takes ownership of job state or performs cleanup.
##########
seatunnel-engine/seatunnel-engine-common/src/main/java/org/apache/seatunnel/engine/common/config/TimerFlushWindow.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.seatunnel.engine.common.config;
+
+import org.apache.seatunnel.api.options.EnvCommonOptions;
+
+import java.time.Instant;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.time.format.ResolverStyle;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/** Recurring job-local time window for the Zeta source's flush timer. */
+public final class TimerFlushWindow {
+
+ private static final String KEY = EnvCommonOptions.SINK_FLUSH_WINDOW.key();
+ private static final String START_KEY =
EnvCommonOptions.SINK_FLUSH_WINDOW_START.key();
+ private static final String END_KEY =
EnvCommonOptions.SINK_FLUSH_WINDOW_END.key();
+ private static final String ZONE_KEY =
EnvCommonOptions.SINK_FLUSH_WINDOW_TIMEZONE.key();
+ private static final Object UNSET = new Object();
+ private static final DateTimeFormatter TIME_FORMAT =
+ DateTimeFormatter.ofPattern("HH:mm", Locale.ROOT)
+ .withResolverStyle(ResolverStyle.STRICT);
+ private static final Set<String> ZONE_IDS = ZoneId.getAvailableZoneIds();
+
+ private final LocalTime start;
+ private final LocalTime end;
+ private final ZoneId zone;
+
+ private TimerFlushWindow(LocalTime start, LocalTime end, ZoneId zone) {
+ this.start = start;
+ this.end = end;
+ this.zone = zone;
+ }
+
+ /** Returns null when the job has no window, or rejects a malformed
explicit setting. */
+ public static TimerFlushWindow fromEnv(Map<String, Object> env) {
+ if (env == null) {
Review Comment:
`job.mode` remains required by the existing environment rule. The
coordinator uses the timer rule for serialized submissions.
--
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]