change pool dispatch task interrupt

This commit is contained in:
Himit_ZH 2021-12-29 15:51:45 +08:00
parent 6e858ab9bc
commit 137d03c1cd
5 changed files with 79 additions and 62 deletions

View File

@ -138,14 +138,22 @@ docker ps -a
以下默认参数说明
:::warning
- 默认超级管理员账号与密码root / hoj123456
- 默认redis密码hoj123456**正式部署请修改**
- 默认mysql账号与密码root / hoj123456**正式部署请修改**
- 默认nacos管理员账号与密码root / hoj123456**正式部署请修改**
- 默认不开启https开启需修改文件同时提供证书文件
- 判题并发数默认cpu核心数+1
- 默认开启vj判题需要手动修改添加账号与密码如果不添加不能vj判题
- vj判题并发数默认cpu核心数*2+1
:::
:::

View File

@ -86,6 +86,20 @@ public class Dispatcher {
Runnable getResultTask = new Runnable() {
@Override
public void run() {
if (count.get() > 300) { // 300次失败则判为提交失败
if (isRemote) { // 远程判题需要将账号归为可用
changeRemoteJudgeStatus(finalOj, data.getUsername(), null);
}
checkResult(null, submitId);
Future future = futureTaskMap.get(key);
if (future != null) {
boolean isCanceled = future.cancel(true);
if (isCanceled) {
futureTaskMap.remove(key);
}
}
return;
}
count.getAndIncrement();
JudgeServer judgeServer = null;
if (!isCFFirstSubmit) {
@ -113,23 +127,12 @@ public class Dispatcher {
}
Future future = futureTaskMap.get(key);
if (future != null) {
future.cancel(true);
futureTaskMap.remove(key);
boolean isCanceled = future.cancel(true);
if (isCanceled) {
futureTaskMap.remove(key);
}
}
}
return;
}
if (count.get() == 300) { // 300次失败则判为提交失败
if (isRemote) { // 远程判题需要将账号归为可用
changeRemoteJudgeStatus(finalOj, data.getUsername(), null);
}
checkResult(null, submitId);
Future future = futureTaskMap.get(key);
if (future != null) {
future.cancel(true);
futureTaskMap.remove(key);
}
}
}
};

View File

@ -123,6 +123,21 @@ public class RemoteJudgeReceiver extends AbstractReceiver {
Runnable getResultTask = new Runnable() {
@Override
public void run() {
if (tryNum.get() > 200) {
// 获取调用多次失败可能为系统忙碌判为提交失败
judge.setStatus(Constants.Judge.STATUS_SUBMITTED_FAILED.getStatus());
judge.setErrorMessage("Submission failed! Please resubmit this submission again!" +
"Cause: Waiting for account scheduling timeout");
judgeService.updateById(judge);
Future future = futureTaskMap.get(key);
if (future != null) {
boolean isCanceled = future.cancel(true);
if (isCanceled) {
futureTaskMap.remove(key);
}
}
return;
}
tryNum.getAndIncrement();
RemoteJudgeAccount account = chooseUtils.chooseRemoteAccount(OJName, judge.getVjudgeUsername(), false);
if (account != null) {
@ -136,20 +151,6 @@ public class RemoteJudgeReceiver extends AbstractReceiver {
future.cancel(true);
futureTaskMap.remove(key);
}
return;
}
if (tryNum.get() > 200) {
// 获取调用多次失败可能为系统忙碌判为提交失败
judge.setStatus(Constants.Judge.STATUS_SUBMITTED_FAILED.getStatus());
judge.setErrorMessage("Submission failed! Please resubmit this submission again!" +
"Cause: Waiting for account scheduling timeout");
judgeService.updateById(judge);
Future future = futureTaskMap.get(key);
if (future != null) {
future.cancel(true);
futureTaskMap.remove(key);
}
}
}
};
@ -183,6 +184,21 @@ public class RemoteJudgeReceiver extends AbstractReceiver {
Runnable getResultTask = new Runnable() {
@Override
public void run() {
if (tryNum.get() > 200) {
// 获取调用多次失败可能为系统忙碌判为提交失败
judge.setStatus(Constants.Judge.STATUS_SUBMITTED_FAILED.getStatus());
judge.setErrorMessage("Submission failed! Please resubmit this submission again!" +
"Cause: Waiting for account scheduling timeout");
judgeService.updateById(judge);
Future future = futureTaskMap.get(key);
if (future != null) {
boolean isCanceled = future.cancel(true);
if (isCanceled) {
futureTaskMap.remove(key);
}
}
return;
}
tryNum.getAndIncrement();
RemoteJudgeAccount account = chooseUtils.chooseRemoteAccount(Constants.RemoteOJ.POJ.getName()
, judge.getVjudgeUsername(), finalIsHasSubmitIdRemoteReJudge);
@ -197,20 +213,6 @@ public class RemoteJudgeReceiver extends AbstractReceiver {
future.cancel(true);
futureTaskMap.remove(key);
}
return;
}
if (tryNum.get() > 200) {
// 获取调用多次失败可能为系统忙碌判为提交失败
judge.setStatus(Constants.Judge.STATUS_SUBMITTED_FAILED.getStatus());
judge.setErrorMessage("Submission failed! Please resubmit this submission again!" +
"Cause: Waiting for account scheduling timeout");
judgeService.updateById(judge);
Future future = futureTaskMap.get(key);
if (future != null) {
future.cancel(true);
futureTaskMap.remove(key);
}
}
}
};
@ -235,6 +237,21 @@ public class RemoteJudgeReceiver extends AbstractReceiver {
Runnable getResultTask = new Runnable() {
@Override
public void run() {
if (tryNum.get() > 200) {
// 获取调用多次失败可能为系统忙碌判为提交失败
judge.setStatus(Constants.Judge.STATUS_SUBMITTED_FAILED.getStatus());
judge.setErrorMessage("Submission failed! Please resubmit this submission again!" +
"Cause: Waiting for account scheduling timeout");
judgeService.updateById(judge);
Future future = futureTaskMap.get(key);
if (future != null) {
boolean isCanceled = future.cancel(true);
if (isCanceled) {
futureTaskMap.remove(key);
}
}
return;
}
tryNum.getAndIncrement();
HashMap<String, Object> result = chooseUtils.chooseFixedAccount(Constants.RemoteOJ.CODEFORCES.getName());
if (result != null) {
@ -253,20 +270,6 @@ public class RemoteJudgeReceiver extends AbstractReceiver {
future.cancel(true);
futureTaskMap.remove(key);
}
return;
}
if (tryNum.get() > 200) {
// 获取调用多次失败可能为系统忙碌判为提交失败
judge.setStatus(Constants.Judge.STATUS_SUBMITTED_FAILED.getStatus());
judge.setErrorMessage("Submission failed! Please resubmit this submission again!" +
"Cause: Waiting for account scheduling timeout");
judgeService.updateById(judge);
Future future = futureTaskMap.get(key);
if (future != null) {
future.cancel(true);
futureTaskMap.remove(key);
}
}
}
};

View File

@ -62,11 +62,14 @@ public class RemoteJudgeGetResult {
Future future = futureTaskMap.get(key);
if (future != null) {
future.cancel(true);
futureTaskMap.remove(key);
boolean isCanceled = future.cancel(true);
if (isCanceled) {
futureTaskMap.remove(key);
}
}
return;
}
count.getAndIncrement();
try {
Map<String, Object> result = remoteJudgeStrategy.result(resultSubmitId, username, password, cookies);

View File

@ -122,7 +122,7 @@ public class CodeForcesJudge implements RemoteJudgeStrategy {
private Long getMaxRunId(String username, String contestNum, String problemNum, String problemId, long nowTime) {
int retryNum = 0;
// 防止cf的nginx限制访问频率重试5次
while (retryNum != 5) {
while (retryNum != 10) {
HttpResponse httpResponse = getSubmissionResult(username, 10);
if (httpResponse.getStatus() == 200) {
try {
@ -131,7 +131,7 @@ public class CodeForcesJudge implements RemoteJudgeStrategy {
for (Map<String, Object> result : results) {
Long runId = Long.valueOf(result.get("id").toString());
long creationTimeSeconds = Long.parseLong(result.get("creationTimeSeconds").toString());
if (creationTimeSeconds < nowTime && retryNum < 4) {
if (creationTimeSeconds < nowTime && retryNum < 8) {
continue;
}
Map<String, Object> problem = (Map<String, Object>) result.get("problem");