...
|
...
|
@@ -17,8 +17,8 @@ import javax.annotation.Resource; |
|
|
@Component
|
|
|
public class BigdataAlarm {
|
|
|
|
|
|
//public static final String WATCH_URL = "http://h5.data.yoho.cn/rs/api/getRtChannelDataByPlatform.do?&platform=3";
|
|
|
public static final String WATCH_URL = "http://qbs-h5-test.yohops.com/rs/api/getRtChannelDataByPlatform.do?&platform=3";
|
|
|
public static final String WATCH_URL = "http://h5.data.yoho.cn/rs/api/getRtChannelDataByPlatform.do?&platform=3";
|
|
|
//public static final String WATCH_URL = "http://qbs-h5-test.yohops.com/rs/api/getRtChannelDataByPlatform.do?&platform=3";
|
|
|
|
|
|
public static final Integer LIMIT = 2;
|
|
|
|
...
|
...
|
@@ -33,6 +33,8 @@ public class BigdataAlarm { |
|
|
|
|
|
private Integer count = 0;
|
|
|
|
|
|
private Integer orderCount = 0;
|
|
|
|
|
|
private AlarmData lastAlarmData = null;
|
|
|
|
|
|
@Scheduled(cron = "${cron_bigdata_alarm}")
|
...
|
...
|
@@ -40,12 +42,33 @@ public class BigdataAlarm { |
|
|
|
|
|
try {
|
|
|
|
|
|
if (!checkResp()) {
|
|
|
AlarmData alarmData = restTemplate.getForObject(WATCH_URL, AlarmData.class);
|
|
|
|
|
|
count = 0;
|
|
|
|
|
|
if (!checkResp(alarmData)) {
|
|
|
|
|
|
alarm("warn:Data is not update.");
|
|
|
alarm("WARN:-YOHOBUY实时监控系统:接口返回值异常");
|
|
|
}
|
|
|
|
|
|
if (null == lastAlarmData) {
|
|
|
|
|
|
lastAlarmData = alarmData;
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
|
|
|
//检查storm
|
|
|
if (!checkStorm(alarmData)) {
|
|
|
alarm("YOHOBUY实时监控系统:storm数据没写入");
|
|
|
}
|
|
|
|
|
|
//检查订单从库同步
|
|
|
if (!checkOrder(alarmData)) {
|
|
|
alarm("YOHOBUY实时监控系统:订单从库不同步");
|
|
|
}
|
|
|
|
|
|
count = 0;
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
...
|
...
|
@@ -55,8 +78,7 @@ public class BigdataAlarm { |
|
|
|
|
|
if (LIMIT <= count) {
|
|
|
|
|
|
alarm("warn:Api response is not 200, continue " + count + " times.");
|
|
|
|
|
|
alarm("YOHOBUY实时监控系统:接口访问不通");
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -68,36 +90,40 @@ public class BigdataAlarm { |
|
|
alarmMsgService.sendSms("Bigdata", content, snsMobileConfig.getBigdataMobile());
|
|
|
}
|
|
|
|
|
|
public boolean checkResp() throws RestClientException {
|
|
|
AlarmData alarmData = restTemplate.getForObject(WATCH_URL, AlarmData.class);
|
|
|
public boolean checkStorm(AlarmData alarmData) {
|
|
|
|
|
|
if (null == lastAlarmData) {
|
|
|
//storm未收到消息
|
|
|
if (alarmData.getToday().getUv() == lastAlarmData.getToday().getUv()) {
|
|
|
|
|
|
lastAlarmData = alarmData;
|
|
|
|
|
|
return true;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
return vsAlarmData(alarmData);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
public boolean vsAlarmData(AlarmData alarmData) {
|
|
|
|
|
|
if (null == alarmData || null == lastAlarmData) {
|
|
|
return false;
|
|
|
public boolean checkOrder(AlarmData alarmData) {
|
|
|
//订单数未变
|
|
|
if (alarmData.getToday().getOrderCount() == lastAlarmData.getToday().getOrderCount()) {
|
|
|
orderCount++;
|
|
|
|
|
|
} else {
|
|
|
orderCount = 0;
|
|
|
}
|
|
|
|
|
|
if (null == alarmData.getToday() || null == lastAlarmData.getToday()) {
|
|
|
if (orderCount >= 3) {
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (alarmData.getToday().equals(lastAlarmData.getToday())) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
public boolean checkResp(AlarmData alarmData) {
|
|
|
if (null == alarmData || null == alarmData.getToday()) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
this.lastAlarmData = alarmData;
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
...
|
...
|
|