Search in sources :

Example 1 with StreamSinkEntity

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

the class ClickHouseStreamSinkOperation method saveOpt.

@Override
public Integer saveOpt(SinkRequest request, String operator) {
    String sinkType = request.getSinkType();
    Preconditions.checkTrue(Constant.SINK_CLICKHOUSE.equals(sinkType), ErrorCodeEnum.SINK_TYPE_NOT_SUPPORT.getMessage() + ": " + sinkType);
    ClickHouseSinkRequest sinkRequest = (ClickHouseSinkRequest) request;
    StreamSinkEntity entity = CommonBeanUtils.copyProperties(sinkRequest, StreamSinkEntity::new);
    entity.setStatus(EntityStatus.SINK_NEW.getCode());
    entity.setIsDeleted(EntityStatus.UN_DELETED.getCode());
    entity.setCreator(operator);
    entity.setModifier(operator);
    Date now = new Date();
    entity.setCreateTime(now);
    entity.setModifyTime(now);
    // get the ext params
    ClickHouseSinkDTO dto = ClickHouseSinkDTO.getFromRequest(sinkRequest);
    try {
        entity.setExtParams(objectMapper.writeValueAsString(dto));
    } catch (Exception e) {
        throw new BusinessException(ErrorCodeEnum.SINK_SAVE_FAILED);
    }
    sinkMapper.insert(entity);
    Integer sinkId = entity.getId();
    request.setId(sinkId);
    this.saveFieldOpt(request);
    return sinkId;
}
Also used : ClickHouseSinkRequest(org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkRequest) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) ClickHouseSinkDTO(org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkDTO) StreamSinkEntity(org.apache.inlong.manager.dao.entity.StreamSinkEntity) Date(java.util.Date) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException)

Example 2 with StreamSinkEntity

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

the class ClickHouseStreamSinkOperation method updateOpt.

@Override
public void updateOpt(SinkRequest request, String operator) {
    String sinkType = request.getSinkType();
    Preconditions.checkTrue(Constant.SINK_CLICKHOUSE.equals(sinkType), String.format(Constant.SINK_TYPE_NOT_SAME, Constant.SINK_CLICKHOUSE, sinkType));
    StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(request.getId());
    Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
    ClickHouseSinkRequest sinkRequest = (ClickHouseSinkRequest) request;
    CommonBeanUtils.copyProperties(sinkRequest, entity, true);
    try {
        ClickHouseSinkDTO dto = ClickHouseSinkDTO.getFromRequest(sinkRequest);
        entity.setExtParams(objectMapper.writeValueAsString(dto));
    } catch (Exception e) {
        throw new BusinessException(ErrorCodeEnum.SINK_INFO_INCORRECT.getMessage());
    }
    entity.setPreviousStatus(entity.getStatus());
    entity.setStatus(EntityStatus.GROUP_CONFIG_ING.getCode());
    entity.setModifier(operator);
    entity.setModifyTime(new Date());
    sinkMapper.updateByPrimaryKeySelective(entity);
    boolean onlyAdd = EntityStatus.SINK_CONFIG_SUCCESSFUL.getCode().equals(entity.getPreviousStatus());
    this.updateFieldOpt(onlyAdd, sinkRequest);
    LOGGER.info("success to update sink of type={}", sinkType);
}
Also used : ClickHouseSinkRequest(org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkRequest) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) ClickHouseSinkDTO(org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkDTO) StreamSinkEntity(org.apache.inlong.manager.dao.entity.StreamSinkEntity) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) Date(java.util.Date)

Example 3 with StreamSinkEntity

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

the class HiveStreamSinkOperation method getById.

@Override
public SinkResponse getById(@NotNull String sinkType, @NotNull Integer id) {
    StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(id);
    Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
    String existType = entity.getSinkType();
    Preconditions.checkTrue(Constant.SINK_HIVE.equals(existType), String.format(Constant.SINK_TYPE_NOT_SAME, Constant.SINK_HIVE, existType));
    SinkResponse response = this.getFromEntity(entity, HiveSinkResponse::new);
    List<StreamSinkFieldEntity> entities = sinkFieldMapper.selectBySinkId(id);
    List<SinkFieldResponse> infos = CommonBeanUtils.copyListProperties(entities, SinkFieldResponse::new);
    response.setFieldList(infos);
    return response;
}
Also used : SinkResponse(org.apache.inlong.manager.common.pojo.sink.SinkResponse) HiveSinkResponse(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkResponse) HiveSinkResponse(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkResponse) StreamSinkEntity(org.apache.inlong.manager.dao.entity.StreamSinkEntity) SinkFieldResponse(org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse) StreamSinkFieldEntity(org.apache.inlong.manager.dao.entity.StreamSinkFieldEntity)

Example 4 with StreamSinkEntity

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

the class HiveStreamSinkOperation method saveOpt.

@Override
public Integer saveOpt(SinkRequest request, String operator) {
    String sinkType = request.getSinkType();
    Preconditions.checkTrue(Constant.SINK_HIVE.equals(sinkType), ErrorCodeEnum.SINK_TYPE_NOT_SUPPORT.getMessage() + ": " + sinkType);
    HiveSinkRequest hiveRequest = (HiveSinkRequest) request;
    StreamSinkEntity entity = CommonBeanUtils.copyProperties(hiveRequest, StreamSinkEntity::new);
    entity.setStatus(EntityStatus.SINK_NEW.getCode());
    entity.setIsDeleted(EntityStatus.UN_DELETED.getCode());
    entity.setCreator(operator);
    entity.setModifier(operator);
    Date now = new Date();
    entity.setCreateTime(now);
    entity.setModifyTime(now);
    // get the ext params
    HiveSinkDTO dto = HiveSinkDTO.getFromRequest(hiveRequest);
    try {
        entity.setExtParams(objectMapper.writeValueAsString(dto));
    } catch (Exception e) {
        throw new BusinessException(ErrorCodeEnum.SINK_SAVE_FAILED);
    }
    sinkMapper.insert(entity);
    Integer sinkId = entity.getId();
    request.setId(sinkId);
    this.saveFieldOpt(request);
    return sinkId;
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) HiveSinkRequest(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkRequest) HiveSinkDTO(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkDTO) StreamSinkEntity(org.apache.inlong.manager.dao.entity.StreamSinkEntity) Date(java.util.Date) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException)

Example 5 with StreamSinkEntity

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

the class HiveStreamSinkOperation method updateOpt.

@Override
public void updateOpt(SinkRequest request, String operator) {
    String sinkType = request.getSinkType();
    Preconditions.checkTrue(Constant.SINK_HIVE.equals(sinkType), String.format(Constant.SINK_TYPE_NOT_SAME, Constant.SINK_HIVE, sinkType));
    StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(request.getId());
    Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
    HiveSinkRequest hiveRequest = (HiveSinkRequest) request;
    CommonBeanUtils.copyProperties(hiveRequest, entity, true);
    try {
        HiveSinkDTO dto = HiveSinkDTO.getFromRequest(hiveRequest);
        entity.setExtParams(objectMapper.writeValueAsString(dto));
    } catch (Exception e) {
        throw new BusinessException(ErrorCodeEnum.SINK_INFO_INCORRECT.getMessage());
    }
    entity.setPreviousStatus(entity.getStatus());
    entity.setStatus(EntityStatus.GROUP_CONFIG_ING.getCode());
    entity.setModifier(operator);
    entity.setModifyTime(new Date());
    sinkMapper.updateByPrimaryKeySelective(entity);
    boolean onlyAdd = EntityStatus.SINK_CONFIG_SUCCESSFUL.getCode().equals(entity.getPreviousStatus());
    this.updateFieldOpt(onlyAdd, hiveRequest);
    LOGGER.info("success to update sink of type={}", sinkType);
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) HiveSinkRequest(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkRequest) HiveSinkDTO(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkDTO) StreamSinkEntity(org.apache.inlong.manager.dao.entity.StreamSinkEntity) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) Date(java.util.Date)

Aggregations

StreamSinkEntity (org.apache.inlong.manager.dao.entity.StreamSinkEntity)18 Date (java.util.Date)12 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)8 SinkResponse (org.apache.inlong.manager.common.pojo.sink.SinkResponse)5 SinkFieldResponse (org.apache.inlong.manager.common.pojo.sink.SinkFieldResponse)4 StreamSinkFieldEntity (org.apache.inlong.manager.dao.entity.StreamSinkFieldEntity)4 Transactional (org.springframework.transaction.annotation.Transactional)4 SinkApproveDTO (org.apache.inlong.manager.common.pojo.sink.SinkApproveDTO)2 ClickHouseSinkDTO (org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkDTO)2 ClickHouseSinkRequest (org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkRequest)2 HiveSinkDTO (org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkDTO)2 HiveSinkRequest (org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkRequest)2 IcebergSinkDTO (org.apache.inlong.manager.common.pojo.sink.iceberg.IcebergSinkDTO)2 IcebergSinkRequest (org.apache.inlong.manager.common.pojo.sink.iceberg.IcebergSinkRequest)2 KafkaSinkDTO (org.apache.inlong.manager.common.pojo.sink.kafka.KafkaSinkDTO)2 InlongGroupEntity (org.apache.inlong.manager.dao.entity.InlongGroupEntity)2 Page (com.github.pagehelper.Page)1 PageHelper (com.github.pagehelper.PageHelper)1 PageInfo (com.github.pagehelper.PageInfo)1 Lists (com.google.common.collect.Lists)1