use of com.alibaba.otter.shared.common.model.statistics.delay.DelayStat 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);
}
use of com.alibaba.otter.shared.common.model.statistics.delay.DelayStat in project otter by alibaba.
the class StatsRemoteServiceImpl method onDelayCount.
public void onDelayCount(DelayCountEvent event) {
Assert.notNull(event);
Assert.notNull(event.getCount());
// 更新delay queue的计数器
DelayCount count = event.getCount();
// 构造一次delay stat快照
DelayStat stat = new DelayStat();
stat.setPipelineId(count.getPipelineId());
// 不再记录堆积量
stat.setDelayNumber(0L);
// 只记录延迟时间,负数直接归为0
stat.setDelayTime(count.getTime() >= 0 ? count.getTime() : 0);
if (statUnit <= 0) {
delayStatService.createDelayStat(stat);
} else {
synchronized (delayStats) {
delayStats.get(count.getPipelineId()).merge(stat);
}
}
}
use of com.alibaba.otter.shared.common.model.statistics.delay.DelayStat 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);
}
Aggregations