Search in sources :

Example 6 with ProcessForm

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

the class ZkDisabledEventSelector method accept.

@Override
public boolean accept(WorkflowContext context) {
    ProcessForm processForm = context.getProcessForm();
    if (processForm instanceof GroupResourceProcessForm) {
        GroupResourceProcessForm groupResourceForm = (GroupResourceProcessForm) processForm;
        InlongGroupInfo groupInfo = groupResourceForm.getGroupInfo();
        return groupInfo.getZookeeperEnabled() == 0 && !groupInfo.getMiddlewareType().equals(Constant.MIDDLEWARE_NONE);
    } else if (processForm instanceof UpdateGroupProcessForm) {
        UpdateGroupProcessForm updateGroupProcessForm = (UpdateGroupProcessForm) processForm;
        InlongGroupInfo groupInfo = updateGroupProcessForm.getGroupInfo();
        return groupInfo.getZookeeperEnabled() == 0 && !groupInfo.getMiddlewareType().equals(Constant.MIDDLEWARE_NONE);
    } else {
        return false;
    }
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)

Example 7 with ProcessForm

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

the class ZkEnabledEventSelector method accept.

@Override
public boolean accept(WorkflowContext context) {
    ProcessForm processForm = context.getProcessForm();
    if (!(processForm instanceof GroupResourceProcessForm)) {
        return false;
    }
    GroupResourceProcessForm groupResourceForm = (GroupResourceProcessForm) processForm;
    InlongGroupInfo groupInfo = groupResourceForm.getGroupInfo();
    return groupInfo.getZookeeperEnabled() == 1 && !groupInfo.getMiddlewareType().equals(Constant.MIDDLEWARE_NONE);
}
Also used : GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)

Example 8 with ProcessForm

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

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

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

the class WorkflowContextBuilderImpl method buildContextForTask.

@SneakyThrows
private WorkflowContext buildContextForTask(Integer taskId, WorkflowAction action, TaskForm taskForm, List<String> transferToUsers, String remark, String operator) {
    WorkflowTaskEntity taskEntity = taskEntityMapper.selectById(taskId);
    Preconditions.checkNotNull(taskEntity, "task not exist with id: " + taskId);
    WorkflowProcessEntity processEntity = processEntityMapper.selectById(taskEntity.getProcessId());
    WorkflowProcess process = definitionRepository.get(processEntity.getName()).clone();
    ProcessForm processForm = WorkflowFormParserUtils.parseProcessForm(processEntity.getFormData(), process);
    WorkflowTask task = process.getTaskByName(taskEntity.getName());
    return new WorkflowContext().setProcess(process).setApplicant(processEntity.getApplicant()).setProcessForm(processForm).setProcessEntity(processEntity).setCurrentElement(task).setActionContext(new WorkflowContext.ActionContext().setAction(action).setTaskEntity(taskEntity).setTask(task).setForm(taskForm).setTransferToUsers(transferToUsers).setOperator(operator).setRemark(remark));
}
Also used : ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) SneakyThrows(lombok.SneakyThrows)

Aggregations

ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)13 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)8 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)7 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)6 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)4 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)4 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)3 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)2 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)2 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)2 WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)2 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)2 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)2 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)2 Test (org.junit.Test)2 Lists (com.google.common.collect.Lists)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 SneakyThrows (lombok.SneakyThrows)1