use of org.apache.inlong.manager.workflow.definition.WorkflowTask in project incubator-inlong by apache.
the class WorkflowServiceImplTest method testStartCreatePulsarWorkflow.
@Test
public void testStartCreatePulsarWorkflow() {
initGroupForm(Constant.MIDDLEWARE_PULSAR);
mockTaskListenerFactory();
WorkflowContext context = workflowEngine.processService().start(processName.name(), applicant, form);
WorkflowResult result = WorkflowBeanUtils.result(context);
ProcessResponse view = result.getProcessInfo();
Assert.assertSame(view.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 CreatePulsarGroupTaskListener);
Assert.assertTrue(listeners.get(1) instanceof CreatePulsarResourceTaskListener);
}
use of org.apache.inlong.manager.workflow.definition.WorkflowTask in project incubator-inlong by apache.
the class ProcessorExecutorImpl method executeStart.
@Override
public void executeStart(Element element, WorkflowContext context) {
ElementProcessor processor = this.getProcessor(element.getClass());
context.setCurrentElement(element);
// If the current component needs to be skipped, proceed directly to the next one
if (isSkipCurrentElement(element, context)) {
executeSkipAndNext(element, context);
return;
}
processor.create(element, context);
if (processor.pendingForAction(context)) {
return;
}
// If it is a continuous task execution transaction isolation
if (element instanceof WorkflowTask) {
transactionHelper.execute(executeCompleteInTransaction(element, context), TransactionDefinition.PROPAGATION_NESTED);
return;
}
executeComplete(element, context);
}
use of org.apache.inlong.manager.workflow.definition.WorkflowTask in project incubator-inlong by apache.
the class DataSourceListenerTest method testFrozenSource.
@Test
public void testFrozenSource() {
groupInfo = initGroupForm("PULSAR");
groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
groupService.update(groupInfo.genRequest(), OPERATOR);
final int sourceId = createBinlogSource(groupInfo);
streamSourceService.updateStatus(groupInfo.getInlongGroupId(), null, SourceState.SOURCE_NORMAL.getCode(), OPERATOR);
form = new UpdateGroupProcessForm();
form.setGroupInfo(groupInfo);
form.setOperateType(OperateType.SUSPEND);
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("stopSource");
Assert.assertTrue(task instanceof ServiceTask);
SourceResponse sourceResponse = streamSourceService.get(sourceId, SourceType.BINLOG.toString());
Assert.assertSame(SourceState.forCode(sourceResponse.getStatus()), SourceState.TO_BE_ISSUED_FROZEN);
}
use of org.apache.inlong.manager.workflow.definition.WorkflowTask in project incubator-inlong by apache.
the class WorkflowFormParserUtils method parseTaskForm.
/**
* Parse the task form in JSON string format into a WorkflowTask instance
*/
public static <T extends TaskForm> T parseTaskForm(WorkflowTaskEntity workflowTaskEntity, WorkflowProcess process) throws FormParseException {
Preconditions.checkNotNull(workflowTaskEntity, "workflowTaskEntity cannot be null");
Preconditions.checkNotNull(process, "process cannot be null");
if (StringUtils.isEmpty(workflowTaskEntity.getFormData())) {
return null;
}
WorkflowTask task = process.getTaskByName(workflowTaskEntity.getName());
Preconditions.checkNotNull(task, "user task not exist " + workflowTaskEntity.getName());
Preconditions.checkTrue(task instanceof UserTask, "task should be userTask " + workflowTaskEntity.getName());
UserTask userTask = (UserTask) task;
try {
JavaType javaType = JsonUtils.MAPPER.constructType(userTask.getFormClass());
return JsonUtils.parse(workflowTaskEntity.getFormData(), javaType);
} catch (Exception e) {
log.error("task form parse failed, form is: {}", workflowTaskEntity.getFormData(), e);
throw new FormParseException("task form parse failed");
}
}
use of org.apache.inlong.manager.workflow.definition.WorkflowTask in project incubator-inlong by apache.
the class TaskEventNotifier method notify.
@Override
public void notify(String listenerName, boolean forceSync, WorkflowContext sourceContext) {
final WorkflowContext context = sourceContext.clone();
Optional.ofNullable(this.eventListenerManager.listener(listenerName)).ifPresent(logableNotify(forceSync, context));
WorkflowTask task = (WorkflowTask) context.getCurrentElement();
Optional.ofNullable(task.listener(listenerName)).ifPresent(logableNotify(forceSync, context));
}
Aggregations