Search in sources :

Example 11 with WorkflowContext

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

the class WorkflowContextBuilderImpl method buildContextForProcess.

@SneakyThrows
@Override
public WorkflowContext buildContextForProcess(String name, String applicant, ProcessForm form) {
    WorkflowProcess process = definitionRepository.get(name).clone();
    WorkflowContext context = new WorkflowContext();
    context.setProcess(process);
    context.setProcessForm(form);
    context.setApplicant(applicant);
    return context;
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) SneakyThrows(lombok.SneakyThrows)

Example 12 with WorkflowContext

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

the class DataSourceListenerTest method testFrozenSource.

@Test
public void testFrozenSource() {
    groupInfo = initGroupForm("PULSAR");
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    final int sourceId = createBinlogSource(groupInfo);
    streamSourceService.updateStatus(groupInfo.getInlongGroupId(), null, SourceState.SOURCE_NORMAL.getCode(), OPERATOR);
    form = new UpdateGroupProcessForm();
    form.setGroupInfo(groupInfo);
    form.setOperateType(OperateType.SUSPEND);
    WorkflowContext context = workflowEngine.processService().start(ProcessName.SUSPEND_GROUP_PROCESS.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("stopSource");
    Assert.assertTrue(task instanceof ServiceTask);
    SourceResponse sourceResponse = streamSourceService.get(sourceId, SourceType.BINLOG.toString());
    Assert.assertSame(SourceState.forCode(sourceResponse.getStatus()), SourceState.TO_BE_ISSUED_FROZEN);
}
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) SourceResponse(org.apache.inlong.manager.common.pojo.source.SourceResponse) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) 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) Test(org.junit.Test) WorkflowServiceImplTest(org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)

Example 13 with WorkflowContext

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

the class EventListenerServiceImpl method executeProcessEventListener.

@Override
public void executeProcessEventListener(Integer processId, String listener) {
    WorkflowContext context = workflowContextBuilder.buildContextForProcess(processId);
    ProcessEvent processEvent = getProcessEventListener(context.getProcess(), listener).event();
    context.setCurrentElement(getCurrentElement(context.getProcess(), processEvent));
    workflowEventNotifier.getProcessEventNotifier().notify(listener, true, context);
}
Also used : ProcessEvent(org.apache.inlong.manager.workflow.event.process.ProcessEvent) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext)

Example 14 with WorkflowContext

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

the class EventListenerServiceImpl method triggerProcessEvent.

@Override
public void triggerProcessEvent(Integer processId, ProcessEvent processEvent) {
    WorkflowContext context = workflowContextBuilder.buildContextForProcess(processId);
    context.setCurrentElement(getCurrentElement(context.getProcess(), processEvent));
    workflowEventNotifier.getProcessEventNotifier().notify(processEvent, context);
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext)

Example 15 with WorkflowContext

use of org.apache.inlong.manager.workflow.WorkflowContext 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);
}
Also used : TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext)

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