Search in sources :

Example 41 with InlongGroupInfo

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

the class InlongGroupServiceImpl method getTopic.

@Override
public InlongGroupTopicResponse getTopic(String groupId) {
    LOGGER.debug("begin to get topic by groupId={}", groupId);
    InlongGroupInfo groupInfo = this.get(groupId);
    String mqType = groupInfo.getMiddlewareType();
    InlongGroupTopicResponse topicVO = new InlongGroupTopicResponse();
    if (Constant.MIDDLEWARE_TUBE.equals(mqType)) {
        // Tube Topic corresponds to inlong group one-to-one
        topicVO.setMqResourceObj(groupInfo.getMqResourceObj());
        topicVO.setTubeMasterUrl(commonOperateService.getSpecifiedParam(Constant.TUBE_MASTER_URL));
    } else if (Constant.MIDDLEWARE_PULSAR.equals(mqType) || Constant.MIDDLEWARE_TDMQ_PULSAR.equals(mqType)) {
        // Pulsar's topic corresponds to the inlong stream one-to-one
        topicVO.setDsTopicList(streamService.getTopicList(groupId));
        topicVO.setPulsarAdminUrl(commonOperateService.getSpecifiedParam(Constant.PULSAR_ADMINURL));
        topicVO.setPulsarServiceUrl(commonOperateService.getSpecifiedParam(Constant.PULSAR_SERVICEURL));
    } else {
        LOGGER.error("middleware type={} not supported", mqType);
        throw new BusinessException(ErrorCodeEnum.MIDDLEWARE_TYPE_NOT_SUPPORTED);
    }
    topicVO.setInlongGroupId(groupId);
    topicVO.setMiddlewareType(mqType);
    return topicVO;
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) InlongGroupTopicResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupTopicResponse) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)

Example 42 with InlongGroupInfo

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

the class PushSortConfigListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("begin to push sort config by context={}", context);
    }
    GroupResourceProcessForm form = (GroupResourceProcessForm) context.getProcessForm();
    String groupId = form.getGroupInfo().getInlongGroupId();
    InlongGroupInfo groupInfo = groupService.get(groupId);
    // if streamId not null, just push the config belongs to the groupId and the streamId
    String streamId = form.getInlongStreamId();
    List<SinkResponse> sinkResponseList = streamSinkService.listSink(groupId, streamId);
    if (CollectionUtils.isEmpty(sinkResponseList)) {
        LOGGER.warn("Sink not found by groupId={}", groupId);
        return ListenerResult.success();
    }
    for (SinkResponse sinkResponse : sinkResponseList) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("sink info: {}", sinkResponse);
        }
        DataFlowInfo dataFlowInfo = commonOperateService.createDataFlow(groupInfo, sinkResponse);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("try to push config to sort: {}", JsonUtils.toJson(dataFlowInfo));
        }
        Integer sinkId = sinkResponse.getId();
        try {
            String zkUrl = clusterBean.getZkUrl();
            String zkRoot = clusterBean.getZkRoot();
            // push data flow info to zk
            String sortClusterName = clusterBean.getAppName();
            ZkTools.updateDataFlowInfo(dataFlowInfo, sortClusterName, sinkId, zkUrl, zkRoot);
            // add sink id to zk
            ZkTools.addDataFlowToCluster(sortClusterName, sinkId, zkUrl, zkRoot);
        } catch (Exception e) {
            LOGGER.error("push sort config to zookeeper failed, sinkId={} ", sinkId, e);
            throw new WorkflowListenerException("push sort config to zookeeper failed: " + e.getMessage());
        }
    }
    return ListenerResult.success();
}
Also used : SinkResponse(org.apache.inlong.manager.common.pojo.sink.SinkResponse) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException) InlongGroupInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupInfo) GroupResourceProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException) DataFlowInfo(org.apache.inlong.sort.protocol.DataFlowInfo)

Aggregations

InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)42 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)18 Test (org.junit.Test)11 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)10 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)10 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)10 WorkflowListenerException (org.apache.inlong.manager.common.exceptions.WorkflowListenerException)9 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)8 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)8 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)6 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)6 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)6 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)5 List (java.util.List)4 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)4 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)4 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)4 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)4 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)4 InlongGroupExtInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)3