Search in sources :

Example 6 with ManagerException

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

the class ChannelServiceImpl method listByIds.

/*--------------------优化内容:listAll、listByIds、findById合并-------------------------------*/
public List<Channel> listByIds(Long... identities) {
    List<Channel> channels = new ArrayList<Channel>();
    try {
        List<ChannelDO> channelDos = null;
        if (identities.length < 1) {
            channelDos = channelDao.listAll();
            if (channelDos.isEmpty()) {
                logger.debug("DEBUG ## couldn't query any channel, maybe hasn't create any channel.");
                return channels;
            }
        } else {
            channelDos = channelDao.listByMultiId(identities);
            if (channelDos.isEmpty()) {
                String exceptionCause = "couldn't query any channel by channelIds:" + Arrays.toString(identities);
                logger.error("ERROR ## " + exceptionCause);
                throw new ManagerException(exceptionCause);
            }
        }
        channels = doToModel(channelDos);
    } catch (Exception e) {
        logger.error("ERROR ## query channels 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) 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)

Example 7 with ManagerException

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

the class ChannelServiceImpl method doToModel.

/**
 * <pre>
 * 用于DO对象转化为Model对象
 * 现阶段优化:
 *      需要五次SQL交互:pipeline\node\dataMediaPair\dataMedia\dataMediaSource(五个层面)
 *      目前优化方案为单层只执行一次SQL,避免重复循环造成IO及数据库查询开销
 * 长期优化:
 *      对SQL进行改造,尽量减小SQL调用次数
 * </pre>
 *
 * @param channelDO
 * @return Channel
 */
private Channel doToModel(ChannelDO channelDo) {
    Channel channel = new Channel();
    try {
        channel.setId(channelDo.getId());
        channel.setName(channelDo.getName());
        channel.setDescription(channelDo.getDescription());
        channel.setStatus(arbitrateManageService.channelEvent().status(channelDo.getId()));
        channel.setParameters(channelDo.getParameters());
        channel.setGmtCreate(channelDo.getGmtCreate());
        channel.setGmtModified(channelDo.getGmtModified());
        List<Pipeline> pipelines = pipelineService.listByChannelIds(channelDo.getId());
        // 合并PipelineParameter和ChannelParameter
        SystemParameter systemParameter = systemParameterService.find();
        for (Pipeline pipeline : pipelines) {
            PipelineParameter parameter = new PipelineParameter();
            parameter.merge(systemParameter);
            parameter.merge(channel.getParameters());
            // 最后复制pipelineId参数
            parameter.merge(pipeline.getParameters());
            pipeline.setParameters(parameter);
        // pipeline.getParameters().merge(channel.getParameters());
        }
        channel.setPipelines(pipelines);
    } catch (Exception e) {
        logger.error("ERROR ## change the channel DO to Model has an exception");
        throw new ManagerException(e);
    }
    return channel;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter) PipelineParameter(com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter) 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 8 with ManagerException

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

the class CanalServiceImpl method listByIds.

public List<Canal> listByIds(Long... identities) {
    List<Canal> canals = new ArrayList<Canal>();
    try {
        List<CanalDO> canalDos = null;
        if (identities.length < 1) {
            canalDos = canalDao.listAll();
            if (canalDos.isEmpty()) {
                logger.debug("DEBUG ## couldn't query any canal, maybe hasn't create any canal.");
                return canals;
            }
        } else {
            canalDos = canalDao.listByMultiId(identities);
            if (canalDos.isEmpty()) {
                String exceptionCause = "couldn't query any canal by canalIds:" + Arrays.toString(identities);
                logger.error("ERROR ## " + exceptionCause);
                throw new ManagerException(exceptionCause);
            }
        }
        canals = doToModel(canalDos);
    } catch (Exception e) {
        logger.error("ERROR ## query channels has an exception!");
        throw new ManagerException(e);
    }
    return canals;
}
Also used : CanalDO(com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO) Canal(com.alibaba.otter.canal.instance.manager.model.Canal) 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)

Example 9 with ManagerException

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

the class CanalServiceImpl method modelToDo.

/**
 * 用于Model对象转化为DO对象
 *
 * @param canal
 * @return CanalDO
 */
private CanalDO modelToDo(Canal canal) {
    CanalDO canalDo = new CanalDO();
    try {
        canalDo.setId(canal.getId());
        canalDo.setName(canal.getName());
        canalDo.setStatus(canal.getStatus());
        canalDo.setDescription(canal.getDesc());
        canalDo.setParameters(canal.getCanalParameter());
        canalDo.setGmtCreate(canal.getGmtCreate());
        canalDo.setGmtModified(canal.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the canal Model to Do has an exception");
        throw new ManagerException(e);
    }
    return canalDo;
}
Also used : CanalDO(com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO) 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 10 with ManagerException

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

the class CanalServiceImpl method modify.

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

        protected void doInTransactionWithoutResult(TransactionStatus status) {
            try {
                CanalDO canalDo = modelToDo(canal);
                if (canalDao.checkUnique(canalDo)) {
                    canalDao.update(canalDo);
                } else {
                    String exceptionCause = "exist the same repeat canal in the database.";
                    logger.warn("WARN ## " + exceptionCause);
                    throw new RepeatConfigureException(exceptionCause);
                }
            } catch (RepeatConfigureException rce) {
                throw rce;
            } catch (Exception e) {
                logger.error("ERROR ## modify canal(" + canal.getId() + ") 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)

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