Search in sources :

Example 1 with DelayStatDO

use of com.alibaba.otter.manager.biz.statistics.delay.dal.dataobject.DelayStatDO in project otter by alibaba.

the class DelayStatServiceImpl method findRealtimeDelayStat.

/**
     * 通过pipeLineId得到一个以gmtCreate倒排序的第一条记录
     */
public DelayStat findRealtimeDelayStat(Long pipelineId) {
    Assert.assertNotNull(pipelineId);
    DelayStatDO delayStatDO = delayStatDao.findRealtimeDelayStat(pipelineId);
    DelayStat delayStat = new DelayStat();
    if (delayStatDO != null) {
        delayStat = delayStatDOToModel(delayStatDO);
    }
    return delayStat;
}
Also used : DelayStatDO(com.alibaba.otter.manager.biz.statistics.delay.dal.dataobject.DelayStatDO) TopDelayStat(com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat) DelayStat(com.alibaba.otter.shared.common.model.statistics.delay.DelayStat)

Example 2 with DelayStatDO

use of com.alibaba.otter.manager.biz.statistics.delay.dal.dataobject.DelayStatDO in project otter by alibaba.

the class DelayStatServiceImpl method listTimelineDelayStat.

/**
     * 列出pipeLineId下,start-end时间段下的delayStat
     */
public Map<Long, DelayStatInfo> listTimelineDelayStat(Long pipelineId, Date start, Date end) {
    Map<Long, DelayStatInfo> delayStatInfos = new LinkedHashMap<Long, DelayStatInfo>();
    List<DelayStatDO> delayStatDOs = delayStatDao.listTimelineDelayStatsByPipelineId(pipelineId, start, end);
    int size = delayStatDOs.size();
    int k = size - 1;
    for (Long i = start.getTime(); i <= end.getTime(); i += 60 * 1000) {
        DelayStatInfo delayStatInfo = new DelayStatInfo();
        List<DelayStat> delayStats = new ArrayList<DelayStat>();
        // 取出每个时间点i以内的数据,k是一个游标,每次遍历时前面已经取过了的数据就不用再遍历了
        for (int j = k; j >= 0; --j) {
            if ((i - delayStatDOs.get(j).getGmtModified().getTime() <= 60 * 1000) && (i - delayStatDOs.get(j).getGmtModified().getTime() >= 0)) {
                delayStats.add(delayStatDOToModel(delayStatDOs.get(j)));
                k = j - 1;
            } else // 如果不满足if条件,则后面的数据也不用再遍历
            {
                break;
            }
        }
        if (delayStats.size() > 0) {
            delayStatInfo.setItems(delayStats);
            delayStatInfos.put(i, delayStatInfo);
        }
    }
    return delayStatInfos;
}
Also used : ArrayList(java.util.ArrayList) DelayStatDO(com.alibaba.otter.manager.biz.statistics.delay.dal.dataobject.DelayStatDO) TopDelayStat(com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat) DelayStat(com.alibaba.otter.shared.common.model.statistics.delay.DelayStat) DelayStatInfo(com.alibaba.otter.manager.biz.statistics.delay.param.DelayStatInfo) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with DelayStatDO

use of com.alibaba.otter.manager.biz.statistics.delay.dal.dataobject.DelayStatDO in project otter by alibaba.

the class DelayStatServiceImpl method delayStatModelToDo.

/**
     * 用于Model对象转化为DO对象
     * 
     * @param delayStat
     * @return DelayStatDO
     */
private DelayStatDO delayStatModelToDo(DelayStat delayStat) {
    DelayStatDO delayStatDO = new DelayStatDO();
    delayStatDO.setId(delayStat.getId());
    delayStatDO.setDelayTime(delayStat.getDelayTime());
    delayStatDO.setDelayNumber(delayStat.getDelayNumber());
    delayStatDO.setPipelineId(delayStat.getPipelineId());
    delayStatDO.setGmtCreate(delayStat.getGmtCreate());
    delayStatDO.setGmtModified(delayStat.getGmtModified());
    return delayStatDO;
}
Also used : DelayStatDO(com.alibaba.otter.manager.biz.statistics.delay.dal.dataobject.DelayStatDO)

Aggregations

DelayStatDO (com.alibaba.otter.manager.biz.statistics.delay.dal.dataobject.DelayStatDO)3 TopDelayStat (com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat)2 DelayStat (com.alibaba.otter.shared.common.model.statistics.delay.DelayStat)2 DelayStatInfo (com.alibaba.otter.manager.biz.statistics.delay.param.DelayStatInfo)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1