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