Search in sources :

Example 1 with ServiceTask

use of org.apache.inlong.manager.workflow.definition.ServiceTask in project incubator-inlong by apache.

the class SuspendGroupWorkflowDefinition method defineProcess.

@Override
public WorkflowProcess defineProcess() {
    // Configuration process
    WorkflowProcess process = new WorkflowProcess();
    process.addListener(updateGroupListener);
    process.addListener(updateGroupCompleteListener);
    process.setType("Group Resource Suspend");
    process.setName(getProcessName().name());
    process.setDisplayName(getProcessName().getDisplayName());
    process.setFormClass(UpdateGroupProcessForm.class);
    process.setVersion(1);
    process.setHidden(1);
    // Start node
    StartEvent startEvent = new StartEvent();
    process.setStartEvent(startEvent);
    // stop datasource
    ServiceTask stopDataSourceTask = new ServiceTask();
    stopDataSourceTask.setName("stopSource");
    stopDataSourceTask.setDisplayName("Group-StopSource");
    stopDataSourceTask.addServiceTaskType(ServiceTaskType.STOP_SOURCE);
    stopDataSourceTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(stopDataSourceTask);
    // stop sort
    ServiceTask stopSortTask = new ServiceTask();
    stopSortTask.setName("stopSort");
    stopSortTask.setDisplayName("Group-StopSort");
    stopSortTask.addServiceTaskType(ServiceTaskType.STOP_SORT);
    stopSortTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(stopSortTask);
    // End node
    EndEvent endEvent = new EndEvent();
    process.setEndEvent(endEvent);
    startEvent.addNext(stopDataSourceTask);
    stopDataSourceTask.addNext(stopSortTask);
    stopSortTask.addNext(endEvent);
    return process;
}
Also used : ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) StartEvent(org.apache.inlong.manager.workflow.definition.StartEvent) EndEvent(org.apache.inlong.manager.workflow.definition.EndEvent) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 2 with ServiceTask

use of org.apache.inlong.manager.workflow.definition.ServiceTask in project incubator-inlong by apache.

the class CreateGroupWorkflowDefinition method defineProcess.

@Override
public WorkflowProcess defineProcess() {
    // Configuration process
    WorkflowProcess process = new WorkflowProcess();
    process.addListener(initGroupListener);
    process.addListener(groupCompleteProcessListener);
    process.addListener(groupFailedProcessListener);
    process.setType("Group Resource Creation");
    process.setName(getProcessName().name());
    process.setDisplayName(getProcessName().getDisplayName());
    process.setFormClass(GroupResourceProcessForm.class);
    process.setVersion(1);
    process.setHidden(1);
    // Start node
    StartEvent startEvent = new StartEvent();
    process.setStartEvent(startEvent);
    // init DataSource
    ServiceTask initDataSourceTask = new ServiceTask();
    initDataSourceTask.setName("initSource");
    initDataSourceTask.setDisplayName("Group-InitSource");
    initDataSourceTask.addServiceTaskType(ServiceTaskType.INIT_SOURCE);
    initDataSourceTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(initDataSourceTask);
    // init MQ resource
    ServiceTask initMQResourceTask = new ServiceTask();
    initMQResourceTask.setName("initMQ");
    initMQResourceTask.setDisplayName("Group-InitMQ");
    initMQResourceTask.addServiceTaskType(ServiceTaskType.INIT_MQ);
    initMQResourceTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(initMQResourceTask);
    // init Sort resource
    ServiceTask initSortResourceTask = new ServiceTask();
    initSortResourceTask.setName("initSort");
    initSortResourceTask.setDisplayName("Group-InitSort");
    initSortResourceTask.addServiceTaskType(ServiceTaskType.INIT_SORT);
    initSortResourceTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(initSortResourceTask);
    // init sink
    ServiceTask initSinkTask = new ServiceTask();
    initSinkTask.setName("initSink");
    initSinkTask.setDisplayName("Group-InitSink");
    initSinkTask.addServiceTaskType(ServiceTaskType.INIT_SINK);
    initSinkTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(initSinkTask);
    // End node
    EndEvent endEvent = new EndEvent();
    process.setEndEvent(endEvent);
    startEvent.addNext(initDataSourceTask);
    initDataSourceTask.addNext(initMQResourceTask);
    initMQResourceTask.addNext(initSortResourceTask);
    initSortResourceTask.addNext(initSinkTask);
    initSinkTask.addNext(endEvent);
    return process;
}
Also used : ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) StartEvent(org.apache.inlong.manager.workflow.definition.StartEvent) EndEvent(org.apache.inlong.manager.workflow.definition.EndEvent) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 3 with ServiceTask

use of org.apache.inlong.manager.workflow.definition.ServiceTask in project incubator-inlong by apache.

the class DeleteGroupWorkflowDefinition method defineProcess.

@Override
public WorkflowProcess defineProcess() {
    // Configuration process
    WorkflowProcess process = new WorkflowProcess();
    process.addListener(updateGroupListener);
    process.addListener(updateGroupCompleteListener);
    process.setType("Group Resource Delete");
    process.setName(getProcessName().name());
    process.setDisplayName(getProcessName().getDisplayName());
    process.setFormClass(UpdateGroupProcessForm.class);
    process.setVersion(1);
    process.setHidden(1);
    // Start node
    StartEvent startEvent = new StartEvent();
    process.setStartEvent(startEvent);
    // delete datasource
    ServiceTask deleteDataSourceTask = new ServiceTask();
    deleteDataSourceTask.setName("deleteSource");
    deleteDataSourceTask.setDisplayName("Group-DeleteSource");
    deleteDataSourceTask.addServiceTaskType(ServiceTaskType.DELETE_SOURCE);
    deleteDataSourceTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(deleteDataSourceTask);
    // delete sort
    ServiceTask deleteSortTask = new ServiceTask();
    deleteSortTask.setName("deleteSort");
    deleteSortTask.setDisplayName("Group-DeleteSort");
    deleteSortTask.addServiceTaskType(ServiceTaskType.DELETE_SORT);
    deleteSortTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(deleteSortTask);
    // End node
    EndEvent endEvent = new EndEvent();
    process.setEndEvent(endEvent);
    startEvent.addNext(deleteDataSourceTask);
    deleteDataSourceTask.addNext(deleteSortTask);
    deleteSortTask.addNext(endEvent);
    return process;
}
Also used : ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) StartEvent(org.apache.inlong.manager.workflow.definition.StartEvent) EndEvent(org.apache.inlong.manager.workflow.definition.EndEvent) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 4 with ServiceTask

use of org.apache.inlong.manager.workflow.definition.ServiceTask 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 5 with ServiceTask

use of org.apache.inlong.manager.workflow.definition.ServiceTask 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)

Aggregations

ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)15 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)14 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)9 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)9 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)9 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)9 Test (org.junit.Test)9 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)7 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)7 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)5 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)5 EndEvent (org.apache.inlong.manager.workflow.definition.EndEvent)5 StartEvent (org.apache.inlong.manager.workflow.definition.StartEvent)5 MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)4 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)4 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)3 SourceResponse (org.apache.inlong.manager.common.pojo.source.SourceResponse)2 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)2 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)2 Date (java.util.Date)1