Search in sources :

Example 1 with ElementProcessor

use of org.apache.inlong.manager.workflow.processor.ElementProcessor 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);
}
Also used : ElementProcessor(org.apache.inlong.manager.workflow.processor.ElementProcessor) SkipableElementProcessor(org.apache.inlong.manager.workflow.processor.SkipableElementProcessor) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask)

Example 2 with ElementProcessor

use of org.apache.inlong.manager.workflow.processor.ElementProcessor in project incubator-inlong by apache.

the class ProcessorExecutorImpl method initProcessors.

private List<ElementProcessor<?>> initProcessors(WorkflowProcessEntityMapper processEntityMapper, WorkflowTaskEntityMapper taskEntityMapper, WorkflowEventNotifier eventNotifier) {
    List<ElementProcessor<?>> processors = Lists.newArrayList();
    processors.add(new StartEventProcessor(processEntityMapper, eventNotifier));
    processors.add(new EndEventProcessor(processEntityMapper, taskEntityMapper, eventNotifier));
    processors.add(new UserTaskProcessor(taskEntityMapper, eventNotifier));
    processors.add(new ServiceTaskProcessor(taskEntityMapper, eventNotifier));
    return processors;
}
Also used : EndEventProcessor(org.apache.inlong.manager.workflow.processor.EndEventProcessor) ServiceTaskProcessor(org.apache.inlong.manager.workflow.processor.ServiceTaskProcessor) ElementProcessor(org.apache.inlong.manager.workflow.processor.ElementProcessor) SkipableElementProcessor(org.apache.inlong.manager.workflow.processor.SkipableElementProcessor) StartEventProcessor(org.apache.inlong.manager.workflow.processor.StartEventProcessor) UserTaskProcessor(org.apache.inlong.manager.workflow.processor.UserTaskProcessor)

Example 3 with ElementProcessor

use of org.apache.inlong.manager.workflow.processor.ElementProcessor in project incubator-inlong by apache.

the class ProcessorExecutorImpl method executeSkipAndNext.

private void executeSkipAndNext(Element element, WorkflowContext context) {
    if (!(element instanceof SkippableElement)) {
        throw new WorkflowException("element not instance of skip element " + element.getDisplayName());
    }
    if (!(element instanceof NextableElement)) {
        throw new WorkflowException("element not instance of nextable element " + element.getDisplayName());
    }
    ElementProcessor processor = this.getProcessor(element.getClass());
    if (!(processor instanceof SkipableElementProcessor)) {
        throw new WorkflowException("element processor not instance of skip processor " + element.getDisplayName());
    }
    // Execute skip logic
    SkipableElementProcessor skipableProcessor = (SkipableElementProcessor) processor;
    skipableProcessor.skip(element, context);
    // Execute next
    context.getActionContext().setAction(((NextableElement) element).defaultNextAction());
    List<Element> nextElements = processor.next(element, context);
    nextElements.forEach(next -> executeStart(next, context));
}
Also used : SkipableElementProcessor(org.apache.inlong.manager.workflow.processor.SkipableElementProcessor) NextableElement(org.apache.inlong.manager.workflow.definition.NextableElement) WorkflowException(org.apache.inlong.manager.common.exceptions.WorkflowException) Element(org.apache.inlong.manager.workflow.definition.Element) NextableElement(org.apache.inlong.manager.workflow.definition.NextableElement) SkippableElement(org.apache.inlong.manager.workflow.definition.SkippableElement) SkippableElement(org.apache.inlong.manager.workflow.definition.SkippableElement) ElementProcessor(org.apache.inlong.manager.workflow.processor.ElementProcessor) SkipableElementProcessor(org.apache.inlong.manager.workflow.processor.SkipableElementProcessor)

Example 4 with ElementProcessor

use of org.apache.inlong.manager.workflow.processor.ElementProcessor in project incubator-inlong by apache.

the class ProcessorExecutorImpl method executeComplete.

@Override
public void executeComplete(Element element, WorkflowContext context) {
    ElementProcessor processor = this.getProcessor(element.getClass());
    context.setCurrentElement(element);
    boolean completed = processor.complete(context);
    if (!completed) {
        return;
    }
    List<Element> nextElements = processor.next(element, context);
    nextElements.forEach(next -> executeStart(next, context));
}
Also used : Element(org.apache.inlong.manager.workflow.definition.Element) NextableElement(org.apache.inlong.manager.workflow.definition.NextableElement) SkippableElement(org.apache.inlong.manager.workflow.definition.SkippableElement) ElementProcessor(org.apache.inlong.manager.workflow.processor.ElementProcessor) SkipableElementProcessor(org.apache.inlong.manager.workflow.processor.SkipableElementProcessor)

Aggregations

ElementProcessor (org.apache.inlong.manager.workflow.processor.ElementProcessor)4 SkipableElementProcessor (org.apache.inlong.manager.workflow.processor.SkipableElementProcessor)4 Element (org.apache.inlong.manager.workflow.definition.Element)2 NextableElement (org.apache.inlong.manager.workflow.definition.NextableElement)2 SkippableElement (org.apache.inlong.manager.workflow.definition.SkippableElement)2 WorkflowException (org.apache.inlong.manager.common.exceptions.WorkflowException)1 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)1 EndEventProcessor (org.apache.inlong.manager.workflow.processor.EndEventProcessor)1 ServiceTaskProcessor (org.apache.inlong.manager.workflow.processor.ServiceTaskProcessor)1 StartEventProcessor (org.apache.inlong.manager.workflow.processor.StartEventProcessor)1 UserTaskProcessor (org.apache.inlong.manager.workflow.processor.UserTaskProcessor)1