Skip to content

Commit d7bf4fa

Browse files
苏义超ruanwenjun
authored andcommitted
add TaskFatalLifecycleEvent and handler
1 parent 39b40c1 commit d7bf4fa

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event;
19+
20+
import org.apache.dolphinscheduler.server.master.engine.ILifecycleEventType;
21+
import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.AbstractTaskLifecycleEvent;
22+
import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.TaskLifecycleEventType;
23+
import org.apache.dolphinscheduler.server.master.engine.task.runnable.ITaskExecutionRunnable;
24+
25+
import java.util.Date;
26+
27+
import lombok.AllArgsConstructor;
28+
import lombok.Builder;
29+
import lombok.Data;
30+
31+
@Data
32+
@Builder
33+
@AllArgsConstructor
34+
public class TaskFatalLifecycleEvent extends AbstractTaskLifecycleEvent {
35+
36+
private final ITaskExecutionRunnable taskExecutionRunnable;
37+
38+
private final Date endTime;
39+
40+
@Override
41+
public ILifecycleEventType getEventType() {
42+
return TaskLifecycleEventType.FATAL;
43+
}
44+
45+
@Override
46+
public String toString() {
47+
return "TaskFatalLifecycleEvent{" +
48+
"task=" + taskExecutionRunnable.getName() +
49+
", endTime=" + endTime +
50+
'}';
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.dolphinscheduler.server.master.engine.task.lifecycle.handler;
19+
20+
import org.apache.dolphinscheduler.server.master.engine.ILifecycleEventType;
21+
import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.TaskLifecycleEventType;
22+
import org.apache.dolphinscheduler.server.master.engine.task.lifecycle.event.TaskFatalLifecycleEvent;
23+
import org.apache.dolphinscheduler.server.master.engine.task.runnable.ITaskExecutionRunnable;
24+
import org.apache.dolphinscheduler.server.master.engine.task.statemachine.ITaskStateAction;
25+
import org.apache.dolphinscheduler.server.master.engine.workflow.runnable.IWorkflowExecutionRunnable;
26+
27+
import org.springframework.stereotype.Component;
28+
29+
@Component
30+
public class TaskFatalLifecycleEventHandler extends AbstractTaskLifecycleEventHandler<TaskFatalLifecycleEvent> {
31+
32+
@Override
33+
public void handle(final ITaskStateAction taskStateAction,
34+
final IWorkflowExecutionRunnable workflowExecutionRunnable,
35+
final ITaskExecutionRunnable taskExecutionRunnable,
36+
final TaskFatalLifecycleEvent taskFatalEvent) {
37+
taskStateAction.onFatalEvent(workflowExecutionRunnable, taskExecutionRunnable, taskFatalEvent);
38+
}
39+
40+
@Override
41+
public ILifecycleEventType matchEventType() {
42+
return TaskLifecycleEventType.FATAL;
43+
}
44+
}

0 commit comments

Comments
 (0)