You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "hawk9821 (via GitHub)" <gi...@apache.org> on 2025/08/11 05:59:07 UTC
[PR] [Future][Engine] extended jobStateEvent event listening for zeta [seatunnel]
hawk9821 opened a new pull request, #9689:
URL: https://github.com/apache/seatunnel/pull/9689
<!--
Thank you for contributing to SeaTunnel! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
## Contribution Checklist
- Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
- Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
- Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
-->
### Purpose of this pull request
<!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released SeaTunnel versions or within the unreleased branches such as dev.
If no, write 'No'.
If you are adding/modifying connector documents, please follow our new specifications: https://github.com/apache/seatunnel/issues/4544.
-->
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If you are adding E2E test cases, maybe refer to https://github.com/apache/seatunnel/blob/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/resources/mysqlcdc_to_mysql.conf, here is a good example.
-->
### Check list
* [ ] If any new Jar binary package adding in your PR, please add License Notice according
[New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
* [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
* [ ] If you are contributing the connector code, please check that the following files are updated:
1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Zeta] extended jobStateEvent event listening for zeta [seatunnel]
Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #9689:
URL: https://github.com/apache/seatunnel/pull/9689#discussion_r2268727123
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/event/JobStateEvent.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.server.event;
+
+import org.apache.seatunnel.api.event.Event;
+import org.apache.seatunnel.api.event.EventType;
+import org.apache.seatunnel.engine.core.job.JobStatus;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@Getter
+@Setter
+@ToString
+public class JobStateEvent implements Event {
+
+ private String jobName;
+ private String jobId;
+ private JobStatus jobStatus;
+ private long createdTime;
+
+ public JobStateEvent(String fullJobName, JobStatus jobStatus) {
+ Pattern compile = Pattern.compile("Job\\s+(\\S+)\\s+\\(([^)]+)\\)");
+ Matcher matcher = compile.matcher(fullJobName);
+ if (!matcher.find()) {
+ throw new IllegalArgumentException("Invalid job name format: " + fullJobName);
+ }
+ this.jobName = matcher.group(1);
+ this.jobId = matcher.group(2);
Review Comment:
fixed
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Zeta] extended jobStateEvent event listening for zeta [seatunnel]
Posted by "corgy-w (via GitHub)" <gi...@apache.org>.
corgy-w merged PR #9689:
URL: https://github.com/apache/seatunnel/pull/9689
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Zeta] extended jobStateEvent event listening for zeta [seatunnel]
Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #9689:
URL: https://github.com/apache/seatunnel/pull/9689#discussion_r2275522998
##########
docs/zh/concept/event-listener.md:
##########
@@ -112,3 +112,125 @@ seatunnel:
### Spark 引擎
您可以定义 `org.apache.seatunnel.api.event.EventHandler` 接口并添加到类路径,SPI会自动加载。
+
+## JobStateEvent 事件监听
Review Comment:
get it
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Zeta] extended jobStateEvent event listening for zeta [seatunnel]
Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #9689:
URL: https://github.com/apache/seatunnel/pull/9689#discussion_r2272513773
##########
docs/zh/concept/event-listener.md:
##########
@@ -112,3 +112,125 @@ seatunnel:
### Spark 引擎
您可以定义 `org.apache.seatunnel.api.event.EventHandler` 接口并添加到类路径,SPI会自动加载。
+
+## JobStateEvent 事件监听
Review Comment:
[Supported statuses include](https://github.com/apache/seatunnel/pull/9689/files#diff-c92ed5de22fd67ae0248351d0514f517b894501ef475c494ea72071849748e1c#L125)
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Zeta] extended jobStateEvent event listening for zeta [seatunnel]
Posted by "hawk9821 (via GitHub)" <gi...@apache.org>.
hawk9821 commented on code in PR #9689:
URL: https://github.com/apache/seatunnel/pull/9689#discussion_r2268727467
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalPlan.java:
##########
@@ -87,6 +89,8 @@ public class PhysicalPlan {
private volatile boolean isRunning = false;
+ private final JobStateEventListner jobStateEventListner;
Review Comment:
fixed
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Zeta] extended jobStateEvent event listening for zeta [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9689:
URL: https://github.com/apache/seatunnel/pull/9689#discussion_r2275173039
##########
docs/zh/concept/event-listener.md:
##########
@@ -112,3 +112,125 @@ seatunnel:
### Spark 引擎
您可以定义 `org.apache.seatunnel.api.event.EventHandler` 接口并添加到类路径,SPI会自动加载。
+
+## JobStateEvent 事件监听
Review Comment:
I mean introduce all event type https://github.com/apache/seatunnel/pull/9689/files#diff-1cdbd73ceed07d97ac2d15569a8f2626bf6e27c5072b9b78b61f8cfdb1637e4e
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Future][Engine] extended jobStateEvent event listening for zeta [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9689:
URL: https://github.com/apache/seatunnel/pull/9689#discussion_r2266592855
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/event/JobStateEvent.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.server.event;
+
+import org.apache.seatunnel.api.event.Event;
+import org.apache.seatunnel.api.event.EventType;
+import org.apache.seatunnel.engine.core.job.JobStatus;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+@Getter
+@Setter
+@ToString
+public class JobStateEvent implements Event {
+
+ private String jobName;
+ private String jobId;
+ private JobStatus jobStatus;
+ private long createdTime;
+
+ public JobStateEvent(String fullJobName, JobStatus jobStatus) {
+ Pattern compile = Pattern.compile("Job\\s+(\\S+)\\s+\\(([^)]+)\\)");
+ Matcher matcher = compile.matcher(fullJobName);
+ if (!matcher.find()) {
+ throw new IllegalArgumentException("Invalid job name format: " + fullJobName);
+ }
+ this.jobName = matcher.group(1);
+ this.jobId = matcher.group(2);
Review Comment:
It's weird and fragile to parse job id and name from string.
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalPlan.java:
##########
@@ -87,6 +89,8 @@ public class PhysicalPlan {
private volatile boolean isRunning = false;
+ private final JobStateEventListner jobStateEventListner;
Review Comment:
we should reuse https://github.com/apache/seatunnel/blob/085023ad0db1a8729ce724a14855c0077f051dfe/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CoordinatorService.java#L187
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Zeta] extended jobStateEvent event listening for zeta [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9689:
URL: https://github.com/apache/seatunnel/pull/9689#discussion_r2269588902
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/event/JobStateEvent.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.server.event;
+
+import org.apache.seatunnel.api.event.Event;
+import org.apache.seatunnel.api.event.EventType;
+import org.apache.seatunnel.engine.core.job.JobStatus;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class JobStateEvent implements Event {
+
+ private String jobId;
+ private String jobName;
+ private JobStatus jobStatus;
+ private long createdTime;
+
+ public JobStateEvent(Long jobId, String jobName, JobStatus jobStatus) {
+ this.jobName = jobName;
+ this.jobId = String.valueOf(jobId);
+ this.jobStatus = jobStatus;
+ this.createdTime = System.currentTimeMillis();
+ }
+
+ @Override
+ public EventType getEventType() {
+ return null;
Review Comment:
why null?
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalPlan.java:
##########
@@ -347,6 +348,14 @@ private synchronized void stateProcess() {
case SAVEPOINT_DONE:
case FINISHED:
stopJobStateProcess();
+ jobMaster
+ .getCoordinatorService()
+ .getEventProcessor()
+ .process(
+ new JobStateEvent(
+ jobImmutableInformation.getJobId(),
+ jobImmutableInformation.getJobConfig().getName(),
+ getJobStatus()));
Review Comment:
Let's store `getJobStatus` result to reduce cpu cost of get status from map.
##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/event/JobStateEventTest.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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.server.event;
+
+import org.apache.seatunnel.api.event.EventHandler;
+import org.apache.seatunnel.common.utils.ReflectionUtils;
+import org.apache.seatunnel.engine.core.job.JobStatus;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.awaitility.Awaitility.await;
+
+public class JobStateEventTest extends AbstractSeaTunnelServerTest {
+
+ @Test
+ public void testJobStateEvent() {
+
+ JobEventProcessor eventProcessor =
+ (JobEventProcessor) server.getCoordinatorService().getEventProcessor();
+
+ AtomicInteger accessCounter = new AtomicInteger(0);
+ EventHandler eventHandler =
+ event -> {
+ if (event instanceof JobStateEvent) {
+ accessCounter.incrementAndGet();
Review Comment:
we should check JobStateEvent values too.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Zeta] extended jobStateEvent event listening for zeta [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #9689:
URL: https://github.com/apache/seatunnel/pull/9689#discussion_r2271936893
##########
docs/zh/concept/event-listener.md:
##########
@@ -112,3 +112,125 @@ seatunnel:
### Spark 引擎
您可以定义 `org.apache.seatunnel.api.event.EventHandler` 接口并添加到类路径,SPI会自动加载。
+
+## JobStateEvent 事件监听
Review Comment:
Could you help to list all event we already supported?
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/dag/physical/PhysicalPlan.java:
##########
@@ -347,10 +349,18 @@ private synchronized void stateProcess() {
case SAVEPOINT_DONE:
case FINISHED:
stopJobStateProcess();
- jobEndFuture.complete(new JobResult(getJobStatus(), errorBySubPlan.get()));
+ jobMaster
+ .getCoordinatorService()
+ .getEventProcessor()
+ .process(
+ new JobStateEvent(
+ jobImmutableInformation.getJobId(),
+ jobImmutableInformation.getJobConfig().getName(),
+ jobStatus));
+ jobEndFuture.complete(new JobResult(jobStatus, errorBySubPlan.get()));
Review Comment:
Let's `complete` first, then process event. Avoid job status delays caused by user-implemented process code.
##########
seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/event/JobStateEvent.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.server.event;
+
+import org.apache.seatunnel.api.event.Event;
+import org.apache.seatunnel.api.event.EventType;
+import org.apache.seatunnel.engine.core.job.JobStatus;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class JobStateEvent implements Event {
Review Comment:
move to `seatunnel-engine-common`?
##########
seatunnel-engine/seatunnel-engine-server/src/test/java/org/apache/seatunnel/engine/server/event/JobStateEventTest.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.server.event;
+
+import org.apache.seatunnel.api.event.EventHandler;
+import org.apache.seatunnel.api.event.EventType;
+import org.apache.seatunnel.common.utils.ReflectionUtils;
+import org.apache.seatunnel.engine.core.job.JobStatus;
+import org.apache.seatunnel.engine.server.AbstractSeaTunnelServerTest;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.apache.seatunnel.engine.server.checkpoint.CheckpointErrorRestoreEndTest.STREAM_CONF_WITH_ERROR_PATH;
+import static org.awaitility.Awaitility.await;
+
+public class JobStateEventTest extends AbstractSeaTunnelServerTest {
+
+ @Test
+ public void testJobStateEvent() {
+
+ JobEventProcessor eventProcessor =
+ (JobEventProcessor) server.getCoordinatorService().getEventProcessor();
+
+ AtomicInteger accessCounter = new AtomicInteger(0);
+ EventHandler eventHandler =
+ event -> {
+ if (event.getEventType() != EventType.JOB_STATUS) {
+ return;
+ }
+ JobStatus status = ((JobStateEvent) event).getJobStatus();
Review Comment:
check jobid, job name and createtime?
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org