Search in sources :

Example 6 with InlongGroupRequest

use of org.apache.inlong.manager.common.pojo.group.InlongGroupRequest in project incubator-inlong by apache.

the class InnerInlongManagerClient method updateGroup.

/**
 * Update inlong group info
 *
 * @return groupId && errMsg
 */
public Pair<String, String> updateGroup(InlongGroupRequest groupRequest) {
    String path = HTTP_PATH + "/group/update";
    final String group = GsonUtil.toJson(groupRequest);
    final RequestBody groupBody = RequestBody.create(MediaType.parse("application/json"), group);
    final String url = formatUrl(path);
    Request request = new Request.Builder().url(url).method("POST", groupBody).build();
    Call call = httpClient.newCall(request);
    try {
        Response response = call.execute();
        assert response.body() != null;
        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);
        return Pair.of(responseBody.getData().toString(), responseBody.getErrMsg());
    } catch (Exception e) {
        throw new RuntimeException(String.format("Inlong group update failed: %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 InlongGroupRequest

use of org.apache.inlong.manager.common.pojo.group.InlongGroupRequest in project incubator-inlong by apache.

the class InnerInlongManagerClient method initInlongGroup.

public WorkflowResult initInlongGroup(InlongGroupRequest groupInfo) {
    final String groupId = groupInfo.getInlongGroupId();
    String path = HTTP_PATH + "/group/startProcess/" + groupId;
    final String url = formatUrl(path);
    RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), "");
    Request request = new Request.Builder().url(url).method("POST", requestBody).build();
    Call call = httpClient.newCall(request);
    try {
        Response response = call.execute();
        assert response.body() != null;
        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);
        AssertUtil.isTrue(responseBody.getErrMsg() == null, String.format("Inlong request failed: %s", responseBody.getErrMsg()));
        return InlongParser.parseWorkflowResult(responseBody);
    } catch (Exception e) {
        throw new RuntimeException(String.format("Inlong group init failed: %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 8 with InlongGroupRequest

use of org.apache.inlong.manager.common.pojo.group.InlongGroupRequest in project incubator-inlong by apache.

the class InnerInlongManagerClient method createGroup.

/**
 * Create inlong group
 */
public String createGroup(InlongGroupRequest groupInfo) {
    String path = HTTP_PATH + "/group/save";
    final String biz = GsonUtil.toJson(groupInfo);
    final RequestBody bizBody = RequestBody.create(MediaType.parse("application/json"), biz);
    final String url = formatUrl(path);
    Request request = new Request.Builder().url(url).method("POST", bizBody).build();
    Call call = httpClient.newCall(request);
    try {
        Response response = call.execute();
        assert response.body() != null;
        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);
        AssertUtil.isTrue(responseBody.getErrMsg() == null, String.format("Inlong request failed: %s", responseBody.getErrMsg()));
        return responseBody.getData().toString();
    } catch (Exception e) {
        throw new RuntimeException(String.format("inlong group save failed: %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)

Aggregations

InlongGroupRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupRequest)8 InlongGroupResponse (org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)4 Call (okhttp3.Call)3 Request (okhttp3.Request)3 RequestBody (okhttp3.RequestBody)3 Response (okhttp3.Response)3 InlongGroupApproveRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest)3 InlongGroupListResponse (org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse)3 SinkListResponse (org.apache.inlong.manager.common.pojo.sink.SinkListResponse)3 SinkRequest (org.apache.inlong.manager.common.pojo.sink.SinkRequest)3 SourceListResponse (org.apache.inlong.manager.common.pojo.source.SourceListResponse)3 SourceRequest (org.apache.inlong.manager.common.pojo.source.SourceRequest)3 FullStreamResponse (org.apache.inlong.manager.common.pojo.stream.FullStreamResponse)3 InlongStreamApproveRequest (org.apache.inlong.manager.common.pojo.stream.InlongStreamApproveRequest)3 InlongStreamConfigLogListResponse (org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogListResponse)3 Date (java.util.Date)2 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)2 InlongGroupEntity (org.apache.inlong.manager.dao.entity.InlongGroupEntity)2 Test (org.junit.Test)2 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)1