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;
}
Aggregations