Search in sources :

Example 1 with ToJudgeDto

use of top.hcode.hoj.pojo.dto.ToJudgeDto in project HOJ by HimitZH.

the class Dispatcher method dispatcherJudge.

public CommonResult dispatcherJudge(String type, String path, Object data) {
    switch(type) {
        case "judge":
            ToJudgeDTO judgeData = (ToJudgeDTO) data;
            toJudge(path, judgeData, judgeData.getJudge().getSubmitId(), judgeData.getRemoteJudgeProblem() != null);
            break;
        case "compile":
            CompileDTO compileDTO = (CompileDTO) data;
            return toCompile(path, compileDTO);
        default:
            throw new IllegalArgumentException("判题机不支持此调用类型");
    }
    return null;
}
Also used : CompileDTO(top.hcode.hoj.pojo.dto.CompileDTO) ToJudgeDTO(top.hcode.hoj.pojo.dto.ToJudgeDTO)

Example 2 with ToJudgeDto

use of top.hcode.hoj.pojo.dto.ToJudgeDto in project HOJ by HimitZH.

the class RemoteJudgeReceiver method dispatchRemoteJudge.

private void dispatchRemoteJudge(Judge judge, String token, String remoteJudgeProblem, Boolean isHasSubmitIdRemoteReJudge, String remoteOJName) {
    ToJudgeDTO toJudgeDTO = new ToJudgeDTO();
    toJudgeDTO.setJudge(judge).setToken(token).setRemoteJudgeProblem(remoteJudgeProblem);
    Constants.RemoteOJ remoteOJ = Constants.RemoteOJ.getRemoteOJ(remoteOJName);
    if (!checkExistedAccountByOJ(remoteOJ)) {
        judge.setStatus(Constants.Judge.STATUS_SYSTEM_ERROR.getStatus());
        judge.setErrorMessage("System Error! Cause: The System does not have [" + remoteOJ + "] account configured. " + "Please report the matter to the administrator!");
        judgeEntityService.updateById(judge);
    } else {
        if (remoteOJName.equals(Constants.RemoteOJ.CODEFORCES.getName()) || remoteOJName.equals(Constants.RemoteOJ.GYM.getName())) {
            if (ChooseUtils.openCodeforcesFixServer) {
                fixServerCFJudge(isHasSubmitIdRemoteReJudge, toJudgeDTO, judge);
            } else {
                commonJudge(Constants.RemoteOJ.CODEFORCES.getName(), isHasSubmitIdRemoteReJudge, toJudgeDTO, judge);
            }
        } else if (remoteOJName.equals(Constants.RemoteOJ.POJ.getName())) {
            pojJudge(isHasSubmitIdRemoteReJudge, toJudgeDTO, judge);
        } else {
            commonJudge(remoteOJName, isHasSubmitIdRemoteReJudge, toJudgeDTO, judge);
        }
    }
    // 如果队列中还有任务,则继续处理
    processWaitingTask();
}
Also used : ToJudgeDTO(top.hcode.hoj.pojo.dto.ToJudgeDTO) Constants(top.hcode.hoj.utils.Constants)

Example 3 with ToJudgeDto

use of top.hcode.hoj.pojo.dto.ToJudgeDto in project HOJ by HimitZH.

the class JudgeReceiver method handleJudgeMsg.

@Override
public void handleJudgeMsg(String taskStr, String queueName) {
    if (Constants.Queue.TEST_JUDGE_WAITING.getName().equals(queueName)) {
        TestJudgeReq testJudgeReq = JSONUtil.toBean(taskStr, TestJudgeReq.class);
        dispatcher.dispatcherTestJudge(testJudgeReq, "/test-judge");
    } else {
        JSONObject task = JSONUtil.parseObj(taskStr);
        Judge judge = task.get("judge", Judge.class);
        String token = task.getStr("token");
        // 调用判题服务
        dispatcher.dispatcherJudge("judge", "/judge", new ToJudgeDTO().setJudge(judge).setToken(token).setRemoteJudgeProblem(null));
    }
    // 接着处理任务
    processWaitingTask();
}
Also used : JSONObject(cn.hutool.json.JSONObject) ToJudgeDTO(top.hcode.hoj.pojo.dto.ToJudgeDTO) TestJudgeReq(top.hcode.hoj.pojo.dto.TestJudgeReq) Judge(top.hcode.hoj.pojo.entity.judge.Judge)

Aggregations

ToJudgeDTO (top.hcode.hoj.pojo.dto.ToJudgeDTO)3 JSONObject (cn.hutool.json.JSONObject)1 CompileDTO (top.hcode.hoj.pojo.dto.CompileDTO)1 TestJudgeReq (top.hcode.hoj.pojo.dto.TestJudgeReq)1 Judge (top.hcode.hoj.pojo.entity.judge.Judge)1 Constants (top.hcode.hoj.utils.Constants)1