Exemplo n.º 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);
  }
Exemplo n.º 2
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;
  }