Search in sources :

Example 6 with HiveSinkRequest

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

the class InlongStreamSinkTransfer method createHiveRequest.

private static HiveSinkRequest createHiveRequest(StreamSink streamSink, InlongStreamInfo streamInfo) {
    HiveSinkRequest hiveSinkRequest = new HiveSinkRequest();
    HiveSink hiveSink = (HiveSink) streamSink;
    hiveSinkRequest.setSinkName(streamSink.getSinkName());
    hiveSinkRequest.setInlongGroupId(streamInfo.getInlongGroupId());
    hiveSinkRequest.setInlongStreamId(streamInfo.getInlongStreamId());
    hiveSinkRequest.setDataEncoding(hiveSink.getCharset().name());
    hiveSinkRequest.setEnableCreateTable(hiveSink.isNeedCreated() ? 1 : 0);
    hiveSinkRequest.setDataSeparator(String.valueOf(hiveSink.getDataSeparator().getAsciiCode()));
    hiveSinkRequest.setDbName(hiveSink.getDbName());
    hiveSinkRequest.setTableName(hiveSink.getTableName());
    hiveSinkRequest.setHdfsDefaultFs(hiveSink.getHdfsDefaultFs());
    hiveSinkRequest.setJdbcUrl(hiveSink.getJdbcUrl());
    hiveSinkRequest.setWarehouseDir(hiveSink.getWarehouseDir());
    hiveSinkRequest.setFileFormat(hiveSink.getFileFormat().name());
    hiveSinkRequest.setSinkType(hiveSink.getSinkType().name());
    DefaultAuthentication defaultAuthentication = hiveSink.getAuthentication();
    AssertUtil.notNull(defaultAuthentication, String.format("Hive storage:%s must be authenticated", hiveSink.getDbName()));
    hiveSinkRequest.setUsername(defaultAuthentication.getUserName());
    hiveSinkRequest.setPassword(defaultAuthentication.getPassword());
    hiveSinkRequest.setPrimaryPartition(hiveSink.getPrimaryPartition());
    hiveSinkRequest.setSecondaryPartition(hiveSink.getSecondaryPartition());
    hiveSinkRequest.setProperties(hiveSink.getProperties());
    if (CollectionUtils.isNotEmpty(hiveSink.getSinkFields())) {
        List<SinkFieldRequest> fieldRequests = createSinkFieldRequests(streamSink.getSinkFields());
        hiveSinkRequest.setFieldList(fieldRequests);
    }
    return hiveSinkRequest;
}
Also used : DefaultAuthentication(org.apache.inlong.manager.client.api.auth.DefaultAuthentication) HiveSink(org.apache.inlong.manager.client.api.sink.HiveSink) HiveSinkRequest(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkRequest) SinkFieldRequest(org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest)

Aggregations

HiveSinkRequest (org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkRequest)6 Date (java.util.Date)2 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)2 SinkFieldRequest (org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest)2 HiveSinkDTO (org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkDTO)2 StreamSinkEntity (org.apache.inlong.manager.dao.entity.StreamSinkEntity)2 Test (org.junit.Test)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 DefaultAuthentication (org.apache.inlong.manager.client.api.auth.DefaultAuthentication)1 HiveSink (org.apache.inlong.manager.client.api.sink.HiveSink)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 SinkResponse (org.apache.inlong.manager.common.pojo.sink.SinkResponse)1 HiveSinkResponse (org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkResponse)1 KafkaSourceRequest (org.apache.inlong.manager.common.pojo.source.kafka.KafkaSourceRequest)1 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)1