Search in sources :

Example 21 with BusinessException

use of org.apache.inlong.manager.common.exceptions.BusinessException in project incubator-inlong by apache.

the class InlongStreamServiceImpl method updateField.

/**
 * Update field information
 * <p/>First physically delete the existing field information, and then add the field information of this batch
 */
@Transactional(rollbackFor = Throwable.class)
void updateField(String groupId, String streamId, List<InlongStreamFieldInfo> fieldInfoList) {
    LOGGER.debug("begin to update inlong stream field, groupId={}, streamId={}, field={}", groupId, streamId, fieldInfoList);
    try {
        streamFieldMapper.deleteAllByIdentifier(groupId, streamId);
        saveField(groupId, streamId, fieldInfoList);
        LOGGER.info("success to update inlong stream field for groupId={}", groupId);
    } catch (Exception e) {
        LOGGER.error("failed to update inlong stream field: ", e);
        throw new BusinessException(ErrorCodeEnum.STREAM_FIELD_SAVE_FAILED);
    }
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with BusinessException

use of org.apache.inlong.manager.common.exceptions.BusinessException in project incubator-inlong by apache.

the class InlongStreamServiceImpl method updateExt.

/**
 * Update extended information
 * <p/>First physically delete the existing extended information, and then add this batch of extended information
 */
@Transactional(rollbackFor = Throwable.class)
void updateExt(String groupId, String streamId, List<InlongStreamExtInfo> extInfoList) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("begin to update inlong stream ext, groupId={}, streamId={}, ext={}", groupId, streamId, extInfoList);
    }
    try {
        streamExtMapper.deleteAllByIdentifier(groupId, streamId);
        saveExt(groupId, streamId, extInfoList, new Date());
        LOGGER.info("success to update inlong stream ext for groupId={}", groupId);
    } catch (Exception e) {
        LOGGER.error("failed to update inlong stream ext: ", e);
        throw new BusinessException(ErrorCodeEnum.STREAM_EXT_SAVE_FAILED);
    }
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) Date(java.util.Date) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with BusinessException

use of org.apache.inlong.manager.common.exceptions.BusinessException in project incubator-inlong by apache.

the class InlongStreamServiceImpl method insertDlqOrRlq.

@Override
public void insertDlqOrRlq(String groupId, String topicName, String operator) {
    Integer count = streamMapper.selectExistByIdentifier(groupId, topicName);
    if (count >= 1) {
        LOGGER.error("DLQ/RLQ topic already exists with name={}", topicName);
        throw new BusinessException(ErrorCodeEnum.STREAM_ID_DUPLICATE, "DLQ/RLQ topic already exists");
    }
    InlongStreamEntity streamEntity = new InlongStreamEntity();
    streamEntity.setInlongGroupId(groupId);
    streamEntity.setInlongStreamId(topicName);
    streamEntity.setMqResourceObj(topicName);
    streamEntity.setDescription("This is DLQ / RLQ topic created by SYSTEM");
    streamEntity.setDailyRecords(1000);
    streamEntity.setDailyStorage(1000);
    streamEntity.setPeakRecords(1000);
    streamEntity.setMaxLength(1000);
    streamEntity.setStatus(EntityStatus.STREAM_CONFIG_SUCCESSFUL.getCode());
    streamEntity.setIsDeleted(EntityStatus.UN_DELETED.getCode());
    streamEntity.setCreator(operator);
    streamEntity.setModifier(operator);
    Date now = new Date();
    streamEntity.setCreateTime(now);
    streamEntity.setModifyTime(now);
    streamMapper.insert(streamEntity);
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity) Date(java.util.Date)

Example 24 with BusinessException

use of org.apache.inlong.manager.common.exceptions.BusinessException in project incubator-inlong by apache.

the class SourceDbServiceImpl method updateDetail.

@Transactional(rollbackFor = Throwable.class)
@Override
public boolean updateDetail(SourceDbDetailInfo detailInfo, String operator) {
    LOGGER.info("begin to update db data source detail={}", detailInfo);
    Preconditions.checkNotNull(detailInfo, "db data source detail is empty");
    Preconditions.checkNotNull(detailInfo.getInlongGroupId(), Constant.GROUP_ID_IS_EMPTY);
    Preconditions.checkNotNull(detailInfo.getInlongStreamId(), Constant.STREAM_ID_IS_EMPTY);
    // The groupId may be modified, it is necessary to determine whether the inlong group status of
    // the modified groupId supports modification
    this.checkGroupIsTempStatus(detailInfo.getInlongGroupId());
    // id exists, update, otherwise add
    if (detailInfo.getId() != null) {
        SourceDbDetailEntity entity = dbDetailMapper.selectByPrimaryKey(detailInfo.getId());
        if (entity == null) {
            LOGGER.error("db data source detail not found by id=" + detailInfo.getId());
            throw new BusinessException(ErrorCodeEnum.SOURCE_DETAIL_NOT_FOUND);
        }
        SourceDbDetailEntity dbEntity = CommonBeanUtils.copyProperties(detailInfo, SourceDbDetailEntity::new);
        dbEntity.setStatus(EntityStatus.GROUP_CONFIG_ING.getCode());
        dbEntity.setModifier(operator);
        dbDetailMapper.updateByPrimaryKeySelective(dbEntity);
    } else {
        saveDetailOpt(detailInfo, operator);
    }
    LOGGER.info("success to update db data source detail");
    return true;
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) SourceDbDetailEntity(org.apache.inlong.manager.dao.entity.SourceDbDetailEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 25 with BusinessException

use of org.apache.inlong.manager.common.exceptions.BusinessException in project incubator-inlong by apache.

the class ConsumptionPassTaskListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    NewConsumptionProcessForm form = (NewConsumptionProcessForm) context.getProcessForm();
    ConsumptionApproveForm approveForm = (ConsumptionApproveForm) context.getActionContext().getForm();
    ConsumptionInfo info = form.getConsumptionInfo();
    if (StringUtils.equals(approveForm.getConsumerGroupId(), info.getConsumerGroupId())) {
        return ListenerResult.success("The consumer group name has not been modified");
    }
    boolean exist = consumptionService.isConsumerGroupIdExists(approveForm.getConsumerGroupId(), info.getId());
    if (exist) {
        log.error("consumerGroupId already exist! duplicate :{}", approveForm.getConsumerGroupId());
        throw new BusinessException(ErrorCodeEnum.CONSUMER_GROUP_NAME_DUPLICATED);
    }
    return ListenerResult.success("Consumer group name from" + info.getConsumerGroupId() + "change to " + approveForm.getConsumerGroupId());
}
Also used : NewConsumptionProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.NewConsumptionProcessForm) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) ConsumptionInfo(org.apache.inlong.manager.common.pojo.consumption.ConsumptionInfo) ConsumptionApproveForm(org.apache.inlong.manager.common.pojo.workflow.form.ConsumptionApproveForm)

Aggregations

BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)58 Date (java.util.Date)20 Transactional (org.springframework.transaction.annotation.Transactional)18 InlongGroupEntity (org.apache.inlong.manager.dao.entity.InlongGroupEntity)14 StreamSinkEntity (org.apache.inlong.manager.dao.entity.StreamSinkEntity)8 InlongStreamEntity (org.apache.inlong.manager.dao.entity.InlongStreamEntity)7 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)6 SourceFileDetailEntity (org.apache.inlong.manager.dao.entity.SourceFileDetailEntity)5 ThirdPartyClusterEntity (org.apache.inlong.manager.dao.entity.ThirdPartyClusterEntity)5 GroupState (org.apache.inlong.manager.common.enums.GroupState)4 InlongGroupPulsarEntity (org.apache.inlong.manager.dao.entity.InlongGroupPulsarEntity)4 SourceDbDetailEntity (org.apache.inlong.manager.dao.entity.SourceDbDetailEntity)4 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)3 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)3 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)3 SourceDbBasicEntity (org.apache.inlong.manager.dao.entity.SourceDbBasicEntity)3 ColumnPositionMappingStrategy (com.opencsv.bean.ColumnPositionMappingStrategy)2 ApiOperation (io.swagger.annotations.ApiOperation)2 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2