Search in sources :

Example 1 with PipelineDO

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

the class PipelineServiceImpl method listByChannelIdsWithoutColumn.

public List<Pipeline> listByChannelIdsWithoutColumn(Long... channelIds) {
    Assert.assertNotNull(channelIds);
    List<Pipeline> pipelines = new ArrayList<Pipeline>();
    try {
        List<PipelineDO> pipelineDos = pipelineDao.listByChannelIds(channelIds);
        if (pipelineDos.isEmpty()) {
            logger.debug("DEBUG ## query pipeline by channelId:" + channelIds + " return null.");
            return pipelines;
        }
        pipelines = doToModelWithoutColumn(pipelineDos);
    } catch (Exception e) {
        logger.error("ERROR ## query pipelines by channelIds:" + channelIds.toString() + " 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)

Example 2 with PipelineDO

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

the class PipelineServiceImpl method listByChannelIds.

/**
 * 更具channelId找到所属所有pipeline
 */
public List<Pipeline> listByChannelIds(Long... channelId) {
    Assert.assertNotNull(channelId);
    List<Pipeline> pipelines = new ArrayList<Pipeline>();
    try {
        List<PipelineDO> pipelineDos = pipelineDao.listByChannelIds(channelId);
        if (pipelineDos.isEmpty()) {
            logger.debug("DEBUG ## query pipeline by channelId:" + channelId + " return null.");
            return pipelines;
        }
        pipelines = doToModel(pipelineDos);
    } catch (Exception e) {
        logger.error("ERROR ## query pipelines by channelIds:" + channelId.toString() + " 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)

Example 3 with PipelineDO

use of com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineDO 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)

Example 4 with PipelineDO

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

the class PipelineServiceImpl method modelToDo.

/**
 * 用于Model对象转化为DO对象
 *
 * @param pipeline
 * @return PipelineDO
 */
private PipelineDO modelToDo(Pipeline pipeline) {
    PipelineDO pipelineDO = new PipelineDO();
    try {
        pipelineDO.setId(pipeline.getId());
        pipelineDO.setName(pipeline.getName());
        pipelineDO.setParameters(pipeline.getParameters());
        pipelineDO.setDescription(pipeline.getDescription());
        pipelineDO.setChannelId(pipeline.getChannelId());
        pipelineDO.setGmtCreate(pipeline.getGmtCreate());
        pipelineDO.setGmtModified(pipeline.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the pipeline Model to Do has an exception");
        throw new ManagerException(e);
    }
    return pipelineDO;
}
Also used : 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)

Example 5 with PipelineDO

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

the class PipelineServiceImpl method modify.

/**
 * 修改
 */
public void modify(Pipeline pipeline) {
    Assert.assertNotNull(pipeline);
    try {
        PipelineDO pipelineDo = modelToDo(pipeline);
        if (!pipelineDao.checkUnique(pipelineDo)) {
            String exceptionCause = "exist the same name pipeline under the channel(" + pipelineDo.getChannelId() + ") in the database.";
            logger.warn("WARN ## " + exceptionCause);
            throw new RepeatConfigureException(exceptionCause);
        }
        pipelineNodeRelationDao.deleteByPipelineId(pipelineDo.getId());
        pipelineDao.update(pipelineDo);
        List<PipelineNodeRelationDO> pipelineNodeRelationDos = new ArrayList<PipelineNodeRelationDO>();
        for (Node node : pipeline.getSelectNodes()) {
            PipelineNodeRelationDO pipelineNodeRelationDo = new PipelineNodeRelationDO();
            pipelineNodeRelationDo.setPipelineId(pipelineDo.getId());
            pipelineNodeRelationDo.setNodeId(node.getId());
            pipelineNodeRelationDo.setLocation(Location.SELECT);
            pipelineNodeRelationDos.add(pipelineNodeRelationDo);
        }
        for (Node node : pipeline.getExtractNodes()) {
            PipelineNodeRelationDO pipelineNodeRelationDo = new PipelineNodeRelationDO();
            pipelineNodeRelationDo.setPipelineId(pipelineDo.getId());
            pipelineNodeRelationDo.setNodeId(node.getId());
            pipelineNodeRelationDo.setLocation(Location.EXTRACT);
            pipelineNodeRelationDos.add(pipelineNodeRelationDo);
        }
        for (Node node : pipeline.getLoadNodes()) {
            PipelineNodeRelationDO pipelineNodeRelationDo = new PipelineNodeRelationDO();
            pipelineNodeRelationDo.setPipelineId(pipelineDo.getId());
            pipelineNodeRelationDo.setNodeId(node.getId());
            pipelineNodeRelationDo.setLocation(Location.LOAD);
            pipelineNodeRelationDos.add(pipelineNodeRelationDo);
        }
        pipelineNodeRelationDao.insertBatch(pipelineNodeRelationDos);
    } catch (Exception e) {
        logger.error("ERROR ## modify the pipeline(" + pipeline.getId() + ") has an exception!");
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) Node(com.alibaba.otter.shared.common.model.config.node.Node) 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) PipelineNodeRelationDO(com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineNodeRelationDO)

Aggregations

ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)10 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)10 PipelineDO (com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineDO)10 ArrayList (java.util.ArrayList)8 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)6 PipelineNodeRelationDO (com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineNodeRelationDO)3 Node (com.alibaba.otter.shared.common.model.config.node.Node)2 TransactionStatus (org.springframework.transaction.TransactionStatus)2 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)2 List (java.util.List)1