use of com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat in project otter by alibaba.
the class AnalysisTopStat method execute.
public void execute(@Param("searchKey") String searchKey, @Param("topN") int topN, @Param("statTime") int minute, Context context) throws Exception {
if (topN <= 0) {
topN = 15;
}
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());
}
Map<Long, ChannelStatus> channelStatuses = new HashMap<Long, ChannelStatus>(tops.size(), 1f);
Map<Long, MainStemEventData> mainstemStatuses = new HashMap<Long, MainStemEventData>(tops.size(), 1f);
if (pipelineIds.size() > 0) {
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;
}
}
}
for (TopDelayStat top : tops) {
if (!channelStatuses.containsKey(top.getChannelId())) {
channelStatuses.put(top.getChannelId(), arbitrateManageService.channelEvent().status(top.getChannelId()));
}
if (!mainstemStatuses.containsKey(top.getPipelineId())) {
mainstemStatuses.put(top.getPipelineId(), arbitrateViewService.mainstemData(top.getChannelId(), top.getPipelineId()));
}
}
}
context.put("tops", tops);
context.put("statTime", minute);
context.put("channelStatuses", channelStatuses);
context.put("mainstemStatuses", mainstemStatuses);
}
use of com.alibaba.otter.manager.biz.statistics.delay.param.TopDelayStat 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);
}
}
Aggregations