Search in sources :

Example 6 with AlarmRule

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);
}
Also used : AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule)

Example 7 with AlarmRule

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);
}
Also used : AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule) SystemParameter(com.alibaba.otter.shared.common.model.config.parameter.SystemParameter) WebxException(com.alibaba.citrus.webx.WebxException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 8 with AlarmRule

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());
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule)

Example 9 with AlarmRule

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);
}
Also used : AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule) ArrayList(java.util.ArrayList) NodeAlarmEvent(com.alibaba.otter.shared.communication.model.arbitrate.NodeAlarmEvent) Date(java.util.Date) Test(org.testng.annotations.Test) BaseOtterTest(com.alibaba.otter.manager.biz.BaseOtterTest)

Example 10 with AlarmRule

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();
}
Also used : HashMap(java.util.HashMap) AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.testng.annotations.Test) BaseOtterTest(com.alibaba.otter.manager.biz.BaseOtterTest)

Aggregations

AlarmRule (com.alibaba.otter.shared.common.model.config.alarm.AlarmRule)21 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)7 Date (java.util.Date)6 List (java.util.List)6 BaseOtterTest (com.alibaba.otter.manager.biz.BaseOtterTest)4 Test (org.testng.annotations.Test)4 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)3 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)3 ThroughputCondition (com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition)2 PositionEventData (com.alibaba.otter.shared.arbitrate.model.PositionEventData)2 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)2 DelayStat (com.alibaba.otter.shared.common.model.statistics.delay.DelayStat)2 ThroughputStat (com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)2 NodeAlarmEvent (com.alibaba.otter.shared.communication.model.arbitrate.NodeAlarmEvent)2 Paginator (com.alibaba.citrus.util.Paginator)1 WebxException (com.alibaba.citrus.webx.WebxException)1 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)1 MainStemEventData (com.alibaba.otter.shared.arbitrate.model.MainStemEventData)1 ChannelStatus (com.alibaba.otter.shared.common.model.config.channel.ChannelStatus)1