Пример #1
0
  public static void startJob(int jobId) {
    Logger.debug("Job ID is %d", jobId);
    Authentication.requireAdmin();
    Class<? extends TrackedJob> jobClass = lookupJobId(jobId);

    if (jobClass == null) {
      badRequest();
    } else {
      try {
        runningJob = jobClass.newInstance().now();
        ok();
      } catch (InstantiationException e) {
        badRequest();
      } catch (IllegalAccessException e) {
        badRequest();
      }
    }
  }
Пример #2
0
  public static void checkJobStatus(int jobId) {
    Authentication.requireAdmin();

    // Check the status of the currently running job
    if (runningJob == null) {
      renderText("No job is currently running.");
    } else if (runningJob.isDone()) {
      try {
        // Return the message
        String message = runningJob.get().message;
        runningJob = null;
        renderText(message);
      } catch (InterruptedException e) {
        renderText("The job that was running has been halted.");
      } catch (ExecutionException e) {
        renderText("The job that was running has failed with an exception.");
      }
    } else {
      ok();
    }
  }