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