Search in sources :

Example 1 with KafkaSourceListResponse

use of org.apache.inlong.manager.common.pojo.source.kafka.KafkaSourceListResponse in project incubator-inlong by apache.

the class InlongParser method parseSourceList.

public static PageInfo<SourceListResponse> parseSourceList(Response response) {
    Object data = response.getData();
    String pageInfoJson = GsonUtil.toJson(data);
    PageInfo<SourceListResponse> pageInfo = GsonUtil.fromJson(pageInfoJson, new TypeToken<PageInfo<SourceListResponse>>() {
    }.getType());
    if (pageInfo.getList() != null && !pageInfo.getList().isEmpty()) {
        SourceListResponse sourceListResponse = pageInfo.getList().get(0);
        SourceType sourceType = SourceType.forType(sourceListResponse.getSourceType());
        if (sourceType == BINLOG) {
            return GsonUtil.fromJson(pageInfoJson, new TypeToken<PageInfo<BinlogSourceListResponse>>() {
            }.getType());
        }
        if (sourceType == KAFKA) {
            return GsonUtil.fromJson(pageInfoJson, new TypeToken<PageInfo<KafkaSourceListResponse>>() {
            }.getType());
        }
        throw new IllegalArgumentException(String.format("Unsupported sourceType=%s for Inlong", sourceType));
    } else {
        return new PageInfo<>();
    }
}
Also used : PageInfo(com.github.pagehelper.PageInfo) TypeToken(com.google.common.reflect.TypeToken) SourceType(org.apache.inlong.manager.common.enums.SourceType) JsonObject(com.google.gson.JsonObject) BinlogSourceListResponse(org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceListResponse) KafkaSourceListResponse(org.apache.inlong.manager.common.pojo.source.kafka.KafkaSourceListResponse) KafkaSourceListResponse(org.apache.inlong.manager.common.pojo.source.kafka.KafkaSourceListResponse) BinlogSourceListResponse(org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceListResponse) SourceListResponse(org.apache.inlong.manager.common.pojo.source.SourceListResponse)

Example 2 with KafkaSourceListResponse

use of org.apache.inlong.manager.common.pojo.source.kafka.KafkaSourceListResponse in project incubator-inlong by apache.

the class InlongStreamSourceTransfer method parseStreamSource.

public static StreamSource parseStreamSource(SourceListResponse sourceListResponse) {
    String type = sourceListResponse.getSourceType();
    SourceType sourceType = SourceType.forType(type);
    if (sourceType == SourceType.KAFKA && sourceListResponse instanceof KafkaSourceListResponse) {
        return parseKafkaSource((KafkaSourceListResponse) sourceListResponse);
    }
    if (sourceType == SourceType.BINLOG && sourceListResponse instanceof BinlogSourceListResponse) {
        return parseMySQLBinlogSource((BinlogSourceListResponse) sourceListResponse);
    }
    throw new IllegalArgumentException(String.format("Unsupported source type : %s for Inlong", sourceType));
}
Also used : SourceType(org.apache.inlong.manager.common.enums.SourceType) BinlogSourceListResponse(org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceListResponse) KafkaSourceListResponse(org.apache.inlong.manager.common.pojo.source.kafka.KafkaSourceListResponse)

Aggregations

SourceType (org.apache.inlong.manager.common.enums.SourceType)2 BinlogSourceListResponse (org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceListResponse)2 KafkaSourceListResponse (org.apache.inlong.manager.common.pojo.source.kafka.KafkaSourceListResponse)2 PageInfo (com.github.pagehelper.PageInfo)1 TypeToken (com.google.common.reflect.TypeToken)1 JsonObject (com.google.gson.JsonObject)1 SourceListResponse (org.apache.inlong.manager.common.pojo.source.SourceListResponse)1