use of cn.edu.zju.acm.onlinejudge.judgeservice.submissiontest.NegationTest in project zoj by licheng.
the class JudgeClientJudgeThread method process.
private void process() throws IOException, InterruptedException {
this.status = Status.CONNECTING;
this.socket = new Socket();
this.socket.setKeepAlive(true);
this.socket.setSoTimeout(JudgeClient.READ_TIMEOUT);
this.logger.info("Connecting to " + this.address.getAddress().getCanonicalHostName() + ":" + this.address.getPort());
this.socket.connect(this.address, JudgeClient.CONNECTION_TIMEOUT);
this.logger.info("Connected");
this.in = new DataInputStream(this.socket.getInputStream());
this.out = new DataOutputStream(this.socket.getOutputStream());
this.status = Status.RUNNING;
try {
while (!this.isInterrupted()) {
try {
this.status = Status.WAITING;
if (this.submissionQueueReader == null) {
CompoundSubmissionFilter submissionFilter = new CompoundSubmissionFilter();
submissionFilter.add(new SimpleSubmissionFilter(new NegationTest(new LanguageTest(this.client.getSupportedLanguages())), Priority.DENY));
submissionFilter.add(this.submissionFilter);
submissionFilter.add(this.client.getSubmissionFilter());
submissionFilter.add(this.client.getService().getSubmissionFilter());
this.submissionQueueReader = this.client.getService().getSubmissionQueue().getReader(submissionFilter);
}
// IMPORTANT: set to null here to avoid rejudging this one when queue.poll throws a
// PersistenceException
this.submission = null;
this.submission = this.submissionQueueReader.poll(this);
this.client.getService().judgeStart(this.submission);
this.status = Status.RUNNING;
try {
this.judge(this.submission);
} catch (JudgeServerErrorException e) {
this.logger.error(e);
this.submission.setJudgeReply(JudgeReply.JUDGE_INTERNAL_ERROR);
} catch (JudgeClientErrorException e) {
this.logger.error(e);
this.submission.setJudgeReply(JudgeReply.JUDGE_INTERNAL_ERROR);
} catch (PersistenceException e) {
this.logger.error(e);
this.submission.setJudgeReply(JudgeReply.JUDGE_INTERNAL_ERROR);
}
this.submissionDAO.updateSubmission(this.submission, 1);
this.submission.setContent(null);
} catch (PersistenceException e) {
this.client.getService().judge(this.submission, Priority.HIGH);
Thread.sleep(60000);
} finally {
this.client.getService().judgeDone(this.submission);
}
}
} finally {
Utility.closeSocket(this.socket);
}
}
Aggregations