Search in sources :

Example 6 with InlongStreamInfo

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

the class DisableZkForSortTest method createHiveSink.

public HiveSinkRequest createHiveSink(InlongStreamInfo streamInfo) {
    HiveSinkRequest hiveSinkRequest = new HiveSinkRequest();
    hiveSinkRequest.setInlongGroupId(streamInfo.getInlongGroupId());
    hiveSinkRequest.setSinkType("HIVE");
    hiveSinkRequest.setSinkName("HIVE");
    hiveSinkRequest.setInlongStreamId(streamInfo.getInlongStreamId());
    List<SinkFieldRequest> sinkFieldRequests = createStreamFields(streamInfo.getInlongGroupId(), streamInfo.getInlongStreamId()).stream().map(streamFieldInfo -> {
        SinkFieldRequest fieldInfo = new SinkFieldRequest();
        fieldInfo.setFieldName(streamFieldInfo.getFieldName());
        fieldInfo.setFieldType(streamFieldInfo.getFieldType());
        fieldInfo.setFieldComment(streamFieldInfo.getFieldComment());
        return fieldInfo;
    }).collect(Collectors.toList());
    hiveSinkRequest.setFieldList(sinkFieldRequests);
    hiveSinkRequest.setEnableCreateTable(0);
    hiveSinkRequest.setUsername(OPERATOR);
    hiveSinkRequest.setPassword("password");
    hiveSinkRequest.setDbName("default");
    hiveSinkRequest.setTableName("kip_test");
    hiveSinkRequest.setJdbcUrl("jdbc:hive2://172.17.12.135:7001");
    hiveSinkRequest.setFileFormat("TextFile");
    hiveSinkRequest.setHdfsDefaultFs("hdfs://172.17.12.235:4007");
    hiveSinkRequest.setWarehouseDir("/user/hive/warehouse");
    hiveSinkRequest.setFileFormat(StandardCharsets.UTF_8.name());
    hiveSinkRequest.setDataSeparator("124");
    streamSinkService.save(hiveSinkRequest, OPERATOR);
    return hiveSinkRequest;
}
Also used : ProcessStatus(org.apache.inlong.manager.common.enums.ProcessStatus) ProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) TaskEventListener(org.apache.inlong.manager.workflow.event.task.TaskEventListener) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) Autowired(org.springframework.beans.factory.annotation.Autowired) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo) WorkflowServiceImplTest(org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) Lists(com.google.common.collect.Lists) StreamSinkService(org.apache.inlong.manager.service.sink.StreamSinkService) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) KafkaSourceRequest(org.apache.inlong.manager.common.pojo.source.kafka.KafkaSourceRequest) OperateType(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm.OperateType) StreamSourceService(org.apache.inlong.manager.service.source.StreamSourceService) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) ProcessName(org.apache.inlong.manager.service.workflow.ProcessName) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) GroupState(org.apache.inlong.manager.common.enums.GroupState) WorkflowBeanUtils(org.apache.inlong.manager.workflow.util.WorkflowBeanUtils) Test(org.junit.Test) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) InlongStreamService(org.apache.inlong.manager.service.core.InlongStreamService) List(java.util.List) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) HiveSinkRequest(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkRequest) SinkFieldRequest(org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest) WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) Assert(org.junit.Assert) HiveSinkRequest(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkRequest) SinkFieldRequest(org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest)

Example 7 with InlongStreamInfo

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

the class DisableZkForSortTest method testCreateSortConfigInUpdateWorkflow.

@Test
public void testCreateSortConfigInUpdateWorkflow() {
    InlongGroupInfo groupInfo = initGroupForm("PULSAR");
    groupInfo.setZookeeperEnabled(0);
    groupInfo.setStatus(GroupState.CONFIG_SUCCESSFUL.getCode());
    groupService.update(groupInfo.genRequest(), OPERATOR);
    InlongStreamInfo streamInfo = createStreamInfo(groupInfo);
    createHiveSink(streamInfo);
    createKafkaSource(streamInfo);
    UpdateGroupProcessForm form = new UpdateGroupProcessForm();
    form.setGroupInfo(groupInfo);
    form.setOperateType(OperateType.SUSPEND);
    taskListenerFactory.acceptPlugin(new MockPlugin());
    WorkflowContext context = workflowEngine.processService().start(ProcessName.SUSPEND_GROUP_PROCESS.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("stopSort");
    Assert.assertTrue(task instanceof ServiceTask);
    Assert.assertEquals(2, task.getNameToListenerMap().size());
    List<TaskEventListener> listeners = Lists.newArrayList(task.getNameToListenerMap().values());
    Assert.assertTrue(listeners.get(1) instanceof CreateSortConfigListener);
    ProcessForm currentProcessForm = context.getProcessForm();
    InlongGroupInfo curGroupRequest = ((UpdateGroupProcessForm) currentProcessForm).getGroupInfo();
    Assert.assertTrue(curGroupRequest.getExtList().size() == 1);
}
Also used : UpdateGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm) WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) ServiceTask(org.apache.inlong.manager.workflow.definition.ServiceTask) MockPlugin(org.apache.inlong.manager.service.mocks.MockPlugin) 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) 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)

Example 8 with InlongStreamInfo

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

the class WorkflowServiceImplTest method createStreamInfo.

/**
 * Create inlong stream
 */
public InlongStreamInfo createStreamInfo(InlongGroupInfo inlongGroupInfo) {
    // delete first
    try {
        streamService.delete(GROUP_ID, OPERATOR, OPERATOR);
    } catch (Exception e) {
    // ignore
    }
    InlongStreamInfo streamInfo = new InlongStreamInfo();
    streamInfo.setInlongGroupId(inlongGroupInfo.getInlongGroupId());
    streamInfo.setInlongStreamId(STREAM_ID);
    streamInfo.setMqResourceObj(STREAM_ID);
    streamInfo.setDataSeparator("124");
    streamInfo.setDataEncoding(DATA_ENCODING);
    streamInfo.setInCharges(OPERATOR);
    streamInfo.setCreator(OPERATOR);
    streamInfo.setFieldList(createStreamFields(inlongGroupInfo.getInlongGroupId(), STREAM_ID));
    streamService.save(streamInfo, OPERATOR);
    return streamInfo;
}
Also used : InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 9 with InlongStreamInfo

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

the class DataSourceListenerTest method createBinlogSource.

public Integer createBinlogSource(InlongGroupInfo groupInfo) {
    final InlongStreamInfo streamInfo = createStreamInfo(groupInfo);
    BinlogSourceRequest sourceRequest = new BinlogSourceRequest();
    sourceRequest.setInlongGroupId(streamInfo.getInlongGroupId());
    sourceRequest.setInlongStreamId(streamInfo.getInlongStreamId());
    sourceRequest.setSourceName("binlog-collect");
    return streamSourceService.save(sourceRequest, OPERATOR);
}
Also used : BinlogSourceRequest(org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceRequest) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 10 with InlongStreamInfo

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

the class CommonOperateService method createDataFlow.

/**
 * Create dataflow info for sort.
 */
public DataFlowInfo createDataFlow(InlongGroupInfo groupInfo, SinkResponse sinkResponse) {
    String groupId = sinkResponse.getInlongGroupId();
    String streamId = sinkResponse.getInlongStreamId();
    // TODO Support all source type, include AUTO_PUSH.
    List<SourceResponse> sourceList = streamSourceService.listSource(groupId, streamId);
    if (CollectionUtils.isEmpty(sourceList)) {
        throw new WorkflowListenerException(String.format("Source not found by groupId=%s and streamId=%s", groupId, streamId));
    }
    // Get all field info
    List<FieldInfo> sourceFields = new ArrayList<>();
    List<FieldInfo> sinkFields = new ArrayList<>();
    String partition = null;
    if (SinkType.forType(sinkResponse.getSinkType()) == SinkType.HIVE) {
        HiveSinkResponse hiveSink = (HiveSinkResponse) sinkResponse;
        partition = hiveSink.getPrimaryPartition();
    }
    // TODO Support more than one source and one sink
    final SourceResponse sourceResponse = sourceList.get(0);
    boolean isAllMigration = SourceInfoUtils.isBinlogAllMigration(sourceResponse);
    FieldMappingRule fieldMappingRule = FieldInfoUtils.createFieldInfo(isAllMigration, sinkResponse.getFieldList(), sourceFields, sinkFields, partition);
    // Get source info
    String masterAddress = getSpecifiedParam(Constant.TUBE_MASTER_URL);
    PulsarClusterInfo pulsarCluster = getPulsarClusterInfo(groupInfo.getMiddlewareType());
    InlongStreamInfo streamInfo = streamService.get(groupId, streamId);
    SourceInfo sourceInfo = SourceInfoUtils.createSourceInfo(pulsarCluster, masterAddress, clusterBean, groupInfo, streamInfo, sourceResponse, sourceFields);
    // Get sink info
    SinkInfo sinkInfo = SinkInfoUtils.createSinkInfo(sourceResponse, sinkResponse, sinkFields);
    // Get transformation info
    TransformationInfo transInfo = new TransformationInfo(fieldMappingRule);
    // Get properties
    Map<String, Object> properties = new HashMap<>();
    if (MapUtils.isNotEmpty(sinkResponse.getProperties())) {
        properties.putAll(sinkResponse.getProperties());
    }
    properties.put(Constant.DATA_FLOW_GROUP_ID_KEY, groupId);
    return new DataFlowInfo(sinkResponse.getId(), sourceInfo, transInfo, sinkInfo, properties);
}
Also used : SourceResponse(org.apache.inlong.manager.common.pojo.source.SourceResponse) FieldMappingRule(org.apache.inlong.sort.protocol.transformation.FieldMappingRule) SourceInfo(org.apache.inlong.sort.protocol.source.SourceInfo) HashMap(java.util.HashMap) PulsarClusterInfo(org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo) ArrayList(java.util.ArrayList) SinkInfo(org.apache.inlong.sort.protocol.sink.SinkInfo) HiveSinkResponse(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkResponse) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException) FieldInfo(org.apache.inlong.sort.protocol.FieldInfo) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo) TransformationInfo(org.apache.inlong.sort.protocol.transformation.TransformationInfo) DataFlowInfo(org.apache.inlong.sort.protocol.DataFlowInfo)

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