Examples of TaskRun


Examples of fm.last.citrine.model.TaskRun

    return runningTasks.containsKey(taskId);
  }

  @Override
  public boolean stop(long taskRunId) {
    TaskRun taskRun = taskRunDAO.get(taskRunId);
    long taskId = taskRun.getTaskId();

    JobExecutionContext context = runningTasks.get(taskId);
    if (context == null) { // there is no task run
      return false;
    }
View Full Code Here

Examples of fm.last.citrine.model.TaskRun

          task.setDescription(description.substring(0, periodIndex));
        }
      }

      // get the most recent status for each task
      TaskRun mostRecentTaskRun = taskRunManager.getMostRecent(task.getId());
      if (task.isEnabled()) {
        if (mostRecentTaskRun != null && mostRecentTaskRun.getStatus() != null) {
          taskRunStatus.put(task.getId(), mostRecentTaskRun.getStatus().toString().toLowerCase());
        } else {
          taskRunStatus.put(task.getId(), Status.UNKNOWN.toString().toLowerCase());
        }
      } else {
        taskRunStatus.put(task.getId(), TASK_STATUS_DISABLED);
View Full Code Here

Examples of fm.last.citrine.model.TaskRun

   * @param context The job's execution context.
   */
  private void startTaskRun(JobExecutionContext context) {
    JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
    long taskId = jobDataMap.getLong(TASK_ID);
    TaskRun taskRun = new TaskRun(new Date(), null, null, null, null, taskId);
    setStatus(taskRun, Status.RUNNING);
    save(taskRun); // saving it will get the task run an id
    jobDataMap.put(TASK_RUN_ID, taskRun.getId());
    runningTasks.put(taskId, context);
  }
View Full Code Here

Examples of fm.last.citrine.model.TaskRun

   * @param exception Exception that caused the TaskRun to fail, else null if the TaskRun succeeded.
   */
  private void finishTaskRun(JobExecutionContext context, JobExecutionException exception) {
    JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
    if (jobDataMap.get(TASK_RUN_ID) != null) { // it could be null (if vetoed ?)
      TaskRun finishedRun = saveFinishedTaskRun(jobDataMap, exception);
      runningTasks.remove(finishedRun.getTaskId());
      handleFinishedRun(finishedRun); // kick off child jobs if necessary
    }
  }
View Full Code Here

Examples of fm.last.citrine.model.TaskRun

   * @param exception Exception that caused the TaskRun to fail, else null if the TaskRun succeeded.
   * @return The saved TaskRun.
   */
  private TaskRun saveFinishedTaskRun(JobDataMap jobDataMap, JobExecutionException exception) {
    long taskRunId = jobDataMap.getLong(TASK_RUN_ID);
    TaskRun taskRun = get(taskRunId);
    taskRun.setEndDate(new Date());
    taskRun.setSysOut(jobDataMap.getString(SYS_OUT));
    taskRun.setSysErr(jobDataMap.getString(SYS_ERR));
    if (exception == null) {
      if (Status.CANCELLING.equals(taskRun.getStatus())) {
        setStatus(taskRun, Status.CANCELLED);
      } else {
        setStatus(taskRun, Status.SUCCESS);
      }
    } else {
      log.error(exception);
      StringWriter writer = new StringWriter();
      exception.printStackTrace(new PrintWriter(writer));
      String stackTrace = writer.toString();
      taskRun.setStackTrace(stackTrace);
      if (Status.CANCELLING.equals(taskRun.getStatus())) {
        setStatus(taskRun, Status.CANCELLED);
      } else {
        setStatus(taskRun, Status.FAILED);
      }
    }
View Full Code Here

Examples of fm.last.citrine.model.TaskRun

          // for example, if a task has 2 parents and 1 of them finishes and we get into the start of this method and
          // then 2nd parent finishes, above code will find no running parents and will continue below
          // and we will run children. While this is happening, handleFinishedRun() for 2nd parent will be
          // triggered which will also try run children, the check on TaskRun start times should prevent
          // children from being run in this case
          TaskRun lastChildRun = getMostRecent(child.getId());
          if (lastChildRun != null && lastChildRun.getStartDate().compareTo(finishedRun.getEndDate()) >= 0) {
            log.error("Task " + child.getId() + " appears to have run already, ignoring");
          } else {
            if (isRunning(child.getId())) { // could be that child is still running from a previous run
              log.warn("Child still/already running, aborting run for task " + child.getId());
              TaskRun taskRun = new TaskRun(new Date(), null, null, null, null, child.getId());
              setStatus(taskRun, Status.ABORTED);
              save(taskRun);
            } else {
              log.info("Running child task " + child.getId());
              schedulerManager.runTaskNow(child);
View Full Code Here

Examples of fm.last.citrine.model.TaskRun

    long taskId = jobDataMap.getLong(TASK_ID);
    if (taskRunManager.isRunning(taskId)) { // task is already running, veto this run
      log.warn("Task " + taskId + " is already running, vetoing TaskRun");
      Task task = taskManager.get(taskId);
      if (task.isErrorIfRunning()) { // only create aborted run and set status if error if running
        TaskRun taskRun = new TaskRun(Status.ABORTED, new Date(), new Date(), null, null, null, taskId);
        taskRunManager.save(taskRun); // save it first so we get an id
        taskRunManager.setStatus(taskRun, Status.ABORTED); // now send notification of status change
      }
      return true;
    }
View Full Code Here

Examples of fm.last.citrine.model.TaskRun

    List<Task> tasks = new ArrayList<Task>();
    Task task = new Task("task1");
    tasks.add(task);
    when(mockTaskManager.getTasks()).thenReturn(tasks);
    DateTime startDate = new DateTime().minusDays(1);
    TaskRun taskRun = new TaskRun(startDate.toDate(), startDate.plusHours(2).toDate(), "", "", "", task.getId());
    when(mockTaskRunManager.getMostRecent(task.getId())).thenReturn(taskRun);
    Map<String, Object> model = getModel();
    Map<Long, String> lastRunMap = (Map<Long, String>) model.get("lastRun");
    assertEquals(1, lastRunMap.size());
    assertEquals("1 day ago", lastRunMap.get(0L));
View Full Code Here

Examples of fm.last.citrine.model.TaskRun

  @Test
  public void testFormatterNormal() {
    DateTime startDate = new DateTime();
    startDate = startDate.minusYears(1).minusMonths(12).minusHours(124).minusMinutes(25).minusSeconds(1);
    TaskRun mostRecentTaskRun = new TaskRun(startDate.toDate(), startDate.plusHours(8).toDate(), "", "", "", 1);
    String printLastRun = formatter.printLastRun(mostRecentTaskRun);
    assertEquals("2 years, 5 days, 4 hours and 25 minutes ago", printLastRun);
  }
View Full Code Here

Examples of fm.last.citrine.model.TaskRun

  @Test
  public void testFormatterPluralForm() {
    DateTime startDate = new DateTime();
    startDate = startDate.minusYears(2).minusMonths(2).minusDays(2).minusHours(2).minusMinutes(2);
    TaskRun mostRecentTaskRun = new TaskRun(startDate.toDate(), startDate.plusHours(8).toDate(), "", "", "", 1);
    String printLastRun = formatter.printLastRun(mostRecentTaskRun);
    assertEquals("2 years, 2 months, 2 days, 2 hours and 2 minutes ago", printLastRun);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.