<P> DaemonResponse<P> reapChild(DaemonTask task) throws InterruptedException { DaemonTask childTask = children.stream() .filter(c -> c.getUuid().equals(task.getUuid())) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Child " + task + " does not belong to this task " + this + "")); // Spin due to spurious wakeups while (!childTask.getState().isTerminal()) { try { synchronized (childTask) { childTask.wait(); } } catch (InterruptedException e) { throw e; } } TaskRepository.getTask(childTask.getUuid()); log.info(this + "Collected child task " + childTask + " with state " + childTask.getState()); if (childTask.getResponse() == null) { throw new RuntimeException("Child response may not be null."); } return childTask.getResponse(); }
if (!state.isTerminal()) { throw new IllegalStateException("Child task " + child + " reaped but non-terminal.");
while (!task.getState().isTerminal()) { updateCycle(); if (interrupted) {
while (!task.getState().isTerminal()) { updateCycle(); if (interrupted) {
@JsonIgnore public Operation getLRO() { // TODO(brnelson): This shouldn't do this, it should set name to name and add the UUID as metadata. return Operation.newBuilder().setName(this.uuid).setDone(this.state.isTerminal()).build(); }