Search in sources :

Example 41 with ManagerException

use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.

the class PipelineServiceImpl method doToModel.

/**
 * 用于DO对象转化为Model对象
 *
 * @param pipelineDO
 * @return Pipeline
 */
private Pipeline doToModel(PipelineDO pipelineDo) {
    Pipeline pipeline = new Pipeline();
    try {
        pipeline.setId(pipelineDo.getId());
        pipeline.setName(pipelineDo.getName());
        pipeline.setParameters(pipelineDo.getParameters());
        pipeline.setDescription(pipelineDo.getDescription());
        pipeline.setGmtCreate(pipelineDo.getGmtCreate());
        pipeline.setGmtModified(pipelineDo.getGmtModified());
        pipeline.setChannelId(pipelineDo.getChannelId());
        pipeline.getParameters().setMainstemClientId(pipeline.getId().shortValue());
        // 组装DatamediaPair
        List<DataMediaPair> pairs = dataMediaPairService.listByPipelineId(pipelineDo.getId());
        Collections.sort(pairs, new DataMediaPairComparable());
        pipeline.setPairs(pairs);
        // 组装Node
        List<PipelineNodeRelationDO> relations = pipelineNodeRelationDao.listByPipelineIds(pipelineDo.getId());
        List<Long> totalNodeIds = new ArrayList<Long>();
        for (PipelineNodeRelationDO relation : relations) {
            Long nodeId = relation.getNodeId();
            if (!totalNodeIds.contains(nodeId)) {
                totalNodeIds.add(nodeId);
            }
        }
        List<Node> totalNodes = nodeService.listByIds(totalNodeIds.toArray(new Long[totalNodeIds.size()]));
        List<Node> selectNodes = new ArrayList<Node>();
        List<Node> extractNodes = new ArrayList<Node>();
        List<Node> loadNodes = new ArrayList<Node>();
        for (Node node : totalNodes) {
            for (PipelineNodeRelationDO relation : relations) {
                if (node.getId().equals(relation.getNodeId())) {
                    if (relation.getLocation().isSelect()) {
                        selectNodes.add(node);
                    } else if (relation.getLocation().isExtract()) {
                        extractNodes.add(node);
                    } else if (relation.getLocation().isLoad()) {
                        loadNodes.add(node);
                    }
                }
            }
        }
        pipeline.setSelectNodes(selectNodes);
        pipeline.setExtractNodes(extractNodes);
        pipeline.setLoadNodes(loadNodes);
    } catch (Exception e) {
        logger.error("ERROR ## change the pipeline Do to Model has an exception");
        throw new ManagerException(e);
    }
    return pipeline;
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) Node(com.alibaba.otter.shared.common.model.config.node.Node) ArrayList(java.util.ArrayList) 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) DataMediaPairComparable(com.alibaba.otter.shared.common.model.config.data.DataMediaPairComparable) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) PipelineNodeRelationDO(com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineNodeRelationDO)

Example 42 with ManagerException

use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.

the class PipelineServiceImpl method doToModelWithoutOther.

private Pipeline doToModelWithoutOther(PipelineDO pipelineDo) {
    Pipeline pipeline = new Pipeline();
    try {
        pipeline.setId(pipelineDo.getId());
        pipeline.setName(pipelineDo.getName());
        pipeline.setParameters(pipelineDo.getParameters());
        pipeline.setDescription(pipelineDo.getDescription());
        pipeline.setGmtCreate(pipelineDo.getGmtCreate());
        pipeline.setGmtModified(pipelineDo.getGmtModified());
        pipeline.setChannelId(pipelineDo.getChannelId());
        pipeline.getParameters().setMainstemClientId(pipeline.getId().shortValue());
    } catch (Exception e) {
        logger.error("ERROR ## change the pipeline Do to Model has an exception");
        throw new ManagerException(e);
    }
    return pipeline;
}
Also used : 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 43 with ManagerException

use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.

the class DataMediaServiceImpl method createReturnId.

/**
 * 添加
 */
@Override
public Long createReturnId(DataMedia dataMedia) {
    Assert.assertNotNull(dataMedia);
    try {
        DataMediaDO dataMediaDo = modelToDo(dataMedia);
        dataMediaDo.setId(0L);
        DataMediaDO dataMediaDoInDb = dataMediaDao.checkUniqueAndReturnExist(dataMediaDo);
        if (dataMediaDoInDb == null) {
            dataMediaDo = dataMediaDao.insert(dataMediaDo);
        } else {
            dataMediaDo = dataMediaDoInDb;
        }
        return dataMediaDo.getId();
    } catch (RepeatConfigureException rce) {
        throw rce;
    } catch (Exception e) {
        logger.error("ERROR ## create dataMedia has an exception!");
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) DataMediaDO(com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 44 with ManagerException

use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.

the class DataMediaServiceImpl method listByCondition.

@Override
public List<DataMedia> listByCondition(Map condition) {
    List<DataMedia> dataMedias = new ArrayList<DataMedia>();
    try {
        List<DataMediaDO> dataMediaDos = dataMediaDao.listByCondition(condition);
        if (dataMediaDos.isEmpty()) {
            logger.debug("DEBUG ## couldn't query any dataMedias by the condition:" + JsonUtils.marshalToString(condition));
            return dataMedias;
        }
        dataMedias = doToModel(dataMediaDos);
    } catch (Exception e) {
        logger.error("ERROR ## query dataMedias by condition has an exception!");
        throw new ManagerException(e);
    }
    return dataMedias;
}
Also used : DataMediaDO(com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO) ArrayList(java.util.ArrayList) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) MqDataMedia(com.alibaba.otter.shared.common.model.config.data.mq.MqDataMedia) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) DbDataMedia(com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 45 with ManagerException

use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.

the class DataMediaServiceImpl method listByDataMediaSourceId.

@Override
public List<DataMedia> listByDataMediaSourceId(Long dataMediaSourceId) {
    Assert.assertNotNull(dataMediaSourceId);
    List<DataMediaDO> dataMediaDos = null;
    try {
        dataMediaDos = dataMediaDao.listByDataMediaSourceId(dataMediaSourceId);
        if (dataMediaDos.isEmpty()) {
            logger.debug("DEBUG ## couldn't query any dataMedia, maybe hasn't create any dataMedia.");
            return new ArrayList<DataMedia>();
        }
    } catch (Exception e) {
        logger.error("ERROR ## query dataMedias by sourceId:" + dataMediaSourceId + " has an exception!");
        throw new ManagerException(e);
    }
    return doToModel(dataMediaDos);
}
Also used : DataMediaDO(com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO) ArrayList(java.util.ArrayList) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Aggregations

ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)85 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)76 ArrayList (java.util.ArrayList)35 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)17 TransactionStatus (org.springframework.transaction.TransactionStatus)13 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)13 InvalidConfigureException (com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException)12 PipelineDO (com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineDO)10 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)10 DataMediaPairDO (com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO)9 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)9 ChannelDO (com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO)8 DataMediaDO (com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO)7 Node (com.alibaba.otter.shared.common.model.config.node.Node)7 CanalDO (com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO)5 DataColumnPairDO (com.alibaba.otter.manager.biz.config.datacolumnpair.dal.dataobject.DataColumnPairDO)5 DataMatrixDO (com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO)5 PipelineNodeRelationDO (com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineNodeRelationDO)5 DataMedia (com.alibaba.otter.shared.common.model.config.data.DataMedia)5 DataMediaSourceDO (com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO)4