Search in sources :

Example 1 with NegationTest

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);
    }
}
Also used : SimpleSubmissionFilter(cn.edu.zju.acm.onlinejudge.judgeservice.submissionfilter.SimpleSubmissionFilter) DataOutputStream(java.io.DataOutputStream) LanguageTest(cn.edu.zju.acm.onlinejudge.judgeservice.submissiontest.LanguageTest) PersistenceException(cn.edu.zju.acm.onlinejudge.persistence.PersistenceException) DataInputStream(java.io.DataInputStream) CompoundSubmissionFilter(cn.edu.zju.acm.onlinejudge.judgeservice.submissionfilter.CompoundSubmissionFilter) NegationTest(cn.edu.zju.acm.onlinejudge.judgeservice.submissiontest.NegationTest) Socket(java.net.Socket)

Aggregations

CompoundSubmissionFilter (cn.edu.zju.acm.onlinejudge.judgeservice.submissionfilter.CompoundSubmissionFilter)1 SimpleSubmissionFilter (cn.edu.zju.acm.onlinejudge.judgeservice.submissionfilter.SimpleSubmissionFilter)1 LanguageTest (cn.edu.zju.acm.onlinejudge.judgeservice.submissiontest.LanguageTest)1 NegationTest (cn.edu.zju.acm.onlinejudge.judgeservice.submissiontest.NegationTest)1 PersistenceException (cn.edu.zju.acm.onlinejudge.persistence.PersistenceException)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 Socket (java.net.Socket)1