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;
}
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);
}
}
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;
}
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);
}
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");
}
Aggregations