Search in sources :

Example 1 with RemoteJudgeStrategy

use of top.hcode.hoj.remoteJudge.task.RemoteJudgeStrategy in project HOJ by HimitZH.

the class RemoteJudgeContext method judge.

@Async
public void judge(ToJudge toJudge) {
    String[] source = toJudge.getRemoteJudgeProblem().split("-");
    String remoteOj = source[0];
    String remoteProblemId = source[1];
    RemoteJudgeDTO remoteJudgeDTO = RemoteJudgeDTO.builder().judgeId(toJudge.getJudge().getSubmitId()).uid(toJudge.getJudge().getUid()).cid(toJudge.getJudge().getCid()).pid(toJudge.getJudge().getPid()).username(toJudge.getUsername()).password(toJudge.getPassword()).oj(remoteOj).completeProblemId(remoteProblemId).userCode(toJudge.getJudge().getCode()).language(toJudge.getJudge().getLanguage()).serverIp(toJudge.getJudgeServerIp()).serverPort(toJudge.getJudgeServerPort()).submitId(toJudge.getJudge().getVjudgeSubmitId()).build();
    initProblemId(remoteJudgeDTO);
    Boolean isHasSubmitIdRemoteReJudge = toJudge.getIsHasSubmitIdRemoteReJudge();
    RemoteJudgeStrategy remoteJudgeStrategy = buildJudgeStrategy(remoteJudgeDTO);
    if (remoteJudgeStrategy != null) {
        if (isHasSubmitIdRemoteReJudge != null && isHasSubmitIdRemoteReJudge) {
            // 拥有远程oj的submitId远程判题的重判
            remoteJudgeGetResult.process(remoteJudgeStrategy);
        } else {
            // 调用远程判题
            boolean isSubmitOk = remoteJudgeToSubmit.process(remoteJudgeStrategy);
            if (isSubmitOk) {
                remoteJudgeGetResult.process(remoteJudgeStrategy);
            }
        }
    }
}
Also used : RemoteJudgeDTO(top.hcode.hoj.remoteJudge.entity.RemoteJudgeDTO) RemoteJudgeStrategy(top.hcode.hoj.remoteJudge.task.RemoteJudgeStrategy) Async(org.springframework.scheduling.annotation.Async)

Example 2 with RemoteJudgeStrategy

use of top.hcode.hoj.remoteJudge.task.RemoteJudgeStrategy in project HOJ by HimitZH.

the class RemoteJudgeContext method buildJudgeStrategy.

private RemoteJudgeStrategy buildJudgeStrategy(RemoteJudgeDTO remoteJudgeDTO) {
    RemoteJudgeStrategy remoteJudgeStrategy = RemoteJudgeFactory.selectJudge(remoteJudgeDTO.getOj());
    if (remoteJudgeStrategy == null) {
        // 更新此次提交状态为系统失败!
        UpdateWrapper<Judge> judgeUpdateWrapper = new UpdateWrapper<>();
        judgeUpdateWrapper.set("status", Constants.Judge.STATUS_SYSTEM_ERROR.getStatus()).set("error_message", "The judge server does not support this oj:" + remoteJudgeDTO.getOj()).eq("submit_id", remoteJudgeDTO.getJudgeId());
        judgeEntityService.update(judgeUpdateWrapper);
        return null;
    }
    remoteJudgeStrategy.setRemoteJudgeDTO(remoteJudgeDTO);
    return remoteJudgeStrategy;
}
Also used : UpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper) RemoteJudgeStrategy(top.hcode.hoj.remoteJudge.task.RemoteJudgeStrategy) Judge(top.hcode.hoj.pojo.entity.judge.Judge)

Example 3 with RemoteJudgeStrategy

use of top.hcode.hoj.remoteJudge.task.RemoteJudgeStrategy in project HOJ by HimitZH.

the class RemoteJudgeContext method judge.

@Async
public void judge(ToJudgeDTO toJudgeDTO) {
    String[] source = toJudgeDTO.getRemoteJudgeProblem().split("-");
    String remoteOj = source[0];
    String remoteProblemId = source[1];
    RemoteJudgeDTO remoteJudgeDTO = RemoteJudgeDTO.builder().judgeId(toJudgeDTO.getJudge().getSubmitId()).uid(toJudgeDTO.getJudge().getUid()).cid(toJudgeDTO.getJudge().getCid()).pid(toJudgeDTO.getJudge().getPid()).gid(toJudgeDTO.getJudge().getGid()).username(toJudgeDTO.getUsername()).password(toJudgeDTO.getPassword()).oj(remoteOj).completeProblemId(remoteProblemId).userCode(toJudgeDTO.getJudge().getCode()).language(toJudgeDTO.getJudge().getLanguage()).serverIp(toJudgeDTO.getJudgeServerIp()).serverPort(toJudgeDTO.getJudgeServerPort()).submitId(toJudgeDTO.getJudge().getVjudgeSubmitId()).build();
    initProblemId(remoteJudgeDTO);
    Boolean isHasSubmitIdRemoteReJudge = toJudgeDTO.getIsHasSubmitIdRemoteReJudge();
    RemoteJudgeStrategy remoteJudgeStrategy = buildJudgeStrategy(remoteJudgeDTO);
    if (remoteJudgeStrategy != null) {
        if (isHasSubmitIdRemoteReJudge != null && isHasSubmitIdRemoteReJudge) {
            // 拥有远程oj的submitId远程判题的重判
            remoteJudgeGetResult.process(remoteJudgeStrategy);
        } else {
            // 调用远程判题
            boolean isSubmitOk = remoteJudgeToSubmit.process(remoteJudgeStrategy);
            if (isSubmitOk) {
                remoteJudgeGetResult.process(remoteJudgeStrategy);
            }
        }
    }
}
Also used : RemoteJudgeDTO(top.hcode.hoj.remoteJudge.entity.RemoteJudgeDTO) RemoteJudgeStrategy(top.hcode.hoj.remoteJudge.task.RemoteJudgeStrategy) Async(org.springframework.scheduling.annotation.Async)

Aggregations

RemoteJudgeStrategy (top.hcode.hoj.remoteJudge.task.RemoteJudgeStrategy)3 Async (org.springframework.scheduling.annotation.Async)2 RemoteJudgeDTO (top.hcode.hoj.remoteJudge.entity.RemoteJudgeDTO)2 UpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper)1 Judge (top.hcode.hoj.pojo.entity.judge.Judge)1