Search in sources :

Example 16 with AlarmRule

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)));
    }
}
Also used : AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat) ThroughputCondition(com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition) Date(java.util.Date)

Example 17 with AlarmRule

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

Example 18 with AlarmRule

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);
}
Also used : PositionEventData(com.alibaba.otter.shared.arbitrate.model.PositionEventData) HashMap(java.util.HashMap) AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ArrayList(java.util.ArrayList) MainStemEventData(com.alibaba.otter.shared.arbitrate.model.MainStemEventData) DelayStat(com.alibaba.otter.shared.common.model.statistics.delay.DelayStat) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat) ArrayList(java.util.ArrayList) List(java.util.List) ThroughputCondition(com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition)

Example 19 with AlarmRule

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

Example 20 with AlarmRule

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

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