Search in sources :

Example 6 with PipelineNodeRelationDO

use of com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineNodeRelationDO in project otter by alibaba.

the class PipelineServiceImpl method listByNodeId.

public List<Pipeline> listByNodeId(Long nodeId) {
    Assert.assertNotNull(nodeId);
    List<Pipeline> pipelines = new ArrayList<Pipeline>();
    try {
        List<PipelineNodeRelationDO> relations = pipelineNodeRelationDao.listByNodeId(nodeId);
        if (relations.isEmpty()) {
            logger.debug("DEBUG ## query the relation by nodeId:" + nodeId + " return null,maybe hasn't create any relations.");
            return pipelines;
        }
        List<Long> piplineIds = new ArrayList<Long>();
        for (PipelineNodeRelationDO relation : relations) {
            piplineIds.add(relation.getPipelineId());
        }
        List<PipelineDO> pipelineDos = pipelineDao.listByMultiId(piplineIds.toArray(new Long[piplineIds.size()]));
        if (pipelineDos.isEmpty()) {
            String exceptionCause = "query the pipelines by pipelineIds:" + piplineIds.toString() + " return null!";
            logger.error("ERROR ## " + exceptionCause);
            throw new ManagerException(exceptionCause);
        }
        pipelines = doToModel(pipelineDos);
    } catch (Exception e) {
        logger.error("ERROR ## query the pipelines by nodeId:" + nodeId + " has an exception!");
        throw new ManagerException(e);
    }
    return pipelines;
}
Also used : ArrayList(java.util.ArrayList) PipelineDO(com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) PipelineNodeRelationDO(com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineNodeRelationDO)

Aggregations

PipelineNodeRelationDO (com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineNodeRelationDO)6 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)5 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)5 ArrayList (java.util.ArrayList)5 Node (com.alibaba.otter.shared.common.model.config.node.Node)4 PipelineDO (com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineDO)3 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)3 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)2 DataMediaPairComparable (com.alibaba.otter.shared.common.model.config.data.DataMediaPairComparable)2 SQLException (java.sql.SQLException)1 Iterator (java.util.Iterator)1 List (java.util.List)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)1