use of org.apache.inlong.manager.dao.entity.StreamSourceEntity in project incubator-inlong by apache.
the class AbstractStreamSourceOperation method getById.
@Override
public SourceResponse getById(@NotNull Integer id) {
StreamSourceEntity entity = sourceMapper.selectByPrimaryKey(id);
Preconditions.checkNotNull(entity, ErrorCodeEnum.SOURCE_INFO_NOT_FOUND.getMessage());
String existType = entity.getSourceType();
Preconditions.checkTrue(getSourceType().equals(existType), String.format(Constant.SOURCE_TYPE_NOT_SAME, getSourceType(), existType));
return this.getFromEntity(entity, this::getResponse);
}
use of org.apache.inlong.manager.dao.entity.StreamSourceEntity in project incubator-inlong by apache.
the class StreamSourceServiceImpl method listByCondition.
@Override
public PageInfo<? extends SourceListResponse> listByCondition(SourcePageRequest request) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("begin to list source page by " + request);
}
Preconditions.checkNotNull(request.getInlongGroupId(), Constant.GROUP_ID_IS_EMPTY);
PageHelper.startPage(request.getPageNum(), request.getPageSize());
List<StreamSourceEntity> entityPage = sourceMapper.selectByCondition(request);
// Encapsulate the paging query results into the PageInfo object to obtain related paging information
Map<SourceType, Page<StreamSourceEntity>> sourceMap = Maps.newHashMap();
for (StreamSourceEntity streamSource : entityPage) {
SourceType sourceType = SourceType.forType(streamSource.getSourceType());
sourceMap.computeIfAbsent(sourceType, k -> new Page<>()).add(streamSource);
}
List<SourceListResponse> sourceListResponses = Lists.newArrayList();
for (Map.Entry<SourceType, Page<StreamSourceEntity>> entry : sourceMap.entrySet()) {
SourceType sourceType = entry.getKey();
StreamSourceOperation operation = operationFactory.getInstance(sourceType);
PageInfo<? extends SourceListResponse> pageInfo = operation.getPageInfo(entry.getValue());
sourceListResponses.addAll(pageInfo.getList());
}
PageInfo<? extends SourceListResponse> pageInfo = PageInfo.of(sourceListResponses);
LOGGER.debug("success to list source page");
return pageInfo;
}
use of org.apache.inlong.manager.dao.entity.StreamSourceEntity in project incubator-inlong by apache.
the class StreamSourceServiceImpl method stop.
@Override
public boolean stop(Integer id, String sourceType, String operator) {
LOGGER.info("begin to stop source by id={}, sourceType={}", id, sourceType);
StreamSourceEntity entity = sourceMapper.selectByPrimaryKey(id);
Preconditions.checkNotNull(entity, ErrorCodeEnum.SOURCE_INFO_NOT_FOUND.getMessage());
commonOperateService.checkGroupStatus(entity.getInlongGroupId(), operator);
StreamSourceOperation operation = operationFactory.getInstance(SourceType.forType(sourceType));
SourceRequest sourceRequest = new SourceRequest();
CommonBeanUtils.copyProperties(entity, sourceRequest, true);
operation.stopOpt(sourceRequest, operator);
LOGGER.info("success to stop source info:{}", entity);
return true;
}
use of org.apache.inlong.manager.dao.entity.StreamSourceEntity in project incubator-inlong by apache.
the class StreamSourceServiceImpl method delete.
@Override
@Transactional(rollbackFor = Throwable.class)
public boolean delete(Integer id, String sourceType, String operator) {
LOGGER.info("begin to delete source by id={}, sourceType={}", id, sourceType);
Preconditions.checkNotNull(id, Constant.ID_IS_EMPTY);
StreamSourceEntity entity = sourceMapper.selectByPrimaryKey(id);
Preconditions.checkNotNull(entity, ErrorCodeEnum.SOURCE_INFO_NOT_FOUND.getMessage());
commonOperateService.checkGroupStatus(entity.getInlongGroupId(), operator);
StreamSourceOperation operation = operationFactory.getInstance(SourceType.forType(sourceType));
SourceRequest sourceRequest = new SourceRequest();
CommonBeanUtils.copyProperties(entity, sourceRequest, true);
operation.deleteOpt(sourceRequest, operator);
LOGGER.info("success to delete source info:{}", entity);
return true;
}
Aggregations