Search in sources :

Example 6 with InlongGroupPulsarInfo

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

the class InlongGroupProcessOperationTest method before.

public void before(int status) {
    MockPlugin mockPlugin = new MockPlugin();
    serviceTaskListenerFactory.acceptPlugin(mockPlugin);
    InlongGroupRequest groupInfo = new InlongGroupRequest();
    groupInfo.setInlongGroupId(GROUP_ID);
    groupInfo.setName(GROUP_NAME);
    groupInfo.setInCharges(OPERATOR);
    groupInfo.setMiddlewareType(Constant.MIDDLEWARE_PULSAR);
    InlongGroupPulsarInfo pulsarInfo = new InlongGroupPulsarInfo();
    pulsarInfo.setInlongGroupId(GROUP_ID);
    groupInfo.setMqExtInfo(pulsarInfo);
    groupService.save(groupInfo, OPERATOR);
    groupService.update(groupInfo, OPERATOR);
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) InlongGroupRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupRequest)

Example 7 with InlongGroupPulsarInfo

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

Example 8 with InlongGroupPulsarInfo

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

the class InlongGroupServiceImpl method get.

@Override
public InlongGroupInfo get(String groupId) {
    LOGGER.debug("begin to get inlong group info by groupId={}", groupId);
    Preconditions.checkNotNull(groupId, Constant.GROUP_ID_IS_EMPTY);
    InlongGroupEntity entity = groupMapper.selectByGroupId(groupId);
    if (entity == null) {
        LOGGER.error("inlong group not found by groupId={}", groupId);
        throw new BusinessException(ErrorCodeEnum.GROUP_NOT_FOUND);
    }
    InlongGroupInfo groupInfo = CommonBeanUtils.copyProperties(entity, InlongGroupInfo::new);
    List<InlongGroupExtEntity> extEntityList = groupExtMapper.selectByGroupId(groupId);
    List<InlongGroupExtInfo> extInfoList = CommonBeanUtils.copyListProperties(extEntityList, InlongGroupExtInfo::new);
    groupInfo.setExtList(extInfoList);
    // If the middleware is Pulsar, we need to encapsulate Pulsar related data
    String mqType = entity.getMiddlewareType();
    if (Constant.MIDDLEWARE_PULSAR.equals(mqType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(mqType)) {
        InlongGroupPulsarEntity pulsarEntity = groupPulsarMapper.selectByGroupId(groupId);
        Preconditions.checkNotNull(pulsarEntity, "Pulsar info not found by the groupId=" + groupId);
        InlongGroupPulsarInfo pulsarInfo = CommonBeanUtils.copyProperties(pulsarEntity, InlongGroupPulsarInfo::new);
        pulsarInfo.setMiddlewareType(mqType);
        groupInfo.setMqExtInfo(pulsarInfo);
    }
    // For approved inlong group, encapsulate the cluster address of the middleware
    if (GroupState.CONFIG_SUCCESSFUL == GroupState.forCode(groupInfo.getStatus())) {
        if (Constant.MIDDLEWARE_TUBE.equalsIgnoreCase(mqType)) {
            groupInfo.setTubeMaster(commonOperateService.getSpecifiedParam(Constant.TUBE_MASTER_URL));
        } else if (Constant.MIDDLEWARE_PULSAR.equals(mqType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(mqType)) {
            PulsarClusterInfo pulsarCluster = commonOperateService.getPulsarClusterInfo(mqType);
            groupInfo.setPulsarAdminUrl(pulsarCluster.getAdminUrl());
            groupInfo.setPulsarServiceUrl(pulsarCluster.getBrokerServiceUrl());
        }
    }
    LOGGER.debug("success to get inlong group for groupId={}", groupId);
    return groupInfo;
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) InlongGroupExtEntity(org.apache.inlong.manager.dao.entity.InlongGroupExtEntity) InlongGroupPulsarEntity(org.apache.inlong.manager.dao.entity.InlongGroupPulsarEntity) PulsarClusterInfo(org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)

Example 9 with InlongGroupPulsarInfo

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

the class WorkflowServiceImplTest method initGroupForm.

/**
 * Init inlong group form
 */
public InlongGroupInfo initGroupForm(String middlewareType) {
    processName = ProcessName.CREATE_GROUP_RESOURCE;
    applicant = OPERATOR;
    try {
        streamService.logicDeleteAll(GROUP_ID, OPERATOR);
        groupService.delete(GROUP_ID, OPERATOR);
    } catch (Exception e) {
    // ignore
    }
    InlongGroupInfo groupInfo = new InlongGroupInfo();
    groupInfo.setName("test");
    groupInfo.setInCharges(OPERATOR);
    groupInfo.setInlongGroupId("b_test");
    groupInfo.setMiddlewareType(middlewareType);
    groupInfo.setMqExtInfo(new InlongGroupPulsarInfo());
    groupInfo.setMqResourceObj("test-queue");
    groupService.save(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.TO_BE_APPROVAL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.APPROVE_PASSED.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    groupInfo.setStatus(GroupState.CONFIG_ING.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    form = new GroupResourceProcessForm();
    form.setInlongStreamId(STREAM_ID);
    form.setGroupInfo(groupInfo);
    return groupInfo;
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)

Example 10 with InlongGroupPulsarInfo

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

the class InlongGroupServiceImpl method update.

@Transactional(rollbackFor = Throwable.class)
@Override
public String update(InlongGroupRequest groupRequest, String operator) {
    LOGGER.debug("begin to update inlong group={}", groupRequest);
    Preconditions.checkNotNull(groupRequest, "inlong group is empty");
    String groupId = groupRequest.getInlongGroupId();
    Preconditions.checkNotNull(groupId, Constant.GROUP_ID_IS_EMPTY);
    InlongGroupEntity entity = groupMapper.selectByGroupId(groupId);
    if (entity == null) {
        LOGGER.error("inlong group not found by groupId={}", groupId);
        throw new BusinessException(ErrorCodeEnum.GROUP_NOT_FOUND);
    }
    // Check whether the current status can be modified
    this.checkGroupCanUpdate(entity, groupRequest, operator);
    CommonBeanUtils.copyProperties(groupRequest, entity, true);
    if (GroupState.CONFIG_FAILED.getCode().equals(entity.getStatus())) {
        entity.setStatus(GroupState.TO_BE_SUBMIT.getCode());
    }
    entity.setModifier(operator);
    groupMapper.updateByIdentifierSelective(entity);
    // Save extended information
    this.saveOrUpdateExt(groupId, groupRequest.getExtList());
    // Update the Pulsar info
    String mqType = groupRequest.getMiddlewareType();
    if (Constant.MIDDLEWARE_PULSAR.equals(mqType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(mqType)) {
        InlongGroupPulsarInfo pulsarInfo = (InlongGroupPulsarInfo) groupRequest.getMqExtInfo();
        Preconditions.checkNotNull(pulsarInfo, "Pulsar info cannot be empty, as the middleware is Pulsar");
        Integer writeQuorum = pulsarInfo.getWriteQuorum();
        Integer ackQuorum = pulsarInfo.getAckQuorum();
        if (!(ackQuorum <= writeQuorum)) {
            throw new BusinessException(ErrorCodeEnum.GROUP_SAVE_FAILED, "Pulsar params must meet: ackQuorum <= writeQuorum");
        }
        InlongGroupPulsarEntity pulsarEntity = CommonBeanUtils.copyProperties(pulsarInfo, InlongGroupPulsarEntity::new);
        pulsarEntity.setInlongGroupId(groupId);
        groupPulsarMapper.updateByIdentifierSelective(pulsarEntity);
    }
    LOGGER.debug("success to update inlong group for groupId={}", groupId);
    return groupId;
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) InlongGroupPulsarEntity(org.apache.inlong.manager.dao.entity.InlongGroupPulsarEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)13 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)4 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)3 InlongGroupExtInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)3 InlongGroupEntity (org.apache.inlong.manager.dao.entity.InlongGroupEntity)3 InlongGroupPulsarEntity (org.apache.inlong.manager.dao.entity.InlongGroupPulsarEntity)3 JsonObject (com.google.gson.JsonObject)2 PulsarBaseConf (org.apache.inlong.manager.client.api.PulsarBaseConf)2 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)2 Transactional (org.springframework.transaction.annotation.Transactional)2 TypeToken (com.google.common.reflect.TypeToken)1 JsonArray (com.google.gson.JsonArray)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)1 FlinkSortBaseConf (org.apache.inlong.manager.client.api.FlinkSortBaseConf)1 MqBaseConf (org.apache.inlong.manager.client.api.MqBaseConf)1 SortBaseConf (org.apache.inlong.manager.client.api.SortBaseConf)1 SortType (org.apache.inlong.manager.client.api.SortBaseConf.SortType)1