@Test public void testDelegatedNestedEffectorNotRepresentedAsTask() { e.delegateSayHi1("Bob", "hi"); Set<Task<?>> tasks = mgmt.getExecutionManager().getTasksWithAllTags(ImmutableList.of( BrooklynTaskTags.tagForContextEntity(e),ManagementContextInternal.EFFECTOR_TAG)); assertEquals(tasks.size(), 1); assertTrue(tasks.iterator().next().getDescription().contains("delegateSayHi1")); assertFalse(tasks.iterator().next().getDescription().contains("sayHi1")); }
@Test public void testEffectorOnProxyIsRecorded() { Object result = entity.identityEffector("abc"); assertEquals(result, "abc"); Set<Task<?>> tasks = mgmt.getExecutionManager().getTasksWithAllTags( ImmutableList.of(ManagementContextInternal.EFFECTOR_TAG, BrooklynTaskTags.tagForContextEntity(entity))); Task<?> task = Iterables.get(tasks, 0); assertEquals(tasks.size(), 1, "tasks="+tasks); assertTrue(task.getDescription().contains("identityEffector")); }
@Test public void testCanRetrieveTaskForEffector() { e.sayHi1("Bob", "hi"); Set<Task<?>> tasks = mgmt.getExecutionManager().getTasksWithAllTags(ImmutableList.of( BrooklynTaskTags.tagForContextEntity(e),ManagementContextInternal.EFFECTOR_TAG)); assertEquals(tasks.size(), 1); assertTrue(tasks.iterator().next().getDescription().contains("sayHi1")); }
@Test public void resizeLoggedAsEffectorCall() throws Exception { DynamicCluster cluster = app.createAndManageChild(EntitySpec.create(DynamicCluster.class) .configure("memberSpec", EntitySpec.create(TestEntity.class))); app.start(ImmutableList.of(loc)); cluster.resize(1); Set<Task<?>> tasks = app.getManagementContext().getExecutionManager().getTasksWithAllTags(ImmutableList.of( BrooklynTaskTags.tagForContextEntity(cluster),"EFFECTOR")); assertEquals(tasks.size(), 2); assertTrue(Iterables.get(tasks, 0).getDescription().contains("start")); assertTrue(Iterables.get(tasks, 1).getDescription().contains("resize")); }
private void checkTags(Task<Integer> t, Entity entity, Effector<?> eff, boolean shouldHaveChild) { Assert.assertEquals(BrooklynTaskTags.getContextEntity(t), app); Assert.assertTrue(t.getTags().contains(BrooklynTaskTags.EFFECTOR_TAG), "missing effector tag; had: "+t.getTags()); Assert.assertTrue(t.getDescription().contains(eff.getName()), "description missing effector name: "+t.getDescription()); Assert.assertTrue(BrooklynTaskTags.isInEffectorTask(t, entity, eff, false)); Assert.assertTrue(BrooklynTaskTags.isInEffectorTask(t, null, null, false)); Assert.assertFalse(BrooklynTaskTags.isInEffectorTask(t, entity, Startable.START, false)); if (shouldHaveChild) { Task<?> subtask = ((HasTaskChildren)t).getChildren().iterator().next(); Assert.assertTrue(BrooklynTaskTags.isInEffectorTask(subtask, entity, eff, false)); Assert.assertTrue(BrooklynTaskTags.isInEffectorTask(subtask, null, null, false)); } }
return submit(Tasks.<T>builder().displayName("Cross-context execution: "+t.getDescription()).dynamic(true).body(new Callable<T>() { @Override public T call() {
return new TaskSummary(task.getId(), task.getDisplayName(), task.getDescription(), entityId, entityDisplayName, task.getTags(), ifPositive(task.getSubmitTimeUtc()), ifPositive(task.getStartTimeUtc()), ifPositive(task.getEndTimeUtc()), task.getStatusSummary(), result, task.isError(), task.isCancelled(),