Search in sources :

Example 16 with ManagerException

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

the class DataColumnPairServiceImpl method listByDataMediaPairId.

public List<ColumnPair> listByDataMediaPairId(Long dataMediaPairId) {
    Assert.assertNotNull(dataMediaPairId);
    List<ColumnPair> dataColumnPairs = new ArrayList<ColumnPair>();
    try {
        List<DataColumnPairDO> dataColumnPairDos = dataColumnPairDao.listByDataMediaPairId(dataMediaPairId);
        if (dataColumnPairDos.isEmpty()) {
            logger.debug("DEBUG ## couldn't query any dataColumnPair, maybe hasn't create any dataColumnPair.");
            return dataColumnPairs;
        }
        dataColumnPairs = doToModel(dataColumnPairDos);
    } catch (Exception e) {
        logger.error("ERROR ## query dataColumnPair by dataMediaId:" + dataMediaPairId + " has an exception!");
        throw new ManagerException(e);
    }
    return dataColumnPairs;
}
Also used : ColumnPair(com.alibaba.otter.shared.common.model.config.data.ColumnPair) 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) DataColumnPairDO(com.alibaba.otter.manager.biz.config.datacolumnpair.dal.dataobject.DataColumnPairDO)

Example 17 with ManagerException

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

the class DataColumnPairServiceImpl method createBatch.

public void createBatch(List<ColumnPair> dataColumnPairs) {
    Assert.assertNotNull(dataColumnPairs);
    try {
        List<DataColumnPairDO> dataColumnPairDos = new ArrayList<DataColumnPairDO>();
        for (ColumnPair columnPair : dataColumnPairs) {
            DataColumnPairDO dataColumnPairDo = modelToDo(columnPair);
            dataColumnPairDos.add(dataColumnPairDo);
        }
        dataColumnPairDao.insertBatch(dataColumnPairDos);
    } catch (RepeatConfigureException rcf) {
        throw rcf;
    } catch (Exception e) {
        logger.error("ERROR ## create dataColumnPair has an exception!");
        throw new ManagerException(e);
    }
}
Also used : ColumnPair(com.alibaba.otter.shared.common.model.config.data.ColumnPair) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) 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) DataColumnPairDO(com.alibaba.otter.manager.biz.config.datacolumnpair.dal.dataobject.DataColumnPairDO)

Example 18 with ManagerException

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

the class AlarmRuleServiceImpl method doToModel.

private AlarmRule doToModel(AlarmRuleDO alarmRuleDo) {
    AlarmRule alarmRule = new AlarmRule();
    alarmRule.setId(alarmRuleDo.getId());
    alarmRule.setMatchValue(alarmRuleDo.getMatchValue());
    alarmRule.setMonitorName(alarmRuleDo.getMonitorName());
    alarmRule.setReceiverKey(alarmRuleDo.getReceiverKey());
    // 如果数据库里面的数据为空,则返回默认值
    alarmRule.setIntervalTime(alarmRuleDo.getAlarmRuleParameter() == null ? 1800L : alarmRuleDo.getAlarmRuleParameter().getIntervalTime());
    String pauseTime = alarmRuleDo.getAlarmRuleParameter() == null ? null : alarmRuleDo.getAlarmRuleParameter().getPauseTime();
    if (StringUtils.isNotEmpty(pauseTime)) {
        SimpleDateFormat format = new SimpleDateFormat(TIMESTAMP_FORMAT);
        try {
            alarmRule.setPauseTime(format.parse(pauseTime));
        } catch (ParseException e) {
            throw new ManagerException(e);
        }
    }
    alarmRule.setAutoRecovery(alarmRuleDo.getAlarmRuleParameter() == null ? false : alarmRuleDo.getAlarmRuleParameter().getAutoRecovery());
    alarmRule.setRecoveryThresold(alarmRuleDo.getAlarmRuleParameter() == null ? 3 : alarmRuleDo.getAlarmRuleParameter().getRecoveryThresold());
    alarmRule.setPipelineId(alarmRuleDo.getPipelineId());
    alarmRule.setStatus(alarmRuleDo.getStatus());
    alarmRule.setDescription(alarmRuleDo.getDescription());
    alarmRule.setGmtCreate(alarmRuleDo.getGmtCreate());
    alarmRule.setGmtModified(alarmRuleDo.getGmtModified());
    return alarmRule;
}
Also used : AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException)

Example 19 with ManagerException

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

the class DataMediaPairAction method doBatchAdd.

/**
 * 批量添加DataMediaPair
 *
 * @param dataMediaPairInfo
 * @throws Exception
 */
public void doBatchAdd(@FormGroup("batchDataMediaPairInfo") Group batchDataMediaPairInfo, @Param("pipelineId") Long pipelineId, @FormField(name = "formBatchDataMediaPairError", group = "batchDataMediaPairInfo") CustomErrors err, Navigator nav) throws Exception {
    String batchPairContent = batchDataMediaPairInfo.getField("batchPairContent").getStringValue();
    List<String> StringPairs = Arrays.asList(batchPairContent.split("\r\n"));
    try {
        for (String stringPair : StringPairs) {
            List<String> pairData = Arrays.asList(stringPair.split(","));
            if (pairData.size() < 4) {
                throw new ManagerException("[" + stringPair + "] the line not all parameters");
            }
            // build the pair source
            DataMedia sourceDataMedia = new DataMedia();
            DataMediaSource sourceDataMediaSource = dataMediaSourceService.findById(Long.parseLong(StringUtils.trimToNull(pairData.get(2))));
            sourceDataMedia.setNamespace(StringUtils.trimToNull(pairData.get(0)));
            sourceDataMedia.setName(StringUtils.trimToNull(pairData.get(1)));
            sourceDataMedia.setSource(sourceDataMediaSource);
            Long sourceMediaId = dataMediaService.createReturnId(sourceDataMedia);
            sourceDataMedia.setId(sourceMediaId);
            // build the pair target
            DataMedia targetDataMedia = new DataMedia();
            Long weight = 5L;
            if (StringUtils.isNumeric(pairData.get(3)) && pairData.size() <= 5) {
                // 如果是纯数字,那说明是简化配置模式
                DataMediaSource targetDataMediaSource = dataMediaSourceService.findById(Long.parseLong(StringUtils.trimToNull(pairData.get(3))));
                targetDataMedia.setNamespace(StringUtils.trimToNull(pairData.get(0)));
                targetDataMedia.setName(StringUtils.trimToNull(pairData.get(1)));
                targetDataMedia.setSource(targetDataMediaSource);
                Long targetMediaId = dataMediaService.createReturnId(targetDataMedia);
                targetDataMedia.setId(targetMediaId);
                if (pairData.size() >= 5) {
                    weight = Long.parseLong(StringUtils.trimToNull(pairData.get(4)));
                }
            } else {
                DataMediaSource targetDataMediaSource = dataMediaSourceService.findById(Long.parseLong(StringUtils.trimToNull(pairData.get(5))));
                targetDataMedia.setNamespace(StringUtils.trimToNull(pairData.get(3)));
                targetDataMedia.setName(StringUtils.trimToNull(pairData.get(4)));
                targetDataMedia.setSource(targetDataMediaSource);
                Long targetMediaId = dataMediaService.createReturnId(targetDataMedia);
                targetDataMedia.setId(targetMediaId);
                if (pairData.size() >= 7) {
                    weight = Long.parseLong(StringUtils.trimToNull(pairData.get(6)));
                }
            }
            // build the pair
            DataMediaPair dataMediaPair = new DataMediaPair();
            dataMediaPair.setSource(sourceDataMedia);
            dataMediaPair.setTarget(targetDataMedia);
            dataMediaPair.setPushWeight(weight);
            dataMediaPair.setPipelineId(pipelineId);
            dataMediaPairService.createIfNotExist(dataMediaPair);
        }
    } catch (Exception e) {
        err.setMessage("invalidBatchDataMediaPair");
        return;
    }
    nav.redirectToLocation("dataMediaPairList.htm?pipelineId=" + pipelineId);
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) DataMediaSource(com.alibaba.otter.shared.common.model.config.data.DataMediaSource) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) WebxException(com.alibaba.citrus.webx.WebxException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 20 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)

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