Search in sources :

Example 31 with RepeatConfigureException

use of com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException 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 32 with RepeatConfigureException

use of com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException 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 33 with RepeatConfigureException

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

Example 34 with RepeatConfigureException

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

the class AlarmRuleAction method doAdd.

public void doAdd(@FormGroup("alarmRuleInfo") Group alarmRuleInfo, @FormField(name = "formAlarmRuleError", group = "alarmRuleInfo") CustomErrors err, Navigator nav) throws Exception {
    AlarmRule alarmRule = new AlarmRule();
    alarmRuleInfo.setProperties(alarmRule);
    try {
        alarmRuleService.create(alarmRule);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidAlarmRule");
        return;
    }
    nav.redirectToLocation("alarmRuleList.htm?pipelineId=" + alarmRule.getPipelineId());
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule)

Example 35 with RepeatConfigureException

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

the class ChannelAction method doAdd.

/**
     * 添加Channel
     * 
     * @param channelInfo
     * @param channelParameterInfo
     * @throws Exception
     */
public void doAdd(@FormGroup("channelInfo") Group channelInfo, @FormGroup("channelParameterInfo") Group channelParameterInfo, @FormField(name = "formChannelError", group = "channelInfo") CustomErrors err, Navigator nav) throws Exception {
    Channel channel = new Channel();
    ChannelParameter parameter = new ChannelParameter();
    channelInfo.setProperties(channel);
    channelParameterInfo.setProperties(parameter);
    // 新建Channel默认关闭该状态
    channel.setStatus(ChannelStatus.STOP);
    channel.setParameters(parameter);
    try {
        channelService.create(channel);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidChannelName");
        return;
    }
    nav.redirectTo(WebConstant.CHANNEL_LIST_LINK);
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ChannelParameter(com.alibaba.otter.shared.common.model.config.channel.ChannelParameter) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel)

Aggregations

RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)46 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)23 TransactionStatus (org.springframework.transaction.TransactionStatus)8 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)8 ArrayList (java.util.ArrayList)7 Node (com.alibaba.otter.shared.common.model.config.node.Node)6 DataMedia (com.alibaba.otter.shared.common.model.config.data.DataMedia)5 AutoKeeperCluster (com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster)4 DataColumnPairDO (com.alibaba.otter.manager.biz.config.datacolumnpair.dal.dataobject.DataColumnPairDO)3 DataMediaDO (com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO)3 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)3 DataMediaSource (com.alibaba.otter.shared.common.model.config.data.DataMediaSource)3 MqMediaSource (com.alibaba.otter.shared.common.model.config.data.mq.MqMediaSource)3 List (java.util.List)3 Canal (com.alibaba.otter.canal.instance.manager.model.Canal)2 CanalParameter (com.alibaba.otter.canal.instance.manager.model.CanalParameter)2 DataSourcing (com.alibaba.otter.canal.instance.manager.model.CanalParameter.DataSourcing)2 SourcingType (com.alibaba.otter.canal.instance.manager.model.CanalParameter.SourcingType)2 InvalidConfigureException (com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException)2 CanalDO (com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO)2