|
27 | 27 | import org.apache.dolphinscheduler.server.master.engine.executor.LogicTaskExecutorLifecycleEventReporter; |
28 | 28 | import org.apache.dolphinscheduler.server.master.engine.executor.LogicTaskExecutorRepository; |
29 | 29 | import org.apache.dolphinscheduler.server.master.engine.system.SystemEventBus; |
30 | | -import org.apache.dolphinscheduler.task.executor.container.AbstractTaskExecutorContainer; |
| 30 | +import org.apache.dolphinscheduler.server.master.engine.task.dispatcher.WorkerGroupDispatcherCoordinator; |
| 31 | +import org.apache.dolphinscheduler.task.executor.container.SharedThreadTaskExecutorContainer; |
31 | 32 | import org.apache.dolphinscheduler.task.executor.container.TaskExecutorAssignmentTable; |
32 | | -import org.apache.dolphinscheduler.task.executor.worker.TaskExecutorWorkers; |
33 | 33 |
|
34 | 34 | import java.util.concurrent.TimeUnit; |
35 | 35 |
|
@@ -57,31 +57,59 @@ public class MasterContainer { |
57 | 57 | @Autowired |
58 | 58 | private LogicTaskExecutorLifecycleEventReporter logicTaskExecutorLifecycleEventReporter; |
59 | 59 |
|
| 60 | + @Autowired |
| 61 | + private WorkerGroupDispatcherCoordinator workerGroupDispatcherCoordinator; |
| 62 | + |
60 | 63 | public void assertAllResourceReleased() { |
61 | 64 | await() |
62 | 65 | .atMost(10, TimeUnit.SECONDS) |
63 | 66 | .untilAsserted(this::doAssertAllResourceReleased); |
64 | 67 | } |
65 | 68 |
|
66 | 69 | private void doAssertAllResourceReleased() { |
| 70 | + assertWorkflowReleased(); |
| 71 | + assertWorkflowEventBusReleased(); |
| 72 | + |
| 73 | + assertSystemEventBusReleased(); |
| 74 | + |
| 75 | + assertLogicTaskEngineReleased(); |
| 76 | + |
| 77 | + assertWorkerGroupDispatcherReleased(); |
| 78 | + } |
| 79 | + |
| 80 | + private void assertWorkflowReleased() { |
67 | 81 | assertThat(workflowRepository.getAll()).isEmpty(); |
| 82 | + assertThat(workflowEventBusFireWorkers.getWorkers()) |
| 83 | + .allMatch(worker -> worker.getRegisteredWorkflowExecuteRunnableSize() == 0); |
| 84 | + } |
68 | 85 |
|
| 86 | + private void assertWorkflowEventBusReleased() { |
69 | 87 | assertThat(workflowEventBusFireWorkers.getWorkers()) |
70 | | - .allMatch(workflowEventBusFireWorker -> workflowEventBusFireWorker |
71 | | - .getRegisteredWorkflowExecuteRunnableSize() == 0); |
| 88 | + .allMatch(worker -> worker.getRegisteredWorkflowExecuteRunnableSize() == 0); |
| 89 | + } |
| 90 | + |
| 91 | + private void assertSystemEventBusReleased() { |
72 | 92 | assertThat(systemEventBus).matches(AbstractDelayEventBus::isEmpty); |
| 93 | + } |
73 | 94 |
|
| 95 | + private void assertLogicTaskEngineReleased() { |
74 | 96 | assertThat(logicTaskExecutorRepository.getAll()).isEmpty(); |
75 | 97 |
|
76 | | - final AbstractTaskExecutorContainer executorContainer = |
77 | | - (AbstractTaskExecutorContainer) logicTaskExecutorContainerProvider.getExecutorContainer(); |
| 98 | + final SharedThreadTaskExecutorContainer executorContainer = |
| 99 | + logicTaskExecutorContainerProvider.getExecutorContainer(); |
78 | 100 | assertThat(executorContainer.getTaskExecutorAssignmentTable()).matches(TaskExecutorAssignmentTable::isEmpty); |
79 | 101 |
|
80 | | - final TaskExecutorWorkers taskExecutorWorkers = executorContainer.getTaskExecutorWorkers(); |
81 | | - assertThat(taskExecutorWorkers.getWorkers()) |
| 102 | + assertThat(executorContainer.getTaskExecutorWorkers().getWorkers()) |
82 | 103 | .allMatch(taskExecutorWorker -> taskExecutorWorker.getRegisteredTaskExecutorSize() == 0) |
83 | 104 | .allMatch(taskExecutorWorker -> taskExecutorWorker.getFiredTaskExecutorSize() == 0); |
84 | 105 |
|
85 | 106 | assertThat(logicTaskExecutorLifecycleEventReporter.getEventChannels()).isEmpty(); |
86 | 107 | } |
| 108 | + |
| 109 | + private void assertWorkerGroupDispatcherReleased() { |
| 110 | + assertThat(workerGroupDispatcherCoordinator.workerGroupDispatchers().values()) |
| 111 | + .allMatch(dispatcher -> dispatcher.dispatchEventCount() == 0) |
| 112 | + .allMatch(dispatcher -> dispatcher.waitingDispatchTaskCount() == 0); |
| 113 | + } |
| 114 | + |
87 | 115 | } |
0 commit comments