Search in sources :

Example 6 with DelayStat

use of com.alibaba.otter.shared.common.model.statistics.delay.DelayStat 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 7 with DelayStat

use of com.alibaba.otter.shared.common.model.statistics.delay.DelayStat in project otter by alibaba.

the class StatsRemoteServiceImpl method onDelayCount.

public void onDelayCount(DelayCountEvent event) {
    Assert.notNull(event);
    Assert.notNull(event.getCount());
    // 更新delay queue的计数器
    DelayCount count = event.getCount();
    // 构造一次delay stat快照
    DelayStat stat = new DelayStat();
    stat.setPipelineId(count.getPipelineId());
    // 不再记录堆积量
    stat.setDelayNumber(0L);
    // 只记录延迟时间,负数直接归为0
    stat.setDelayTime(count.getTime() >= 0 ? count.getTime() : 0);
    if (statUnit <= 0) {
        delayStatService.createDelayStat(stat);
    } else {
        synchronized (delayStats) {
            delayStats.get(count.getPipelineId()).merge(stat);
        }
    }
}
Also used : DelayCount(com.alibaba.otter.shared.common.model.statistics.delay.DelayCount) DelayStat(com.alibaba.otter.shared.common.model.statistics.delay.DelayStat)

Example 8 with DelayStat

use of com.alibaba.otter.shared.common.model.statistics.delay.DelayStat 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)

Aggregations

DelayStat (com.alibaba.otter.shared.common.model.statistics.delay.DelayStat)8 TopDelayStat (com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat)3 DelayStatDO (com.alibaba.otter.manager.biz.statistics.delay.dal.dataobject.DelayStatDO)2 ThroughputCondition (com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition)2 AlarmRule (com.alibaba.otter.shared.common.model.config.alarm.AlarmRule)2 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)2 ThroughputStat (com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 DelayStatInfo (com.alibaba.otter.manager.biz.statistics.delay.param.DelayStatInfo)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 DelayCount (com.alibaba.otter.shared.common.model.statistics.delay.DelayCount)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1