/** * Deletes the given tag, including all tasks using this tag. * * Useful, for example, if an entity is being expunged so that we don't keep holding * a reference to it as a tag. */ public void deleteTag(Object tag) { Set<Task<?>> tasks; synchronized (tasksByTag) { tasks = tasksByTag.remove(tag); } if (tasks != null) { for (Task<?> task : tasks) { deleteTask(task); } } }
public void deleteTask(Task<?> task) { boolean removed = deleteTaskNonRecursive(task); if (!removed) return; if (task instanceof HasTaskChildren) { List<Task<?>> children = ImmutableList.copyOf(((HasTaskChildren)task).getChildren()); for (Task<?> child : children) { deleteTask(child); } } }
public void onTaskDone(Task<?> task) { if (shouldDeleteTaskImmediately(task)) { executionManager.deleteTask(task); } }
protected void expireTransientTasks() { Set<Task<?>> transientTasks = executionManager.getTasksWithTag(BrooklynTaskTags.TRANSIENT_TASK_TAG); for (Task<?> t: transientTasks) { if (!t.isDone()) continue; executionManager.deleteTask(t); } }
executionManager.deleteTask(task); for (Object tag: task.getTags()) { AtomicInteger counter = taskAllTagsOverCapacity.get(tag);
protected int expireSubTasksWhoseSubmitterIsExpired() { // ideally we wouldn't have this; see comments on CHECK_SUBTASK_SUBMITTERS if (!brooklynProperties.getConfig(CHECK_SUBTASK_SUBMITTERS)) return 0; Collection<Task<?>> allTasks = executionManager.allTasksLive(); Collection<Task<?>> tasksToDelete = MutableList.of(); try { for (Task<?> task: allTasks) { if (!task.isDone()) continue; Task<?> submitter = task.getSubmittedByTask(); // if we've leaked, ie a subtask which is not a child task, // and the submitter is GC'd, then delete this also if (submitter!=null && submitter.isDone() && executionManager.getTask(submitter.getId())==null) { tasksToDelete.add(task); } } } catch (ConcurrentModificationException e) { // delete what we've found so far LOG.debug("Got CME inspecting aged tasks, with "+tasksToDelete.size()+" found for deletion: "+e); } for (Task<?> task: tasksToDelete) { executionManager.deleteTask(task); } return tasksToDelete.size(); }
protected void expireAgedTasks() { Duration maxTaskAge = brooklynProperties.getConfig(MAX_TASK_AGE); Collection<Task<?>> allTasks = executionManager.allTasksLive(); Collection<Task<?>> tasksToDelete = MutableList.of(); try { for (Task<?> task: allTasks) { if (!task.isDone()) continue; if (BrooklynTaskTags.isSubTask(task)) continue; if (maxTaskAge.isShorterThan(Duration.sinceUtc(task.getEndTimeUtc()))) tasksToDelete.add(task); } } catch (ConcurrentModificationException e) { // delete what we've found so far LOG.debug("Got CME inspecting aged tasks, with "+tasksToDelete.size()+" found for deletion: "+e); } for (Task<?> task: tasksToDelete) { executionManager.deleteTask(task); } }
executionManager.deleteTask( tasks.get(numDeleted++) );