Search in sources :

Example 1 with SinkFieldRequest

use of org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest in project incubator-inlong by apache.

the class InlongStreamSinkTransfer method createClickHouseRequest.

private static SinkRequest createClickHouseRequest(StreamSink streamSink, InlongStreamInfo streamInfo) {
    ClickHouseSinkRequest clickHouseSinkRequest = new ClickHouseSinkRequest();
    ClickHouseSink clickHouseSink = (ClickHouseSink) streamSink;
    clickHouseSinkRequest.setSinkName(clickHouseSink.getSinkName());
    clickHouseSinkRequest.setDatabaseName(clickHouseSink.getDatabaseName());
    clickHouseSinkRequest.setSinkType(clickHouseSink.getSinkType().name());
    clickHouseSinkRequest.setJdbcUrl(clickHouseSink.getJdbcUrl());
    DefaultAuthentication defaultAuthentication = clickHouseSink.getAuthentication();
    AssertUtil.notNull(defaultAuthentication, String.format("Clickhouse storage:%s must be authenticated", clickHouseSink.getDatabaseName()));
    clickHouseSinkRequest.setUsername(defaultAuthentication.getUserName());
    clickHouseSinkRequest.setPassword(defaultAuthentication.getPassword());
    clickHouseSinkRequest.setTableName(clickHouseSink.getTableName());
    clickHouseSinkRequest.setDistributedTable(clickHouseSink.getDistributedTable());
    clickHouseSinkRequest.setFlushInterval(clickHouseSink.getFlushInterval());
    clickHouseSinkRequest.setFlushRecordNumber(clickHouseSink.getFlushRecordNumber());
    clickHouseSinkRequest.setKeyFieldNames(clickHouseSink.getKeyFieldNames());
    clickHouseSinkRequest.setPartitionKey(clickHouseSink.getPartitionKey());
    clickHouseSinkRequest.setPartitionStrategy(clickHouseSink.getPartitionStrategy());
    clickHouseSinkRequest.setWriteMaxRetryTimes(clickHouseSink.getWriteMaxRetryTimes());
    clickHouseSinkRequest.setInlongGroupId(streamInfo.getInlongGroupId());
    clickHouseSinkRequest.setInlongStreamId(streamInfo.getInlongStreamId());
    clickHouseSinkRequest.setProperties(clickHouseSink.getProperties());
    clickHouseSinkRequest.setEnableCreateResource(clickHouseSink.isNeedCreated() ? 1 : 0);
    if (CollectionUtils.isNotEmpty(clickHouseSink.getSinkFields())) {
        List<SinkFieldRequest> fieldRequests = createSinkFieldRequests(streamSink.getSinkFields());
        clickHouseSinkRequest.setFieldList(fieldRequests);
    }
    return clickHouseSinkRequest;
}
Also used : ClickHouseSinkRequest(org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkRequest) DefaultAuthentication(org.apache.inlong.manager.client.api.auth.DefaultAuthentication) SinkFieldRequest(org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest) ClickHouseSink(org.apache.inlong.manager.client.api.sink.ClickHouseSink)

Example 2 with SinkFieldRequest

use of org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest in project incubator-inlong by apache.

the class InlongStreamSinkTransfer method createKafkaRequest.

private static SinkRequest createKafkaRequest(StreamSink streamSink, InlongStreamInfo streamInfo) {
    KafkaSinkRequest kafkaSinkRequest = new KafkaSinkRequest();
    KafkaSink kafkaSink = (KafkaSink) streamSink;
    kafkaSinkRequest.setSinkName(streamSink.getSinkName());
    kafkaSinkRequest.setAddress(kafkaSink.getAddress());
    kafkaSinkRequest.setTopicName(kafkaSink.getTopicName());
    kafkaSinkRequest.setSinkType(kafkaSink.getSinkType().name());
    kafkaSinkRequest.setInlongGroupId(streamInfo.getInlongGroupId());
    kafkaSinkRequest.setInlongStreamId(streamInfo.getInlongStreamId());
    kafkaSinkRequest.setSerializationType(kafkaSink.getDataFormat().name());
    kafkaSinkRequest.setEnableCreateResource(kafkaSink.isNeedCreated() ? 1 : 0);
    kafkaSinkRequest.setProperties(kafkaSink.getProperties());
    if (CollectionUtils.isNotEmpty(kafkaSink.getSinkFields())) {
        List<SinkFieldRequest> fieldRequests = createSinkFieldRequests(kafkaSink.getSinkFields());
        kafkaSinkRequest.setFieldList(fieldRequests);
    }
    return kafkaSinkRequest;
}
Also used : KafkaSinkRequest(org.apache.inlong.manager.common.pojo.sink.kafka.KafkaSinkRequest) KafkaSink(org.apache.inlong.manager.client.api.sink.KafkaSink) SinkFieldRequest(org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest)

Example 3 with SinkFieldRequest

use of org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest in project incubator-inlong by apache.

the class HiveStreamSinkOperation method saveFieldOpt.

@Override
public void saveFieldOpt(SinkRequest request) {
    List<SinkFieldRequest> fieldList = request.getFieldList();
    LOGGER.info("begin to save field={}", fieldList);
    if (CollectionUtils.isEmpty(fieldList)) {
        return;
    }
    int size = fieldList.size();
    List<StreamSinkFieldEntity> entityList = new ArrayList<>(size);
    String groupId = request.getInlongGroupId();
    String streamId = request.getInlongStreamId();
    String sinkType = request.getSinkType();
    Integer sinkId = request.getId();
    for (SinkFieldRequest fieldInfo : fieldList) {
        StreamSinkFieldEntity fieldEntity = CommonBeanUtils.copyProperties(fieldInfo, StreamSinkFieldEntity::new);
        if (StringUtils.isEmpty(fieldEntity.getFieldComment())) {
            fieldEntity.setFieldComment(fieldEntity.getFieldName());
        }
        fieldEntity.setInlongGroupId(groupId);
        fieldEntity.setInlongStreamId(streamId);
        fieldEntity.setSinkType(sinkType);
        fieldEntity.setSinkId(sinkId);
        fieldEntity.setIsDeleted(EntityStatus.UN_DELETED.getCode());
        entityList.add(fieldEntity);
    }
    sinkFieldMapper.insertAll(entityList);
    LOGGER.info("success to save hive field");
}
Also used : SinkFieldRequest(org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest) ArrayList(java.util.ArrayList) StreamSinkFieldEntity(org.apache.inlong.manager.dao.entity.StreamSinkFieldEntity)

Example 4 with SinkFieldRequest

use of org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest in project incubator-inlong by apache.

the class KafkaStreamSinkOperation method saveFieldOpt.

@Override
public void saveFieldOpt(SinkRequest request) {
    List<SinkFieldRequest> fieldList = request.getFieldList();
    LOGGER.info("begin to save field={}", fieldList);
    if (CollectionUtils.isEmpty(fieldList)) {
        return;
    }
    int size = fieldList.size();
    List<StreamSinkFieldEntity> entityList = new ArrayList<>(size);
    String groupId = request.getInlongGroupId();
    String streamId = request.getInlongStreamId();
    String sinkType = request.getSinkType();
    Integer sinkId = request.getId();
    for (SinkFieldRequest fieldInfo : fieldList) {
        StreamSinkFieldEntity fieldEntity = CommonBeanUtils.copyProperties(fieldInfo, StreamSinkFieldEntity::new);
        if (StringUtils.isEmpty(fieldEntity.getFieldComment())) {
            fieldEntity.setFieldComment(fieldEntity.getFieldName());
        }
        fieldEntity.setInlongGroupId(groupId);
        fieldEntity.setInlongStreamId(streamId);
        fieldEntity.setSinkType(sinkType);
        fieldEntity.setSinkId(sinkId);
        fieldEntity.setIsDeleted(EntityStatus.UN_DELETED.getCode());
        entityList.add(fieldEntity);
    }
    sinkFieldMapper.insertAll(entityList);
    LOGGER.info("success to save field");
}
Also used : SinkFieldRequest(org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest) ArrayList(java.util.ArrayList) StreamSinkFieldEntity(org.apache.inlong.manager.dao.entity.StreamSinkFieldEntity)

Example 5 with SinkFieldRequest

use of org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest 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)

Aggregations

SinkFieldRequest (org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest)9 ArrayList (java.util.ArrayList)4 StreamSinkFieldEntity (org.apache.inlong.manager.dao.entity.StreamSinkFieldEntity)4 DefaultAuthentication (org.apache.inlong.manager.client.api.auth.DefaultAuthentication)2 HiveSinkRequest (org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkRequest)2 Lists (com.google.common.collect.Lists)1 StandardCharsets (java.nio.charset.StandardCharsets)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 SinkField (org.apache.inlong.manager.client.api.SinkField)1 ClickHouseSink (org.apache.inlong.manager.client.api.sink.ClickHouseSink)1 HiveSink (org.apache.inlong.manager.client.api.sink.HiveSink)1 KafkaSink (org.apache.inlong.manager.client.api.sink.KafkaSink)1 GroupState (org.apache.inlong.manager.common.enums.GroupState)1 ProcessStatus (org.apache.inlong.manager.common.enums.ProcessStatus)1 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)1 ClickHouseSinkRequest (org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkRequest)1 KafkaSinkRequest (org.apache.inlong.manager.common.pojo.sink.kafka.KafkaSinkRequest)1 KafkaSourceRequest (org.apache.inlong.manager.common.pojo.source.kafka.KafkaSourceRequest)1 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)1