use of org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkResponse in project incubator-inlong by apache.
the class ClickHouseStreamSinkOperation method getById.
@Override
public SinkResponse getById(@NotNull String sinkType, @NotNull Integer id) {
StreamSinkEntity entity = sinkMapper.selectByPrimaryKey(id);
Preconditions.checkNotNull(entity, ErrorCodeEnum.SINK_INFO_NOT_FOUND.getMessage());
String existType = entity.getSinkType();
Preconditions.checkTrue(Constant.SINK_CLICKHOUSE.equals(existType), String.format(Constant.SINK_TYPE_NOT_SAME, Constant.SINK_CLICKHOUSE, existType));
SinkResponse response = this.getFromEntity(entity, ClickHouseSinkResponse::new);
List<StreamSinkFieldEntity> entities = sinkFieldMapper.selectBySinkId(id);
List<SinkFieldResponse> infos = CommonBeanUtils.copyListProperties(entities, SinkFieldResponse::new);
response.setFieldList(infos);
return response;
}
use of org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkResponse in project incubator-inlong by apache.
the class ClickHouseStreamSinkServiceTest method testGetAndUpdate.
@Test
public void testGetAndUpdate() {
SinkResponse response = sinkService.get(sinkId, Constant.SINK_CLICKHOUSE);
Assert.assertEquals(globalGroupId, response.getInlongGroupId());
ClickHouseSinkResponse kafkaSinkResponse = (ClickHouseSinkResponse) response;
kafkaSinkResponse.setEnableCreateResource(Constant.ENABLE_CREATE_RESOURCE);
ClickHouseSinkRequest request = CommonBeanUtils.copyProperties(kafkaSinkResponse, ClickHouseSinkRequest::new);
boolean result = sinkService.update(request, globalOperator);
Assert.assertTrue(result);
}
use of org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkResponse in project incubator-inlong by apache.
the class SinkInfoUtils method createSinkInfo.
/**
* Create sink info for DataFlowInfo.
*/
public static SinkInfo createSinkInfo(SourceResponse sourceResponse, SinkResponse sinkResponse, List<FieldInfo> sinkFields) {
String sinkType = sinkResponse.getSinkType();
SinkInfo sinkInfo;
if (SinkType.forType(sinkType) == SinkType.HIVE) {
sinkInfo = createHiveSinkInfo((HiveSinkResponse) sinkResponse, sinkFields);
} else if (SinkType.forType(sinkType) == SinkType.KAFKA) {
sinkInfo = createKafkaSinkInfo(sourceResponse, (KafkaSinkResponse) sinkResponse, sinkFields);
} else if (SinkType.forType(sinkType) == SinkType.CLICKHOUSE) {
sinkInfo = createClickhouseSinkInfo((ClickHouseSinkResponse) sinkResponse, sinkFields);
} else {
throw new RuntimeException(String.format("Unsupported SinkType {%s}", sinkType));
}
return sinkInfo;
}
use of org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkResponse in project incubator-inlong by apache.
the class InlongParser method parseStreamList.
public static List<FullStreamResponse> parseStreamList(Response response) {
Object data = response.getData();
JsonObject pageInfoJson = GsonUtil.fromJson(GsonUtil.toJson(data), JsonObject.class);
JsonArray fullStreamArray = pageInfoJson.getAsJsonArray("list");
List<FullStreamResponse> list = Lists.newArrayList();
for (int i = 0; i < fullStreamArray.size(); i++) {
JsonObject fullStreamJson = (JsonObject) fullStreamArray.get(i);
FullStreamResponse fullStreamResponse = GsonUtil.fromJson(fullStreamJson.toString(), FullStreamResponse.class);
list.add(fullStreamResponse);
// Parse sourceResponse in each stream
JsonArray sourceJsonArr = fullStreamJson.getAsJsonArray(SOURCE_INFO);
List<SourceResponse> sourceResponses = Lists.newArrayList();
fullStreamResponse.setSourceInfo(sourceResponses);
for (int j = 0; j < sourceJsonArr.size(); j++) {
JsonObject sourceJson = (JsonObject) sourceJsonArr.get(i);
String type = sourceJson.get(SOURCE_TYPE).getAsString();
SourceType sourceType = SourceType.forType(type);
switch(sourceType) {
case BINLOG:
BinlogSourceResponse binlogSourceResponse = GsonUtil.fromJson(sourceJson.toString(), BinlogSourceResponse.class);
sourceResponses.add(binlogSourceResponse);
break;
case KAFKA:
KafkaSourceResponse kafkaSourceResponse = GsonUtil.fromJson(sourceJson.toString(), KafkaSourceResponse.class);
sourceResponses.add(kafkaSourceResponse);
break;
default:
throw new RuntimeException(String.format("Unsupport sourceType=%s for Inlong", sourceType));
}
}
// Parse sinkResponse in each stream
JsonArray sinkJsonArr = fullStreamJson.getAsJsonArray(SINK_INFO);
List<SinkResponse> sinkResponses = Lists.newArrayList();
fullStreamResponse.setSinkInfo(sinkResponses);
for (int j = 0; j < sinkJsonArr.size(); j++) {
JsonObject sinkJson = (JsonObject) sinkJsonArr.get(i);
String type = sinkJson.get(SINK_TYPE).getAsString();
SinkType sinkType = SinkType.forType(type);
switch(sinkType) {
case HIVE:
HiveSinkResponse hiveSinkResponse = GsonUtil.fromJson(sinkJson.toString(), HiveSinkResponse.class);
sinkResponses.add(hiveSinkResponse);
break;
case KAFKA:
KafkaSinkResponse kafkaSinkResponse = GsonUtil.fromJson(sinkJson.toString(), KafkaSinkResponse.class);
sinkResponses.add(kafkaSinkResponse);
break;
case ICEBERG:
IcebergSinkResponse icebergSinkResponse = GsonUtil.fromJson(sinkJson.toString(), IcebergSinkResponse.class);
sinkResponses.add(icebergSinkResponse);
break;
case CLICKHOUSE:
ClickHouseSinkResponse clickHouseSinkResponse = GsonUtil.fromJson(sinkJson.toString(), ClickHouseSinkResponse.class);
sinkResponses.add(clickHouseSinkResponse);
break;
default:
throw new RuntimeException(String.format("Unsupport sinkType=%s for Inlong", sinkType));
}
}
}
return list;
}
use of org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkResponse in project incubator-inlong by apache.
the class InlongStreamSinkTransfer method parseStreamSink.
public static StreamSink parseStreamSink(SinkResponse sinkResponse, StreamSink streamSink) {
String type = sinkResponse.getSinkType();
SinkType sinkType = SinkType.forType(type);
StreamSink streamSinkResult;
if (sinkType == SinkType.HIVE) {
streamSinkResult = parseHiveSink((HiveSinkResponse) sinkResponse, streamSink);
} else if (sinkType == SinkType.KAFKA) {
streamSinkResult = parseKafkaSink((KafkaSinkResponse) sinkResponse, streamSink);
} else if (sinkType == SinkType.CLICKHOUSE) {
streamSinkResult = parseClickHouseSink((ClickHouseSinkResponse) sinkResponse, streamSink);
} else {
throw new IllegalArgumentException(String.format("Unsupport sink type : %s for Inlong", sinkType));
}
return streamSinkResult;
}
Aggregations