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