brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aled Sage <>
Subject Re: Prevent task from being GCed?
Date Mon, 16 Mar 2015 12:11:01 GMT

I couldn't reproduce this. I wrote the following test, which passed:

     public void testNonTransientTaskNotGced() throws Exception {
         Task<String> task = TaskBuilder.<String>builder()
         Entities.submit(app, task);

         Set<Task<?>> alltasks = app.getExecutionContext().getTasks();

Could your task be not top-level perhaps? If the parent task is 
transient, then the parent can be GC'ed, which will cause all its 
children to be GC'ed even if they are non-transient.

Or could there be a lot of other tasks (it will by default only keep a 
max number of tasks per entity/tag, but it should delete the oldest 
tasks first).


p.s. the relevant code is 
`BrooklynGarbageCollector.shouldDeleteTaskImmediately`, which checks for 
the presence of the tag `ManagementContextInternal.NON_TRANSIENT_TASK_TAG`.

On 16/03/2015 11:46, Svetoslav Neykov wrote:
> How do I create a top level task for an entity which remains after the current task completes?
> I have code running in a poller which starts a task in certain conditions. I want the
task to remain in the task list of the entity, but it is GCed after the ScheduledTaskcompletes
and I see no way to prevent it.
> I am starting the task as follows because I want it as a top-level task, instead of as
a child of the current one.
> TaskBuilder.builder()
>                  .tag(BrooklynTaskTags.tagForContextEntity(entity))
>                  .tag(BrooklynTaskTags.NON_TRANSIENT_TASK_TAG)
> Entities.submit(entity, updateService);
> Svet.

View raw message