Search in sources :

Example 1 with InlongStreamInfo

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

the class InlongStreamTransfer method createStreamInfo.

public static InlongStreamInfo createStreamInfo(InlongStreamConf streamConf, InlongGroupInfo groupInfo) {
    InlongStreamInfo dataStreamInfo = new InlongStreamInfo();
    dataStreamInfo.setInlongGroupId(groupInfo.getInlongGroupId());
    final String streamId = "b_" + streamConf.getName();
    dataStreamInfo.setInlongStreamId(streamId);
    dataStreamInfo.setName(streamConf.getName());
    dataStreamInfo.setDataEncoding(streamConf.getCharset().name());
    if (StringUtils.isEmpty(streamConf.getTopic())) {
        dataStreamInfo.setMqResourceObj(streamId);
    } else {
        dataStreamInfo.setMqResourceObj(streamConf.getTopic());
    }
    dataStreamInfo.setSyncSend(streamConf.isStrictlyOrdered() ? 1 : 0);
    dataStreamInfo.setDataSeparator(String.valueOf(streamConf.getDataSeparator().getAsciiCode()));
    dataStreamInfo.setDescription(streamConf.getDescription());
    dataStreamInfo.setCreator(groupInfo.getCreator());
    dataStreamInfo.setDailyRecords(streamConf.getDailyRecords());
    dataStreamInfo.setDailyStorage(streamConf.getDailyStorage());
    dataStreamInfo.setPeakRecords(streamConf.getPeakRecords());
    dataStreamInfo.setHavePredefinedFields(0);
    if (CollectionUtils.isNotEmpty(streamConf.getStreamFields())) {
        dataStreamInfo.setFieldList(createStreamFields(streamConf.getStreamFields(), dataStreamInfo));
    }
    return dataStreamInfo;
}
Also used : InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 2 with InlongStreamInfo

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

the class PushSortConfigListener method getSourceInfo.

/**
 * Get source info for DataFlowInfo
 */
@Deprecated
private SourceInfo getSourceInfo(InlongGroupInfo groupInfo, String streamId, List<StreamSinkFieldEntity> fieldList) {
    DeserializationInfo deserializationInfo = null;
    String groupId = groupInfo.getInlongGroupId();
    InlongStreamInfo streamInfo = streamService.get(groupId, streamId);
    boolean isDbType = Constant.DATA_SOURCE_DB.equals(streamInfo.getDataType());
    if (!isDbType) {
        // FILE and auto push source, the data format is TEXT or KEY-VALUE, temporarily use InLongMsgCsv
        String dataType = streamInfo.getDataType();
        if (Constant.DATA_TYPE_TEXT.equalsIgnoreCase(dataType) || Constant.DATA_TYPE_KEY_VALUE.equalsIgnoreCase(dataType)) {
            // Use the field separator from the inlong stream
            char separator = (char) Integer.parseInt(streamInfo.getDataSeparator());
            // TODO support escape
            /*Character escape = null;
                if (info.getDataEscapeChar() != null) {
                    escape = info.getDataEscapeChar().charAt(0);
                }*/
            // Whether to delete the first separator, the default is false for the time being
            deserializationInfo = new InLongMsgCsvDeserializationInfo(streamId, separator);
        }
    }
    // The number and order of the source fields must be the same as the target fields
    return null;
}
Also used : DeserializationInfo(org.apache.inlong.sort.protocol.deserialization.DeserializationInfo) InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) InLongMsgCsvDeserializationInfo(org.apache.inlong.sort.protocol.deserialization.InLongMsgCsvDeserializationInfo) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 3 with InlongStreamInfo

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

the class InlongGroupProcessOperation method genUpdateGroupProcessForm.

private UpdateGroupProcessForm genUpdateGroupProcessForm(String groupId, OperateType operateType) {
    InlongGroupInfo groupInfo = groupService.get(groupId);
    UpdateGroupProcessForm form = new UpdateGroupProcessForm();
    if (OperateType.RESTART == operateType) {
        List<InlongStreamEntity> inlongStreamEntityList = streamMapper.selectByGroupId(groupInfo.getInlongGroupId());
        List<InlongStreamInfo> inlongStreamInfoList = CommonBeanUtils.copyListProperties(inlongStreamEntityList, InlongStreamInfo::new);
        form.setInlongStreamInfoList(inlongStreamInfoList);
    }
    form.setGroupInfo(groupInfo);
    form.setOperateType(operateType);
    return form;
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 4 with InlongStreamInfo

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

the class InlongStreamServiceImpl method batchSaveAll.

@Transactional(rollbackFor = Throwable.class)
@Override
public boolean batchSaveAll(List<FullStreamRequest> fullStreamRequestList, String operator) {
    if (CollectionUtils.isEmpty(fullStreamRequestList)) {
        return true;
    }
    LOGGER.info("begin to batch save all stream page info, batch size={}", fullStreamRequestList.size());
    // Check if it can be added
    InlongStreamInfo firstStream = fullStreamRequestList.get(0).getStreamInfo();
    Preconditions.checkNotNull(firstStream, "inlong stream info is empty");
    String groupId = firstStream.getInlongGroupId();
    this.checkBizIsTempStatus(groupId);
    // This bulk save is only used when creating or editing inlong group after approval is rejected.
    // To ensure data consistency, you need to physically delete all associated data and then add
    // Note: There may be records with the same groupId and streamId in the historical data,
    // and the ones with is_deleted=0 should be deleted
    streamMapper.deleteAllByGroupId(groupId);
    for (FullStreamRequest pageInfo : fullStreamRequestList) {
        // 1.1 Delete the inlong stream extensions and fields corresponding to groupId and streamId
        InlongStreamInfo streamInfo = pageInfo.getStreamInfo();
        String streamId = streamInfo.getInlongStreamId();
        streamExtMapper.deleteAllByIdentifier(groupId, streamId);
        streamFieldMapper.deleteAllByIdentifier(groupId, streamId);
        // 2. Delete file data source, DB data source information
        sourceFileService.deleteAllByIdentifier(groupId, streamId);
        sourceDbService.deleteAllByIdentifier(groupId, streamId);
        // 3. Delete data sink information
        sinkService.deleteAll(groupId, streamId, operator);
        // 4. Save the inlong stream of this batch
        this.saveAll(pageInfo, operator);
    }
    LOGGER.info("success to batch save all stream page info");
    return true;
}
Also used : InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo) FullStreamRequest(org.apache.inlong.manager.common.pojo.stream.FullStreamRequest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with InlongStreamInfo

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

the class DisableZkForSortTest method testCreateSortConfigInCreateWorkflow.

@Test
public void testCreateSortConfigInCreateWorkflow() {
    InlongGroupInfo groupInfo = initGroupForm("PULSAR");
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupInfo.setZookeeperEnabled(0);
    groupService.update(groupInfo.genRequest(), OPERATOR);
    InlongStreamInfo streamInfo = createStreamInfo(groupInfo);
    createHiveSink(streamInfo);
    createKafkaSource(streamInfo);
    mockTaskListenerFactory();
    WorkflowContext context = workflowEngine.processService().start(processName.name(), applicant, form);
    WorkflowResult result = WorkflowBeanUtils.result(context);
    ProcessResponse response = result.getProcessInfo();
    Assert.assertSame(response.getStatus(), ProcessStatus.COMPLETED);
    WorkflowProcess process = context.getProcess();
    WorkflowTask task = process.getTaskByName("initSort");
    Assert.assertTrue(task instanceof ServiceTask);
    Assert.assertEquals(1, task.getNameToListenerMap().size());
    List<TaskEventListener> listeners = Lists.newArrayList(task.getNameToListenerMap().values());
    Assert.assertTrue(listeners.get(0) instanceof CreateSortConfigListener);
    ProcessForm form = context.getProcessForm();
    InlongGroupInfo curGroupRequest = ((GroupResourceProcessForm) form).getGroupInfo();
    Assert.assertTrue(curGroupRequest.getExtList().size() == 1);
}
Also used : WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo) WorkflowServiceImplTest(org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest) Test(org.junit.Test)

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