Search in sources :

Example 6 with ProcessResponse

use of org.apache.inlong.manager.common.pojo.workflow.ProcessResponse in project incubator-inlong by apache.

the class WorkflowServiceImplTest method testSuspendProcess.

@Test
public void testSuspendProcess() {
    InlongGroupInfo groupInfo = initGroupForm(Constant.MIDDLEWARE_PULSAR);
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    UpdateGroupProcessForm form = new UpdateGroupProcessForm();
    form.setGroupInfo(groupInfo);
    form.setOperateType(OperateType.SUSPEND);
    taskListenerFactory.acceptPlugin(new MockPlugin());
    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 stopSortTask = process.getTaskByName("stopSort");
    Assert.assertTrue(stopSortTask instanceof ServiceTask);
    List<TaskEventListener> listeners = Lists.newArrayList(stopSortTask.getNameToListenerMap().values());
    Assert.assertTrue(listeners.get(0) instanceof MockStopSortListener);
    WorkflowTask stopSourceTask = process.getTaskByName("stopSource");
    Assert.assertTrue(stopSourceTask instanceof ServiceTask);
    listeners = Lists.newArrayList(stopSourceTask.getNameToListenerMap().values());
}
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) MockStopSortListener(org.apache.inlong.manager.service.mocks.MockStopSortListener) 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) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 7 with ProcessResponse

use of org.apache.inlong.manager.common.pojo.workflow.ProcessResponse in project incubator-inlong by apache.

the class WorkflowServiceImplTest method testStartCreatePulsarWorkflow.

@Test
public void testStartCreatePulsarWorkflow() {
    initGroupForm(Constant.MIDDLEWARE_PULSAR);
    mockTaskListenerFactory();
    WorkflowContext context = workflowEngine.processService().start(processName.name(), applicant, form);
    WorkflowResult result = WorkflowBeanUtils.result(context);
    ProcessResponse view = result.getProcessInfo();
    Assert.assertSame(view.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 CreatePulsarGroupTaskListener);
    Assert.assertTrue(listeners.get(1) instanceof CreatePulsarResourceTaskListener);
}
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) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) CreatePulsarGroupTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreatePulsarGroupTaskListener) 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) CreatePulsarResourceTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreatePulsarResourceTaskListener) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 8 with ProcessResponse

use of org.apache.inlong.manager.common.pojo.workflow.ProcessResponse 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 9 with ProcessResponse

use of org.apache.inlong.manager.common.pojo.workflow.ProcessResponse in project incubator-inlong by apache.

the class WorkflowServiceImpl method listProcess.

@Override
public PageInfo<ProcessResponse> listProcess(ProcessQuery query) {
    PageHelper.startPage(query.getPageNum(), query.getPageSize());
    Page<WorkflowProcessEntity> result = (Page<WorkflowProcessEntity>) queryService.listProcessEntity(query);
    PageInfo<ProcessResponse> pageInfo = result.toPageInfo(entity -> {
        ProcessResponse response = WorkflowBeanUtils.fromProcessEntity(entity);
        if (query.getIncludeShowInList()) {
            response.setShowInList(getShowInList(entity));
        }
        return response;
    });
    pageInfo.setTotal(result.getTotal());
    if (query.getIncludeCurrentTask()) {
        TaskQuery taskQuery = TaskQuery.builder().type(UserTask.class.getSimpleName()).statusSet(Collections.singleton(TaskStatus.PENDING)).build();
        PageHelper.startPage(0, 100);
        pageInfo.getList().forEach(this.addCurrentTask(taskQuery));
    }
    return pageInfo;
}
Also used : TaskQuery(org.apache.inlong.manager.common.pojo.workflow.TaskQuery) UserTask(org.apache.inlong.manager.workflow.definition.UserTask) Page(com.github.pagehelper.Page) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)

Example 10 with ProcessResponse

use of org.apache.inlong.manager.common.pojo.workflow.ProcessResponse 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)

Aggregations

ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)14 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)13 Test (org.junit.Test)12 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)9 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)9 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)9 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)9 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)9 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)8 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)7 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)7 MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)4 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)4 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 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)2 Page (com.github.pagehelper.Page)1 List (java.util.List)1 InlongGroupApproveRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest)1