Search in sources :

Example 1 with SourceDbDetailInfo

use of org.apache.inlong.manager.common.pojo.source.SourceDbDetailInfo in project incubator-inlong by apache.

the class SourceDbServiceImpl method getDetailById.

@Override
public SourceDbDetailInfo getDetailById(Integer id) {
    LOGGER.info("begin to get db data source detail by id={}", id);
    Preconditions.checkNotNull(id, "db data source detail's id is null");
    SourceDbDetailEntity entity = dbDetailMapper.selectByPrimaryKey(id);
    if (entity == null) {
        LOGGER.error("db data source detail not found by id={}", id);
        throw new BusinessException(ErrorCodeEnum.SOURCE_DETAIL_NOT_FOUND);
    }
    SourceDbDetailInfo detailInfo = CommonBeanUtils.copyProperties(entity, SourceDbDetailInfo::new);
    LOGGER.info("success to get db data source detail");
    return detailInfo;
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) SourceDbDetailInfo(org.apache.inlong.manager.common.pojo.source.SourceDbDetailInfo) SourceDbDetailEntity(org.apache.inlong.manager.dao.entity.SourceDbDetailEntity)

Example 2 with SourceDbDetailInfo

use of org.apache.inlong.manager.common.pojo.source.SourceDbDetailInfo in project incubator-inlong by apache.

the class InlongStreamServiceImpl method listAllWithGroupId.

@Override
public PageInfo<FullStreamResponse> listAllWithGroupId(InlongStreamPageRequest request) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("begin to list full inlong stream page by {}", request);
    }
    Preconditions.checkNotNull(request, "request is empty");
    Preconditions.checkNotNull(request.getInlongGroupId(), Constant.GROUP_ID_IS_EMPTY);
    // 1. Query all valid data sources under groupId
    String groupId = request.getInlongGroupId();
    // The person in charge of the inlong group has the authority of all inlong streams
    InlongGroupEntity inlongGroupEntity = groupMapper.selectByGroupId(groupId);
    Preconditions.checkNotNull(inlongGroupEntity, "inlong group not found by groupId=" + groupId);
    String inCharges = inlongGroupEntity.getInCharges();
    request.setInCharges(inCharges);
    PageHelper.startPage(request.getPageNum(), request.getPageSize());
    Page<InlongStreamEntity> page = (Page<InlongStreamEntity>) streamMapper.selectByCondition(request);
    List<InlongStreamInfo> streamInfoList = CommonBeanUtils.copyListProperties(page, InlongStreamInfo::new);
    // Convert and encapsulate the paged results
    List<FullStreamResponse> responseList = new ArrayList<>(streamInfoList.size());
    for (InlongStreamInfo streamInfo : streamInfoList) {
        // 2.1 Set the extended information and field information of the inlong stream
        String streamId = streamInfo.getInlongStreamId();
        setStreamExtAndField(groupId, streamId, streamInfo);
        // 2.3 Set the inlong stream to the result sub-object
        FullStreamResponse pageInfo = new FullStreamResponse();
        pageInfo.setStreamInfo(streamInfo);
        // 3. Query the basic and detailed information of the data source
        String dataSourceType = streamInfo.getDataSourceType();
        if (StringUtils.isEmpty(dataSourceType)) {
            continue;
        }
        switch(dataSourceType.toUpperCase(Locale.ROOT)) {
            case Constant.DATA_SOURCE_FILE:
                SourceFileBasicInfo fileBasicInfo = sourceFileService.getBasicByIdentifier(groupId, streamId);
                pageInfo.setFileBasicInfo(fileBasicInfo);
                List<SourceFileDetailInfo> fileDetailInfoList = sourceFileService.listDetailByIdentifier(groupId, streamId);
                pageInfo.setFileDetailInfoList(fileDetailInfoList);
                break;
            case Constant.DATA_SOURCE_DB:
                SourceDbBasicInfo dbBasicInfo = sourceDbService.getBasicByIdentifier(groupId, streamId);
                pageInfo.setDbBasicInfo(dbBasicInfo);
                List<SourceDbDetailInfo> dbDetailInfoList = sourceDbService.listDetailByIdentifier(groupId, streamId);
                pageInfo.setDbDetailInfoList(dbDetailInfoList);
                break;
            case Constant.DATA_SOURCE_AUTO_PUSH:
                break;
            default:
                throw new BusinessException(ErrorCodeEnum.SOURCE_TYPE_NOT_SUPPORTED);
        }
        // 4. Query stream sources information
        List<SourceResponse> sourceList = sourceService.listSource(groupId, streamId);
        pageInfo.setSourceInfo(sourceList);
        // 5. Query various stream sinks and its extended information, field information
        List<SinkResponse> sinkList = sinkService.listSink(groupId, streamId);
        pageInfo.setSinkInfo(sinkList);
        // 6. Add a single result to the paginated list
        responseList.add(pageInfo);
    }
    PageInfo<FullStreamResponse> pageInfo = new PageInfo<>(responseList);
    pageInfo.setTotal(pageInfo.getTotal());
    LOGGER.debug("success to list full inlong stream info");
    return pageInfo;
}
Also used : SourceDbBasicInfo(org.apache.inlong.manager.common.pojo.source.SourceDbBasicInfo) SourceResponse(org.apache.inlong.manager.common.pojo.source.SourceResponse) ArrayList(java.util.ArrayList) Page(com.github.pagehelper.Page) SourceFileDetailInfo(org.apache.inlong.manager.common.pojo.source.SourceFileDetailInfo) InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) PageInfo(com.github.pagehelper.PageInfo) SinkResponse(org.apache.inlong.manager.common.pojo.sink.SinkResponse) InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity) FullStreamResponse(org.apache.inlong.manager.common.pojo.stream.FullStreamResponse) SourceDbDetailInfo(org.apache.inlong.manager.common.pojo.source.SourceDbDetailInfo) SourceFileBasicInfo(org.apache.inlong.manager.common.pojo.source.SourceFileBasicInfo) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 3 with SourceDbDetailInfo

use of org.apache.inlong.manager.common.pojo.source.SourceDbDetailInfo in project incubator-inlong by apache.

the class InlongStreamServiceImpl method saveAll.

@Transactional(rollbackFor = Throwable.class)
@Override
public boolean saveAll(FullStreamRequest fullStreamRequest, String operator) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("begin to save all stream page info: {}", fullStreamRequest);
    }
    Preconditions.checkNotNull(fullStreamRequest, "fullStreamRequest is empty");
    InlongStreamInfo streamInfo = fullStreamRequest.getStreamInfo();
    Preconditions.checkNotNull(streamInfo, "inlong stream info is empty");
    // Check whether it can be added: check by lower-level specific services
    // this.checkBizIsTempStatus(streamInfo.getInlongGroupId());
    // 1. Save inlong stream
    this.save(streamInfo, operator);
    // 2.1 Save file data source information
    if (fullStreamRequest.getFileBasicInfo() != null) {
        sourceFileService.saveBasic(fullStreamRequest.getFileBasicInfo(), operator);
    }
    if (CollectionUtils.isNotEmpty(fullStreamRequest.getFileDetailInfoList())) {
        for (SourceFileDetailInfo detailInfo : fullStreamRequest.getFileDetailInfoList()) {
            sourceFileService.saveDetail(detailInfo, operator);
        }
    }
    // 2.2 Save DB data source information
    if (fullStreamRequest.getDbBasicInfo() != null) {
        sourceDbService.saveBasic(fullStreamRequest.getDbBasicInfo(), operator);
    }
    if (CollectionUtils.isNotEmpty(fullStreamRequest.getDbDetailInfoList())) {
        for (SourceDbDetailInfo detailInfo : fullStreamRequest.getDbDetailInfoList()) {
            sourceDbService.saveDetail(detailInfo, operator);
        }
    }
    // 3. Save data sink information
    if (CollectionUtils.isNotEmpty(fullStreamRequest.getSinkInfo())) {
        for (SinkRequest sinkInfo : fullStreamRequest.getSinkInfo()) {
            sinkService.save(sinkInfo, operator);
        }
    }
    LOGGER.info("success to save all stream page info");
    return true;
}
Also used : SourceDbDetailInfo(org.apache.inlong.manager.common.pojo.source.SourceDbDetailInfo) SourceFileDetailInfo(org.apache.inlong.manager.common.pojo.source.SourceFileDetailInfo) SinkRequest(org.apache.inlong.manager.common.pojo.sink.SinkRequest) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SourceDbDetailInfo (org.apache.inlong.manager.common.pojo.source.SourceDbDetailInfo)3 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)2 SourceFileDetailInfo (org.apache.inlong.manager.common.pojo.source.SourceFileDetailInfo)2 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)2 Page (com.github.pagehelper.Page)1 PageInfo (com.github.pagehelper.PageInfo)1 ArrayList (java.util.ArrayList)1 SinkRequest (org.apache.inlong.manager.common.pojo.sink.SinkRequest)1 SinkResponse (org.apache.inlong.manager.common.pojo.sink.SinkResponse)1 SourceDbBasicInfo (org.apache.inlong.manager.common.pojo.source.SourceDbBasicInfo)1 SourceFileBasicInfo (org.apache.inlong.manager.common.pojo.source.SourceFileBasicInfo)1 SourceResponse (org.apache.inlong.manager.common.pojo.source.SourceResponse)1 FullStreamResponse (org.apache.inlong.manager.common.pojo.stream.FullStreamResponse)1 InlongGroupEntity (org.apache.inlong.manager.dao.entity.InlongGroupEntity)1 InlongStreamEntity (org.apache.inlong.manager.dao.entity.InlongStreamEntity)1 SourceDbDetailEntity (org.apache.inlong.manager.dao.entity.SourceDbDetailEntity)1 Transactional (org.springframework.transaction.annotation.Transactional)1