Search in sources :

Example 11 with GroupResourceProcessForm

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

the class CreatePulsarResourceTaskListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    GroupResourceProcessForm form = (GroupResourceProcessForm) context.getProcessForm();
    String groupId = form.getInlongGroupId();
    log.info("begin to create pulsar resource for groupId={}", groupId);
    InlongGroupInfo groupInfo = groupService.get(groupId);
    if (groupInfo == null) {
        throw new WorkflowListenerException("inlong group or pulsar cluster not found for groupId=" + groupId);
    }
    PulsarClusterInfo globalCluster = commonOperateService.getPulsarClusterInfo(groupInfo.getMiddlewareType());
    try (PulsarAdmin globalPulsarAdmin = PulsarUtils.getPulsarAdmin(globalCluster)) {
        List<String> pulsarClusters = PulsarUtils.getPulsarClusters(globalPulsarAdmin);
        for (String cluster : pulsarClusters) {
            String serviceUrl = PulsarUtils.getServiceUrl(globalPulsarAdmin, cluster);
            PulsarClusterInfo pulsarClusterInfo = PulsarClusterInfo.builder().token(globalCluster.getToken()).adminUrl(serviceUrl).build();
            this.createPulsarProcess(groupInfo, pulsarClusterInfo);
        }
    } catch (Exception e) {
        log.error("create pulsar resource error for groupId={}", groupId, e);
        throw new WorkflowListenerException("create pulsar resource error for groupId=" + groupId);
    }
    log.info("success to create pulsar resource for groupId={}", groupId);
    return ListenerResult.success();
}
Also used : PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) PulsarClusterInfo(org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException)

Example 12 with GroupResourceProcessForm

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

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

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

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

the class CreateHiveTableEventSelectorTest method testAccept.

@Test
public void testAccept() {
    WorkflowContext workflowContext = new WorkflowContext();
    GroupResourceProcessForm processForm = new GroupResourceProcessForm();
    workflowContext.setProcessForm(processForm);
    Assert.assertFalse(createHiveTableEventSelector.accept(workflowContext));
    processForm.setGroupInfo(new InlongGroupInfo());
    Assert.assertFalse(createHiveTableEventSelector.accept(workflowContext));
    processForm.getGroupInfo().setInlongGroupId("test");
    Assert.assertTrue(createHiveTableEventSelector.accept(workflowContext));
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest) Test(org.junit.Test)

Aggregations

GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)26 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)16 WorkflowListenerException (org.apache.inlong.manager.common.exceptions.WorkflowListenerException)7 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)6 InlongStreamEntity (org.apache.inlong.manager.dao.entity.InlongStreamEntity)5 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)4 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)4 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)4 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)3 Test (org.junit.Test)3 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)2 PulsarTopicBean (org.apache.inlong.manager.common.pojo.pulsar.PulsarTopicBean)2 SinkForSortDTO (org.apache.inlong.manager.common.pojo.sink.SinkForSortDTO)2 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)2 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)2 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)2 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)2 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1