Search in sources :

Example 46 with ManagerException

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

the class DataColumnPairServiceImpl method listByDataMediaPairIds.

public Map<Long, List<ColumnPair>> listByDataMediaPairIds(Long... dataMediaPairIds) {
    Assert.assertNotNull(dataMediaPairIds);
    Map<Long, List<ColumnPair>> dataColumnPairs = new HashMap<Long, List<ColumnPair>>();
    try {
        List<DataColumnPairDO> dataColumnPairDos = dataColumnPairDao.listByDataMediaPairIds(dataMediaPairIds);
        if (dataColumnPairDos.isEmpty()) {
            logger.debug("DEBUG ## couldn't query any dataColumnPair, maybe hasn't create any dataColumnPair.");
            return dataColumnPairs;
        }
        for (DataColumnPairDO dataColumnPairDo : dataColumnPairDos) {
            List<ColumnPair> columnPairs = dataColumnPairs.get(dataColumnPairDo.getDataMediaPairId());
            if (columnPairs != null) {
                if (!columnPairs.contains(doToModel(dataColumnPairDo))) {
                    columnPairs.add(doToModel(dataColumnPairDo));
                }
            } else {
                columnPairs = new ArrayList<ColumnPair>();
                columnPairs.add(doToModel(dataColumnPairDo));
                dataColumnPairs.put(dataColumnPairDo.getDataMediaPairId(), columnPairs);
            }
        }
    } catch (Exception e) {
        logger.error("ERROR ## query dataColumnPair by dataMediaId:" + dataMediaPairIds + " has an exception!");
        throw new ManagerException(e);
    }
    return dataColumnPairs;
}
Also used : ColumnPair(com.alibaba.otter.shared.common.model.config.data.ColumnPair) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) 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 47 with ManagerException

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

the class SystemParameterAction method doEdit.

/**
     * 修改系统参数
     */
public void doEdit(@FormGroup("systemParameterDetailInfo") Group systemParameterDetailInfo, Navigator nav) throws Exception {
    SystemParameter systemParameter = new SystemParameter();
    systemParameterDetailInfo.setProperties(systemParameter);
    String defaultAlarmReceiver = systemParameterDetailInfo.getField("defaultAlarmReceiver").getStringValue();
    String[] defaultAlarmReceiverStrs = StringUtils.split(defaultAlarmReceiver, "=");
    if (defaultAlarmReceiverStrs.length != 2) {
        throw new ManagerException("defaultAlarmReceiver[" + defaultAlarmReceiver + "] is not valid!");
    }
    systemParameter.setDefaultAlarmReceiveKey(defaultAlarmReceiverStrs[0]);
    systemParameter.setDefaultAlarmReceiver(defaultAlarmReceiverStrs[1]);
    String alarmReceiver = systemParameterDetailInfo.getField("alarmReceiver").getStringValue();
    List<String> alarmReceivers = new ArrayList<String>();
    String[] alarmReceiver1 = StringUtils.split(alarmReceiver, "\n");
    for (String alarmReceiverStr : alarmReceiver1) {
        String[] alarmReceiver2 = StringUtils.split(alarmReceiverStr, ";");
        for (String alarmReceiverStr2 : alarmReceiver2) {
            alarmReceivers.add(alarmReceiverStr2);
        }
    }
    Map<String, String> alarmReceiverMap = new LinkedHashMap<String, String>();
    for (String alarmReceiverStr : alarmReceivers) {
        String[] alarmReceiverStrs = StringUtils.split(alarmReceiverStr, "=");
        if (alarmReceiverStrs.length != 2) {
            throw new ManagerException("alarmReceiver[" + alarmReceiver + "] is not valid!");
        }
        alarmReceiverMap.put(alarmReceiverStrs[0], alarmReceiverStrs[1]);
    }
    systemParameter.setAlarmReceiver(alarmReceiverMap);
    systemParameterService.createOrUpdate(systemParameter);
    nav.redirectToLocation("systemParameter.htm?edit=true");
}
Also used : ArrayList(java.util.ArrayList) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) LinkedHashMap(java.util.LinkedHashMap)

Example 48 with ManagerException

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

the class AlarmRuleServiceImpl method switchAlarmRuleStatus.

private void switchAlarmRuleStatus(Long alarmRuleId, AlarmRuleStatus alarmRuleStatus, String pauseTime) {
    AlarmRuleDO alarmRuleDo = alarmRuleDao.findById(alarmRuleId);
    if (null == alarmRuleDo) {
        String exceptionCause = "query alarmRule:" + alarmRuleId + " return null.";
        logger.error("ERROR ## " + exceptionCause);
        throw new ManagerException(exceptionCause);
    }
    alarmRuleDo.setStatus(alarmRuleStatus);
    if (alarmRuleDo.getAlarmRuleParameter() != null) {
        alarmRuleDo.getAlarmRuleParameter().setPauseTime(pauseTime);
    } else if (StringUtils.isNotEmpty(pauseTime)) {
        alarmRuleDo.setAlarmRuleParameter(new AlarmRuleParameter());
        alarmRuleDo.getAlarmRuleParameter().setPauseTime(pauseTime);
    }
    alarmRuleDao.update(alarmRuleDo);
}
Also used : AlarmRuleDO(com.alibaba.otter.manager.biz.config.alarm.dal.dataobject.AlarmRuleDO) AlarmRuleParameter(com.alibaba.otter.manager.biz.config.alarm.dal.dataobject.AlarmRuleParameter) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Example 49 with ManagerException

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

the class ChannelServiceImpl method listOnlyChannels.

public List<Channel> listOnlyChannels(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 = doToModelOnlyChannels(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 50 with ManagerException

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

the class ChannelServiceImpl method doToModelWithColumn.

private List<Channel> doToModelWithColumn(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.listByChannelIdsWithoutColumn(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)

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