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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
