Search in sources :

Example 1 with WorkflowListenerException

use of org.apache.inlong.manager.common.exceptions.WorkflowListenerException in project incubator-inlong by apache.

the class CreatePulsarTopicForStreamTaskListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    GroupResourceProcessForm form = (GroupResourceProcessForm) context.getProcessForm();
    String groupId = form.getInlongGroupId();
    String streamId = form.getInlongStreamId();
    InlongGroupInfo groupInfo = groupService.get(groupId);
    InlongStreamEntity streamEntity = streamMapper.selectByIdentifier(groupId, streamId);
    if (groupInfo == null || streamEntity == null) {
        throw new WorkflowListenerException("inlong group or inlong stream not found with groupId=" + groupId + ", streamId=" + streamId);
    }
    log.info("begin to create pulsar topic for groupId={}, streamId={}", groupId, streamId);
    PulsarClusterInfo globalCluster = commonOperateService.getPulsarClusterInfo(groupInfo.getMiddlewareType());
    try (PulsarAdmin globalPulsarAdmin = PulsarUtils.getPulsarAdmin(globalCluster)) {
        List<String> pulsarClusters = PulsarUtils.getPulsarClusters(globalPulsarAdmin);
        for (String cluster : pulsarClusters) {
            String serviceUrl = PulsarUtils.getServiceUrl(globalPulsarAdmin, cluster);
            PulsarClusterInfo pulsarClusterInfo = PulsarClusterInfo.builder().token(globalCluster.getToken()).adminUrl(serviceUrl).build();
            String pulsarTopic = streamEntity.getMqResourceObj();
            this.createTopic(groupInfo, pulsarTopic, pulsarClusterInfo);
        }
    } catch (Exception e) {
        log.error("create pulsar topic error for groupId={}, streamId={}", groupId, streamId, e);
        throw new WorkflowListenerException("create pulsar topic error for groupId=" + groupId + ", streamId=" + streamId);
    }
    log.info("success to create pulsar topic for groupId={}, streamId={}", groupId, streamId);
    return ListenerResult.success();
}
Also used : PulsarAdmin(org.apache.pulsar.client.admin.PulsarAdmin) InlongStreamEntity(org.apache.inlong.manager.dao.entity.InlongStreamEntity) PulsarClusterInfo(org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo) 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)

Example 2 with WorkflowListenerException

use of org.apache.inlong.manager.common.exceptions.WorkflowListenerException in project incubator-inlong by apache.

the class CreateTubeGroupTaskListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    GroupResourceProcessForm form = (GroupResourceProcessForm) context.getProcessForm();
    String groupId = form.getInlongGroupId();
    log.info("try to create consumer group for groupId {}", groupId);
    InlongGroupInfo groupInfo = groupService.get(groupId);
    String topicName = groupInfo.getMqResourceObj();
    int clusterId = Integer.parseInt(commonOperateService.getSpecifiedParam(Constant.CLUSTER_TUBE_CLUSTER_ID));
    QueryTubeTopicRequest queryTubeTopicRequest = QueryTubeTopicRequest.builder().topicName(topicName).clusterId(clusterId).user(groupInfo.getCreator()).build();
    // Query whether the tube topic exists
    boolean topicExist = tubeMqOptService.queryTopicIsExist(queryTubeTopicRequest);
    Integer tryNumber = reTryConfigBean.getMaxAttempts();
    Long delay = reTryConfigBean.getDelay();
    while (!topicExist && --tryNumber > 0) {
        log.info("check whether the tube topic exists, try count={}", tryNumber);
        try {
            Thread.sleep(delay);
            delay *= reTryConfigBean.getMultiplier();
            topicExist = tubeMqOptService.queryTopicIsExist(queryTubeTopicRequest);
        } catch (InterruptedException e) {
            log.error("check the tube topic exists error", e);
        }
    }
    AddTubeConsumeGroupRequest addTubeConsumeGroupRequest = new AddTubeConsumeGroupRequest();
    addTubeConsumeGroupRequest.setClusterId(clusterId);
    addTubeConsumeGroupRequest.setCreateUser(groupInfo.getCreator());
    GroupNameJsonSetBean groupNameJsonSetBean = new GroupNameJsonSetBean();
    groupNameJsonSetBean.setTopicName(topicName);
    String consumeGroupName = "sort_" + topicName + "_group";
    groupNameJsonSetBean.setGroupName(consumeGroupName);
    addTubeConsumeGroupRequest.setGroupNameJsonSet(Collections.singletonList(groupNameJsonSetBean));
    try {
        tubeMqOptService.createNewConsumerGroup(addTubeConsumeGroupRequest);
    } catch (Exception e) {
        throw new WorkflowListenerException("create tube consumer group for groupId=" + groupId + " error", e);
    }
    log.info("finish to create consumer group for {}", groupId);
    return ListenerResult.success();
}
Also used : GroupNameJsonSetBean(org.apache.inlong.manager.common.pojo.tubemq.AddTubeConsumeGroupRequest.GroupNameJsonSetBean) 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) AddTubeConsumeGroupRequest(org.apache.inlong.manager.common.pojo.tubemq.AddTubeConsumeGroupRequest) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException) QueryTubeTopicRequest(org.apache.inlong.manager.common.pojo.tubemq.QueryTubeTopicRequest)

Example 3 with WorkflowListenerException

use of org.apache.inlong.manager.common.exceptions.WorkflowListenerException in project incubator-inlong by apache.

the class GroupCancelProcessListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    NewGroupProcessForm form = (NewGroupProcessForm) context.getProcessForm();
    // After canceling the approval, the status becomes [Waiting to submit]
    String groupId = form.getInlongGroupId();
    // Only the [Wait approval] status allowed the canceling operation
    InlongGroupEntity entity = groupMapper.selectByGroupId(groupId);
    if (entity == null) {
        throw new WorkflowListenerException("inlong group not found with group id=" + groupId);
    }
    if (!Objects.equals(GroupState.TO_BE_APPROVAL.getCode(), entity.getStatus())) {
        throw new WorkflowListenerException("current status was not allowed to cancel business");
    }
    // After canceling the approval, the status becomes [Waiting to submit]
    String username = context.getApplicant();
    groupMapper.updateStatus(groupId, GroupState.TO_BE_SUBMIT.getCode(), username);
    return ListenerResult.success();
}
Also used : InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) NewGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.NewGroupProcessForm) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException)

Example 4 with WorkflowListenerException

use of org.apache.inlong.manager.common.exceptions.WorkflowListenerException in project incubator-inlong by apache.

the class GroupPassTaskListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    // Save the data format selected at the time of approval and the cluster information of the inlong stream
    InlongGroupApproveForm form = (InlongGroupApproveForm) context.getActionContext().getForm();
    InlongGroupApproveRequest approveInfo = form.getGroupApproveInfo();
    // Only the [Wait approval] status allowed the passing operation
    String groupId = approveInfo.getInlongGroupId();
    InlongGroupEntity entity = groupMapper.selectByGroupId(groupId);
    if (entity == null) {
        throw new WorkflowListenerException("inlong group not found with group id=" + groupId);
    }
    if (!Objects.equals(GroupState.TO_BE_APPROVAL.getCode(), entity.getStatus())) {
        throw new WorkflowListenerException("inlong group status is [wait_approval], not allowed to approve again");
    }
    // Save the inlong group information after approval
    groupService.updateAfterApprove(approveInfo, context.getApplicant());
    // Save inlong stream information after approval
    List<InlongStreamApproveRequest> streamApproveInfoList = form.getStreamApproveInfoList();
    streamService.updateAfterApprove(streamApproveInfoList, context.getApplicant());
    return ListenerResult.success();
}
Also used : InlongGroupApproveForm(org.apache.inlong.manager.common.pojo.workflow.form.InlongGroupApproveForm) InlongStreamApproveRequest(org.apache.inlong.manager.common.pojo.stream.InlongStreamApproveRequest) InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException) InlongGroupApproveRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest)

Example 5 with WorkflowListenerException

use of org.apache.inlong.manager.common.exceptions.WorkflowListenerException in project incubator-inlong by apache.

the class GroupRejectProcessListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    NewGroupProcessForm form = (NewGroupProcessForm) context.getProcessForm();
    // Only the [Wait approval] status allowed the rejecting operation
    String groupId = form.getInlongGroupId();
    InlongGroupEntity entity = groupMapper.selectByGroupId(groupId);
    if (entity == null) {
        throw new WorkflowListenerException("inlong group not found with group id=" + groupId);
    }
    if (!Objects.equals(GroupState.TO_BE_APPROVAL.getCode(), entity.getStatus())) {
        throw new WorkflowListenerException("current status was not allowed to reject inlong group");
    }
    // After reject, update inlong group status to [GROUP_APPROVE_REJECT]
    String username = context.getApplicant();
    groupService.updateStatus(groupId, GroupState.APPROVE_REJECTED.getCode(), username);
    return ListenerResult.success();
}
Also used : InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) NewGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.NewGroupProcessForm) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException)

Aggregations

WorkflowListenerException (org.apache.inlong.manager.common.exceptions.WorkflowListenerException)18 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)8 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)7 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)7 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)6 PulsarTopicBean (org.apache.inlong.manager.common.pojo.pulsar.PulsarTopicBean)3 InlongGroupEntity (org.apache.inlong.manager.dao.entity.InlongGroupEntity)3 InlongStreamEntity (org.apache.inlong.manager.dao.entity.InlongStreamEntity)3 AddTubeConsumeGroupRequest (org.apache.inlong.manager.common.pojo.tubemq.AddTubeConsumeGroupRequest)2 NewGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.NewGroupProcessForm)2 WorkflowEventLogEntity (org.apache.inlong.manager.dao.entity.WorkflowEventLogEntity)2 DataFlowInfo (org.apache.inlong.sort.protocol.DataFlowInfo)2 SourceInfo (org.apache.inlong.sort.protocol.source.SourceInfo)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)1 InlongGroupApproveRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest)1 SinkResponse (org.apache.inlong.manager.common.pojo.sink.SinkResponse)1 HiveSinkResponse (org.apache.inlong.manager.common.pojo.sink.hive.HiveSinkResponse)1