Search in sources :

Example 1 with ThroughputCondition

use of com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition in project otter by alibaba.

the class CheckDelayStat method execute.

public void execute(@Param("queueSize") String queueSize, @Param("delayTime") String delayTime, @Param("timeout") String timeout, Context context) throws WebxException {
    Map<Long, Long> queueSizeMap = parseAlert(queueSize);
    Map<Long, Long> delayTimeMap = parseAlert(delayTime);
    Map<Long, Long> timeoutMap = parseAlert(timeout);
    Boolean result = true;
    if ((queueSizeMap != null) && (false == queueSizeMap.isEmpty())) {
        Set<Long> key = queueSizeMap.keySet();
        for (Iterator it = key.iterator(); it.hasNext(); ) {
            Long pipelineId = (Long) it.next();
            Channel channel = channelService.findByPipelineId(pipelineId);
            // 判断channel状态,只有启动状态才进行判断超时时间
            if (!channel.getStatus().isStop()) {
                DelayStat delayStat = delayStatService.findRealtimeDelayStat(pipelineId);
                logger.info("delayStat.getDelayNumber() == " + delayStat.getDelayNumber());
                if (null != delayStat.getDelayNumber() && delayStat.getDelayNumber() >= queueSizeMap.get(pipelineId)) {
                    result = false;
                }
            }
        }
    }
    if ((delayTimeMap != null) && (false == delayTimeMap.isEmpty())) {
        Set<Long> key = delayTimeMap.keySet();
        for (Iterator it = key.iterator(); it.hasNext(); ) {
            Long pipelineId = (Long) it.next();
            Channel channel = channelService.findByPipelineId(pipelineId);
            // 判断channel状态,只有启动状态才进行判断超时时间
            if (!channel.getStatus().isStop()) {
                DelayStat delayStat = delayStatService.findRealtimeDelayStat(pipelineId);
                logger.info("delayStat.getDelayTime() == " + delayStat.getDelayTime());
                if (null != delayStat.getDelayTime() && delayStat.getDelayTime() >= delayTimeMap.get(pipelineId)) {
                    result = false;
                }
            }
        }
    }
    if ((timeoutMap != null) && (false == timeoutMap.isEmpty())) {
        Set<Long> key = timeoutMap.keySet();
        for (Iterator it = key.iterator(); it.hasNext(); ) {
            Long pipelineId = (Long) it.next();
            Channel channel = channelService.findByPipelineId(pipelineId);
            // 判断channel状态,只有启动状态才进行判断超时时间
            if (!channel.getStatus().isStop()) {
                ThroughputCondition condition = new ThroughputCondition();
                condition.setPipelineId(pipelineId);
                condition.setType(ThroughputType.ROW);
                ThroughputStat throughputStat = throughputStatService.findThroughputStatByPipelineId(condition);
                if (null != throughputStat.getGmtModified()) {
                    Date now = new Date();
                    long time = now.getTime() - throughputStat.getGmtModified().getTime();
                    logger.info("timeout == " + time + "(ms)");
                    // 单位为分钟
                    long timeout_min = MAX_TIMEOUT;
                    if (timeoutMap.containsKey(pipelineId)) {
                        timeout_min = timeoutMap.get(pipelineId);
                    }
                    if (time / (1000 * 60) > timeout_min) {
                        result = false;
                    }
                }
            }
        }
    }
    context.put("result", result);
}
Also used : Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) Iterator(java.util.Iterator) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat) DelayStat(com.alibaba.otter.shared.common.model.statistics.delay.DelayStat) ThroughputCondition(com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition) Date(java.util.Date)

Example 2 with ThroughputCondition

use of com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition 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 3 with ThroughputCondition

use of com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition 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 4 with ThroughputCondition

use of com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition in project otter by alibaba.

the class AnalysisThroughputStat method execute.

public void execute(@Param("pipelineId") Long pipelineId, Context context) throws Exception {
    Channel channel = channelService.findByPipelineId(pipelineId);
    RealtimeThroughputCondition condition1 = new RealtimeThroughputCondition();
    RealtimeThroughputCondition condition2 = new RealtimeThroughputCondition();
    ThroughputCondition condition11 = new ThroughputCondition();
    ThroughputCondition condition22 = new ThroughputCondition();
    List<AnalysisType> analysisType = new ArrayList<AnalysisType>();
    analysisType.add(AnalysisType.ONE_MINUTE);
    analysisType.add(AnalysisType.FIVE_MINUTE);
    analysisType.add(AnalysisType.FIFTEEN_MINUTE);
    condition1.setPipelineId(pipelineId);
    condition1.setAnalysisType(analysisType);
    condition1.setType(ThroughputType.FILE);
    condition2.setPipelineId(pipelineId);
    condition2.setAnalysisType(analysisType);
    condition2.setType(ThroughputType.ROW);
    condition11.setPipelineId(pipelineId);
    condition11.setType(ThroughputType.FILE);
    condition22.setPipelineId(pipelineId);
    condition22.setType(ThroughputType.ROW);
    Map<AnalysisType, ThroughputInfo> throughputInfos1 = throughputStatService.listRealtimeThroughput(condition1);
    Map<AnalysisType, ThroughputInfo> throughputInfos2 = throughputStatService.listRealtimeThroughput(condition2);
    ThroughputStat throughputStat1 = throughputStatService.findThroughputStatByPipelineId(condition11);
    ThroughputStat throughputStat2 = throughputStatService.findThroughputStatByPipelineId(condition22);
    context.put("throughputInfos1", throughputInfos1);
    context.put("throughputInfos2", throughputInfos2);
    context.put("channel", channel);
    context.put("pipelineId", pipelineId);
    context.put("throughputStat1", throughputStat1);
    context.put("throughputStat2", throughputStat2);
    context.put("one", AnalysisType.ONE_MINUTE);
    context.put("five", AnalysisType.FIVE_MINUTE);
    context.put("fifteen", AnalysisType.FIFTEEN_MINUTE);
}
Also used : RealtimeThroughputCondition(com.alibaba.otter.manager.biz.statistics.throughput.param.RealtimeThroughputCondition) AnalysisType(com.alibaba.otter.manager.biz.statistics.throughput.param.AnalysisType) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ThroughputInfo(com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputInfo) ArrayList(java.util.ArrayList) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat) ThroughputCondition(com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition) RealtimeThroughputCondition(com.alibaba.otter.manager.biz.statistics.throughput.param.RealtimeThroughputCondition)

Aggregations

ThroughputCondition (com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition)4 ThroughputStat (com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)4 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)3 AlarmRule (com.alibaba.otter.shared.common.model.config.alarm.AlarmRule)2 DelayStat (com.alibaba.otter.shared.common.model.statistics.delay.DelayStat)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 AnalysisType (com.alibaba.otter.manager.biz.statistics.throughput.param.AnalysisType)1 RealtimeThroughputCondition (com.alibaba.otter.manager.biz.statistics.throughput.param.RealtimeThroughputCondition)1 ThroughputInfo (com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputInfo)1 MainStemEventData (com.alibaba.otter.shared.arbitrate.model.MainStemEventData)1 PositionEventData (com.alibaba.otter.shared.arbitrate.model.PositionEventData)1 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1