Search in sources :

Example 66 with ManagerException

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

the class NodeServiceImpl method modify.

/**
     * 修改
     */
public void modify(final Node node) {
    Assert.assertNotNull(node);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                NodeDO nodeDo = modelToDo(node);
                if (nodeDao.checkUnique(nodeDo)) {
                    nodeDao.update(nodeDo);
                } else {
                    String exceptionCause = "exist the same repeat node in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## modify node(" + node.getId() + ") has an exception!");
                throw new ManagerException(e);
            }
        }
    });
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) NodeDO(com.alibaba.otter.manager.biz.config.node.dal.dataobject.NodeDO) TransactionStatus(org.springframework.transaction.TransactionStatus) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 67 with ManagerException

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

the class PipelineServiceImpl method listByDestinationWithoutOther.

public List<Pipeline> listByDestinationWithoutOther(String destination) {
    Assert.assertNotNull(destination);
    List<Pipeline> pipelines = new ArrayList<Pipeline>();
    try {
        List<PipelineDO> pipelineDos = pipelineDao.listByDestinationCondition(destination);
        if (pipelineDos.isEmpty()) {
            logger.debug("DEBUG ## query pipeline by destination:" + destination + " return null.");
            return pipelines;
        }
        pipelines = doToModelWithoutOther(pipelineDos);
    } catch (Exception e) {
        logger.error("ERROR ## query pipelines by destination:" + destination + " 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 68 with ManagerException

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

the class PipelineServiceImpl method remove.

/**
     * 删除
     */
public void remove(final Long pipelineId) {
    Assert.assertNotNull(pipelineId);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                PipelineDO pipelineDO = pipelineDao.findById(pipelineId);
                if (pipelineDO != null) {
                    pipelineDao.delete(pipelineId);
                    pipelineNodeRelationDao.deleteByPipelineId(pipelineId);
                    // 删除历史cursor
                    String destination = pipelineDO.getParameters().getDestinationName();
                    short clientId = pipelineDO.getId().shortValue();
                    arbitrateViewService.removeCanal(destination, clientId);
                    arbitrateManageService.pipelineEvent().destory(pipelineDO.getChannelId(), pipelineId);
                }
            } catch (Exception e) {
                logger.error("ERROR ## remove the pipeline(" + pipelineId + ") has an exception!");
                throw new ManagerException(e);
            }
        }
    });
}
Also used : TransactionStatus(org.springframework.transaction.TransactionStatus) PipelineDO(com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Example 69 with ManagerException

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

the class PipelineServiceImpl method create.

/**
     * 添加
     */
public void create(final Pipeline pipeline) {
    Assert.assertNotNull(pipeline);
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                PipelineDO pipelineDo = modelToDo(pipeline);
                pipelineDo.setId(0L);
                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);
                }
                pipelineDao.insert(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);
                arbitrateManageService.pipelineEvent().init(pipelineDo.getChannelId(), pipelineDo.getId());
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## create pipeline 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) TransactionStatus(org.springframework.transaction.TransactionStatus) PipelineDO(com.alibaba.otter.manager.biz.config.pipeline.dal.dataobject.PipelineDO) ArrayList(java.util.ArrayList) List(java.util.List) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) 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)

Example 70 with ManagerException

use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException 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)

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