congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
HasTaskChildren
Code IndexAdd Tabnine to your IDE (free)

How to use
HasTaskChildren
in
org.apache.brooklyn.api.mgmt

Best Java code snippets using org.apache.brooklyn.api.mgmt.HasTaskChildren (Showing top 19 results out of 315)

origin: org.apache.brooklyn/brooklyn-core

/** return all children tasks of the given tasks, if it has children, else empty list */
public static Iterable<Task<?>> children(Task<?> task) {
  if (task instanceof HasTaskChildren)
    return ((HasTaskChildren)task).getChildren();
  return Collections.emptyList();
}

origin: org.apache.brooklyn/brooklyn-rest-resources

private List<TaskSummary> getSubTaskChildren(Task<?> t) {
  if (!(t instanceof HasTaskChildren)) {
    return Collections.emptyList();
  }
  return new LinkedList<TaskSummary>(Collections2.transform(Lists.newArrayList(((HasTaskChildren) t).getChildren()),
      TaskTransformer.fromTask(ui.getBaseUriBuilder())));
}
origin: org.apache.brooklyn/brooklyn-core

  public static void dumpInfo(Task<?> t, Writer out, String currentIndentation, String tab) throws IOException {
    out.append(currentIndentation+t+": "+t.getStatusDetail(false)+"\n");

    if (t instanceof HasTaskChildren) {
      for (Task<?> child: ((HasTaskChildren)t).getChildren()) {
        dumpInfo(child, out, currentIndentation+tab, tab);
      }
    }
    out.flush();
  }
}
origin: org.apache.brooklyn/brooklyn-core

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);
    }
  }
}
origin: org.apache.brooklyn/brooklyn-rest-resources

private LinkedHashMap<String, TaskSummary> getAllDescendantTasks(final Task<?> parentTask, int limit, int maxDepth) {
  final LinkedHashMap<String, TaskSummary> result = Maps.newLinkedHashMap();
  if (!(parentTask instanceof HasTaskChildren)) {
    return result;
  }
  Set<Task<?>> nextLayer = MutableSet.copyOf( ((HasTaskChildren) parentTask).getChildren() );
  outer: while (limit!=0 && !nextLayer.isEmpty() && maxDepth-- != 0) {
    Set<Task<?>> thisLayer = nextLayer;
    nextLayer = MutableSet.of();
    for (final Task<?> childTask : thisLayer) {
      TaskSummary wasThere = result.put(childTask.getId(), TaskTransformer.fromTask(ui.getBaseUriBuilder()).apply(childTask));
      if (wasThere==null) {
        if (--limit == 0) {
          break outer;
        }
        if (childTask instanceof HasTaskChildren) {
          Iterables.addAll(nextLayer, ((HasTaskChildren)childTask).getChildren());
        }
      }
    }
  }
  return result;
}
origin: org.apache.brooklyn/brooklyn-camp

protected Optional<Task<?>> findTaskOrSubTaskImpl(Iterable<? extends Task<?>> tasks, Predicate<? super Task<?>> matcher, List<String> taskNames) {
  for (Task<?> task : tasks) {
    if (matcher.apply(task)) return Optional.<Task<?>>of(task);
    if (task instanceof HasTaskChildren) {
      Optional<Task<?>> subResult = findTaskOrSubTask(((HasTaskChildren) task).getChildren(), matcher);
      if (subResult.isPresent()) return subResult;
    }
  }
  return Optional.<Task<?>>absent();
}
origin: org.apache.brooklyn/brooklyn-software-base

public static Optional<Task<?>> findTaskOrSubTaskImpl(Iterable<? extends Task<?>> tasks, Predicate<? super Task<?>> matcher, List<String> taskNames) {
  for (Task<?> task : tasks) {
    if (matcher.apply(task)) return Optional.<Task<?>>of(task);
    if (task instanceof HasTaskChildren) {
      Optional<Task<?>> subResult = findTaskOrSubTask(((HasTaskChildren) task).getChildren(), matcher);
      if (subResult.isPresent()) return subResult;
    }
  }
  return Optional.<Task<?>>absent();
}
origin: org.apache.brooklyn/brooklyn-software-base

  protected Optional<Task<?>> findTaskOrSubTaskImpl(Iterable<? extends Task<?>> tasks, Predicate<? super Task<?>> matcher) {
    for (Task<?> task : tasks) {
      if (matcher.apply(task)) return Optional.<Task<?>>of(task);

      if (!(task instanceof HasTaskChildren)) {
        return Optional.absent();
      } else {
        Optional<Task<?>> subResult = findTaskOrSubTask(((HasTaskChildren) task).getChildren(), matcher);
        if (subResult.isPresent()) return subResult;
      }
    }

    return Optional.<Task<?>>absent();
  }
}
origin: org.apache.brooklyn/brooklyn-core

private void assertTaskHasFailedChild(Task<Void> task) {
  Assert.assertTrue(Tasks.failed( ((HasTaskChildren)task).getChildren() ).iterator().hasNext());
}
  
origin: org.apache.brooklyn/brooklyn-core

/** the composed effector should allow us to inspect its children */
@Test
public void testComposedEffector() throws Exception {
  Entity txp1 = app.createAndManageChild(EntitySpec.create(Entity.class, Txp1Entity.class));
  
  Task<Integer> e = txp1.invoke(TWO_X_PLUS_ONE, MutableMap.of("numberToStartWith", 3));
  Assert.assertTrue(e instanceof DynamicSequentialTask);
  Assert.assertEquals(e.get(), (Integer)7);
  Assert.assertEquals( Iterables.size( ((HasTaskChildren)e).getChildren() ), 1);
  Task<?> child = ((HasTaskChildren)e).getChildren().iterator().next();
  Assert.assertEquals( Iterables.size( ((HasTaskChildren)child).getChildren() ), 1);
}
origin: org.apache.brooklyn/brooklyn-rest-resources

@Override
public List<TaskSummary> listTasks(String applicationId, String entityId, int limit, Boolean recurse) {
  int sizeRemaining = limit;
  Entity entity = brooklyn().getEntity(applicationId, entityId);
  List<Task<?>> tasksToScan = MutableList.copyOf(BrooklynTaskTags.getTasksInEntityContext(mgmt().getExecutionManager(), entity));
  if (limit>0) {
    tasksToScan = MutableList.copyOf(Ordering.from(new InterestingTasksFirstComparator(entity)).leastOf(tasksToScan, limit));
  }
  Map<String,Task<?>> tasksLoaded = MutableMap.of();
  
  while (!tasksToScan.isEmpty()) {
    Task<?> t = tasksToScan.remove(0);
    if (tasksLoaded.put(t.getId(), t)==null) {
      if (--sizeRemaining==0) {
        break;
      }
      if (Boolean.TRUE.equals(recurse)) {
        if (t instanceof HasTaskChildren) {
          Iterables.addAll(tasksToScan, ((HasTaskChildren) t).getChildren() );
        }
      }
    }
  }
  return new LinkedList<TaskSummary>(Collections2.transform(tasksLoaded.values(), 
    TaskTransformer.fromTask(ui.getBaseUriBuilder())));
}

origin: org.apache.brooklyn/brooklyn-core

/** the composed effector should allow us to inspect its children */
@Test
public void testComposedEffectorBasic() throws Exception {
  Entity txp1 = app.createAndManageChild(EntitySpec.create(Entity.class, Txp1Entity.class));
  
  Task<Integer> e = txp1.invoke(TWO_X_PLUS_ONE_BASIC, MutableMap.of("numberToStartWith", 3));
  Assert.assertTrue(e instanceof DynamicSequentialTask);
  Assert.assertEquals(e.get(), (Integer)7);
  Assert.assertEquals( Iterables.size( ((HasTaskChildren)e).getChildren() ), 2);
}
origin: org.apache.brooklyn/brooklyn-core

if (parent instanceof HasTaskChildren && Iterables.contains(((HasTaskChildren)parent).getChildren(), task)) {
origin: org.apache.brooklyn/brooklyn-core

MutableList<Task<?>> childrenReversed = MutableList.copyOf( ((HasTaskChildren)task).getChildren() );
Collections.reverse(childrenReversed);
origin: org.apache.brooklyn/brooklyn-core

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));
  }
}
origin: org.apache.brooklyn/brooklyn-core

Iterable<Task<?>> childrenTasks = ((HasTaskChildren)this).getChildren();
if (childrenTasks.iterator().hasNext()) {
  rv += "Children:\n";
origin: org.apache.brooklyn/brooklyn-core

log.info("testCancelled acquired semaphore; permits left is "+cancellations.availablePermits());
Iterator<Task<?>> ci = ((HasTaskChildren)t).getChildren().iterator();
origin: org.apache.brooklyn/brooklyn-core

final Task<T> t = (Task<T>)task;
if (!Tasks.isQueuedOrSubmitted(t) && (!(Tasks.current() instanceof HasTaskChildren) || 
    !Iterables.contains( ((HasTaskChildren)Tasks.current()).getChildren(), t ))) {
origin: org.apache.brooklyn/brooklyn-rest-resources

if (task instanceof HasTaskChildren) {
  children = new ArrayList<LinkWithMetadata>();
  for (Task<?> t: ((HasTaskChildren)task).getChildren()) {
    children.add(asLink(t, ub));
org.apache.brooklyn.api.mgmtHasTaskChildren

Javadoc

Interface marks tasks which have explicit children, typically where the task defines the ordering of running those children tasks

The Task#getSubmittedByTask() on the child will typically return the parent, but note there are other means of submitting tasks (e.g. background, in the same ExecutionContext), where the submitter has no API reference to the submitted tasks.

In general the children mechanism is preferred as it is easier to navigate (otherwise you have to scan the ExecutionContext to find tasks submitted by a task).

Most used methods

  • getChildren

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSystemService (Context)
  • compareTo (BigDecimal)
  • setScale (BigDecimal)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now