use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class WorkflowContextBuilderImpl method buildContextForProcess.
@SneakyThrows
@Override
public WorkflowContext buildContextForProcess(String name, String applicant, ProcessForm form) {
WorkflowProcess process = definitionRepository.get(name).clone();
WorkflowContext context = new WorkflowContext();
context.setProcess(process);
context.setProcessForm(form);
context.setApplicant(applicant);
return context;
}
use of org.apache.inlong.manager.workflow.WorkflowContext 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.WorkflowContext in project incubator-inlong by apache.
the class EventListenerServiceImpl method executeProcessEventListener.
@Override
public void executeProcessEventListener(Integer processId, String listener) {
WorkflowContext context = workflowContextBuilder.buildContextForProcess(processId);
ProcessEvent processEvent = getProcessEventListener(context.getProcess(), listener).event();
context.setCurrentElement(getCurrentElement(context.getProcess(), processEvent));
workflowEventNotifier.getProcessEventNotifier().notify(listener, true, context);
}
use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class EventListenerServiceImpl method triggerProcessEvent.
@Override
public void triggerProcessEvent(Integer processId, ProcessEvent processEvent) {
WorkflowContext context = workflowContextBuilder.buildContextForProcess(processId);
context.setCurrentElement(getCurrentElement(context.getProcess(), processEvent));
workflowEventNotifier.getProcessEventNotifier().notify(processEvent, context);
}
use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class EventListenerServiceImpl method executeTaskEventListener.
@Override
public void executeTaskEventListener(Integer taskId, String listener) {
WorkflowContext context = workflowContextBuilder.buildContextForTask(taskId, null);
TaskEventListener eventListener = getTaskEventListener((WorkflowTask) context.getCurrentElement(), listener);
context.getActionContext().setAction(WorkflowAction.fromTaskEvent(eventListener.event()));
workflowEventNotifier.getTaskEventNotifier().notify(listener, true, context);
}
Aggregations