use of org.apache.inlong.sort.protocol.sink.IcebergSinkInfo in project incubator-inlong by apache.
the class Entrance method buildSinkStream.
private static void buildSinkStream(DataStream<Row> sourceStream, Configuration config, SinkInfo sinkInfo, Map<String, Object> properties, long dataflowId) throws IOException, ClassNotFoundException {
final String sinkType = checkNotNull(config.getString(Constants.SINK_TYPE));
final int sinkParallelism = config.getInteger(Constants.SINK_PARALLELISM);
switch(sinkType) {
case Constants.SINK_TYPE_CLICKHOUSE:
checkState(sinkInfo instanceof ClickHouseSinkInfo);
ClickHouseSinkInfo clickHouseSinkInfo = (ClickHouseSinkInfo) sinkInfo;
sourceStream.addSink(new ClickhouseRowSinkFunction(clickHouseSinkInfo)).uid(Constants.SINK_UID).name("Clickhouse Sink").setParallelism(sinkParallelism);
break;
case Constants.SINK_TYPE_HIVE:
checkState(sinkInfo instanceof HiveSinkInfo);
HiveSinkInfo hiveSinkInfo = (HiveSinkInfo) sinkInfo;
if (hiveSinkInfo.getPartitions().length == 0) {
// The committer operator is not necessary if partition is not existent.
sourceStream.process(new HiveWriter(config, dataflowId, hiveSinkInfo)).uid(Constants.SINK_UID).name("Hive Sink").setParallelism(sinkParallelism);
} else {
sourceStream.process(new HiveWriter(config, dataflowId, hiveSinkInfo)).uid(Constants.SINK_UID).name("Hive Sink").setParallelism(sinkParallelism).addSink(new HiveCommitter(config, hiveSinkInfo)).name("Hive Committer").setParallelism(1);
}
break;
case Constants.SINK_TYPE_ICEBERG:
checkState(sinkInfo instanceof IcebergSinkInfo);
IcebergSinkInfo icebergSinkInfo = (IcebergSinkInfo) sinkInfo;
TableLoader tableLoader = TableLoader.fromHadoopTable(icebergSinkInfo.getTableLocation(), new org.apache.hadoop.conf.Configuration());
FlinkSink.forRow(sourceStream, CommonUtils.getTableSchema(sinkInfo.getFields())).tableLoader(tableLoader).writeParallelism(sinkParallelism).build();
break;
case Constants.SINK_TYPE_KAFKA:
checkState(sinkInfo instanceof KafkaSinkInfo);
SerializationSchema<Row> schema = SerializationSchemaFactory.build(sinkInfo.getFields(), ((KafkaSinkInfo) sinkInfo).getSerializationInfo());
sourceStream.addSink(buildKafkaSink((KafkaSinkInfo) sinkInfo, properties, schema, config)).uid(Constants.SINK_UID).name("Kafka Sink").setParallelism(sinkParallelism);
break;
default:
throw new IllegalArgumentException("Unsupported sink type " + sinkType);
}
}
Aggregations