Search in sources :

Example 6 with UpdateGroupProcessForm

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

the class InlongGroupProcessOperation method restartProcess.

/**
 * Restart resource application group which is suspended successfully,
 * starting from the last persist snapshot.
 *
 * @return Workflow result
 */
public WorkflowResult restartProcess(String groupId, String operator) {
    LOGGER.info("begin to restart process, groupId = {}, operator = {}", groupId, operator);
    groupService.updateStatus(groupId, GroupState.RESTARTING.getCode(), operator);
    UpdateGroupProcessForm form = genUpdateGroupProcessForm(groupId, OperateType.RESTART);
    return workflowService.start(ProcessName.RESTART_GROUP_PROCESS, operator, form);
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)

Example 7 with UpdateGroupProcessForm

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

the class InlongGroupProcessOperation method genUpdateGroupProcessForm.

private UpdateGroupProcessForm genUpdateGroupProcessForm(String groupId, OperateType operateType) {
    InlongGroupInfo groupInfo = groupService.get(groupId);
    UpdateGroupProcessForm form = new UpdateGroupProcessForm();
    if (OperateType.RESTART == operateType) {
        List<InlongStreamEntity> inlongStreamEntityList = streamMapper.selectByGroupId(groupInfo.getInlongGroupId());
        List<InlongStreamInfo> inlongStreamInfoList = CommonBeanUtils.copyListProperties(inlongStreamEntityList, InlongStreamInfo::new);
        form.setInlongStreamInfoList(inlongStreamInfoList);
    }
    form.setGroupInfo(groupInfo);
    form.setOperateType(operateType);
    return form;
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 8 with UpdateGroupProcessForm

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

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

Example 10 with UpdateGroupProcessForm

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

Aggregations

UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)17 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)9 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)7 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)6 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)6 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)6 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)6 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)6 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)6 Test (org.junit.Test)6 MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)4 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)4 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)3 OperateType (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm.OperateType)3 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)3 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)3 SourceResponse (org.apache.inlong.manager.common.pojo.source.SourceResponse)2 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)2 Lists (com.google.common.collect.Lists)1 List (java.util.List)1