Search in sources :

Example 16 with InlongStreamEntity

use of org.apache.inlong.manager.dao.entity.InlongStreamEntity in project incubator-inlong by apache.

the class InlongStreamServiceImpl method get.

@Override
public InlongStreamInfo get(String groupId, String streamId) {
    LOGGER.debug("begin to get inlong stream by groupId={}, streamId={}", groupId, streamId);
    Preconditions.checkNotNull(groupId, Constant.GROUP_ID_IS_EMPTY);
    Preconditions.checkNotNull(streamId, Constant.STREAM_ID_IS_EMPTY);
    InlongStreamEntity streamEntity = streamMapper.selectByIdentifier(groupId, streamId);
    if (streamEntity == null) {
        LOGGER.error("inlong stream not found by groupId={}, streamId={}", groupId, streamId);
        throw new BusinessException(ErrorCodeEnum.STREAM_NOT_FOUND);
    }
    InlongStreamInfo streamInfo = CommonBeanUtils.copyProperties(streamEntity, InlongStreamInfo::new);
    this.setStreamExtAndField(groupId, streamId, streamInfo);
    LOGGER.info("success to get inlong stream for groupId={}", groupId);
    return streamInfo;
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 17 with InlongStreamEntity

use of org.apache.inlong.manager.dao.entity.InlongStreamEntity in project incubator-inlong by apache.

the class InlongStreamServiceImpl method save.

@Transactional(rollbackFor = Throwable.class)
@Override
public Integer save(InlongStreamInfo streamInfo, String operator) {
    LOGGER.debug("begin to save inlong stream info={}", streamInfo);
    Preconditions.checkNotNull(streamInfo, "inlong stream info is empty");
    String groupId = streamInfo.getInlongGroupId();
    String streamId = streamInfo.getInlongStreamId();
    Preconditions.checkNotNull(groupId, Constant.GROUP_ID_IS_EMPTY);
    Preconditions.checkNotNull(streamId, Constant.STREAM_ID_IS_EMPTY);
    // Check if it can be added
    checkBizIsTempStatus(groupId);
    // The streamId under the same groupId cannot be repeated
    Integer count = streamMapper.selectExistByIdentifier(groupId, streamId);
    if (count >= 1) {
        LOGGER.error("inlong stream id [{}] has already exists", streamId);
        throw new BusinessException(ErrorCodeEnum.STREAM_ID_DUPLICATE);
    }
    if (StringUtils.isEmpty(streamInfo.getMqResourceObj())) {
        streamInfo.setMqResourceObj(streamId);
    }
    // Processing inlong stream
    InlongStreamEntity streamEntity = CommonBeanUtils.copyProperties(streamInfo, InlongStreamEntity::new);
    Date date = new Date();
    streamEntity.setStatus(EntityStatus.STREAM_NEW.getCode());
    streamEntity.setModifier(operator);
    streamEntity.setCreateTime(date);
    streamMapper.insertSelective(streamEntity);
    // Processing extended information
    this.saveExt(groupId, streamId, streamInfo.getExtList(), date);
    // WorkflowProcess data source fields
    this.saveField(groupId, streamId, streamInfo.getFieldList());
    LOGGER.info("success to save inlong stream info for groupId={}", groupId);
    return streamEntity.getId();
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity) Date(java.util.Date) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with InlongStreamEntity

use of org.apache.inlong.manager.dao.entity.InlongStreamEntity in project incubator-inlong by apache.

the class InlongStreamServiceImpl method delete.

@Transactional(rollbackFor = Throwable.class)
@Override
public boolean delete(String groupId, String streamId, String operator) {
    LOGGER.debug("begin to delete inlong stream, groupId={}, streamId={}", groupId, streamId);
    Preconditions.checkNotNull(groupId, Constant.GROUP_ID_IS_EMPTY);
    Preconditions.checkNotNull(streamId, Constant.STREAM_ID_IS_EMPTY);
    // Check if it can be deleted
    InlongGroupEntity inlongGroupEntity = this.checkBizIsTempStatus(groupId);
    InlongStreamEntity entity = streamMapper.selectByIdentifier(groupId, streamId);
    if (entity == null) {
        LOGGER.error("inlong stream not found by groupId={}, streamId={}", groupId, streamId);
        throw new BusinessException(ErrorCodeEnum.STREAM_NOT_FOUND);
    }
    // If there is an undeleted data source, the deletion fails
    boolean dataSourceExist = hasDataSource(groupId, streamId, entity.getDataSourceType());
    if (dataSourceExist) {
        LOGGER.error("inlong stream has undeleted data sources, delete failed");
        throw new BusinessException(ErrorCodeEnum.STREAM_DELETE_HAS_SOURCE);
    }
    // If there is undeleted data sink information, the deletion fails
    int sinkCount = sinkService.getCount(groupId, streamId);
    if (sinkCount > 0) {
        LOGGER.error("inlong stream has undeleted sinks, delete failed");
        throw new BusinessException(ErrorCodeEnum.STREAM_DELETE_HAS_SINK);
    }
    entity.setIsDeleted(1);
    entity.setModifier(operator);
    streamMapper.updateByPrimaryKey(entity);
    // To logically delete the associated extension table
    LOGGER.debug("begin to delete inlong stream ext property, groupId={}, streamId={}", groupId, streamId);
    streamExtMapper.logicDeleteAllByIdentifier(groupId, streamId);
    // Logically delete the associated field table
    LOGGER.debug("begin to delete inlong stream field, streamId={}", streamId);
    streamFieldMapper.logicDeleteAllByIdentifier(groupId, streamId);
    LOGGER.info("success to delete inlong stream, ext property and fields for groupId={}", groupId);
    return true;
}
Also used : InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 19 with InlongStreamEntity

use of org.apache.inlong.manager.dao.entity.InlongStreamEntity in project incubator-inlong by apache.

the class InlongStreamServiceImpl method updateAfterApprove.

@Override
public boolean updateAfterApprove(List<InlongStreamApproveRequest> streamApproveList, String operator) {
    if (CollectionUtils.isEmpty(streamApproveList)) {
        return true;
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("begin to update stream after approve={}", streamApproveList);
    }
    String groupId = null;
    for (InlongStreamApproveRequest info : streamApproveList) {
        // Modify the inlong stream info after approve
        InlongStreamEntity streamEntity = new InlongStreamEntity();
        // these groupIds are all the same
        groupId = info.getInlongGroupId();
        streamEntity.setInlongGroupId(groupId);
        streamEntity.setInlongStreamId(info.getInlongStreamId());
        streamEntity.setStatus(EntityStatus.STREAM_CONFIG_ING.getCode());
        streamMapper.updateByIdentifierSelective(streamEntity);
        // Modify the sink info after approve, such as update cluster info
        sinkService.updateAfterApprove(info.getSinkList(), operator);
    }
    LOGGER.info("success to update stream after approve for groupId={}", groupId);
    return true;
}
Also used : InlongStreamApproveRequest(org.apache.inlong.manager.common.pojo.stream.InlongStreamApproveRequest) InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity)

Aggregations

InlongStreamEntity (org.apache.inlong.manager.dao.entity.InlongStreamEntity)19 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)7 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)5 InlongGroupEntity (org.apache.inlong.manager.dao.entity.InlongGroupEntity)5 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)4 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)4 Transactional (org.springframework.transaction.annotation.Transactional)4 ArrayList (java.util.ArrayList)3 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)3 WorkflowListenerException (org.apache.inlong.manager.common.exceptions.WorkflowListenerException)3 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)3 Date (java.util.Date)2 DataProxyConfig (org.apache.inlong.common.pojo.dataproxy.DataProxyConfig)2 PulsarTopicBean (org.apache.inlong.manager.common.pojo.pulsar.PulsarTopicBean)2 Page (com.github.pagehelper.Page)1 PageInfo (com.github.pagehelper.PageInfo)1 LocalDateTime (java.time.LocalDateTime)1 List (java.util.List)1 DataConfig (org.apache.inlong.common.pojo.agent.DataConfig)1 ThirdPartyClusterDTO (org.apache.inlong.common.pojo.dataproxy.ThirdPartyClusterDTO)1