Search in sources :

Example 1 with TableHistoryStatDO

use of com.alibaba.otter.manager.biz.statistics.table.dal.dataobject.TableHistoryStatDO in project otter by alibaba.

the class TableStatServiceImpl method tableHistoryStatModelToDo.

/**
 * 用于Model对象转化为DO对象
 *
 * @param tableStat
 * @return TableHistoryStatDO
 */
private TableHistoryStatDO tableHistoryStatModelToDo(TableStat tableStat) {
    TableHistoryStatDO tableHistoryStatDO = new TableHistoryStatDO();
    tableHistoryStatDO.setId(tableStat.getId());
    tableHistoryStatDO.setPipelineId(tableStat.getPipelineId());
    tableHistoryStatDO.setDataMediaPairId(tableStat.getDataMediaPairId());
    tableHistoryStatDO.setStartTime(tableStat.getStartTime());
    tableHistoryStatDO.setEndTime(tableStat.getEndTime());
    tableHistoryStatDO.setFileSize(tableStat.getFileSize());
    tableHistoryStatDO.setFileCount(tableStat.getFileCount());
    tableHistoryStatDO.setDeleteCount(tableStat.getDeleteCount());
    tableHistoryStatDO.setInsertCount(tableStat.getInsertCount());
    tableHistoryStatDO.setUpdateCount(tableStat.getUpdateCount());
    tableHistoryStatDO.setGmtCreate(tableStat.getGmtCreate());
    tableHistoryStatDO.setGmtModified(tableStat.getGmtModified());
    return tableHistoryStatDO;
}
Also used : TableHistoryStatDO(com.alibaba.otter.manager.biz.statistics.table.dal.dataobject.TableHistoryStatDO)

Example 2 with TableHistoryStatDO

use of com.alibaba.otter.manager.biz.statistics.table.dal.dataobject.TableHistoryStatDO in project otter by alibaba.

the class TableStatServiceImpl method listTimelineBehaviorHistory.

/**
 * 列出pairId下,start-end时间段下的tableStat, 首先从数据库中取出这一段时间所有数据,该数据都是根据end_time倒排序的, 每隔1分钟将这些数据分组
 */
public Map<Long, BehaviorHistoryInfo> listTimelineBehaviorHistory(TimelineBehaviorHistoryCondition condition) {
    Assert.assertNotNull(condition);
    Map<Long, BehaviorHistoryInfo> behaviorHistoryInfos = new LinkedHashMap<Long, BehaviorHistoryInfo>();
    List<TableHistoryStatDO> tableHistoryStatDOs = tableHistoryStatDao.listTimelineTableStat(condition);
    int size = tableHistoryStatDOs.size();
    int k = size - 1;
    for (Long i = condition.getStart().getTime(); i <= condition.getEnd().getTime(); i += 60 * 1000) {
        BehaviorHistoryInfo behaviorHistoryInfo = new BehaviorHistoryInfo();
        List<TableStat> tableStat = new ArrayList<TableStat>();
        // 取出每个时间点i以内的数据,k是一个游标,每次遍历时前面已经取过了的数据就不用再遍历了
        for (int j = k; j >= 0; --j) {
            if ((i - tableHistoryStatDOs.get(j).getEndTime().getTime() <= 60 * 1000) && (i - tableHistoryStatDOs.get(j).getEndTime().getTime() >= 0)) {
                tableStat.add(tableHistoryStatDOToModel(tableHistoryStatDOs.get(j)));
                k = j - 1;
            } else // 如果不满足if条件,则后面的数据也不用再遍历
            {
                break;
            }
        }
        if (tableStat.size() > 0) {
            behaviorHistoryInfo.setItems(tableStat);
            behaviorHistoryInfos.put(i, behaviorHistoryInfo);
        }
    }
    return behaviorHistoryInfos;
}
Also used : TableHistoryStatDO(com.alibaba.otter.manager.biz.statistics.table.dal.dataobject.TableHistoryStatDO) BehaviorHistoryInfo(com.alibaba.otter.manager.biz.statistics.table.param.BehaviorHistoryInfo) ArrayList(java.util.ArrayList) TableStat(com.alibaba.otter.shared.common.model.statistics.table.TableStat) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

TableHistoryStatDO (com.alibaba.otter.manager.biz.statistics.table.dal.dataobject.TableHistoryStatDO)2 BehaviorHistoryInfo (com.alibaba.otter.manager.biz.statistics.table.param.BehaviorHistoryInfo)1 TableStat (com.alibaba.otter.shared.common.model.statistics.table.TableStat)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1