Search in sources :

Example 21 with InlongGroupInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo in project incubator-inlong by apache.

the class ServiceTaskListenerFactoryTest method testGetQueueOperateListener.

@Test
public void testGetQueueOperateListener() {
    WorkflowContext context = new WorkflowContext();
    GroupResourceProcessForm processForm = new GroupResourceProcessForm();
    InlongGroupInfo groupInfo = new InlongGroupInfo();
    // check pulsar listener
    groupInfo.setMiddlewareType(Constant.MIDDLEWARE_PULSAR);
    processForm.setGroupInfo(groupInfo);
    context.setProcessForm(processForm);
    List<QueueOperateListener> queueOperateListeners = serviceTaskListenerFactory.getQueueOperateListener(context);
    Assert.assertEquals(2, queueOperateListeners.size());
    Assert.assertTrue(queueOperateListeners.get(0) instanceof CreatePulsarResourceTaskListener);
    Assert.assertTrue(queueOperateListeners.get(1) instanceof CreatePulsarGroupTaskListener);
    // check tube listener
    groupInfo.setMiddlewareType(Constant.MIDDLEWARE_TUBE);
    queueOperateListeners = serviceTaskListenerFactory.getQueueOperateListener(context);
    Assert.assertEquals(2, queueOperateListeners.size());
    Assert.assertTrue(queueOperateListeners.get(0) instanceof CreateTubeTopicTaskListener);
    Assert.assertTrue(queueOperateListeners.get(1) instanceof CreateTubeGroupTaskListener);
}
Also used : QueueOperateListener(org.apache.inlong.manager.workflow.event.task.QueueOperateListener) CreateTubeTopicTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreateTubeTopicTaskListener) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) CreatePulsarGroupTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreatePulsarGroupTaskListener) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) CreateTubeGroupTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreateTubeGroupTaskListener) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) CreatePulsarResourceTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreatePulsarResourceTaskListener) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 22 with InlongGroupInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo in project incubator-inlong by apache.

the class WorkflowServiceImplTest method initGroupForm.

/**
 * Init inlong group form
 */
public InlongGroupInfo initGroupForm(String middlewareType) {
    processName = ProcessName.CREATE_GROUP_RESOURCE;
    applicant = OPERATOR;
    try {
        streamService.logicDeleteAll(GROUP_ID, OPERATOR);
        groupService.delete(GROUP_ID, OPERATOR);
    } catch (Exception e) {
    // ignore
    }
    InlongGroupInfo groupInfo = new InlongGroupInfo();
    groupInfo.setName("test");
    groupInfo.setInCharges(OPERATOR);
    groupInfo.setInlongGroupId("b_test");
    groupInfo.setMiddlewareType(middlewareType);
    groupInfo.setMqExtInfo(new InlongGroupPulsarInfo());
    groupInfo.setMqResourceObj("test-queue");
    groupService.save(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.TO_BE_APPROVAL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.APPROVE_PASSED.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.CONFIG_ING.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    form = new GroupResourceProcessForm();
    form.setInlongStreamId(STREAM_ID);
    form.setGroupInfo(groupInfo);
    return groupInfo;
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)

Example 23 with InlongGroupInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo 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 24 with InlongGroupInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo 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 25 with InlongGroupInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo in project incubator-inlong by apache.

the class NewConsumptionWorkflowDefinition method bizOwnerUserTaskApprover.

private List<String> bizOwnerUserTaskApprover(WorkflowContext context) {
    NewConsumptionProcessForm form = (NewConsumptionProcessForm) context.getProcessForm();
    InlongGroupInfo groupInfo = groupService.get(form.getConsumptionInfo().getInlongGroupId());
    if (groupInfo == null || groupInfo.getInCharges() == null) {
        return Collections.emptyList();
    }
    return Arrays.asList(groupInfo.getInCharges().split(","));
}
Also used : NewConsumptionProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.NewConsumptionProcessForm) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)

Aggregations

InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)42 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)18 Test (org.junit.Test)11 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)10 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)10 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)10 WorkflowListenerException (org.apache.inlong.manager.common.exceptions.WorkflowListenerException)9 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)8 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)8 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)6 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)6 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)6 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)5 List (java.util.List)4 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)4 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)4 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)4 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)4 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)4 InlongGroupExtInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)3