|
|
@@ -10,14 +10,12 @@ import cn.seecoder.ojserver.manager.QuestionManager;
|
|
|
import cn.seecoder.ojserver.model.vo.CodeJudgeVO;
|
|
|
import cn.seecoder.ojserver.service.JudgeService;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.nju.edu.paasMonitorClient.MonitorClient;
|
|
|
import com.nju.edu.paasMonitorClient.entity.Call;
|
|
|
import com.nju.edu.paasMonitorCommon.enums.SeecSystem;
|
|
|
import okhttp3.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -62,43 +60,5 @@ public class JudgeServiceImpl implements JudgeService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public String newJudgeCode(Integer questionId, CodeJudgeVO codeJudgeVO) {
|
|
|
- try {
|
|
|
- Call call = MonitorClient.createCall(SeecSystem.CODER, "newcode", "buildJudge");
|
|
|
- call.start();
|
|
|
- JudgeDTO judgeDTO = new JudgeDTO();
|
|
|
- judgeDTO.setCode(codeJudgeVO.getCode());
|
|
|
- judgeDTO.setLanguage(codeJudgeVO.getLanguage());
|
|
|
- Problem problem = questionManager.getProblemById(questionId).get();
|
|
|
- List<TestCase> testCaseList = questionManager.getTestCaseByProblemId(questionId);
|
|
|
- judgeDTO.setMemoryLimit(problem.getMemoryLimit());
|
|
|
- judgeDTO.setTimeLimit(problem.getTimeLimit());
|
|
|
- List<String> inputList = testCaseList.stream().map(TestCase::getInput).collect(Collectors.toList());
|
|
|
- List<String> outputList = testCaseList.stream().map(TestCase::getOutput).collect(Collectors.toList());
|
|
|
- judgeDTO.setInputList(inputList);
|
|
|
- judgeDTO.setOutputList(outputList);
|
|
|
- call.end();
|
|
|
-
|
|
|
-
|
|
|
- String url = "http://environment-22-200.seec.svc.cluster.local:5000/api/judge";
|
|
|
- String authStr = JSON.toJSONString(judgeDTO);
|
|
|
- System.out.println(authStr);
|
|
|
- Request postRequest = new Request.Builder()
|
|
|
- .url(url)
|
|
|
- .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), authStr))
|
|
|
- .build();
|
|
|
- okhttp3.Call authCall = client.newCall(postRequest);
|
|
|
- Response authResponse = authCall.execute();
|
|
|
- String body = authResponse.body().string();
|
|
|
- return body;
|
|
|
- } catch (ThirdPartyServiceException exception) {
|
|
|
- throw exception;
|
|
|
- } catch (IOException ioException) {
|
|
|
- ioException.printStackTrace();
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
}
|