Search in sources :

Example 6 with TableStat

use of com.alibaba.otter.shared.common.model.statistics.table.TableStat in project otter by alibaba.

the class TableStatServiceImpl method listTableStat.

/**
 * 列出对应同步任务下的统计信息
 */
public List<TableStat> listTableStat(Long pipelineId) {
    Assert.assertNotNull(pipelineId);
    List<TableStatDO> tableStatDOs = tableStatDao.listTableStatsByPipelineId(pipelineId);
    List<TableStat> tableStats = new ArrayList<TableStat>();
    for (TableStatDO tableStatDO : tableStatDOs) {
        tableStats.add(tableStatDOToModel(tableStatDO));
    }
    return tableStats;
}
Also used : TableStatDO(com.alibaba.otter.manager.biz.statistics.table.dal.dataobject.TableStatDO) ArrayList(java.util.ArrayList) TableStat(com.alibaba.otter.shared.common.model.statistics.table.TableStat)

Example 7 with TableStat

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

Example 8 with TableStat

use of com.alibaba.otter.shared.common.model.statistics.table.TableStat in project otter by alibaba.

the class TableStatServiceImpl method tableStatDOToModel.

/**
 * 用于DO对象转化为Model对象
 *
 * @param tableStatDO
 * @return TableStat
 */
private TableStat tableStatDOToModel(TableStatDO tableStatDO) {
    TableStat tableStat = new TableStat();
    tableStat.setId(tableStatDO.getId());
    tableStat.setPipelineId(tableStatDO.getPipelineId());
    tableStat.setDataMediaPairId(tableStatDO.getDataMediaPairId());
    tableStat.setFileSize(tableStatDO.getFileSize());
    tableStat.setFileCount(tableStatDO.getFileCount());
    tableStat.setDeleteCount(tableStatDO.getDeleteCount());
    tableStat.setInsertCount(tableStatDO.getInsertCount());
    tableStat.setUpdateCount(tableStatDO.getUpdateCount());
    tableStat.setGmtCreate(tableStatDO.getGmtCreate());
    tableStat.setGmtModified(tableStatDO.getGmtModified());
    return tableStat;
}
Also used : TableStat(com.alibaba.otter.shared.common.model.statistics.table.TableStat)

Example 9 with TableStat

use of com.alibaba.otter.shared.common.model.statistics.table.TableStat in project otter by alibaba.

the class TableStatServiceImpl method flushBehaviorHistory.

private void flushBehaviorHistory() {
    synchronized (tableStats) {
        // 需要做同步,避免delay数据丢失
        Collection<TableStat> stats = tableStats.values();
        for (TableStat stat : stats) {
            insertBehaviorHistory(stat);
        }
        tableStats.clear();
    }
}
Also used : TableStat(com.alibaba.otter.shared.common.model.statistics.table.TableStat)

Example 10 with TableStat

use of com.alibaba.otter.shared.common.model.statistics.table.TableStat in project otter by alibaba.

the class StatisticsClientServiceIntegration method sendTableStats.

private void sendTableStats() {
    TableStat stat1 = new TableStat();
    stat1.setPipelineId(1L);
    stat1.setDataMediaPairId(1L);
    stat1.setFileCount(100L);
    stat1.setFileSize(100L);
    stat1.setInsertCount(100L);
    stat1.setUpdateCount(100L);
    stat1.setDeleteCount(100L);
    TableStat stat2 = new TableStat();
    stat2.setPipelineId(1L);
    stat2.setDataMediaPairId(2L);
    stat2.setFileCount(101L);
    stat2.setFileSize(101L);
    stat2.setInsertCount(101L);
    stat2.setUpdateCount(101L);
    stat2.setDeleteCount(101L);
    statisticsClientService.sendTableStats(Arrays.asList(stat1, stat2));
}
Also used : TableStat(com.alibaba.otter.shared.common.model.statistics.table.TableStat)

Aggregations

TableStat (com.alibaba.otter.shared.common.model.statistics.table.TableStat)10 ArrayList (java.util.ArrayList)3 TableHistoryStatDO (com.alibaba.otter.manager.biz.statistics.table.dal.dataobject.TableHistoryStatDO)1 TableStatDO (com.alibaba.otter.manager.biz.statistics.table.dal.dataobject.TableStatDO)1 BehaviorHistoryInfo (com.alibaba.otter.manager.biz.statistics.table.param.BehaviorHistoryInfo)1 LoadCounter (com.alibaba.otter.node.etl.load.loader.LoadStatsTracker.LoadCounter)1 LoadThroughput (com.alibaba.otter.node.etl.load.loader.LoadStatsTracker.LoadThroughput)1 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)1 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)1 ThroughputStat (com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1