예제 #1
0
  /**
   * Records a new task.
   *
   * @param task The task itself. It must have an ID field set.
   */
  public synchronized void recordTask(AppFactoryTask task) {
    long taskId = task.getCurrentTaskState().getId();
    mapTaskIdToTask.put(taskId, task);

    String taskHandle = task.getTaskHandle();
    mapTaskHandleToTasks.put(taskHandle, task);
  }
예제 #2
0
 @Nullable
 public synchronized TaskState findTaskById(long id) {
   AppFactoryTask task = mapTaskIdToTask.get(id);
   if (null == task) {
     return null;
   }
   return task.getCurrentTaskState();
 }
예제 #3
0
  /**
   * Deletes a task from the recorder.
   *
   * @param taskId id of the task to delete
   * @return the AppFactoryTask which was removed from the recorder, or null if no task by the given
   *     id was found.
   */
  @Nullable
  public synchronized AppFactoryTask eraseTask(long taskId) {
    AppFactoryTask removedTask = mapTaskIdToTask.remove(taskId);
    if (null == removedTask) {
      // nothing more to do
      return null;
    }

    String taskHandle = removedTask.getTaskHandle();
    mapTaskHandleToTasks.remove(taskHandle, removedTask);

    return removedTask;
  }
예제 #4
0
 @Override
 public TaskState apply(AppFactoryTask input) {
   return input.getCurrentTaskState();
 }