Authored by jack-xue

Fix 2-5

... ... @@ -10,6 +10,7 @@ import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.Calendar;
/**
* Created by jack on 2017/3/23.
... ... @@ -47,18 +48,11 @@ public class BigdataAlarm {
count = 0;
if (!checkResp(alarmData)) {
alarm("WARN:-YOHOBUY实时监控系统:接口返回值异常");
}
if (null == lastAlarmData) {
lastAlarmData = alarmData;
return;
}
//检查storm
if (!checkStorm(alarmData)) {
alarm("YOHOBUY实时监控系统:storm数据没写入");
... ... @@ -69,6 +63,10 @@ public class BigdataAlarm {
alarm("YOHOBUY实时监控系统:订单从库不同步");
}
if (null != alarmData) {
lastAlarmData = alarmData;
}
} catch (Exception e) {
... ... @@ -91,9 +89,13 @@ public class BigdataAlarm {
}
public boolean checkStorm(AlarmData alarmData) {
//不参与比较
if (null == lastAlarmData) {
return true;
}
//storm未收到消息
if (alarmData.getToday().getUv() == lastAlarmData.getToday().getUv()) {
if (alarmData.getToday().getUv() == lastAlarmData.getToday().getUv() && alarmData.getToday().getPv() == lastAlarmData.getToday().getPv()) {
return false;
}
... ... @@ -103,14 +105,32 @@ public class BigdataAlarm {
public boolean checkOrder(AlarmData alarmData) {
//不参与比较
if (null == lastAlarmData) {
return true;
}
//2点-5点 不检查
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
if (hour >= 2 && hour <= 6) {
return true;
}
//订单数未变
if (alarmData.getToday().getOrderCount() == lastAlarmData.getToday().getOrderCount()) {
orderCount++;
} else {
orderCount = 0;
}
//三次以上order一样
if (orderCount >= 3) {
return false;
... ... @@ -121,10 +141,10 @@ public class BigdataAlarm {
public boolean checkResp(AlarmData alarmData) {
if (null == alarmData || null == alarmData.getToday()) {
return false;
}
return true;
}
}
... ...