Search in sources :

Example 6 with StartEvent

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

the class NewConsumptionWorkflowDefinition method defineProcess.

@Override
public WorkflowProcess defineProcess() {
    // Define process information
    WorkflowProcess process = new WorkflowProcess();
    process.setType("Data Consumption Resource Creation");
    process.setName(getProcessName().name());
    process.setDisplayName(getProcessName().getDisplayName());
    process.setFormClass(NewConsumptionProcessForm.class);
    process.setVersion(1);
    process.setProcessDetailHandler(newConsumptionProcessDetailHandler);
    // Start node
    StartEvent startEvent = new StartEvent();
    process.setStartEvent(startEvent);
    // End node
    EndEvent endEvent = new EndEvent();
    process.setEndEvent(endEvent);
    // Group approval tasks
    UserTask groupOwnerUserTask = new UserTask();
    groupOwnerUserTask.setName(UT_GROUP_OWNER_NAME);
    groupOwnerUserTask.setDisplayName("Group Approval");
    groupOwnerUserTask.setApproverAssign(this::bizOwnerUserTaskApprover);
    process.addTask(groupOwnerUserTask);
    // System administrator approval
    UserTask adminUserTask = new UserTask();
    adminUserTask.setName(UT_ADMINT_NAME);
    adminUserTask.setDisplayName("System Administrator");
    adminUserTask.setFormClass(ConsumptionApproveForm.class);
    adminUserTask.setApproverAssign(this::adminUserTaskApprover);
    adminUserTask.addListener(consumptionPassTaskListener);
    process.addTask(adminUserTask);
    // Set order relationship
    startEvent.addNext(groupOwnerUserTask);
    groupOwnerUserTask.addNext(adminUserTask);
    adminUserTask.addNext(endEvent);
    // Set up the listener
    process.addListener(consumptionCompleteProcessListener);
    process.addListener(consumptionRejectProcessListener);
    process.addListener(consumptionCancelProcessListener);
    return process;
}
Also used : StartEvent(org.apache.inlong.manager.workflow.definition.StartEvent) UserTask(org.apache.inlong.manager.workflow.definition.UserTask) EndEvent(org.apache.inlong.manager.workflow.definition.EndEvent) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess)

Example 7 with StartEvent

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

the class CreateStreamWorkflowDefinition method defineProcess.

@Override
public WorkflowProcess defineProcess() {
    // Configuration process
    WorkflowProcess process = new WorkflowProcess();
    process.addListener(initGroupListener);
    process.addListener(streamFailedProcessListener);
    process.addListener(streamCompleteProcessListener);
    process.setType("Inlong stream access 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);
    // End node
    EndEvent endEvent = new EndEvent();
    process.setEndEvent(endEvent);
    ServiceTask createPulsarTopicTask = new ServiceTask();
    createPulsarTopicTask.setSkipResolver(c -> {
        GroupResourceProcessForm form = (GroupResourceProcessForm) c.getProcessForm();
        String mqType = form.getGroupInfo().getMiddlewareType();
        if (Constant.MIDDLEWARE_PULSAR.equals(mqType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(mqType)) {
            return false;
        }
        log.warn("no need to create pulsar topic for groupId={}, streamId={}, as the middlewareType={}", form.getInlongGroupId(), form.getInlongStreamId(), mqType);
        return true;
    });
    createPulsarTopicTask.setName("createPulsarTopic");
    createPulsarTopicTask.setDisplayName("Stream-CreatePulsarTopic");
    createPulsarTopicTask.addListener(createPulsarTopicTaskListener);
    process.addTask(createPulsarTopicTask);
    ServiceTask createPulsarSubscriptionGroupTask = new ServiceTask();
    createPulsarSubscriptionGroupTask.setSkipResolver(c -> {
        GroupResourceProcessForm form = (GroupResourceProcessForm) c.getProcessForm();
        String mqType = form.getGroupInfo().getMiddlewareType();
        if (Constant.MIDDLEWARE_PULSAR.equals(mqType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(mqType)) {
            return false;
        }
        log.warn("no need to create pulsar subscription for groupId={}, streamId={}, as the middlewareType={}", form.getInlongGroupId(), form.getInlongStreamId(), mqType);
        return true;
    });
    createPulsarSubscriptionGroupTask.setName("createPulsarSubscription");
    createPulsarSubscriptionGroupTask.setDisplayName("Stream-CreatePulsarSubscription");
    createPulsarSubscriptionGroupTask.addListener(createPulsarGroupTaskListener);
    process.addTask(createPulsarSubscriptionGroupTask);
    ServiceTask createHiveTableTask = new ServiceTask();
    createHiveTableTask.setSkipResolver(c -> {
        GroupResourceProcessForm form = (GroupResourceProcessForm) c.getProcessForm();
        String groupId = form.getInlongGroupId();
        String streamId = form.getInlongStreamId();
        List<String> dsForHive = sinkService.getExistsStreamIdList(groupId, Constant.SINK_HIVE, Collections.singletonList(streamId));
        if (CollectionUtils.isEmpty(dsForHive)) {
            log.warn("inlong group [{}] adn inlong stream [{}] does not have sink, skip create hive table", groupId, streamId);
            return true;
        }
        return false;
    });
    createHiveTableTask.setName("createHiveTable");
    createHiveTableTask.setDisplayName("Stream-CreateHiveTable");
    createHiveTableTask.addListener(createHiveTableListener);
    process.addTask(createHiveTableTask);
    ServiceTask pushSortConfig = new ServiceTask();
    pushSortConfig.setName("pushSortConfig");
    pushSortConfig.setDisplayName("Stream-PushSortConfig");
    pushSortConfig.addListener(pushSortConfigListener);
    process.addTask(pushSortConfig);
    startEvent.addNext(createPulsarTopicTask);
    createPulsarTopicTask.addNext(createPulsarSubscriptionGroupTask);
    createPulsarSubscriptionGroupTask.addNext(createHiveTableTask);
    createHiveTableTask.addNext(pushSortConfig);
    pushSortConfig.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) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)

Example 8 with StartEvent

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

the class RestartGroupWorkflowDefinition method defineProcess.

@Override
public WorkflowProcess defineProcess() {
    // Configuration process
    WorkflowProcess process = new WorkflowProcess();
    process.addListener(updateGroupListener);
    process.addListener(updateGroupCompleteListener);
    process.setType("Group Resource Restart");
    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);
    // restart sort
    ServiceTask restartSortTask = new ServiceTask();
    restartSortTask.setName("restartSort");
    restartSortTask.setDisplayName("Group-RestartSort");
    restartSortTask.addServiceTaskType(ServiceTaskType.RESTART_SORT);
    restartSortTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(restartSortTask);
    // restart datasource
    ServiceTask restartDataSourceTask = new ServiceTask();
    restartDataSourceTask.setName("restartSource");
    restartDataSourceTask.setDisplayName("Group-RestartSource");
    restartDataSourceTask.addServiceTaskType(ServiceTaskType.RESTART_SOURCE);
    restartDataSourceTask.addListenerProvider(serviceTaskListenerFactory);
    process.addTask(restartDataSourceTask);
    // End node
    EndEvent endEvent = new EndEvent();
    process.setEndEvent(endEvent);
    startEvent.addNext(restartSortTask);
    restartSortTask.addNext(restartDataSourceTask);
    restartDataSourceTask.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)

Aggregations

StartEvent (org.apache.inlong.manager.workflow.definition.StartEvent)8 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)8 EndEvent (org.apache.inlong.manager.workflow.definition.EndEvent)7 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)5 UserTask (org.apache.inlong.manager.workflow.definition.UserTask)2 TaskStatus (org.apache.inlong.manager.common.enums.TaskStatus)1 ElementDTO (org.apache.inlong.manager.common.pojo.workflow.ElementDTO)1 WorkflowBriefDTO (org.apache.inlong.manager.common.pojo.workflow.WorkflowBriefDTO)1 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)1 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)1