Search in sources :

Example 1 with UpdateGroupProcessForm

use of org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm in project incubator-inlong by apache.

the class SourceRestartEventSelector method accept.

@Override
public boolean accept(WorkflowContext context) {
    ProcessForm processForm = context.getProcessForm();
    if (!(processForm instanceof UpdateGroupProcessForm)) {
        return false;
    }
    UpdateGroupProcessForm updateGroupProcessForm = (UpdateGroupProcessForm) processForm;
    return updateGroupProcessForm.getOperateType() == OperateType.RESTART;
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)

Example 2 with UpdateGroupProcessForm

use of org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm in project incubator-inlong by apache.

the class CreateSortConfigListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws Exception {
    LOGGER.info("Create sort config for context={}", context);
    ProcessForm form = context.getProcessForm();
    if (form instanceof UpdateGroupProcessForm) {
        UpdateGroupProcessForm updateGroupProcessForm = (UpdateGroupProcessForm) form;
        OperateType operateType = updateGroupProcessForm.getOperateType();
        if (operateType == OperateType.SUSPEND || operateType == OperateType.DELETE) {
            return ListenerResult.success();
        }
    }
    InlongGroupInfo groupInfo = this.getGroupInfo(form);
    String groupId = groupInfo.getInlongGroupId();
    if (StringUtils.isEmpty(groupId)) {
        LOGGER.warn("GroupId is null for context={}", context);
        return ListenerResult.success();
    }
    List<SinkResponse> sinkResponseList = streamSinkService.listSink(groupId, null);
    if (CollectionUtils.isEmpty(sinkResponseList)) {
        LOGGER.warn("Sink not found by groupId={}", groupId);
        return ListenerResult.success();
    }
    Map<String, DataFlowInfo> dataFlowInfoMap = sinkResponseList.stream().map(sink -> {
        DataFlowInfo flowInfo = commonOperateService.createDataFlow(groupInfo, sink);
        return Pair.of(sink.getInlongStreamId(), flowInfo);
    }).collect(Collectors.toMap(Pair::getKey, Pair::getValue));
    String dataFlows = OBJECT_MAPPER.writeValueAsString(dataFlowInfoMap);
    InlongGroupExtInfo extInfo = new InlongGroupExtInfo();
    extInfo.setInlongGroupId(groupId);
    extInfo.setKeyName(InlongGroupSettings.DATA_FLOW);
    extInfo.setKeyValue(dataFlows);
    if (groupInfo.getExtList() == null) {
        groupInfo.setExtList(Lists.newArrayList());
    }
    upsertDataFlow(groupInfo, extInfo);
    return ListenerResult.success();
}
Also used : ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) Lists(com.google.common.collect.Lists) Pair(org.apache.commons.lang3.tuple.Pair) CollectionUtils(org.apache.commons.collections.CollectionUtils) CommonOperateService(org.apache.inlong.manager.service.CommonOperateService) StreamSinkService(org.apache.inlong.manager.service.sink.StreamSinkService) TaskEvent(org.apache.inlong.manager.workflow.event.task.TaskEvent) ObjectMapper(org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper) Map(java.util.Map) OperateType(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm.OperateType) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupSettings(org.apache.inlong.manager.common.settings.InlongGroupSettings) Logger(org.slf4j.Logger) SinkResponse(org.apache.inlong.manager.common.pojo.sink.SinkResponse) Collectors(java.util.stream.Collectors) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException) ListenerResult(org.apache.inlong.manager.workflow.event.ListenerResult) Component(org.springframework.stereotype.Component) List(java.util.List) UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) DataFlowInfo(org.apache.inlong.sort.protocol.DataFlowInfo) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo) SortOperateListener(org.apache.inlong.manager.workflow.event.task.SortOperateListener) UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) SinkResponse(org.apache.inlong.manager.common.pojo.sink.SinkResponse) ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) OperateType(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm.OperateType) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo) DataFlowInfo(org.apache.inlong.sort.protocol.DataFlowInfo)

Example 3 with UpdateGroupProcessForm

use of org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm in project incubator-inlong by apache.

the class ZkDisabledEventSelector method accept.

@Override
public boolean accept(WorkflowContext context) {
    ProcessForm processForm = context.getProcessForm();
    if (processForm instanceof GroupResourceProcessForm) {
        GroupResourceProcessForm groupResourceForm = (GroupResourceProcessForm) processForm;
        InlongGroupInfo groupInfo = groupResourceForm.getGroupInfo();
        return groupInfo.getZookeeperEnabled() == 0 && !groupInfo.getMiddlewareType().equals(Constant.MIDDLEWARE_NONE);
    } else if (processForm instanceof UpdateGroupProcessForm) {
        UpdateGroupProcessForm updateGroupProcessForm = (UpdateGroupProcessForm) processForm;
        InlongGroupInfo groupInfo = updateGroupProcessForm.getGroupInfo();
        return groupInfo.getZookeeperEnabled() == 0 && !groupInfo.getMiddlewareType().equals(Constant.MIDDLEWARE_NONE);
    } else {
        return false;
    }
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)

Example 4 with UpdateGroupProcessForm

use of org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm in project incubator-inlong by apache.

the class InlongGroupProcessOperation method deleteProcess.

/**
 * Delete resource application group logically and delete related resource
 */
public boolean deleteProcess(String groupId, String operator) {
    LOGGER.info("begin to delete process, groupId = {}, operator = {}", groupId, operator);
    try {
        UpdateGroupProcessForm form = genUpdateGroupProcessForm(groupId, OperateType.DELETE);
        workflowService.start(ProcessName.DELETE_GROUP_PROCESS, operator, form);
    } catch (Exception ex) {
        LOGGER.error("exception while delete process, groupId = {}, operator = {}", groupId, operator, ex);
        throw ex;
    }
    return groupService.delete(groupId, operator);
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)

Example 5 with UpdateGroupProcessForm

use of org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm in project incubator-inlong by apache.

the class InlongGroupProcessOperation method suspendProcess.

/**
 * Suspend resource application group which is started up successfully,
 * stop source and sort task related to application group asynchronously,
 * persist the application status if necessary.
 *
 * @return Workflow result
 */
public WorkflowResult suspendProcess(String groupId, String operator) {
    LOGGER.info("begin to suspend process, groupId = {}, operator = {}", groupId, operator);
    groupService.updateStatus(groupId, GroupState.SUSPENDING.getCode(), operator);
    UpdateGroupProcessForm form = genUpdateGroupProcessForm(groupId, OperateType.SUSPEND);
    return workflowService.start(ProcessName.SUSPEND_GROUP_PROCESS, operator, form);
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)

Aggregations

UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)17 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)9 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)7 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)6 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)6 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)6 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)6 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)6 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)6 Test (org.junit.Test)6 MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)4 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)4 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)3 OperateType (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm.OperateType)3 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)3 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)3 SourceResponse (org.apache.inlong.manager.common.pojo.source.SourceResponse)2 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)2 Lists (com.google.common.collect.Lists)1 List (java.util.List)1