Search in sources :

Example 1 with DataStat

use of com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat.DataStat 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 2 with DataStat

use of com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat.DataStat in project otter by alibaba.

the class TopDelay method execute.

public void execute(@Param("searchKey") String searchKey, @Param("topN") int topN, @Param("statTime") int minute) {
    try {
        if (topN <= 0) {
            topN = 10;
        }
        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());
        }
        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;
                }
            }
        }
        returnSuccess(JsonUtils.marshalToString(tops));
    } catch (Exception e) {
        String errorMsg = String.format("error happens while searchKey[%s] topN [%d]", searchKey, topN);
        log.error(errorMsg, e);
        returnError(errorMsg);
    }
}
Also used : DataStat(com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat.DataStat) TopDelayStat(com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat) ArrayList(java.util.ArrayList) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)

Aggregations

TopDelayStat (com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat)2 DataStat (com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat.DataStat)2 ThroughputStat (com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)2 ArrayList (java.util.ArrayList)2 MainStemEventData (com.alibaba.otter.shared.arbitrate.model.MainStemEventData)1 ChannelStatus (com.alibaba.otter.shared.common.model.config.channel.ChannelStatus)1 HashMap (java.util.HashMap)1