Search in sources :

Example 1 with BinlogSourceDTO

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

the class BinlogStreamSourceOperation method getFromEntity.

@Override
public <T> T getFromEntity(StreamSourceEntity entity, Supplier<T> target) {
    T result = target.get();
    if (entity == null) {
        return result;
    }
    String existType = entity.getSourceType();
    Preconditions.checkTrue(getSourceType().equals(existType), String.format(Constant.SOURCE_TYPE_NOT_SAME, getSourceType(), existType));
    BinlogSourceDTO dto = BinlogSourceDTO.getFromJson(entity.getExtParams());
    CommonBeanUtils.copyProperties(entity, result, true);
    CommonBeanUtils.copyProperties(dto, result, true);
    return result;
}
Also used : BinlogSourceDTO(org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceDTO)

Example 2 with BinlogSourceDTO

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

the class BinlogStreamSourceOperation method setTargetEntity.

@Override
protected void setTargetEntity(SourceRequest request, StreamSourceEntity targetEntity) {
    BinlogSourceRequest sourceRequest = (BinlogSourceRequest) request;
    CommonBeanUtils.copyProperties(sourceRequest, targetEntity, true);
    try {
        BinlogSourceDTO dto = BinlogSourceDTO.getFromRequest(sourceRequest);
        targetEntity.setExtParams(objectMapper.writeValueAsString(dto));
    } catch (Exception e) {
        throw new BusinessException(ErrorCodeEnum.SOURCE_INFO_INCORRECT.getMessage());
    }
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) BinlogSourceDTO(org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceDTO) BinlogSourceRequest(org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceRequest) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException)

Aggregations

BinlogSourceDTO (org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceDTO)2 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)1 BinlogSourceRequest (org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceRequest)1