Search in sources :

Example 51 with ManagerException

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

the class CanalServiceImpl method doToModel.

/**
     * 用于DO对象转化为Model对象
     * 
     * @param canalDo
     * @return Canal
     */
private Canal doToModel(CanalDO canalDo) {
    Canal canal = new Canal();
    try {
        canal.setId(canalDo.getId());
        canal.setName(canalDo.getName());
        canal.setStatus(canalDo.getStatus());
        canal.setDesc(canalDo.getDescription());
        CanalParameter parameter = canalDo.getParameters();
        AutoKeeperCluster zkCluster = autoKeeperClusterService.findAutoKeeperClusterById(parameter.getZkClusterId());
        if (zkCluster != null) {
            parameter.setZkClusters(Arrays.asList(StringUtils.join(zkCluster.getServerList(), ',')));
        }
        canal.setCanalParameter(canalDo.getParameters());
        canal.setGmtCreate(canalDo.getGmtCreate());
        canal.setGmtModified(canalDo.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the canal Do to Model has an exception");
        throw new ManagerException(e);
    }
    return canal;
}
Also used : CanalParameter(com.alibaba.otter.canal.instance.manager.model.CanalParameter) Canal(com.alibaba.otter.canal.instance.manager.model.Canal) AutoKeeperCluster(com.alibaba.otter.shared.common.model.autokeeper.AutoKeeperCluster) 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 52 with ManagerException

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

the class CanalServiceImpl method create.

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

        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                CanalDO canalDO = modelToDo(canal);
                canalDO.setId(0L);
                if (!canalDao.checkUnique(canalDO)) {
                    String exceptionCause = "exist the same repeat canal in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
                canalDao.insert(canalDO);
                canal.setId(canalDO.getId());
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## create canal has an exception!");
                throw new ManagerException(e);
            }
        }
    });
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) CanalDO(com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO) 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 53 with ManagerException

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

the class CanalServiceImpl method remove.

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

        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                Canal canal = findById(canalId);
                canalDao.delete(canalId);
                // 删除canal节点信息
                arbitrateViewService.removeCanal(canal.getName());
            } catch (Exception e) {
                logger.error("ERROR ## remove canal(" + canalId + ") has an exception!");
                throw new ManagerException(e);
            }
        }
    });
}
Also used : Canal(com.alibaba.otter.canal.instance.manager.model.Canal) 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 54 with ManagerException

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

the class CanalServiceImpl method findByName.

public Canal findByName(String name) {
    Assert.assertNotNull(name);
    CanalDO canalDo = canalDao.findByName(name);
    if (canalDo == null) {
        String exceptionCause = "query name:" + name + " return null.";
        logger.error("ERROR ## " + exceptionCause);
        throw new ManagerException(exceptionCause);
    }
    return doToModel(canalDo);
}
Also used : CanalDO(com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Example 55 with ManagerException

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

the class ChannelServiceImpl method modify.

/**
     * 修改Channel
     */
public void modify(Channel channel) {
    Assert.assertNotNull(channel);
    try {
        ChannelDO channelDo = modelToDo(channel);
        if (channelDao.checkUnique(channelDo)) {
            channelDao.update(channelDo);
        } else {
            String exceptionCause = "exist the same name channel in the database.";
            logger.warn("WARN ## " + exceptionCause);
            throw new RepeatConfigureException(exceptionCause);
        }
    } catch (RepeatConfigureException rce) {
        throw rce;
    } catch (Exception e) {
        logger.error("ERROR ## modify channel has an exception ", e);
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ChannelDO(com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) InvalidConfigureException(com.alibaba.otter.manager.biz.common.exceptions.InvalidConfigureException) 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