use of com.alibaba.otter.shared.common.model.config.alarm.AlarmRule in project otter by alibaba.
the class PipelineTimeoutRuleMonitor method explore.
@Override
public void explore(List<AlarmRule> rules) {
if (CollectionUtils.isEmpty(rules)) {
return;
}
Long pipelineId = rules.get(0).getPipelineId();
ThroughputCondition condition = new ThroughputCondition();
condition.setPipelineId(pipelineId);
condition.setType(ThroughputType.ROW);
ThroughputStat stat = throughputStatService.findThroughputStatByPipelineId(condition);
long latestSyncTime = 0L;
if (stat != null && stat.getGmtModified() != null) {
Date modifiedDate = stat.getGmtModified();
latestSyncTime = modifiedDate.getTime();
}
long now = System.currentTimeMillis();
long elapsed = now - latestSyncTime;
boolean flag = false;
for (AlarmRule rule : rules) {
flag |= checkTimeout(rule, elapsed);
}
if (flag) {
logRecordAlarm(pipelineId, MonitorName.PIPELINETIMEOUT, String.format(TIME_OUT_MESSAGE, pipelineId, (elapsed / 1000)));
}
}
use of com.alibaba.otter.shared.common.model.config.alarm.AlarmRule in project otter by alibaba.
the class AlarmRuleAction method doAdd.
public void doAdd(@FormGroup("alarmRuleInfo") Group alarmRuleInfo, @FormField(name = "formAlarmRuleError", group = "alarmRuleInfo") CustomErrors err, Navigator nav) throws Exception {
AlarmRule alarmRule = new AlarmRule();
alarmRuleInfo.setProperties(alarmRule);
try {
alarmRuleService.create(alarmRule);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidAlarmRule");
return;
}
nav.redirectToLocation("alarmRuleList.htm?pipelineId=" + alarmRule.getPipelineId());
}
use of com.alibaba.otter.shared.common.model.config.alarm.AlarmRule in project otter by alibaba.
the class PipelineList method execute.
public void execute(@Param("channelId") Long channelId, @Param("pipelineId") Long pipelineId, HttpSession session, Context context) throws Exception {
Channel channel = channelService.findByIdWithoutColumn(channelId);
List<Pipeline> pipelines = channel.getPipelines();
List<Pipeline> tempPipe = new ArrayList<Pipeline>();
if ((pipelineId != null) && (pipelineId != 0l)) {
for (Pipeline pipeline : pipelines) {
if (!pipeline.getId().equals(pipelineId)) {
tempPipe.add(pipeline);
}
}
pipelines.removeAll(tempPipe);
}
Map<Long, DelayStat> delayStats = new HashMap<Long, DelayStat>(pipelines.size(), 1f);
Map<Long, MainStemEventData> mainstemDatas = new HashMap<Long, MainStemEventData>(pipelines.size(), 1f);
Map<Long, ThroughputStat> throughputStats = new HashMap<Long, ThroughputStat>(pipelines.size(), 1f);
Map<Long, List<AlarmRule>> alarmRuleStats = new HashMap<Long, List<AlarmRule>>(pipelines.size(), 1f);
Map<Long, PositionEventData> positionDatas = new HashMap<Long, PositionEventData>(pipelines.size(), 1f);
for (Pipeline pipeline : pipelines) {
DelayStat delayStat = delayStatService.findRealtimeDelayStat(pipeline.getId());
if (delayStat.getDelayNumber() == null) {
delayStat.setDelayNumber(0L);
delayStat.setDelayTime(0L);
delayStat.setGmtModified(pipeline.getGmtModified());
}
delayStats.put(pipeline.getId(), delayStat);
mainstemDatas.put(pipeline.getId(), arbitrateViewService.mainstemData(channel.getId(), pipeline.getId()));
ThroughputCondition condition = new ThroughputCondition();
condition.setPipelineId(pipeline.getId());
condition.setType(ThroughputType.ROW);
ThroughputStat throughputStat = throughputStatService.findThroughputStatByPipelineId(condition);
throughputStats.put(pipeline.getId(), throughputStat);
List<AlarmRule> alarmRules = alarmRuleService.getAlarmRules(pipeline.getId());
alarmRuleStats.put(pipeline.getId(), alarmRules);
PositionEventData positionData = arbitrateViewService.getCanalCursor(pipeline.getParameters().getDestinationName(), pipeline.getParameters().getMainstemClientId());
positionDatas.put(pipeline.getId(), positionData);
}
context.put("channel", channel);
context.put("pipelines", pipelines);
context.put("delayStats", delayStats);
context.put("throughputStats", throughputStats);
context.put("alarmRuleStats", alarmRuleStats);
context.put("mainstemDatas", mainstemDatas);
context.put("positionDatas", positionDatas);
}
use of com.alibaba.otter.shared.common.model.config.alarm.AlarmRule in project otter by alibaba.
the class EditAlarmRule method execute.
public void execute(@Param("alarmRuleId") Long alarmRuleId, Context context, Navigator nav) throws Exception {
AlarmRule alarmRule = alarmRuleService.getAlarmRuleById(alarmRuleId);
context.put("alarmRule", alarmRule);
context.put("channelId", channelService.findByPipelineId(alarmRule.getPipelineId()).getId());
}
use of com.alibaba.otter.shared.common.model.config.alarm.AlarmRule in project otter by alibaba.
the class AlarmRuleList method execute.
public void execute(@Param("pipelineId") Long pipelineId, Context context) throws Exception {
List<AlarmRule> alarmRules = alarmRuleService.getAlarmRules(pipelineId);
Channel channel = channelService.findByPipelineId(pipelineId);
context.put("alarmRules", alarmRules);
context.put("pipelineId", pipelineId);
context.put("channelId", channel.getId());
}
Aggregations