Search in sources :

Example 6 with InlongGroupInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo 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 7 with InlongGroupInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo 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 8 with InlongGroupInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo in project incubator-inlong by apache.

the class ZkEnabledEventSelector method accept.

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

Example 9 with InlongGroupInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo in project incubator-inlong by apache.

the class InlongGroupProcessOperationTest method testRestartProcess.

@Test
public void testRestartProcess() {
    testSuspendProcess();
    WorkflowResult result = groupProcessOperation.restartProcess(GROUP_ID, OPERATOR);
    ProcessResponse response = result.getProcessInfo();
    Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
    InlongGroupInfo groupInfo = groupService.get(GROUP_ID);
    Assert.assertEquals(groupInfo.getStatus(), EntityStatus.GROUP_RESTART.getCode());
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 10 with InlongGroupInfo

use of org.apache.inlong.manager.common.pojo.group.InlongGroupInfo in project incubator-inlong by apache.

the class InlongGroupServiceTest method saveGroup.

/**
 * Test to save group
 */
public String saveGroup(String groupName, String operator) {
    InlongGroupInfo groupInfo;
    try {
        groupInfo = groupService.get(globalGroupId);
        if (groupInfo != null) {
            return groupInfo.getInlongGroupId();
        }
    } catch (Exception e) {
    // ignore
    }
    groupInfo = new InlongGroupInfo();
    groupInfo.setName(groupName);
    groupInfo.setMiddlewareType(Constant.MIDDLEWARE_PULSAR);
    groupInfo.setCreator(operator);
    groupInfo.setInCharges(operator);
    groupInfo.setStatus(EntityStatus.GROUP_CONFIG_SUCCESSFUL.getCode());
    InlongGroupPulsarInfo pulsarInfo = new InlongGroupPulsarInfo();
    pulsarInfo.setMiddlewareType(Constant.MIDDLEWARE_PULSAR);
    pulsarInfo.setEnsemble(3);
    pulsarInfo.setWriteQuorum(3);
    pulsarInfo.setAckQuorum(2);
    groupInfo.setMqExtInfo(pulsarInfo);
    return groupService.save(groupInfo.genRequest(), operator);
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)

Aggregations

InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)42 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)18 Test (org.junit.Test)11 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)10 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)10 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)10 WorkflowListenerException (org.apache.inlong.manager.common.exceptions.WorkflowListenerException)9 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)8 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)8 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)6 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)6 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)6 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)5 List (java.util.List)4 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)4 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)4 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)4 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)4 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)4 InlongGroupExtInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)3