Search in sources :

Example 56 with ManagerException

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

the class ChannelServiceImpl method listByPipelineIds.

/**
     * <pre>
     * 根据PipelineID找到对应的Channel
     * 优化设想:
     *    应该通过变长参数达到后期扩展的方便性
     * </pre>
     */
public List<Channel> listByPipelineIds(Long... pipelineIds) {
    List<Channel> channels = new ArrayList<Channel>();
    try {
        List<Pipeline> pipelines = pipelineService.listByIds(pipelineIds);
        List<Long> channelIds = new ArrayList<Long>();
        for (Pipeline pipeline : pipelines) {
            if (!channelIds.contains(pipeline.getChannelId())) {
                channelIds.add(pipeline.getChannelId());
            }
        }
        channels = listByIds(channelIds.toArray(new Long[channelIds.size()]));
    } catch (Exception e) {
        logger.error("ERROR ## list query channel by pipelineIds:" + pipelineIds.toString() + " has an exception!");
        throw new ManagerException(e);
    }
    return channels;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArrayList(java.util.ArrayList) 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) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 57 with ManagerException

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

the class DataColumnPairServiceImpl method modify.

public void modify(ColumnPair entityObj) {
    Assert.assertNotNull(entityObj);
    try {
        DataColumnPairDO dataColumnPairDo = modelToDo(entityObj);
        dataColumnPairDao.update(dataColumnPairDo);
    } catch (RepeatConfigureException rce) {
        throw rce;
    } catch (Exception e) {
        logger.error("ERROR ## modify dataColumnPair has an exception!");
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) 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) DataColumnPairDO(com.alibaba.otter.manager.biz.config.datacolumnpair.dal.dataobject.DataColumnPairDO)

Example 58 with ManagerException

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

the class DataMatrixServiceImpl method create.

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

        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                DataMatrixDO matrixlDO = modelToDo(matrix);
                matrixlDO.setId(0L);
                if (!dataMatrixDao.checkUnique(matrixlDO)) {
                    String exceptionCause = "exist the same repeat canal in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
                dataMatrixDao.insert(matrixlDO);
            } 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) DataMatrixDO(com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO) 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 59 with ManagerException

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

the class DataMediaServiceImpl method doToModel.

/**
     * 用于DO对象转化为Model对象
     * 
     * @param dataMediaDo
     * @return DataMedia
     */
private DataMedia doToModel(DataMediaDO dataMediaDo) {
    DataMedia dataMedia = null;
    try {
        DataMediaSource dataMediaSource = dataMediaSourceService.findById(dataMediaDo.getDataMediaSourceId());
        if (dataMediaSource.getType().isMysql() || dataMediaSource.getType().isOracle()) {
            dataMedia = JsonUtils.unmarshalFromString(dataMediaDo.getProperties(), DbDataMedia.class);
            dataMedia.setSource(dataMediaSource);
        } else if (dataMediaSource.getType().isNapoli() || dataMediaSource.getType().isMq()) {
            dataMedia = JsonUtils.unmarshalFromString(dataMediaDo.getProperties(), MqDataMedia.class);
            dataMedia.setSource(dataMediaSource);
        }
        dataMedia.setId(dataMediaDo.getId());
        dataMedia.setGmtCreate(dataMediaDo.getGmtCreate());
        dataMedia.setGmtModified(dataMediaDo.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the dataMedia Do to Model has an exception");
        throw new ManagerException(e);
    }
    return dataMedia;
}
Also used : DataMediaSource(com.alibaba.otter.shared.common.model.config.data.DataMediaSource) DbDataMedia(com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia) 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 60 with ManagerException

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

the class DataMediaServiceImpl method modify.

/**
     * 修改
     */
@Override
public void modify(DataMedia dataMedia) {
    Assert.assertNotNull(dataMedia);
    try {
        DataMediaDO dataMediaDo = modelToDo(dataMedia);
        if (dataMediaDao.checkUnique(dataMediaDo)) {
            dataMediaDao.update(dataMediaDo);
        } else {
            String exceptionCause = "exist the same name dataMedia in the database.";
            logger.warn("WARN ## " + exceptionCause);
            throw new RepeatConfigureException(exceptionCause);
        }
    } catch (RepeatConfigureException rce) {
        throw rce;
    } catch (Exception e) {
        logger.error("ERROR ## modify 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)

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