|
|
@ -1,8 +1,9 @@
|
|
|
|
package net.educoder.shedule;
|
|
|
|
package net.educoder.schedule;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
import net.educoder.config.PropertiesConfig;
|
|
|
|
import net.educoder.model.AutoEvaParamConfig;
|
|
|
|
import net.educoder.model.AutoEvaParamConfig;
|
|
|
|
import net.educoder.service.AutoEvaParamConfigService;
|
|
|
|
import net.educoder.service.AutoEvaParamConfigService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@ -20,43 +21,39 @@ import java.util.UUID;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @Author: youys
|
|
|
|
* @Author: youys
|
|
|
|
* @Date: 2022/4/2
|
|
|
|
* @Date: 2022/4/2
|
|
|
|
* @Description: 评测检查告警任务
|
|
|
|
* @Description: 评测检查告警任务.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Slf4j
|
|
|
|
@Slf4j
|
|
|
|
@Component
|
|
|
|
@Component
|
|
|
|
public class EvaCheckWarningTask {
|
|
|
|
public class EvaCheckWarningTask {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${bridge.evaluation}")
|
|
|
|
@Autowired
|
|
|
|
private String gameEvaluationUrl;
|
|
|
|
private PropertiesConfig propertiesConfig;
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${bridge.ojEvaluation}")
|
|
|
|
|
|
|
|
private String ojEvaluationUrl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${bridge.callbackUrl}")
|
|
|
|
|
|
|
|
private String callbackUrl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private AutoEvaParamConfigService autoEvaParamConfigService;
|
|
|
|
private AutoEvaParamConfigService autoEvaParamConfigService;
|
|
|
|
|
|
|
|
|
|
|
|
@Async
|
|
|
|
@Async
|
|
|
|
@Scheduled(initialDelay = 5 * 1000, fixedRate = 30 * 1000)
|
|
|
|
@Scheduled(cron = "${task.cron.evalCheck}")
|
|
|
|
public void check() {
|
|
|
|
public void check() {
|
|
|
|
log.info("自动化评测接口告警检查---------start ");
|
|
|
|
log.info("自动化评测接口告警检查---------start ");
|
|
|
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
|
|
List<AutoEvaParamConfig> autoEvaParamConfigList = autoEvaParamConfigService.findAll();
|
|
|
|
List<AutoEvaParamConfig> autoEvaParamConfigList = autoEvaParamConfigService.findAll();
|
|
|
|
log.info(JSONObject.toJSONString(autoEvaParamConfigList));
|
|
|
|
log.info(JSONObject.toJSONString(autoEvaParamConfigList));
|
|
|
|
|
|
|
|
|
|
|
|
for (AutoEvaParamConfig autoEvaParamConfig : autoEvaParamConfigList) {
|
|
|
|
for (AutoEvaParamConfig autoEvaParamConfig : autoEvaParamConfigList) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if (autoEvaParamConfig.getType() == 0) {
|
|
|
|
if (autoEvaParamConfig.getType().equals(AutoEvaParamConfig.SX_EVA)) {
|
|
|
|
String extras = autoEvaParamConfig.getExtras();
|
|
|
|
String extras = autoEvaParamConfig.getExtras();
|
|
|
|
if (!StringUtils.hasLength(extras)) {
|
|
|
|
if (!StringUtils.hasLength(extras)) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
postEvaluation(autoEvaParamConfig);
|
|
|
|
postEvaluation(autoEvaParamConfig);
|
|
|
|
} else if (autoEvaParamConfig.getType() == 1) {
|
|
|
|
} else if (autoEvaParamConfig.getType().equals(AutoEvaParamConfig.OJ_EVA)) {
|
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.hasLength(autoEvaParamConfig.getCodeFileContent())) {
|
|
|
|
if (!StringUtils.hasLength(autoEvaParamConfig.getCodeFileContent())) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
@ -67,10 +64,15 @@ public class EvaCheckWarningTask {
|
|
|
|
log.error("自动化评测接口告警检查任务异常", e);
|
|
|
|
log.error("自动化评测接口告警检查任务异常", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.info("自动化评测接口告警检查 ---------end ");
|
|
|
|
log.info("自动化评测接口告警检查 ---------end ,总耗时:{}ms", (System.currentTimeMillis() - startTime));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 处理实训评测.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param autoEvaParamConfig 配置
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void postEvaluation(AutoEvaParamConfig autoEvaParamConfig) {
|
|
|
|
private void postEvaluation(AutoEvaParamConfig autoEvaParamConfig) {
|
|
|
|
JSONObject extrasObject = JSONObject.parseObject(autoEvaParamConfig.getExtras());
|
|
|
|
JSONObject extrasObject = JSONObject.parseObject(autoEvaParamConfig.getExtras());
|
|
|
|
|
|
|
|
|
|
|
@ -90,20 +92,25 @@ public class EvaCheckWarningTask {
|
|
|
|
param.put("tpiGitURL", autoEvaParamConfig.getTpiGitUrl());
|
|
|
|
param.put("tpiGitURL", autoEvaParamConfig.getTpiGitUrl());
|
|
|
|
param.put("buildID", autoEvaParamConfig.getBuildId());
|
|
|
|
param.put("buildID", autoEvaParamConfig.getBuildId());
|
|
|
|
param.put("sec_key", UUID.randomUUID().toString());
|
|
|
|
param.put("sec_key", UUID.randomUUID().toString());
|
|
|
|
param.put("callBackUrl", callbackUrl);
|
|
|
|
param.put("callBackUrl", propertiesConfig.getCallbackUrl());
|
|
|
|
String result = HttpUtil.post(gameEvaluationUrl, param);
|
|
|
|
String result = HttpUtil.post(propertiesConfig.getGameEvaluationUrl(), param);
|
|
|
|
JSONObject jsonResult = JSONObject.parseObject(result);
|
|
|
|
JSONObject jsonResult = JSONObject.parseObject(result);
|
|
|
|
log.info("实训评测接口返回:{},tpiId:{}", jsonResult, autoEvaParamConfig.getTpiId());
|
|
|
|
log.info("实训评测接口返回:{},tpiId:{}", jsonResult, autoEvaParamConfig.getTpiId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 处理oj评测.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param autoEvaParamConfig 配置
|
|
|
|
|
|
|
|
*/
|
|
|
|
private void postOjEvaluation(AutoEvaParamConfig autoEvaParamConfig) {
|
|
|
|
private void postOjEvaluation(AutoEvaParamConfig autoEvaParamConfig) {
|
|
|
|
Map<String, Object> param = new HashMap<>(8);
|
|
|
|
Map<String, Object> param = new HashMap<>(8);
|
|
|
|
param.put("tpiID", autoEvaParamConfig.getTpiId());
|
|
|
|
param.put("tpiID", autoEvaParamConfig.getTpiId());
|
|
|
|
param.put("testCases", autoEvaParamConfig.getTestCases());
|
|
|
|
param.put("testCases", autoEvaParamConfig.getTestCases());
|
|
|
|
param.put("codeFileContent", autoEvaParamConfig.getCodeFileContent());
|
|
|
|
param.put("codeFileContent", autoEvaParamConfig.getCodeFileContent());
|
|
|
|
param.put("sec_key", UUID.randomUUID().toString());
|
|
|
|
param.put("sec_key", UUID.randomUUID().toString());
|
|
|
|
param.put("callBackUrl", callbackUrl);
|
|
|
|
param.put("callBackUrl", propertiesConfig.getCallbackUrl());
|
|
|
|
String result = HttpUtil.post(ojEvaluationUrl, param);
|
|
|
|
String result = HttpUtil.post(propertiesConfig.getOjEvaluationUrl(), param);
|
|
|
|
JSONObject jsonResult = JSONObject.parseObject(result);
|
|
|
|
JSONObject jsonResult = JSONObject.parseObject(result);
|
|
|
|
log.info("Oj评测接口返回:{},tpiId:{}", jsonResult, autoEvaParamConfig.getTpiId());
|
|
|
|
log.info("Oj评测接口返回:{},tpiId:{}", jsonResult, autoEvaParamConfig.getTpiId());
|
|
|
|
}
|
|
|
|
}
|