Search in sources :

Example 1 with ManagerException

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

the class UserServiceImpl method createUser.

public void createUser(User user) {
    Assert.assertNotNull(user);
    try {
        UserDO userDo = userDao.insertUser(modelToDo(user));
        if (userDo.getId() == 0) {
            String exceptionCause = "exist the same name user in the database.";
            logger.warn("WARN ## " + exceptionCause);
            throw new RepeatConfigureException(exceptionCause);
        }
    } catch (RepeatConfigureException rce) {
        throw rce;
    } catch (Exception e) {
        logger.error("ERROR ## create user has an exception!");
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) UserDO(com.alibaba.otter.manager.biz.user.dal.dataobject.UserDO) 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 2 with ManagerException

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

the class UserServiceImpl method updataUser.

public void updataUser(User user) {
    Assert.assertNotNull(user);
    try {
        UserDO UserDo = modelToDo(user);
        if (userDao.chackUnique(UserDo)) {
            userDao.updateUser(UserDo);
        } else {
            String exceptionCause = "exist the same name user in the database.";
            logger.warn("WARN ## " + exceptionCause);
            throw new RepeatConfigureException(exceptionCause);
        }
    } catch (RepeatConfigureException rce) {
        throw rce;
    } catch (Exception e) {
        logger.error("ERROR ## create user has an exception!");
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) UserDO(com.alibaba.otter.manager.biz.user.dal.dataobject.UserDO) 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 3 with ManagerException

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

the class ChannelServiceImpl method doToModelOnlyChannels.

private List<Channel> doToModelOnlyChannels(List<ChannelDO> channelDos) {
    List<Channel> channels = new ArrayList<Channel>();
    try {
        // 1.将ChannelID单独拿出来
        List<Long> channelIds = new ArrayList<Long>();
        for (ChannelDO channelDo : channelDos) {
            channelIds.add(channelDo.getId());
        }
        for (ChannelDO channelDo : channelDos) {
            Channel channel = new Channel();
            channel.setId(channelDo.getId());
            channel.setName(channelDo.getName());
            channel.setDescription(channelDo.getDescription());
            ChannelStatus channelStatus = arbitrateManageService.channelEvent().status(channelDo.getId());
            channel.setStatus(null == channelStatus ? ChannelStatus.STOP : channelStatus);
            channel.setParameters(channelDo.getParameters());
            channel.setGmtCreate(channelDo.getGmtCreate());
            channel.setGmtModified(channelDo.getGmtModified());
            // 遍历,将该Channel节点下的Pipeline提取出来。
            List<Pipeline> subPipelines = new ArrayList<Pipeline>();
            channel.setPipelines(subPipelines);
            channels.add(channel);
        }
    } catch (Exception e) {
        logger.error("ERROR ## change the channels doToModelOnlyChannels 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) ChannelStatus(com.alibaba.otter.shared.common.model.config.channel.ChannelStatus) 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) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 4 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 List<Channel> doToModel(List<ChannelDO> channelDos) {
    List<Channel> channels = new ArrayList<Channel>();
    try {
        // 1.将ChannelID单独拿出来
        List<Long> channelIds = new ArrayList<Long>();
        for (ChannelDO channelDo : channelDos) {
            channelIds.add(channelDo.getId());
        }
        Long[] idArray = new Long[channelIds.size()];
        // 拿到所有的Pipeline进行ChannelID过滤,避免重复查询。
        List<Pipeline> pipelines = pipelineService.listByChannelIds(channelIds.toArray(idArray));
        SystemParameter systemParameter = systemParameterService.find();
        for (ChannelDO channelDo : channelDos) {
            Channel channel = new Channel();
            channel.setId(channelDo.getId());
            channel.setName(channelDo.getName());
            channel.setDescription(channelDo.getDescription());
            ChannelStatus channelStatus = arbitrateManageService.channelEvent().status(channelDo.getId());
            channel.setStatus(null == channelStatus ? ChannelStatus.STOP : channelStatus);
            channel.setParameters(channelDo.getParameters());
            channel.setGmtCreate(channelDo.getGmtCreate());
            channel.setGmtModified(channelDo.getGmtModified());
            // 遍历,将该Channel节点下的Pipeline提取出来。
            List<Pipeline> subPipelines = new ArrayList<Pipeline>();
            for (Pipeline pipeline : pipelines) {
                if (pipeline.getChannelId().equals(channelDo.getId())) {
                    // 合并PipelineParameter和ChannelParameter
                    PipelineParameter parameter = new PipelineParameter();
                    parameter.merge(systemParameter);
                    parameter.merge(channel.getParameters());
                    // 最后复制pipelineId参数
                    parameter.merge(pipeline.getParameters());
                    pipeline.setParameters(parameter);
                    subPipelines.add(pipeline);
                }
            }
            channel.setPipelines(subPipelines);
            channels.add(channel);
        }
    } catch (Exception e) {
        logger.error("ERROR ## change the channels DO to Model 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) ChannelStatus(com.alibaba.otter.shared.common.model.config.channel.ChannelStatus) 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) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter) ChannelDO(com.alibaba.otter.manager.biz.config.channel.dal.dataobject.ChannelDO) PipelineParameter(com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Example 5 with ManagerException

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

the class ChannelServiceImpl method listByNodeId.

/**
 * 根据NodeId和Channel状态找到对应的Channel列表。
 */
public List<Channel> listByNodeId(Long nodeId, ChannelStatus... statuses) {
    List<Channel> channels = new ArrayList<Channel>();
    List<Channel> results = new ArrayList<Channel>();
    try {
        List<Pipeline> pipelines = pipelineService.listByNodeId(nodeId);
        List<Long> pipelineIds = new ArrayList<Long>();
        for (Pipeline pipeline : pipelines) {
            pipelineIds.add(pipeline.getId());
        }
        if (pipelineIds.isEmpty()) {
            // 没有关联任务直接返回
            return channels;
        }
        // 反查对应的channel
        channels = listByPipelineIds(pipelineIds.toArray(new Long[pipelineIds.size()]));
        if (null == statuses || statuses.length == 0) {
            return channels;
        }
        for (Channel channel : channels) {
            for (ChannelStatus status : statuses) {
                if (channel.getStatus().equals(status)) {
                    results.add(channel);
                }
            }
        }
    } catch (Exception e) {
        logger.error("ERROR ## list query channel by nodeId:" + nodeId + " has an exception!");
        throw new ManagerException(e);
    }
    return results;
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArrayList(java.util.ArrayList) ChannelStatus(com.alibaba.otter.shared.common.model.config.channel.ChannelStatus) 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)

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