Search in sources :

Example 1 with CreateTubeTopicTaskListener

use of org.apache.inlong.manager.service.thirdparty.mq.CreateTubeTopicTaskListener 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 2 with CreateTubeTopicTaskListener

use of org.apache.inlong.manager.service.thirdparty.mq.CreateTubeTopicTaskListener in project incubator-inlong by apache.

the class WorkflowServiceImplTest method mockTaskListenerFactory.

/**
 * Mock the task listener factory
 */
public void mockTaskListenerFactory() {
    CreateTubeGroupTaskListener createTubeGroupTaskListener = mock(CreateTubeGroupTaskListener.class);
    when(createTubeGroupTaskListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
    when(createTubeGroupTaskListener.name()).thenReturn(CreateHiveTableListener.class.getSimpleName());
    when(createTubeGroupTaskListener.event()).thenReturn(TaskEvent.COMPLETE);
    taskListenerFactory.setCreateTubeGroupTaskListener(createTubeGroupTaskListener);
    CreateTubeTopicTaskListener createTubeTopicTaskListener = mock(CreateTubeTopicTaskListener.class);
    when(createTubeTopicTaskListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
    when(createTubeTopicTaskListener.name()).thenReturn(CreateTubeTopicTaskListener.class.getSimpleName());
    when(createTubeTopicTaskListener.event()).thenReturn(TaskEvent.COMPLETE);
    taskListenerFactory.setCreateTubeTopicTaskListener(createTubeTopicTaskListener);
    CreatePulsarResourceTaskListener createPulsarResourceTaskListener = mock(CreatePulsarResourceTaskListener.class);
    when(createPulsarResourceTaskListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
    when(createPulsarResourceTaskListener.name()).thenReturn(CreatePulsarResourceTaskListener.class.getSimpleName());
    when(createPulsarResourceTaskListener.event()).thenReturn(TaskEvent.COMPLETE);
    taskListenerFactory.setCreatePulsarResourceTaskListener(createPulsarResourceTaskListener);
    CreatePulsarGroupTaskListener createPulsarGroupTaskListener = mock(CreatePulsarGroupTaskListener.class);
    when(createPulsarGroupTaskListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
    when(createPulsarGroupTaskListener.name()).thenReturn(CreatePulsarGroupTaskListener.class.getSimpleName());
    when(createPulsarGroupTaskListener.event()).thenReturn(TaskEvent.COMPLETE);
    taskListenerFactory.setCreatePulsarGroupTaskListener(createPulsarGroupTaskListener);
    CreateHiveTableListener createHiveTableListener = mock(CreateHiveTableListener.class);
    when(createHiveTableListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
    when(createHiveTableListener.name()).thenReturn(CreateHiveTableListener.class.getSimpleName());
    when(createHiveTableListener.event()).thenReturn(TaskEvent.COMPLETE);
    taskListenerFactory.setCreateHiveTableListener(createHiveTableListener);
    PushSortConfigListener pushSortConfigListener = mock(PushSortConfigListener.class);
    when(pushSortConfigListener.listen(any(WorkflowContext.class))).thenReturn(ListenerResult.success());
    when(pushSortConfigListener.name()).thenReturn(PushSortConfigListener.class.getSimpleName());
    when(pushSortConfigListener.event()).thenReturn(TaskEvent.COMPLETE);
    taskListenerFactory.setPushSortConfigListener(pushSortConfigListener);
    taskListenerFactory.clearListeners();
    taskListenerFactory.init();
}
Also used : CreateHiveTableListener(org.apache.inlong.manager.service.thirdparty.hive.CreateHiveTableListener) 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) CreateTubeGroupTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreateTubeGroupTaskListener) CreatePulsarResourceTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreatePulsarResourceTaskListener) PushSortConfigListener(org.apache.inlong.manager.service.thirdparty.sort.PushSortConfigListener)

Example 3 with CreateTubeTopicTaskListener

use of org.apache.inlong.manager.service.thirdparty.mq.CreateTubeTopicTaskListener in project incubator-inlong by apache.

the class WorkflowServiceImplTest method testStartCreateTubeWorkflow.

@Test
public void testStartCreateTubeWorkflow() {
    initGroupForm(Constant.MIDDLEWARE_TUBE);
    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("initMQ");
    Assert.assertTrue(task instanceof ServiceTask);
    Assert.assertEquals(2, task.getNameToListenerMap().size());
    List<TaskEventListener> listeners = Lists.newArrayList(task.getNameToListenerMap().values());
    Assert.assertTrue(listeners.get(0) instanceof CreateTubeTopicTaskListener);
    Assert.assertTrue(listeners.get(1) instanceof CreateTubeGroupTaskListener);
}
Also used : 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) CreateTubeTopicTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreateTubeTopicTaskListener) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) CreateTubeGroupTaskListener(org.apache.inlong.manager.service.thirdparty.mq.CreateTubeGroupTaskListener) 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

CreateTubeGroupTaskListener (org.apache.inlong.manager.service.thirdparty.mq.CreateTubeGroupTaskListener)3 CreateTubeTopicTaskListener (org.apache.inlong.manager.service.thirdparty.mq.CreateTubeTopicTaskListener)3 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)3 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)2 CreatePulsarGroupTaskListener (org.apache.inlong.manager.service.thirdparty.mq.CreatePulsarGroupTaskListener)2 CreatePulsarResourceTaskListener (org.apache.inlong.manager.service.thirdparty.mq.CreatePulsarResourceTaskListener)2 Test (org.junit.Test)2 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)1 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)1 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)1 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)1 CreateHiveTableListener (org.apache.inlong.manager.service.thirdparty.hive.CreateHiveTableListener)1 PushSortConfigListener (org.apache.inlong.manager.service.thirdparty.sort.PushSortConfigListener)1 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)1 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)1 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)1 QueueOperateListener (org.apache.inlong.manager.workflow.event.task.QueueOperateListener)1 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)1