use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat in project otter by alibaba.
the class ThroughputStatServiceImpl method listRealtimeThroughputByPipelineIds.
public List<ThroughputStat> listRealtimeThroughputByPipelineIds(List<Long> pipelineIds, int minute) {
Assert.assertNotNull(pipelineIds);
List<ThroughputStatDO> throughputStatDOs = throughputDao.listRealTimeThroughputStatByPipelineIds(pipelineIds, minute);
List<ThroughputStat> infos = new ArrayList<ThroughputStat>();
for (ThroughputStatDO throughputStatDO : throughputStatDOs) {
infos.add(throughputStatDOToModel(throughputStatDO));
}
return infos;
}
use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat in project otter by alibaba.
the class PipelineList method execute.
public void execute(@Param("channelId") Long channelId, @Param("pipelineId") Long pipelineId, HttpSession session, Context context) throws Exception {
Channel channel = channelService.findByIdWithoutColumn(channelId);
List<Pipeline> pipelines = channel.getPipelines();
List<Pipeline> tempPipe = new ArrayList<Pipeline>();
if ((pipelineId != null) && (pipelineId != 0l)) {
for (Pipeline pipeline : pipelines) {
if (!pipeline.getId().equals(pipelineId)) {
tempPipe.add(pipeline);
}
}
pipelines.removeAll(tempPipe);
}
Map<Long, DelayStat> delayStats = new HashMap<Long, DelayStat>(pipelines.size(), 1f);
Map<Long, MainStemEventData> mainstemDatas = new HashMap<Long, MainStemEventData>(pipelines.size(), 1f);
Map<Long, ThroughputStat> throughputStats = new HashMap<Long, ThroughputStat>(pipelines.size(), 1f);
Map<Long, List<AlarmRule>> alarmRuleStats = new HashMap<Long, List<AlarmRule>>(pipelines.size(), 1f);
Map<Long, PositionEventData> positionDatas = new HashMap<Long, PositionEventData>(pipelines.size(), 1f);
for (Pipeline pipeline : pipelines) {
DelayStat delayStat = delayStatService.findRealtimeDelayStat(pipeline.getId());
if (delayStat.getDelayNumber() == null) {
delayStat.setDelayNumber(0L);
delayStat.setDelayTime(0L);
delayStat.setGmtModified(pipeline.getGmtModified());
}
delayStats.put(pipeline.getId(), delayStat);
mainstemDatas.put(pipeline.getId(), arbitrateViewService.mainstemData(channel.getId(), pipeline.getId()));
ThroughputCondition condition = new ThroughputCondition();
condition.setPipelineId(pipeline.getId());
condition.setType(ThroughputType.ROW);
ThroughputStat throughputStat = throughputStatService.findThroughputStatByPipelineId(condition);
throughputStats.put(pipeline.getId(), throughputStat);
List<AlarmRule> alarmRules = alarmRuleService.getAlarmRules(pipeline.getId());
alarmRuleStats.put(pipeline.getId(), alarmRules);
PositionEventData positionData = arbitrateViewService.getCanalCursor(pipeline.getParameters().getDestinationName(), pipeline.getParameters().getMainstemClientId());
positionDatas.put(pipeline.getId(), positionData);
}
context.put("channel", channel);
context.put("pipelines", pipelines);
context.put("delayStats", delayStats);
context.put("throughputStats", throughputStats);
context.put("alarmRuleStats", alarmRuleStats);
context.put("mainstemDatas", mainstemDatas);
context.put("positionDatas", positionDatas);
}
use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat 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);
}
use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat 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);
}
}
use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat in project otter by alibaba.
the class StatisticsClientServiceIntegration method sendThroughputs.
private void sendThroughputs() {
Date now = new Date();
ThroughputStat rowStat = new ThroughputStat();
rowStat.setType(ThroughputType.ROW);
rowStat.setStartTime(new Date(now.getTime() - 600 * 1000L));
rowStat.setEndTime(now);
rowStat.setPipelineId(1L);
rowStat.setNumber(100L);
rowStat.setSize(100L);
ThroughputStat fileStat = new ThroughputStat();
fileStat.setType(ThroughputType.FILE);
fileStat.setStartTime(new Date(now.getTime() - 800 * 1000L));
fileStat.setEndTime(now);
fileStat.setPipelineId(1L);
fileStat.setNumber(101L);
fileStat.setSize(101L);
statisticsClientService.sendThroughputs(Arrays.asList(rowStat, fileStat));
}
Aggregations