Search in sources :

Example 1 with InlongGroupListResponse

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

the class InnerInlongManagerClient method listGroups.

public PageInfo<InlongGroupListResponse> listGroups(String keyword, int status, int pageNum, int pageSize) {
    if (pageNum <= 0) {
        pageNum = 1;
    }
    JSONObject groupQuery = new JSONObject();
    groupQuery.put("keyWord", pageNum);
    groupQuery.put("status", status);
    groupQuery.put("pageNum", pageNum);
    groupQuery.put("pageSize", pageSize);
    String operationData = GsonUtil.toJson(groupQuery);
    RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), operationData);
    String path = HTTP_PATH + "/group/list";
    final String url = formatUrl(path);
    Request request = new Request.Builder().get().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);
        if (responseBody.getErrMsg() != null) {
            if (responseBody.getErrMsg().contains("Inlong group does not exist")) {
                return null;
            } else {
                throw new RuntimeException(responseBody.getErrMsg());
            }
        } else {
            return InlongParser.parseGroupList(responseBody);
        }
    } catch (Exception e) {
        throw new RuntimeException(String.format("Inlong group get failed: %s", e.getMessage()), e);
    }
}
Also used : 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) 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) JSONObject(com.alibaba.fastjson.JSONObject) RequestBody(okhttp3.RequestBody)

Example 2 with InlongGroupListResponse

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

the class InlongClientImpl method listGroup.

@Override
public List<InlongGroup> listGroup(String expr, int status, int pageNum, int pageSize) throws Exception {
    InnerInlongManagerClient managerClient = new InnerInlongManagerClient(this);
    PageInfo<InlongGroupListResponse> responsePageInfo = managerClient.listGroups(expr, status, pageNum, pageSize);
    if (CollectionUtils.isEmpty(responsePageInfo.getList())) {
        return Lists.newArrayList();
    } else {
        return responsePageInfo.getList().stream().map(response -> {
            String groupId = response.getInlongGroupId();
            InlongGroupResponse groupResponse = managerClient.getGroupInfo(groupId);
            InlongGroupConf groupConf = InlongGroupTransfer.parseGroupResponse(groupResponse);
            return new InlongGroupImpl(groupConf, this);
        }).collect(Collectors.toList());
    }
}
Also used : Socket(java.net.Socket) Getter(lombok.Getter) MapUtils(org.apache.commons.collections.MapUtils) ClientConfiguration(org.apache.inlong.manager.client.api.ClientConfiguration) IOException(java.io.IOException) PageInfo(com.github.pagehelper.PageInfo) InlongGroup(org.apache.inlong.manager.client.api.InlongGroup) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) InlongGroupTransfer(org.apache.inlong.manager.client.api.util.InlongGroupTransfer) InlongGroupListResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse) Slf4j(lombok.extern.slf4j.Slf4j) InlongGroupResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupResponse) List(java.util.List) Lists(com.google.common.collect.Lists) CollectionUtils(org.apache.commons.collections.CollectionUtils) InlongGroupConf(org.apache.inlong.manager.client.api.InlongGroupConf) Map(java.util.Map) InnerInlongManagerClient(org.apache.inlong.manager.client.api.inner.InnerInlongManagerClient) InlongClient(org.apache.inlong.manager.client.api.InlongClient) Splitter(com.google.common.base.Splitter) InlongGroupConf(org.apache.inlong.manager.client.api.InlongGroupConf) InnerInlongManagerClient(org.apache.inlong.manager.client.api.inner.InnerInlongManagerClient) InlongGroupListResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse) InlongGroupResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)

Example 3 with InlongGroupListResponse

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

the class InlongParser method parseGroupList.

public static PageInfo<InlongGroupListResponse> parseGroupList(Response response) {
    Object data = response.getData();
    String pageInfoJson = GsonUtil.toJson(data);
    return GsonUtil.fromJson(pageInfoJson, new TypeToken<PageInfo<InlongGroupListResponse>>() {
    }.getType());
}
Also used : TypeToken(com.google.common.reflect.TypeToken) JsonObject(com.google.gson.JsonObject) InlongGroupListResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse)

Aggregations

InlongGroupListResponse (org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse)3 InlongGroupResponse (org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)2 JSONObject (com.alibaba.fastjson.JSONObject)1 PageInfo (com.github.pagehelper.PageInfo)1 Splitter (com.google.common.base.Splitter)1 Lists (com.google.common.collect.Lists)1 TypeToken (com.google.common.reflect.TypeToken)1 JsonObject (com.google.gson.JsonObject)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 Socket (java.net.Socket)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Getter (lombok.Getter)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Call (okhttp3.Call)1 Request (okhttp3.Request)1 RequestBody (okhttp3.RequestBody)1 Response (okhttp3.Response)1