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;
}
}
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);
}
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);
}
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);
}
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));
}
Aggregations