Search in sources :

Example 11 with WorkflowProcess

use of org.apache.inlong.manager.workflow.definition.WorkflowProcess 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 WorkflowProcess

use of org.apache.inlong.manager.workflow.definition.WorkflowProcess 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 WorkflowProcess

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

the class WorkflowQueryServiceImpl method getBriefFromProcessEntity.

private WorkflowBriefDTO getBriefFromProcessEntity(WorkflowProcessEntity processEntity) {
    WorkflowProcess process = definitionRepository.get(processEntity.getName());
    if (process == null) {
        return null;
    }
    Map<String, TaskStatus> nameStatusMap = this.getTaskNameStatusMap(processEntity);
    ElementDTO elementDTO = new ElementDTO();
    StartEvent startEvent = process.getStartEvent();
    elementDTO.setName(startEvent.getName());
    elementDTO.setDisplayName(startEvent.getDisplayName());
    WorkflowContext context = WorkflowBeanUtils.buildContext(process, processEntity);
    addNext(startEvent, elementDTO, context, nameStatusMap);
    WorkflowBriefDTO briefDTO = new WorkflowBriefDTO();
    briefDTO.setName(process.getName());
    briefDTO.setDisplayName(process.getDisplayName());
    briefDTO.setType(process.getType());
    briefDTO.setStartEvent(elementDTO);
    return briefDTO;
}
Also used : WorkflowBriefDTO(org.apache.inlong.manager.common.pojo.workflow.WorkflowBriefDTO) ElementDTO(org.apache.inlong.manager.common.pojo.workflow.ElementDTO) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) StartEvent(org.apache.inlong.manager.workflow.definition.StartEvent) TaskStatus(org.apache.inlong.manager.common.enums.TaskStatus) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 14 with WorkflowProcess

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

the class ProcessEventNotifier method notify.

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

Example 15 with WorkflowProcess

use of org.apache.inlong.manager.workflow.definition.WorkflowProcess 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)

Aggregations

WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)29 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)15 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)14 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)13 Test (org.junit.Test)10 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)9 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)9 StartEvent (org.apache.inlong.manager.workflow.definition.StartEvent)8 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)7 EndEvent (org.apache.inlong.manager.workflow.definition.EndEvent)7 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)7 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)6 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)5 SneakyThrows (lombok.SneakyThrows)4 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)4 WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)4 MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)4 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)4 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)3 WorkflowApproverEntity (org.apache.inlong.manager.dao.entity.WorkflowApproverEntity)3