Search in sources :

Example 21 with WorkflowContext

use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.

the class ProcessEventNotifier method notify.

@Override
public void notify(ProcessEvent event, WorkflowContext sourceContext) {
    final WorkflowContext context = sourceContext.clone();
    WorkflowProcess process = context.getProcess();
    eventListenerManager.syncListeners(event).forEach(syncLogableNotify(context));
    process.syncListeners(event).forEach(syncLogableNotify(context));
    eventListenerManager.asyncListeners(event).forEach(asyncLogableNotify(context));
    process.asyncListeners(event).forEach(asyncLogableNotify(context));
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 22 with WorkflowContext

use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.

the class TaskEventNotifier method notify.

@Override
public void notify(String listenerName, boolean forceSync, WorkflowContext sourceContext) {
    final WorkflowContext context = sourceContext.clone();
    Optional.ofNullable(this.eventListenerManager.listener(listenerName)).ifPresent(logableNotify(forceSync, context));
    WorkflowTask task = (WorkflowTask) context.getCurrentElement();
    Optional.ofNullable(task.listener(listenerName)).ifPresent(logableNotify(forceSync, context));
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask)

Example 23 with WorkflowContext

use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.

the class CreateHiveTableEventSelectorTest method testAccept.

@Test
public void testAccept() {
    WorkflowContext workflowContext = new WorkflowContext();
    GroupResourceProcessForm processForm = new GroupResourceProcessForm();
    workflowContext.setProcessForm(processForm);
    Assert.assertFalse(createHiveTableEventSelector.accept(workflowContext));
    processForm.setGroupInfo(new InlongGroupInfo());
    Assert.assertFalse(createHiveTableEventSelector.accept(workflowContext));
    processForm.getGroupInfo().setInlongGroupId("test");
    Assert.assertTrue(createHiveTableEventSelector.accept(workflowContext));
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest) Test(org.junit.Test)

Example 24 with WorkflowContext

use of org.apache.inlong.manager.workflow.WorkflowContext 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());
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) MockDeleteSortListener(org.apache.inlong.manager.service.mocks.MockDeleteSortListener) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 25 with WorkflowContext

use of org.apache.inlong.manager.workflow.WorkflowContext 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);
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) CreateTubeTopicTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreateTubeTopicTaskListener) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) CreateTubeGroupTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreateTubeGroupTaskListener) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Aggregations

WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)37 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)15 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)13 Test (org.junit.Test)11 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)9 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)9 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)9 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)8 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)8 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)8 WorkflowTaskEntity (org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)7 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)7 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)6 List (java.util.List)4 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)4 MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)4 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)4 Collectors (java.util.stream.Collectors)3 SneakyThrows (lombok.SneakyThrows)3 WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)3