Search in sources :

Example 1 with InlongGroupResponse

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

the class InlongParser method parseGroupInfo.

public static InlongGroupResponse parseGroupInfo(Response response) {
    Object data = response.getData();
    JsonObject groupJson = GsonUtil.fromJson(GsonUtil.toJson(data), JsonObject.class);
    InlongGroupResponse inlongGroupResponse = GsonUtil.fromJson(GsonUtil.toJson(data), InlongGroupResponse.class);
    JsonObject mqExtInfo = groupJson.getAsJsonObject(MQ_EXT_INFO);
    if (mqExtInfo != null && mqExtInfo.get(MIDDLEWARE_TYPE) != null) {
        String middlewareType = mqExtInfo.get(MIDDLEWARE_TYPE).getAsString();
        if (Constant.MIDDLEWARE_PULSAR.equals(middlewareType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(middlewareType)) {
            InlongGroupPulsarInfo pulsarInfo = GsonUtil.fromJson(mqExtInfo.toString(), InlongGroupPulsarInfo.class);
            inlongGroupResponse.setMqExtInfo(pulsarInfo);
        }
    }
    return inlongGroupResponse;
}
Also used : InlongGroupPulsarInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject) InlongGroupResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)

Example 2 with InlongGroupResponse

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

the class InlongGroupImpl method delete.

@Override
public InlongGroupContext delete() throws Exception {
    InlongGroupResponse groupResponse = managerClient.getGroupInfo(groupContext.getGroupId());
    boolean isDeleted = managerClient.deleteInlongGroup(groupResponse.getInlongGroupId());
    if (isDeleted) {
        groupResponse.setStatus(GroupState.DELETED.getCode());
    }
    return generateSnapshot();
}
Also used : InlongGroupResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)

Example 3 with InlongGroupResponse

use of org.apache.inlong.manager.common.pojo.group.InlongGroupResponse 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 4 with InlongGroupResponse

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

the class InlongClientImpl method getGroup.

@Override
public InlongGroup getGroup(String groupName) throws Exception {
    InnerInlongManagerClient managerClient = new InnerInlongManagerClient(this);
    final String groupId = "b_" + groupName;
    InlongGroupResponse groupResponse = managerClient.getGroupInfo(groupId);
    if (groupResponse == null) {
        return new BlankInlongGroup();
    }
    InlongGroupConf groupConf = InlongGroupTransfer.parseGroupResponse(groupResponse);
    return new InlongGroupImpl(groupConf, this);
}
Also used : InlongGroupConf(org.apache.inlong.manager.client.api.InlongGroupConf) InnerInlongManagerClient(org.apache.inlong.manager.client.api.inner.InnerInlongManagerClient) InlongGroupResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)

Example 5 with InlongGroupResponse

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

the class InlongGroupImpl method generateSnapshot.

private InlongGroupContext generateSnapshot() {
    // Fetch current group
    InlongGroupResponse groupResponse = managerClient.getGroupInfo(groupContext.getGroupId());
    InlongGroupInfo currentGroupInfo = CommonBeanUtils.copyProperties(groupResponse, InlongGroupInfo::new);
    groupContext.setGroupInfo(currentGroupInfo);
    String inlongGroupId = currentGroupInfo.getInlongGroupId();
    // Fetch stream in group
    List<InlongStream> dataStreams = fetchDataStreams(inlongGroupId);
    if (CollectionUtils.isNotEmpty(dataStreams)) {
        dataStreams.forEach(dataStream -> groupContext.setStream(dataStream));
    }
    // Create group context
    InlongGroupContext inlongGroupContext = new InlongGroupContext(groupContext, groupConf);
    // Fetch group logs
    List<EventLogView> logViews = managerClient.getInlongGroupError(inlongGroupId);
    if (CollectionUtils.isNotEmpty(logViews)) {
        Map<String, List<String>> errMsgs = Maps.newHashMap();
        Map<String, List<String>> groupLogs = Maps.newHashMap();
        logViews.stream().filter(x -> StringUtils.isNotEmpty(x.getElementName())).forEach(eventLogView -> {
            String taskName = eventLogView.getElementName();
            if (StringUtils.isNotEmpty(eventLogView.getException())) {
                errMsgs.computeIfAbsent(taskName, Lists::newArrayList).add(eventLogView.getException());
            }
            if (StringUtils.isNotEmpty(eventLogView.getRemark())) {
                groupLogs.computeIfAbsent(taskName, Lists::newArrayList).add(eventLogView.getRemark());
            }
        });
        inlongGroupContext.setErrMsgs(errMsgs);
        inlongGroupContext.setGroupLogs(groupLogs);
    }
    // Fetch stream logs
    Map<String, InlongStream> streams = inlongGroupContext.getInlongStreamMap();
    streams.keySet().stream().forEach(streamName -> {
        String inlongStreamId = "b_" + streamName;
        List<InlongStreamConfigLogListResponse> logList = managerClient.getStreamLogs(inlongGroupId, inlongStreamId);
        if (CollectionUtils.isNotEmpty(logList)) {
            Map<String, List<String>> streamLogs = Maps.newHashMap();
            logList.stream().filter(x -> StringUtils.isNotEmpty(x.getComponentName())).forEach(streamLog -> {
                String componentName = streamLog.getComponentName();
                String log = GsonUtil.toJson(streamLog);
                streamLogs.computeIfAbsent(componentName, Lists::newArrayList).add(log);
            });
            inlongGroupContext.getStreamLogs().put(streamName, streamLogs);
        }
    });
    return inlongGroupContext;
}
Also used : InlongParser(org.apache.inlong.manager.client.api.util.InlongParser) GsonUtil(org.apache.inlong.manager.client.api.util.GsonUtil) AssertUtil(org.apache.inlong.manager.client.api.util.AssertUtil) ProcessStatus(org.apache.inlong.manager.common.enums.ProcessStatus) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) TaskResponse(org.apache.inlong.manager.common.pojo.workflow.TaskResponse) StringUtils(org.apache.commons.lang3.StringUtils) InlongGroupContext(org.apache.inlong.manager.client.api.InlongGroupContext) Lists(com.google.common.collect.Lists) Pair(org.apache.commons.lang3.tuple.Pair) CollectionUtils(org.apache.commons.collections.CollectionUtils) InlongStream(org.apache.inlong.manager.client.api.InlongStream) Map(java.util.Map) InnerInlongManagerClient(org.apache.inlong.manager.client.api.inner.InnerInlongManagerClient) ProcessResponse(org.apache.inlong.manager.common.pojo.workflow.ProcessResponse) InlongStreamBuilder(org.apache.inlong.manager.client.api.InlongStreamBuilder) GroupState(org.apache.inlong.manager.common.enums.GroupState) InlongStreamApproveRequest(org.apache.inlong.manager.common.pojo.stream.InlongStreamApproveRequest) InlongStreamConfigLogListResponse(org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogListResponse) InlongGroup(org.apache.inlong.manager.client.api.InlongGroup) InlongGroupRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupRequest) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) InlongGroupTransfer(org.apache.inlong.manager.client.api.util.InlongGroupTransfer) EventLogView(org.apache.inlong.manager.common.pojo.workflow.EventLogView) InlongGroupResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupResponse) List(java.util.List) InnerGroupContext(org.apache.inlong.manager.client.api.inner.InnerGroupContext) InlongGroupConf(org.apache.inlong.manager.client.api.InlongGroupConf) InlongStreamConf(org.apache.inlong.manager.client.api.InlongStreamConf) CommonBeanUtils(org.apache.inlong.manager.common.util.CommonBeanUtils) FullStreamResponse(org.apache.inlong.manager.common.pojo.stream.FullStreamResponse) WorkflowResult(org.apache.inlong.manager.common.pojo.workflow.WorkflowResult) InlongGroupApproveRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest) InlongGroupState(org.apache.inlong.manager.client.api.InlongGroupContext.InlongGroupState) EventLogView(org.apache.inlong.manager.common.pojo.workflow.EventLogView) InlongStreamConfigLogListResponse(org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogListResponse) InlongGroupContext(org.apache.inlong.manager.client.api.InlongGroupContext) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) InlongStream(org.apache.inlong.manager.client.api.InlongStream) List(java.util.List) 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