Search in sources :

Example 1 with ThroughputStat

use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat in project otter by alibaba.

the class ThroughputStatServiceImpl method listRealtimeThroughput.

/**
     * 3种时间间隔的统计信息
     */
public Map<AnalysisType, ThroughputInfo> listRealtimeThroughput(RealtimeThroughputCondition condition) {
    Assert.assertNotNull(condition);
    Map<AnalysisType, ThroughputInfo> throughputInfos = new HashMap<AnalysisType, ThroughputInfo>();
    TimelineThroughputCondition timelineCondition = new TimelineThroughputCondition();
    Date realtime = new Date(System.currentTimeMillis());
    timelineCondition.setPipelineId(condition.getPipelineId());
    timelineCondition.setType(condition.getType());
    timelineCondition.setStart(new Date(realtime.getTime() - condition.getMax() * 60 * 1000));
    timelineCondition.setEnd(realtime);
    List<ThroughputStatDO> throughputStatDOs = throughputDao.listTimelineThroughputStat(timelineCondition);
    for (AnalysisType analysisType : condition.getAnalysisType()) {
        ThroughputInfo throughputInfo = new ThroughputInfo();
        List<ThroughputStat> throughputStat = new ArrayList<ThroughputStat>();
        for (ThroughputStatDO throughputStatDO : throughputStatDOs) {
            if (realtime.getTime() - throughputStatDO.getEndTime().getTime() <= analysisType.getValue() * 60 * 1000) {
                throughputStat.add(throughputStatDOToModel(throughputStatDO));
            }
        }
        throughputInfo.setItems(throughputStat);
        throughputInfo.setSeconds(analysisType.getValue() * 60L);
        throughputInfos.put(analysisType, throughputInfo);
    }
    return throughputInfos;
}
Also used : AnalysisType(com.alibaba.otter.manager.biz.statistics.throughput.param.AnalysisType) TimelineThroughputCondition(com.alibaba.otter.manager.biz.statistics.throughput.param.TimelineThroughputCondition) ThroughputStatDO(com.alibaba.otter.manager.biz.statistics.throughput.dal.dataobject.ThroughputStatDO) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ThroughputInfo(com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputInfo) ArrayList(java.util.ArrayList) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat) Date(java.util.Date)

Example 2 with ThroughputStat

use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat in project otter by alibaba.

the class ThroughputStatServiceImpl method throughputStatDOToModel.

/**
     * 用于DO对象转化为Model对象
     * 
     * @param throughputStatDO
     * @return throughputStat
     */
private ThroughputStat throughputStatDOToModel(ThroughputStatDO throughputStatDO) {
    ThroughputStat throughputStat = new ThroughputStat();
    throughputStat.setId(throughputStatDO.getId());
    throughputStat.setPipelineId(throughputStatDO.getPipelineId());
    throughputStat.setStartTime(throughputStatDO.getStartTime());
    throughputStat.setEndTime(throughputStatDO.getEndTime());
    throughputStat.setType(throughputStatDO.getType());
    throughputStat.setNumber(throughputStatDO.getNumber());
    throughputStat.setSize(throughputStatDO.getSize());
    throughputStat.setGmtCreate(throughputStatDO.getGmtCreate());
    throughputStat.setGmtModified(throughputStatDO.getGmtModified());
    return throughputStat;
}
Also used : ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)

Example 3 with ThroughputStat

use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat in project otter by alibaba.

the class ThroughputStatServiceImpl method findThroughputStatByPipelineId.

public ThroughputStat findThroughputStatByPipelineId(ThroughputCondition condition) {
    Assert.assertNotNull(condition);
    ThroughputStatDO throughputStatDO = throughputDao.findRealtimeThroughputStat(condition);
    ThroughputStat throughputStat = new ThroughputStat();
    if (throughputStatDO != null) {
        throughputStat = throughputStatDOToModel(throughputStatDO);
    }
    return throughputStat;
}
Also used : ThroughputStatDO(com.alibaba.otter.manager.biz.statistics.throughput.dal.dataobject.ThroughputStatDO) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)

Example 4 with ThroughputStat

use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat in project otter by alibaba.

the class AnalysisTopStat method execute.

public void execute(@Param("searchKey") String searchKey, @Param("topN") int topN, @Param("statTime") int minute, Context context) throws Exception {
    if (topN <= 0) {
        topN = 15;
    }
    if (minute <= 0) {
        minute = 1;
    }
    List<TopDelayStat> tops = delayStatService.listTopDelayStat(searchKey, topN);
    List<Long> pipelineIds = new ArrayList<Long>();
    for (TopDelayStat top : tops) {
        top.setStatTime(Long.valueOf(minute));
        pipelineIds.add(top.getPipelineId());
    }
    Map<Long, ChannelStatus> channelStatuses = new HashMap<Long, ChannelStatus>(tops.size(), 1f);
    Map<Long, MainStemEventData> mainstemStatuses = new HashMap<Long, MainStemEventData>(tops.size(), 1f);
    if (pipelineIds.size() > 0) {
        List<ThroughputStat> stats = throughputStatService.listRealtimeThroughputByPipelineIds(pipelineIds, minute);
        for (ThroughputStat stat : stats) {
            for (TopDelayStat top : tops) {
                if (stat.getPipelineId().equals(top.getPipelineId())) {
                    DataStat s = new DataStat(stat.getNumber(), stat.getSize());
                    if (ThroughputType.FILE == stat.getType()) {
                        top.setFileStat(s);
                    } else if (ThroughputType.ROW == stat.getType()) {
                        top.setDbStat(s);
                    }
                    break;
                }
            }
        }
        for (TopDelayStat top : tops) {
            if (!channelStatuses.containsKey(top.getChannelId())) {
                channelStatuses.put(top.getChannelId(), arbitrateManageService.channelEvent().status(top.getChannelId()));
            }
            if (!mainstemStatuses.containsKey(top.getPipelineId())) {
                mainstemStatuses.put(top.getPipelineId(), arbitrateViewService.mainstemData(top.getChannelId(), top.getPipelineId()));
            }
        }
    }
    context.put("tops", tops);
    context.put("statTime", minute);
    context.put("channelStatuses", channelStatuses);
    context.put("mainstemStatuses", mainstemStatuses);
}
Also used : DataStat(com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat.DataStat) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MainStemEventData(com.alibaba.otter.shared.arbitrate.model.MainStemEventData) ChannelStatus(com.alibaba.otter.shared.common.model.config.channel.ChannelStatus) TopDelayStat(com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)

Example 5 with ThroughputStat

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

Aggregations

ThroughputStat (com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)15 ArrayList (java.util.ArrayList)8 Date (java.util.Date)5 ThroughputStatDO (com.alibaba.otter.manager.biz.statistics.throughput.dal.dataobject.ThroughputStatDO)4 ThroughputCondition (com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition)4 HashMap (java.util.HashMap)4 ThroughputInfo (com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputInfo)3 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)3 TopDelayStat (com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat)2 DataStat (com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat.DataStat)2 AnalysisType (com.alibaba.otter.manager.biz.statistics.throughput.param.AnalysisType)2 MainStemEventData (com.alibaba.otter.shared.arbitrate.model.MainStemEventData)2 AlarmRule (com.alibaba.otter.shared.common.model.config.alarm.AlarmRule)2 DelayStat (com.alibaba.otter.shared.common.model.statistics.delay.DelayStat)2 ThroughputType (com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputType)2 LinkedHashMap (java.util.LinkedHashMap)2 RealtimeThroughputCondition (com.alibaba.otter.manager.biz.statistics.throughput.param.RealtimeThroughputCondition)1 TimelineThroughputCondition (com.alibaba.otter.manager.biz.statistics.throughput.param.TimelineThroughputCondition)1 LoadCounter (com.alibaba.otter.node.etl.load.loader.LoadStatsTracker.LoadCounter)1 LoadThroughput (com.alibaba.otter.node.etl.load.loader.LoadStatsTracker.LoadThroughput)1