Search in sources :

Example 1 with FullStreamRequest

use of org.apache.inlong.manager.common.pojo.stream.FullStreamRequest in project incubator-inlong by apache.

the class InlongStreamServiceImpl method batchSaveAll.

@Transactional(rollbackFor = Throwable.class)
@Override
public boolean batchSaveAll(List<FullStreamRequest> fullStreamRequestList, String operator) {
    if (CollectionUtils.isEmpty(fullStreamRequestList)) {
        return true;
    }
    LOGGER.info("begin to batch save all stream page info, batch size={}", fullStreamRequestList.size());
    // Check if it can be added
    InlongStreamInfo firstStream = fullStreamRequestList.get(0).getStreamInfo();
    Preconditions.checkNotNull(firstStream, "inlong stream info is empty");
    String groupId = firstStream.getInlongGroupId();
    this.checkBizIsTempStatus(groupId);
    // This bulk save is only used when creating or editing inlong group after approval is rejected.
    // To ensure data consistency, you need to physically delete all associated data and then add
    // Note: There may be records with the same groupId and streamId in the historical data,
    // and the ones with is_deleted=0 should be deleted
    streamMapper.deleteAllByGroupId(groupId);
    for (FullStreamRequest pageInfo : fullStreamRequestList) {
        // 1.1 Delete the inlong stream extensions and fields corresponding to groupId and streamId
        InlongStreamInfo streamInfo = pageInfo.getStreamInfo();
        String streamId = streamInfo.getInlongStreamId();
        streamExtMapper.deleteAllByIdentifier(groupId, streamId);
        streamFieldMapper.deleteAllByIdentifier(groupId, streamId);
        // 2. Delete file data source, DB data source information
        sourceFileService.deleteAllByIdentifier(groupId, streamId);
        sourceDbService.deleteAllByIdentifier(groupId, streamId);
        // 3. Delete data sink information
        sinkService.deleteAll(groupId, streamId, operator);
        // 4. Save the inlong stream of this batch
        this.saveAll(pageInfo, operator);
    }
    LOGGER.info("success to batch save all stream page info");
    return true;
}
Also used : InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo) FullStreamRequest(org.apache.inlong.manager.common.pojo.stream.FullStreamRequest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

FullStreamRequest (org.apache.inlong.manager.common.pojo.stream.FullStreamRequest)1 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)1 Transactional (org.springframework.transaction.annotation.Transactional)1