Search in sources :

Example 1 with ProcessResponse

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

the class InlongGroupProcessOperationTest method testRestartProcess.

@Test
public void testRestartProcess() {
    testSuspendProcess();
    WorkflowResult result = groupProcessOperation.restartProcess(GROUP_ID, OPERATOR);
    ProcessResponse response = result.getProcessInfo();
    Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
    InlongGroupInfo groupInfo = groupService.get(GROUP_ID);
    Assert.assertEquals(groupInfo.getStatus(), EntityStatus.GROUP_RESTART.getCode());
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 2 with ProcessResponse

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

the class InlongGroupImpl method init.

@Override
public InlongGroupContext init() throws Exception {
    InlongGroupInfo groupInfo = this.groupContext.getGroupInfo();
    WorkflowResult initWorkflowResult = managerClient.initInlongGroup(groupInfo.genRequest());
    List<TaskResponse> taskViews = initWorkflowResult.getNewTasks();
    AssertUtil.notEmpty(taskViews, "Init business info failed");
    TaskResponse taskView = taskViews.get(0);
    final int taskId = taskView.getId();
    ProcessResponse processView = initWorkflowResult.getProcessInfo();
    AssertUtil.isTrue(ProcessStatus.PROCESSING == processView.getStatus(), String.format("Business info state : %s is not corrected , should be PROCESSING", processView.getStatus()));
    String formData = GsonUtil.toJson(processView.getFormData());
    Pair<InlongGroupApproveRequest, List<InlongStreamApproveRequest>> initMsg = InlongParser.parseGroupForm(formData);
    groupContext.setInitMsg(initMsg);
    WorkflowResult startWorkflowResult = managerClient.startInlongGroup(taskId, initMsg);
    processView = startWorkflowResult.getProcessInfo();
    AssertUtil.isTrue(ProcessStatus.COMPLETED == processView.getStatus(), String.format("Business info state : %s is not corrected , should be COMPLETED", processView.getStatus()));
    return generateSnapshot();
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) List(java.util.List) TaskResponse(org.apache.inlong.manager.common.pojo.workflow.TaskResponse) InlongGroupApproveRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)

Example 3 with ProcessResponse

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

the class DisableZkForSortTest method testCreateSortConfigInCreateWorkflow.

@Test
public void testCreateSortConfigInCreateWorkflow() {
    InlongGroupInfo groupInfo = initGroupForm("PULSAR");
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupInfo.setZookeeperEnabled(0);
    groupService.update(groupInfo.genRequest(), OPERATOR);
    InlongStreamInfo streamInfo = createStreamInfo(groupInfo);
    createHiveSink(streamInfo);
    createKafkaSource(streamInfo);
    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("initSort");
    Assert.assertTrue(task instanceof ServiceTask);
    Assert.assertEquals(1, task.getNameToListenerMap().size());
    List<TaskEventListener> listeners = Lists.newArrayList(task.getNameToListenerMap().values());
    Assert.assertTrue(listeners.get(0) instanceof CreateSortConfigListener);
    ProcessForm form = context.getProcessForm();
    InlongGroupInfo curGroupRequest = ((GroupResourceProcessForm) form).getGroupInfo();
    Assert.assertTrue(curGroupRequest.getExtList().size() == 1);
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo) WorkflowServiceImplTest(org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest) Test(org.junit.Test)

Example 4 with ProcessResponse

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

the class DisableZkForSortTest method testCreateSortConfigInUpdateWorkflow.

@Test
public void testCreateSortConfigInUpdateWorkflow() {
    InlongGroupInfo groupInfo = initGroupForm("PULSAR");
    groupInfo.setZookeeperEnabled(0);
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    InlongStreamInfo streamInfo = createStreamInfo(groupInfo);
    createHiveSink(streamInfo);
    createKafkaSource(streamInfo);
    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 task = process.getTaskByName("stopSort");
    Assert.assertTrue(task instanceof ServiceTask);
    Assert.assertEquals(2, task.getNameToListenerMap().size());
    List<TaskEventListener> listeners = Lists.newArrayList(task.getNameToListenerMap().values());
    Assert.assertTrue(listeners.get(1) instanceof CreateSortConfigListener);
    ProcessForm currentProcessForm = context.getProcessForm();
    InlongGroupInfo curGroupRequest = ((UpdateGroupProcessForm) currentProcessForm).getGroupInfo();
    Assert.assertTrue(curGroupRequest.getExtList().size() == 1);
}
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) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo) WorkflowServiceImplTest(org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest) Test(org.junit.Test)

Example 5 with ProcessResponse

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

the class WorkflowServiceImplTest method testRestartProcess.

@Test
public void testRestartProcess() {
    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.RESTART);
    taskListenerFactory.acceptPlugin(new MockPlugin());
    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 restartSort = process.getTaskByName("restartSort");
    Assert.assertTrue(restartSort instanceof ServiceTask);
    List<TaskEventListener> listeners = Lists.newArrayList(restartSort.getNameToListenerMap().values());
    Assert.assertEquals(1, listeners.size());
    Assert.assertTrue(listeners.get(0) instanceof MockRestartSortListener);
    WorkflowTask restartSourceTask = process.getTaskByName("restartSource");
    Assert.assertTrue(restartSourceTask instanceof ServiceTask);
    listeners = Lists.newArrayList(restartSourceTask.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) MockRestartSortListener(org.apache.inlong.manager.service.mocks.MockRestartSortListener) 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)

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