Search in sources :

Example 26 with GroupResourceProcessForm

use of org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm 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

GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)26 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)16 WorkflowListenerException (org.apache.inlong.manager.common.exceptions.WorkflowListenerException)7 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)6 InlongStreamEntity (org.apache.inlong.manager.dao.entity.InlongStreamEntity)5 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)4 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)4 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)4 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)3 Test (org.junit.Test)3 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)2 PulsarTopicBean (org.apache.inlong.manager.common.pojo.pulsar.PulsarTopicBean)2 SinkForSortDTO (org.apache.inlong.manager.common.pojo.sink.SinkForSortDTO)2 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)2 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)2 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)2 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)2 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1