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;
}
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();
}
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;
}
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;
}
Aggregations