use of com.alibaba.otter.shared.common.model.config.alarm.AlarmRule in project otter by alibaba.
the class AlarmRuleAction method doStatusByPipeline.
public void doStatusByPipeline(@Param("pipelineId") Long pipelineId, @Param("status") String status, @Param("pauseTime") String pauseTime, Navigator nav) throws WebxException {
List<AlarmRule> alarmRules = alarmRuleService.getAlarmRules(pipelineId);
for (AlarmRule alarmRule : alarmRules) {
if (status.equals("enable")) {
if (alarmRule.getStatus().isDisable()) {
alarmRuleService.enableMonitor(alarmRule.getId());
}
} else if (status.equals("disable")) {
if (alarmRule.getStatus().isEnable()) {
if (pauseTime != null) {
alarmRuleService.disableMonitor(alarmRule.getId(), pauseTime);
} else {
alarmRuleService.disableMonitor(alarmRule.getId());
}
}
}
}
nav.redirectToLocation("alarmRuleList.htm?pipelineId=" + pipelineId);
}
use of com.alibaba.otter.shared.common.model.config.alarm.AlarmRule in project otter by alibaba.
the class AlarmRuleAction method doOnekeyAddMonitor.
/**
* 一键添加监控
*/
public void doOnekeyAddMonitor(@Param("pipelineId") Long pipelineId, Navigator nav) throws Exception {
List<AlarmRule> existRules = alarmRuleService.getAlarmRules(pipelineId);
if (!existRules.isEmpty()) {
nav.redirectToLocation("alarmRuleList.htm?pipelineId=" + pipelineId);
return;
}
SystemParameter systemParameter = systemParameterService.find();
AlarmRule alarmRule = new AlarmRule();
alarmRule.setPipelineId(pipelineId);
alarmRule.setDescription("one key added!");
alarmRule.setAutoRecovery(Boolean.FALSE);
alarmRule.setReceiverKey(systemParameter.getDefaultAlarmReceiveKey());
alarmRule.setStatus(AlarmRuleStatus.DISABLE);
alarmRule.setRecoveryThresold(3);
alarmRule.setIntervalTime(1800L);
try {
alarmRule.setMonitorName(MonitorName.EXCEPTION);
alarmRule.setMatchValue("ERROR,EXCEPTION");
alarmRule.setIntervalTime(1800L);
alarmRule.setAutoRecovery(false);
alarmRule.setRecoveryThresold(2);
alarmRuleService.create(alarmRule);
alarmRule.setMonitorName(MonitorName.POSITIONTIMEOUT);
alarmRule.setMatchValue("600");
alarmRule.setIntervalTime(1800L);
alarmRule.setAutoRecovery(true);
alarmRule.setRecoveryThresold(0);
alarmRuleService.create(alarmRule);
alarmRule.setMonitorName(MonitorName.DELAYTIME);
alarmRule.setMatchValue("600");
alarmRule.setIntervalTime(1800L);
alarmRule.setAutoRecovery(false);
alarmRule.setRecoveryThresold(2);
alarmRuleService.create(alarmRule);
alarmRule.setMonitorName(MonitorName.PROCESSTIMEOUT);
alarmRule.setMatchValue("60");
alarmRule.setIntervalTime(1800L);
alarmRule.setAutoRecovery(true);
alarmRule.setRecoveryThresold(2);
alarmRuleService.create(alarmRule);
// alarmRule.setMonitorName(MonitorName.PIPELINETIMEOUT);
// alarmRule.setMatchValue("43200");
// alarmRuleService.create(alarmRule);
} catch (Exception e) {
return;
}
nav.redirectToLocation("alarmRuleList.htm?pipelineId=" + pipelineId);
}
use of com.alibaba.otter.shared.common.model.config.alarm.AlarmRule in project otter by alibaba.
the class AlarmRuleAction method doEdit.
/**
* 修改Node
*/
public void doEdit(@FormGroup("alarmRuleInfo") Group alarmRuleInfo, @FormField(name = "formAlarmRuleError", group = "alarmRuleInfo") CustomErrors err, Navigator nav) throws Exception {
AlarmRule alarmRule = new AlarmRule();
alarmRuleInfo.setProperties(alarmRule);
try {
alarmRuleService.modify(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 ExceptionRuleMonitorTest method testSerialProcess.
@Test
public void testSerialProcess() {
new NonStrictExpectations() {
{
alarmRuleService.getAlarmRules(anyLong, AlarmRuleStatus.ENABLE);
List<AlarmRule> rules = new ArrayList<AlarmRule>();
AlarmRule rule = new AlarmRule();
rule.setDescription("xxx");
rule.setGmtCreate(new Date());
rule.setGmtModified(new Date());
rule.setId(1L);
rule.setMatchValue("EXCEPTION");
rule.setMonitorName(MonitorName.EXCEPTION);
rule.setPipelineId(2L);
rule.setReceiverKey("otterteam");
rule.setStatus(AlarmRuleStatus.ENABLE);
rules.add(rule);
returns(rules);
}
};
NodeAlarmEvent event = new NodeAlarmEvent();
event.setMessage("pid:77 nid:5 exception:EXCEPTON,nid:5[setl:ERROR ## SelectTask processId = 644408,parallelism = 5,ProcessEnd processId = 644394 invalid]");
event.setNid(5L);
event.setPipelineId(2L);
event.setTitle("EXCEPTON");
monitor.feed(event, 2L);
}
use of com.alibaba.otter.shared.common.model.config.alarm.AlarmRule in project otter by alibaba.
the class GlobalMonitorTest method testSerialProcess.
@Test
public void testSerialProcess() {
new NonStrictExpectations() {
{
alarmRuleService.getAlarmRules(AlarmRuleStatus.ENABLE);
Map<Long, List<AlarmRule>> allRules = new HashMap<Long, List<AlarmRule>>();
for (long i = 0; i < 10; i++) {
List<AlarmRule> rules = new ArrayList<AlarmRule>();
for (int j = 0; j < 5; j++) {
rules.add(new AlarmRule());
}
allRules.put(i + 1, rules);
}
returns(allRules);
}
};
globalMonitor.setNeedConcurrent(false);
globalMonitor.setPipelineMonitor(normalPipelineMonitor);
globalMonitor.explore();
}
Aggregations