use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat 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;
}
use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat in project otter by alibaba.
the class ThroughputStatServiceImpl method throughputStatDOToModel.
/**
* 用于DO对象转化为Model对象
*
* @param throughputStatDO
* @return throughputStat
*/
private ThroughputStat throughputStatDOToModel(ThroughputStatDO throughputStatDO) {
ThroughputStat throughputStat = new ThroughputStat();
throughputStat.setId(throughputStatDO.getId());
throughputStat.setPipelineId(throughputStatDO.getPipelineId());
throughputStat.setStartTime(throughputStatDO.getStartTime());
throughputStat.setEndTime(throughputStatDO.getEndTime());
throughputStat.setType(throughputStatDO.getType());
throughputStat.setNumber(throughputStatDO.getNumber());
throughputStat.setSize(throughputStatDO.getSize());
throughputStat.setGmtCreate(throughputStatDO.getGmtCreate());
throughputStat.setGmtModified(throughputStatDO.getGmtModified());
return throughputStat;
}
use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat in project otter by alibaba.
the class ThroughputStatServiceImpl method findThroughputStatByPipelineId.
public ThroughputStat findThroughputStatByPipelineId(ThroughputCondition condition) {
Assert.assertNotNull(condition);
ThroughputStatDO throughputStatDO = throughputDao.findRealtimeThroughputStat(condition);
ThroughputStat throughputStat = new ThroughputStat();
if (throughputStatDO != null) {
throughputStat = throughputStatDOToModel(throughputStatDO);
}
return throughputStat;
}
use of com.alibaba.otter.shared.common.model.statistics.throughput.ThroughputStat 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.shared.common.model.statistics.throughput.ThroughputStat in project otter by alibaba.
the class CheckDelayStat method execute.
public void execute(@Param("queueSize") String queueSize, @Param("delayTime") String delayTime, @Param("timeout") String timeout, Context context) throws WebxException {
Map<Long, Long> queueSizeMap = parseAlert(queueSize);
Map<Long, Long> delayTimeMap = parseAlert(delayTime);
Map<Long, Long> timeoutMap = parseAlert(timeout);
Boolean result = true;
if ((queueSizeMap != null) && (false == queueSizeMap.isEmpty())) {
Set<Long> key = queueSizeMap.keySet();
for (Iterator it = key.iterator(); it.hasNext(); ) {
Long pipelineId = (Long) it.next();
Channel channel = channelService.findByPipelineId(pipelineId);
// 判断channel状态,只有启动状态才进行判断超时时间
if (!channel.getStatus().isStop()) {
DelayStat delayStat = delayStatService.findRealtimeDelayStat(pipelineId);
logger.info("delayStat.getDelayNumber() == " + delayStat.getDelayNumber());
if (null != delayStat.getDelayNumber() && delayStat.getDelayNumber() >= queueSizeMap.get(pipelineId)) {
result = false;
}
}
}
}
if ((delayTimeMap != null) && (false == delayTimeMap.isEmpty())) {
Set<Long> key = delayTimeMap.keySet();
for (Iterator it = key.iterator(); it.hasNext(); ) {
Long pipelineId = (Long) it.next();
Channel channel = channelService.findByPipelineId(pipelineId);
// 判断channel状态,只有启动状态才进行判断超时时间
if (!channel.getStatus().isStop()) {
DelayStat delayStat = delayStatService.findRealtimeDelayStat(pipelineId);
logger.info("delayStat.getDelayTime() == " + delayStat.getDelayTime());
if (null != delayStat.getDelayTime() && delayStat.getDelayTime() >= delayTimeMap.get(pipelineId)) {
result = false;
}
}
}
}
if ((timeoutMap != null) && (false == timeoutMap.isEmpty())) {
Set<Long> key = timeoutMap.keySet();
for (Iterator it = key.iterator(); it.hasNext(); ) {
Long pipelineId = (Long) it.next();
Channel channel = channelService.findByPipelineId(pipelineId);
// 判断channel状态,只有启动状态才进行判断超时时间
if (!channel.getStatus().isStop()) {
ThroughputCondition condition = new ThroughputCondition();
condition.setPipelineId(pipelineId);
condition.setType(ThroughputType.ROW);
ThroughputStat throughputStat = throughputStatService.findThroughputStatByPipelineId(condition);
if (null != throughputStat.getGmtModified()) {
Date now = new Date();
long time = now.getTime() - throughputStat.getGmtModified().getTime();
logger.info("timeout == " + time + "(ms)");
// 单位为分钟
long timeout_min = MAX_TIMEOUT;
if (timeoutMap.containsKey(pipelineId)) {
timeout_min = timeoutMap.get(pipelineId);
}
if (time / (1000 * 60) > timeout_min) {
result = false;
}
}
}
}
}
context.put("result", result);
}
Aggregations