use of org.apache.inlong.manager.workflow.event.task.TaskEventListener in project incubator-inlong by apache.
the class EventListenerServiceImpl method executeTaskEventListener.
@Override
public void executeTaskEventListener(Integer taskId, String listener) {
WorkflowContext context = workflowContextBuilder.buildContextForTask(taskId, null);
TaskEventListener eventListener = getTaskEventListener((WorkflowTask) context.getCurrentElement(), listener);
context.getActionContext().setAction(WorkflowAction.fromTaskEvent(eventListener.event()));
workflowEventNotifier.getTaskEventNotifier().notify(listener, true, context);
}
use of org.apache.inlong.manager.workflow.event.task.TaskEventListener in project incubator-inlong by apache.
the class WorkflowServiceImplTest method testStopProcess.
@Test
public void testStopProcess() {
InlongGroupInfo groupInfo = initGroupForm(Constant.MIDDLEWARE_PULSAR);
groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
groupInfo.setStatus(GroupState.SUSPENDED.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
UpdateGroupProcessForm form = new UpdateGroupProcessForm();
form.setGroupInfo(groupInfo);
form.setOperateType(OperateType.DELETE);
taskListenerFactory.acceptPlugin(new MockPlugin());
WorkflowContext context = workflowEngine.processService().start(ProcessName.DELETE_GROUP_PROCESS.name(), applicant, form);
WorkflowResult result = WorkflowBeanUtils.result(context);
ProcessResponse view = result.getProcessInfo();
Assert.assertSame(view.getStatus(), ProcessStatus.COMPLETED);
WorkflowProcess process = context.getProcess();
WorkflowTask deleteSort = process.getTaskByName("deleteSort");
Assert.assertTrue(deleteSort instanceof ServiceTask);
List<TaskEventListener> listeners = Lists.newArrayList(deleteSort.getNameToListenerMap().values());
Assert.assertEquals(1, listeners.size());
Assert.assertTrue(listeners.get(0) instanceof MockDeleteSortListener);
WorkflowTask deleteSourceTask = process.getTaskByName("deleteSource");
Assert.assertTrue(deleteSourceTask instanceof ServiceTask);
listeners = Lists.newArrayList(deleteSourceTask.getNameToListenerMap().values());
Assert.assertEquals(2, listeners.size());
}
use of org.apache.inlong.manager.workflow.event.task.TaskEventListener in project incubator-inlong by apache.
the class WorkflowServiceImplTest method testStartCreateTubeWorkflow.
@Test
public void testStartCreateTubeWorkflow() {
initGroupForm(Constant.MIDDLEWARE_TUBE);
mockTaskListenerFactory();
WorkflowContext context = workflowEngine.processService().start(processName.name(), applicant, form);
WorkflowResult result = WorkflowBeanUtils.result(context);
ProcessResponse response = result.getProcessInfo();
Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
WorkflowProcess process = context.getProcess();
WorkflowTask task = process.getTaskByName("initMQ");
Assert.assertTrue(task instanceof ServiceTask);
Assert.assertEquals(2, task.getNameToListenerMap().size());
List<TaskEventListener> listeners = Lists.newArrayList(task.getNameToListenerMap().values());
Assert.assertTrue(listeners.get(0) instanceof CreateTubeTopicTaskListener);
Assert.assertTrue(listeners.get(1) instanceof CreateTubeGroupTaskListener);
}
use of org.apache.inlong.manager.workflow.event.task.TaskEventListener in project incubator-inlong by apache.
the class EventListenerServiceImpl method getTaskEventListener.
private TaskEventListener getTaskEventListener(WorkflowTask task, String listenerName) {
TaskEventListener listener = task.listener(listenerName);
if (listener != null) {
return listener;
}
listener = listenerManagerFactory.getTaskListenerManager().listener(listenerName);
Preconditions.checkNotNull(listener, "task listener not exist with name: " + listenerName);
return listener;
}
Aggregations