Search in sources :

Example 1 with AnalysisType

use of com.alibaba.otter.manager.biz.statistics.throughput.param.AnalysisType 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 AnalysisType

use of com.alibaba.otter.manager.biz.statistics.throughput.param.AnalysisType in project otter by alibaba.

the class AnalysisThroughputStat method execute.

public void execute(@Param("pipelineId") Long pipelineId, Context context) throws Exception {
    Channel channel = channelService.findByPipelineId(pipelineId);
    RealtimeThroughputCondition condition1 = new RealtimeThroughputCondition();
    RealtimeThroughputCondition condition2 = new RealtimeThroughputCondition();
    ThroughputCondition condition11 = new ThroughputCondition();
    ThroughputCondition condition22 = new ThroughputCondition();
    List<AnalysisType> analysisType = new ArrayList<AnalysisType>();
    analysisType.add(AnalysisType.ONE_MINUTE);
    analysisType.add(AnalysisType.FIVE_MINUTE);
    analysisType.add(AnalysisType.FIFTEEN_MINUTE);
    condition1.setPipelineId(pipelineId);
    condition1.setAnalysisType(analysisType);
    condition1.setType(ThroughputType.FILE);
    condition2.setPipelineId(pipelineId);
    condition2.setAnalysisType(analysisType);
    condition2.setType(ThroughputType.ROW);
    condition11.setPipelineId(pipelineId);
    condition11.setType(ThroughputType.FILE);
    condition22.setPipelineId(pipelineId);
    condition22.setType(ThroughputType.ROW);
    Map<AnalysisType, ThroughputInfo> throughputInfos1 = throughputStatService.listRealtimeThroughput(condition1);
    Map<AnalysisType, ThroughputInfo> throughputInfos2 = throughputStatService.listRealtimeThroughput(condition2);
    ThroughputStat throughputStat1 = throughputStatService.findThroughputStatByPipelineId(condition11);
    ThroughputStat throughputStat2 = throughputStatService.findThroughputStatByPipelineId(condition22);
    context.put("throughputInfos1", throughputInfos1);
    context.put("throughputInfos2", throughputInfos2);
    context.put("channel", channel);
    context.put("pipelineId", pipelineId);
    context.put("throughputStat1", throughputStat1);
    context.put("throughputStat2", throughputStat2);
    context.put("one", AnalysisType.ONE_MINUTE);
    context.put("five", AnalysisType.FIVE_MINUTE);
    context.put("fifteen", AnalysisType.FIFTEEN_MINUTE);
}
Also used : RealtimeThroughputCondition(com.alibaba.otter.manager.biz.statistics.throughput.param.RealtimeThroughputCondition) AnalysisType(com.alibaba.otter.manager.biz.statistics.throughput.param.AnalysisType) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ThroughputInfo(com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputInfo) ArrayList(java.util.ArrayList) ThroughputStat(com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat) ThroughputCondition(com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition) RealtimeThroughputCondition(com.alibaba.otter.manager.biz.statistics.throughput.param.RealtimeThroughputCondition)

Aggregations

AnalysisType (com.alibaba.otter.manager.biz.statistics.throughput.param.AnalysisType)2 ThroughputInfo (com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputInfo)2 ThroughputStat (com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat)2 ArrayList (java.util.ArrayList)2 ThroughputStatDO (com.alibaba.otter.manager.biz.statistics.throughput.dal.dataobject.ThroughputStatDO)1 RealtimeThroughputCondition (com.alibaba.otter.manager.biz.statistics.throughput.param.RealtimeThroughputCondition)1 ThroughputCondition (com.alibaba.otter.manager.biz.statistics.throughput.param.ThroughputCondition)1 TimelineThroughputCondition (com.alibaba.otter.manager.biz.statistics.throughput.param.TimelineThroughputCondition)1 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1