Search in sources :

Example 6 with InlongGroupResponse

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

the class InlongGroupImpl method initOnUpdate.

@Override
public InlongGroupContext initOnUpdate(InlongGroupConf conf) throws Exception {
    update(conf);
    InlongGroupInfo groupInfo = InlongGroupTransfer.createGroupInfo(conf);
    InlongGroupRequest groupRequest = groupInfo.genRequest();
    Pair<Boolean, InlongGroupResponse> existMsg = managerClient.isGroupExists(groupRequest);
    if (existMsg.getKey()) {
        groupInfo = CommonBeanUtils.copyProperties(existMsg.getValue(), InlongGroupInfo::new);
        this.groupContext.setGroupInfo(groupInfo);
        return init();
    } else {
        throw new RuntimeException(String.format("Group is not found by groupName=%s", groupInfo.getName()));
    }
}
Also used : InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) InlongGroupRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupRequest) InlongGroupResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)

Example 7 with InlongGroupResponse

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

the class InnerInlongManagerClient method getGroupInfo.

public InlongGroupResponse getGroupInfo(String inlongGroupId) {
    if (StringUtils.isEmpty(inlongGroupId)) {
        throw new IllegalArgumentException("InlongGroupId should not be empty");
    }
    String path = HTTP_PATH + "/group/get/" + inlongGroupId;
    final String url = formatUrl(path);
    Request request = new Request.Builder().get().url(url).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.parseGroupInfo(responseBody);
        }
    } catch (Exception e) {
        throw new RuntimeException(String.format("Inlong group get 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)

Example 8 with InlongGroupResponse

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

the class InnerInlongManagerClient method isGroupExists.

public Pair<Boolean, InlongGroupResponse> isGroupExists(InlongGroupRequest groupInfo) {
    String inlongGroupId = groupInfo.getInlongGroupId();
    if (StringUtils.isEmpty(inlongGroupId)) {
        inlongGroupId = "b_" + groupInfo.getName();
    }
    InlongGroupResponse currentBizInfo = getGroupInfo(inlongGroupId);
    if (currentBizInfo != null) {
        return Pair.of(true, currentBizInfo);
    } else {
        return Pair.of(false, null);
    }
}
Also used : InlongGroupResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)

Aggregations

InlongGroupResponse (org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)8 InlongGroupConf (org.apache.inlong.manager.client.api.InlongGroupConf)3 InnerInlongManagerClient (org.apache.inlong.manager.client.api.inner.InnerInlongManagerClient)3 InlongGroupRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupRequest)3 Lists (com.google.common.collect.Lists)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 CollectionUtils (org.apache.commons.collections.CollectionUtils)2 InlongGroup (org.apache.inlong.manager.client.api.InlongGroup)2 InlongGroupTransfer (org.apache.inlong.manager.client.api.util.InlongGroupTransfer)2 InlongGroupApproveRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest)2 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)2 InlongGroupListResponse (org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse)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 PageInfo (com.github.pagehelper.PageInfo)1 Splitter (com.google.common.base.Splitter)1 Maps (com.google.common.collect.Maps)1