Search in sources :

Example 16 with WorkflowTask

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

the class TaskEventNotifier method notify.

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

Example 17 with WorkflowTask

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

the class WorkflowApproverServiceImpl method add.

@Override
public void add(WorkflowApprover approver, String operator) {
    Date now = new Date();
    approver.setCreateTime(now);
    approver.setModifyTime(now);
    approver.setModifier(operator);
    approver.setCreator(operator);
    WorkflowProcess process = workflowEngine.processDefinitionService().getByName(approver.getProcessName());
    Preconditions.checkNotNull(process, "process not exit with name: " + approver.getProcessName());
    WorkflowTask task = process.getTaskByName(approver.getTaskName());
    Preconditions.checkNotNull(task, "task not exit with name: " + approver.getTaskName());
    Preconditions.checkTrue(task instanceof UserTask, "task should be UserTask");
    List<WorkflowApproverEntity> exist = this.workflowApproverMapper.selectByQuery(WorkflowApproverQuery.builder().processName(approver.getProcessName()).taskName(approver.getTaskName()).filterKey(approver.getFilterKey().name()).filterValue(approver.getFilterValue()).build());
    Preconditions.checkEmpty(exist, "already exit the same config");
    WorkflowApproverEntity entity = CommonBeanUtils.copyProperties(approver, WorkflowApproverEntity::new);
    entity.setIsDeleted(EntityStatus.UN_DELETED.getCode());
    int success = this.workflowApproverMapper.insert(entity);
    Preconditions.checkTrue(success == 1, "add failed");
}
Also used : UserTask(org.apache.inlong.manager.workflow.definition.UserTask) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) WorkflowApproverEntity(org.apache.inlong.manager.dao.entity.WorkflowApproverEntity) Date(java.util.Date)

Example 18 with WorkflowTask

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

the class DataSourceListenerTest method testRestartSource.

@Test
public void testRestartSource() {
    // testFrozenSource();
    groupInfo = initGroupForm("PULSAR");
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.SUSPENDED.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.RESTART);
    WorkflowContext context = workflowEngine.processService().start(ProcessName.RESTART_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("restartSource");
    Assert.assertTrue(task instanceof ServiceTask);
    SourceResponse sourceResponse = streamSourceService.get(sourceId, SourceType.BINLOG.toString());
    Assert.assertSame(SourceState.forCode(sourceResponse.getStatus()), SourceState.TO_BE_ISSUED_ACTIVE);
}
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)

Aggregations

WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)18 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)13 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)13 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 Test (org.junit.Test)9 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)7 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)7 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)5 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)5 MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)4 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)4 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)3 WorkflowApproverEntity (org.apache.inlong.manager.dao.entity.WorkflowApproverEntity)3 WorkflowTaskEntity (org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)3 SourceResponse (org.apache.inlong.manager.common.pojo.source.SourceResponse)2 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)2 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)2 WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)2