Search in sources :

Example 6 with SinkRequest

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

the class InnerInlongManagerClient method updateSink.

public Pair<Boolean, String> updateSink(SinkRequest sinkRequest) {
    final String path = HTTP_PATH + "/sink/update";
    final String url = formatUrl(path);
    final String storage = GsonUtil.toJson(sinkRequest);
    final RequestBody storageBody = RequestBody.create(MediaType.parse("application/json"), storage);
    Request request = new Request.Builder().method("POST", storageBody).url(url).build();
    Call call = httpClient.newCall(request);
    try {
        Response response = call.execute();
        String body = response.body().string();
        AssertUtil.isTrue(response.isSuccessful(), String.format("Inlong request failed:%s", body));
        org.apache.inlong.manager.common.beans.Response responseBody = InlongParser.parseResponse(body);
        if (responseBody.getData() != null) {
            return Pair.of(Boolean.valueOf(responseBody.getData().toString()), responseBody.getErrMsg());
        } else {
            return Pair.of(false, responseBody.getErrMsg());
        }
    } catch (Exception e) {
        throw new RuntimeException(String.format("Inlong sink update failed with ex:%s", e.getMessage()), e);
    }
}
Also used : Response(okhttp3.Response) InlongStreamConfigLogListResponse(org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogListResponse) SinkListResponse(org.apache.inlong.manager.common.pojo.sink.SinkListResponse) SourceListResponse(org.apache.inlong.manager.common.pojo.source.SourceListResponse) InlongGroupListResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse) InlongGroupResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupResponse) FullStreamResponse(org.apache.inlong.manager.common.pojo.stream.FullStreamResponse) Call(okhttp3.Call) SinkRequest(org.apache.inlong.manager.common.pojo.sink.SinkRequest) Request(okhttp3.Request) InlongStreamApproveRequest(org.apache.inlong.manager.common.pojo.stream.InlongStreamApproveRequest) InlongGroupRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupRequest) SourceRequest(org.apache.inlong.manager.common.pojo.source.SourceRequest) InlongGroupApproveRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest) RequestBody(okhttp3.RequestBody)

Example 7 with SinkRequest

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

the class InlongStreamSinkTransfer method createSinkRequest.

public static SinkRequest createSinkRequest(StreamSink streamSink, InlongStreamInfo streamInfo) {
    SinkType sinkType = streamSink.getSinkType();
    SinkRequest sinkRequest;
    if (sinkType == SinkType.HIVE) {
        sinkRequest = createHiveRequest(streamSink, streamInfo);
    } else if (sinkType == SinkType.KAFKA) {
        sinkRequest = createKafkaRequest(streamSink, streamInfo);
    } else if (sinkType == SinkType.CLICKHOUSE) {
        sinkRequest = createClickHouseRequest(streamSink, streamInfo);
    } else {
        throw new IllegalArgumentException(String.format("Unsupport sink type : %s for Inlong", sinkType));
    }
    return sinkRequest;
}
Also used : SinkType(org.apache.inlong.manager.common.enums.SinkType) SinkRequest(org.apache.inlong.manager.common.pojo.sink.SinkRequest) KafkaSinkRequest(org.apache.inlong.manager.common.pojo.sink.kafka.KafkaSinkRequest) HiveSinkRequest(org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkRequest) ClickHouseSinkRequest(org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkRequest)

Aggregations

SinkRequest (org.apache.inlong.manager.common.pojo.sink.SinkRequest)7 SourceRequest (org.apache.inlong.manager.common.pojo.source.SourceRequest)4 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)3 Call (okhttp3.Call)2 Request (okhttp3.Request)2 RequestBody (okhttp3.RequestBody)2 Response (okhttp3.Response)2 InlongGroupApproveRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest)2 InlongGroupListResponse (org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse)2 InlongGroupRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupRequest)2 InlongGroupResponse (org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)2 SinkListResponse (org.apache.inlong.manager.common.pojo.sink.SinkListResponse)2 SourceListResponse (org.apache.inlong.manager.common.pojo.source.SourceListResponse)2 FullStreamResponse (org.apache.inlong.manager.common.pojo.stream.FullStreamResponse)2 InlongStreamApproveRequest (org.apache.inlong.manager.common.pojo.stream.InlongStreamApproveRequest)2 InlongStreamConfigLogListResponse (org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogListResponse)2 SinkType (org.apache.inlong.manager.common.enums.SinkType)1 ClickHouseSinkRequest (org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkRequest)1 HiveSinkRequest (org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkRequest)1 KafkaSinkRequest (org.apache.inlong.manager.common.pojo.sink.kafka.KafkaSinkRequest)1