// }
os.flush();
}
private void sendProtobuf() throws AgentException, IOException {
Builder protoBuilder = GradeProto.Grade.newBuilder();
protoBuilder.setTaskName(currentJob.getTask());
protoBuilder.setLanguage(currentJob.getLanguage());
Task task = getTask();
if (currentJob.getType() != JobType.TEST) {
if (task.getType() == Task.PROBLEM_TYPE_OUTPUT) {
try {
protoBuilder.addTestIndexes(Integer.parseInt(currentJob.getTestIndex()));
} catch (NumberFormatException e) {
throw new AgentException("Invalid test index.");
}
} else {
Contest contest = extractContest();
protoBuilder.addAllTestIndexes(task.getTestIndexesByJobType(currentJob.getType(),
!currentJob.isNotGradeFeedback(),
contest.isFeedbackOn()));
}
for (BigDecimal points : task.getTestsPoints(protoBuilder.getTestIndexesList())) {
protoBuilder.addMaxPoints(points.toString());
}
}
protoBuilder.setExplicitGrade(currentJob.getType() == JobType.GRADE);
protoBuilder.setTaskType(task.getType());
protoBuilder.setTimeLimit(task.getTimeLimit());
protoBuilder.setMemoryLimit(task.getMemoryLimit());
protoBuilder.setOutputLimit(task.getOutputLimit());
protoBuilder.setTestsCount(task.getNumberOfTests());
Grade gradeProto = protoBuilder.build();
DataOutputStream dataOutput = new DataOutputStream(os);
dataOutput.writeInt(gradeProto.getSerializedSize());
gradeProto.writeTo(dataOutput);
// we will continue work with os, so do not close dataOutput.
}