Search in sources :

Example 11 with InlongStreamInfo

use of org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo in project incubator-inlong by apache.

the class DefaultInlongStreamBuilder method initOrUpdate.

@Override
public InlongStream initOrUpdate() {
    InlongStreamInfo dataStreamInfo = streamContext.getStreamInfo();
    Pair<Boolean, InlongStreamInfo> existMsg = managerClient.isStreamExists(dataStreamInfo);
    if (existMsg.getKey()) {
        Pair<Boolean, String> updateMsg = managerClient.updateStreamInfo(dataStreamInfo);
        if (updateMsg.getKey()) {
            List<SourceRequest> sourceRequests = Lists.newArrayList(streamContext.getSourceRequests().values());
            for (SourceRequest sourceRequest : sourceRequests) {
                sourceRequest.setId(initOrUpdateSource(sourceRequest));
            }
            List<SinkRequest> sinkRequests = Lists.newArrayList(streamContext.getSinkRequests().values());
            for (SinkRequest sinkRequest : sinkRequests) {
                sinkRequest.setId(initOrUpdateSink(sinkRequest));
            }
        } else {
            throw new RuntimeException(String.format("Update data stream failed:%s", updateMsg.getValue()));
        }
        return inlongStream;
    } else {
        return init();
    }
}
Also used : SourceRequest(org.apache.inlong.manager.common.pojo.source.SourceRequest) SinkRequest(org.apache.inlong.manager.common.pojo.sink.SinkRequest) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 12 with InlongStreamInfo

use of org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo in project incubator-inlong by apache.

the class DefaultInlongStreamBuilder method init.

@Override
public InlongStream init() {
    InlongStreamInfo streamInfo = streamContext.getStreamInfo();
    String streamIndex = managerClient.createStreamInfo(streamInfo);
    streamInfo.setId(Double.valueOf(streamIndex).intValue());
    // Create source and update index
    List<SourceRequest> sourceRequests = Lists.newArrayList(streamContext.getSourceRequests().values());
    for (SourceRequest sourceRequest : sourceRequests) {
        String sourceIndex = managerClient.createSource(sourceRequest);
        sourceRequest.setId(Double.valueOf(sourceIndex).intValue());
    }
    // Create sink and update index
    List<SinkRequest> sinkRequests = Lists.newArrayList(streamContext.getSinkRequests().values());
    for (SinkRequest sinkRequest : sinkRequests) {
        String sinkIndex = managerClient.createSink(sinkRequest);
        sinkRequest.setId(Double.valueOf(sinkIndex).intValue());
    }
    return inlongStream;
}
Also used : SourceRequest(org.apache.inlong.manager.common.pojo.source.SourceRequest) SinkRequest(org.apache.inlong.manager.common.pojo.sink.SinkRequest) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 13 with InlongStreamInfo

use of org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo in project incubator-inlong by apache.

the class StartCreateGroupProcessListener method listen.

/**
 * Initiate the process of creating inlong group resources after new inlong group access approved
 */
@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    NewGroupProcessForm form = (NewGroupProcessForm) context.getProcessForm();
    String groupId = form.getInlongGroupId();
    GroupResourceProcessForm processForm = new GroupResourceProcessForm();
    processForm.setGroupInfo(groupService.get(groupId));
    String username = context.getApplicant();
    List<InlongStreamEntity> inlongStreamEntityList = streamMapper.selectByGroupId(groupId);
    List<InlongStreamInfo> inlongStreamInfoList = CommonBeanUtils.copyListProperties(inlongStreamEntityList, InlongStreamInfo::new);
    processForm.setInlongStreamInfoList(inlongStreamInfoList);
    workflowService.start(ProcessName.CREATE_GROUP_RESOURCE, username, processForm);
    return ListenerResult.success();
}
Also used : InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity) NewGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.NewGroupProcessForm) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 14 with InlongStreamInfo

use of org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo in project incubator-inlong by apache.

the class InlongStreamServiceTest method saveInlongStream.

/**
 * Test save inlong stream
 */
public Integer saveInlongStream(String groupId, String streamId, String operator) {
    InlongStreamInfo streamInfo;
    try {
        streamInfo = streamService.get(groupId, streamId);
        if (streamInfo != null) {
            return streamInfo.getId();
        }
    } catch (Exception e) {
    // ignore
    }
    groupServiceTest.saveGroup(globalGroupName, operator);
    streamInfo = new InlongStreamInfo();
    streamInfo.setInlongGroupId(groupId);
    streamInfo.setInlongStreamId(streamId);
    streamInfo.setDataEncoding("UTF-8");
    return streamService.save(streamInfo, operator);
}
Also used : InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 15 with InlongStreamInfo

use of org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo in project incubator-inlong by apache.

the class InlongStreamServiceImpl method listAllWithGroupId.

@Override
public PageInfo<FullStreamResponse> listAllWithGroupId(InlongStreamPageRequest request) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("begin to list full inlong stream page by {}", request);
    }
    Preconditions.checkNotNull(request, "request is empty");
    Preconditions.checkNotNull(request.getInlongGroupId(), Constant.GROUP_ID_IS_EMPTY);
    // 1. Query all valid data sources under groupId
    String groupId = request.getInlongGroupId();
    // The person in charge of the inlong group has the authority of all inlong streams
    InlongGroupEntity inlongGroupEntity = groupMapper.selectByGroupId(groupId);
    Preconditions.checkNotNull(inlongGroupEntity, "inlong group not found by groupId=" + groupId);
    String inCharges = inlongGroupEntity.getInCharges();
    request.setInCharges(inCharges);
    PageHelper.startPage(request.getPageNum(), request.getPageSize());
    Page<InlongStreamEntity> page = (Page<InlongStreamEntity>) streamMapper.selectByCondition(request);
    List<InlongStreamInfo> streamInfoList = CommonBeanUtils.copyListProperties(page, InlongStreamInfo::new);
    // Convert and encapsulate the paged results
    List<FullStreamResponse> responseList = new ArrayList<>(streamInfoList.size());
    for (InlongStreamInfo streamInfo : streamInfoList) {
        // 2.1 Set the extended information and field information of the inlong stream
        String streamId = streamInfo.getInlongStreamId();
        setStreamExtAndField(groupId, streamId, streamInfo);
        // 2.3 Set the inlong stream to the result sub-object
        FullStreamResponse pageInfo = new FullStreamResponse();
        pageInfo.setStreamInfo(streamInfo);
        // 3. Query the basic and detailed information of the data source
        String dataSourceType = streamInfo.getDataSourceType();
        if (StringUtils.isEmpty(dataSourceType)) {
            continue;
        }
        switch(dataSourceType.toUpperCase(Locale.ROOT)) {
            case Constant.DATA_SOURCE_FILE:
                SourceFileBasicInfo fileBasicInfo = sourceFileService.getBasicByIdentifier(groupId, streamId);
                pageInfo.setFileBasicInfo(fileBasicInfo);
                List<SourceFileDetailInfo> fileDetailInfoList = sourceFileService.listDetailByIdentifier(groupId, streamId);
                pageInfo.setFileDetailInfoList(fileDetailInfoList);
                break;
            case Constant.DATA_SOURCE_DB:
                SourceDbBasicInfo dbBasicInfo = sourceDbService.getBasicByIdentifier(groupId, streamId);
                pageInfo.setDbBasicInfo(dbBasicInfo);
                List<SourceDbDetailInfo> dbDetailInfoList = sourceDbService.listDetailByIdentifier(groupId, streamId);
                pageInfo.setDbDetailInfoList(dbDetailInfoList);
                break;
            case Constant.DATA_SOURCE_AUTO_PUSH:
                break;
            default:
                throw new BusinessException(ErrorCodeEnum.SOURCE_TYPE_NOT_SUPPORTED);
        }
        // 4. Query stream sources information
        List<SourceResponse> sourceList = sourceService.listSource(groupId, streamId);
        pageInfo.setSourceInfo(sourceList);
        // 5. Query various stream sinks and its extended information, field information
        List<SinkResponse> sinkList = sinkService.listSink(groupId, streamId);
        pageInfo.setSinkInfo(sinkList);
        // 6. Add a single result to the paginated list
        responseList.add(pageInfo);
    }
    PageInfo<FullStreamResponse> pageInfo = new PageInfo<>(responseList);
    pageInfo.setTotal(pageInfo.getTotal());
    LOGGER.debug("success to list full inlong stream info");
    return pageInfo;
}
Also used : SourceDbBasicInfo(org.apache.inlong.manager.common.pojo.source.SourceDbBasicInfo) SourceResponse(org.apache.inlong.manager.common.pojo.source.SourceResponse) ArrayList(java.util.ArrayList) Page(com.github.pagehelper.Page) SourceFileDetailInfo(org.apache.inlong.manager.common.pojo.source.SourceFileDetailInfo) InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) PageInfo(com.github.pagehelper.PageInfo) SinkResponse(org.apache.inlong.manager.common.pojo.sink.SinkResponse) InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity) FullStreamResponse(org.apache.inlong.manager.common.pojo.stream.FullStreamResponse) SourceDbDetailInfo(org.apache.inlong.manager.common.pojo.source.SourceDbDetailInfo) SourceFileBasicInfo(org.apache.inlong.manager.common.pojo.source.SourceFileBasicInfo) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Aggregations

InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)17 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)4 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)4 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)4 InlongStreamEntity (org.apache.inlong.manager.dao.entity.InlongStreamEntity)4 SinkRequest (org.apache.inlong.manager.common.pojo.sink.SinkRequest)3 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)3 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)3 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)3 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)3 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)3 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)3 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)3 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)3 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)2 SourceDbDetailInfo (org.apache.inlong.manager.common.pojo.source.SourceDbDetailInfo)2 SourceFileDetailInfo (org.apache.inlong.manager.common.pojo.source.SourceFileDetailInfo)2