Esempio n. 1
0
  private void setupCutoffTimers() {
    Logger cutoffLogger = sessionLogger();
    Random random = new Random();
    int cutoffIfSimultaneous = (int) (random.nextDouble() * (latestCutoff - earliestCutoff));
    if (simultaneousCutoff) {
      cutoffLogger.info("using a simultaneous cutoff of " + cutoffIfSimultaneous + " seconds.");
    }
    Iterator<String> nameIterator = playerNameIterator();
    while (nameIterator.hasNext()) {
      Judge judge = getJudgeOrNull(nameIterator.next());
      if (judge == null) {
        continue;
      }

      int cutoff;
      if (simultaneousCutoff) {
        cutoff = cutoffIfSimultaneous;
      } else {
        cutoff = earliestCutoff + (int) (random.nextDouble() * (latestCutoff - earliestCutoff));
        cutoffLogger.info(
            "using a cutoff for judge '" + judge.getName() + "' of " + cutoff + " seconds.");
        int roundDuration = timeLimit();
        if (cutoff > roundDuration + 10) {
          cutoff = roundDuration + 10;
          cutoffLogger.info(
              "reducing timeout to " + cutoff + " (10 seconds after round finishes).");
        }
      }
      TimerTask task = judge.getCutoffTimer();
      timer.schedule(task, 1000 * cutoff);
    }
  }
Esempio n. 2
0
  private void logCutoffParameters() {
    String earliest = props.getProperty(EARLIEST_JUDGE_CUTOFF_WORD);
    String latest = props.getProperty(LATEST_JUDGE_CUTOFF_WORD);
    String simultaneity = props.getProperty(SIMULTANEOUS_JUDGE_CUTOFF_WORD);
    sliderLabelStepSize = PropertyHelper.getSliderLabelStepSize(props);
    sliderInputStepSize = PropertyHelper.getSliderInputStepSize(props);
    Logger logger = PropertyHelper.configLogger();
    if (earliest == null && latest == null && simultaneity == null) {
      earliestCutoff = 0;
      latestCutoff = 0;
      timer = null;

      logger.info("Not cutting off judges.");
      return;
    }

    timer = new Timer();
    DEAD_TASK =
        new TimerTask() {
          public void run() {
            /* empty */
          }
        };
    timer.schedule(DEAD_TASK, new Date().getTime()); // scheduledExecutionTime() is in the past

    int roundDuration = timeLimit();
    if (earliest == null || earliest.length() == 0) {
      earliestCutoff = (roundDuration - 60);
      logger.info("Defaulting Earliest Cutoff to one minute before round end: " + earliestCutoff);
    } else {
      earliestCutoff = PropertyHelper.parseTimeStringAsSeconds(earliest);
      logger.info("Earliest Judge Cutoff: " + earliestCutoff);
    }

    if (latest == null || latest.length() == 0) {
      latestCutoff = roundDuration + 10;
      logger.info(
          "Defaulting Latest Cutoff to round duration: " + roundDuration + " plus 10 seconds");
    } else {
      latestCutoff = PropertyHelper.parseTimeStringAsSeconds(latest);
      logger.info("Latest Judge Cutoff: " + latestCutoff);
    }

    simultaneousCutoff = PropertyHelper.parseBoolean(SIMULTANEOUS_JUDGE_CUTOFF_WORD, props, false);
  }