本文整理了Java中com.evolveum.midpoint.task.api.Task.listSubtasks()
方法的一些代码示例,展示了Task.listSubtasks()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.listSubtasks()
方法的具体详情如下:
包路径:com.evolveum.midpoint.task.api.Task
类名称:Task
方法名:listSubtasks
[英]Lists the (direct) subtasks of a given task.
[中]列出给定任务的(直接)子任务。
代码示例来源:origin: Evolveum/midpoint
@NotNull
List<Task> listSubtasks(boolean persistentOnly, OperationResult parentResult) throws SchemaException;
代码示例来源:origin: Evolveum/midpoint
public List<WfTask> listChildren(OperationResult result) throws SchemaException {
List<WfTask> wfTasks = new ArrayList<>();
for (Task subtask : task.listSubtasks(result)) {
wfTasks.add(wfTaskController.recreateChildWfTask(subtask, this));
}
return wfTasks;
}
代码示例来源:origin: Evolveum/midpoint
private static void dumpTaskTree(StringBuilder sb, int indent, Task task, OperationResult result) throws SchemaException {
DebugUtil.indentDebugDump(sb, indent);
sb.append(task)
.append(" [").append(task.getExecutionStatus())
.append(", ").append(task.getProgress())
.append(", ").append(task.getNode())
.append("]").append("\n");
List<Task> subtasks = task.listSubtasks(result);
for (Task subtask : subtasks) {
dumpTaskTree(sb, indent + 1, subtask, result);
}
}
}
代码示例来源:origin: Evolveum/midpoint
private Integer closeAllWorkers(Task coordinatorTask, OperationResult result) throws SchemaException {
int count = 0;
List<Task> workers = new ArrayList<>(coordinatorTask.listSubtasks(true, result));
for (Task worker : workers) {
if (worker.getExecutionStatus() != TaskExecutionStatus.CLOSED) {
LOGGER.info("Closing worker because the work is done: {}", worker);
taskManager.suspendAndCloseTaskQuietly(worker, TaskManager.DO_NOT_WAIT, result);
count++;
}
}
return count;
}
代码示例来源:origin: Evolveum/midpoint
private List<Task> checkSubtasksClosed(Task masterTask, OperationResult opResult, TaskRunResult runResult)
throws SchemaException, ExitHandlerException {
List<Task> subtasks = masterTask.listSubtasks(opResult);
List<Task> subtasksNotClosed = subtasks.stream()
.filter(w -> w.getExecutionStatus() != TaskExecutionStatus.CLOSED)
.collect(Collectors.toList());
if (!subtasksNotClosed.isEmpty()) {
LOGGER.warn("Couldn't (re)create/restart subtasks tasks because the following ones are not closed yet: {}", subtasksNotClosed);
opResult.recordFatalError("Couldn't (re)create/restart subtasks because the following ones are not closed yet: " + subtasksNotClosed);
runResult.setRunResultStatus(TaskRunResultStatus.TEMPORARY_ERROR);
throw new ExitHandlerException(runResult);
}
return subtasks;
}
代码示例来源:origin: Evolveum/midpoint
private void createAndStartSubtasks(TaskPartitionsDefinition partitionsDefinition, Task masterTask,
OperationResult opResult) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
List<Task> subtasksCreated;
try {
subtasksCreated = createSubtasks(partitionsDefinition, masterTask, opResult);
} catch (Throwable t) {
List<Task> subtasksToRollback = masterTask.listSubtasks(opResult);
taskManager.suspendAndDeleteTasks(TaskUtil.tasksToOids(subtasksToRollback), TaskManager.DO_NOT_WAIT, true,
opResult);
throw t;
}
masterTask.makeWaiting(TaskWaitingReason.OTHER_TASKS, TaskUnpauseActionType.RESCHEDULE); // i.e. close for single-run tasks
masterTask.savePendingModifications(opResult);
List<Task> subtasksToResume = subtasksCreated.stream()
.filter(t -> t.getExecutionStatus() == TaskExecutionStatus.SUSPENDED)
.collect(Collectors.toList());
taskManager.resumeTasks(TaskUtil.tasksToOids(subtasksToResume), opResult);
LOGGER.info("Partitioned subtasks were successfully created and started for master {}", masterTask);
}
代码示例来源:origin: Evolveum/midpoint
protected void assertObjectInTaskTree(Task rootTask, String oid, boolean checkObjectOnSubtasks, OperationResult result) throws SchemaException {
assertObjectInTask(rootTask, oid);
if (checkObjectOnSubtasks) {
for (Task task : rootTask.listSubtasks(result)) {
assertObjectInTask(task, oid);
}
}
}
代码示例来源:origin: Evolveum/midpoint
protected void assertObjectInTaskTree(Task rootTask, String oid, boolean checkObjectOnSubtasks, OperationResult result)
throws SchemaException {
assertObjectInTask(rootTask, oid);
if (checkObjectOnSubtasks) {
for (Task task : rootTask.listSubtasks(result)) {
assertObjectInTask(task, oid);
}
}
}
代码示例来源:origin: Evolveum/midpoint
private boolean deleteWorkersAndWorkState(List<Task> workers, Task task, OperationResult opResult, TaskRunResult runResult)
throws SchemaException, ObjectNotFoundException, ObjectAlreadyExistsException {
deleteWorkState(task, opResult);
for (Task worker : workers) {
try {
List<Task> workerSubtasks = worker.listSubtasks(true, opResult);
if (!workerSubtasks.isEmpty()) {
LOGGER.warn("Couldn't recreate worker task {} because it has its own subtasks: {}", worker, workerSubtasks);
opResult.recordFatalError("Couldn't recreate worker task " + worker + " because it has its own subtasks: " + workerSubtasks);
runResult.setRunResultStatus(TaskRunResultStatus.TEMPORARY_ERROR);
return true;
}
taskManager.deleteTask(worker.getOid(), opResult);
} catch (ObjectNotFoundException | SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't delete worker task {} (coordinator {})", e, worker, task);
}
}
return false;
}
代码示例来源:origin: Evolveum/midpoint
@Override
protected void assertLastScanTimestamp(String taskOid, XMLGregorianCalendar startCal, XMLGregorianCalendar endCal)
throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException,
ConfigurationException, ExpressionEvaluationException {
OperationResult result = new OperationResult(TestValidityRecomputeTaskPartitioned.class.getName() + ".assertLastScanTimestamp");
Task master = taskManager.getTask(taskOid, result);
for (Task subtask : master.listSubtasks(result)) {
super.assertLastScanTimestamp(subtask.getOid(), startCal, endCal);
}
}
}
代码示例来源:origin: Evolveum/midpoint
List<Task> workers = task.listSubtasks(true, opResult);
List<Task> workersNotClosed = workers.stream()
.filter(w -> w.getExecutionStatus() != TaskExecutionStatus.CLOSED)
代码示例来源:origin: Evolveum/midpoint
public void deleteWorkersAndWorkState(String coordinatorTaskOid, long subtasksWaitTime, OperationResult result)
throws SchemaException, ObjectNotFoundException {
Task coordinatorTask = taskManager.getTask(coordinatorTaskOid, result);
if (coordinatorTask.getKind() != TaskKindType.COORDINATOR) {
throw new IllegalArgumentException("Task is not a coordinator task: " + coordinatorTask);
}
if (coordinatorTask.getExecutionStatus() == TaskExecutionStatus.WAITING) {
throw new IllegalStateException("Couldn't delete workers and work state while operation is in progress (coordinator state is WAITING): " + coordinatorTask);
}
if (coordinatorTask.getExecutionStatus() == TaskExecutionStatus.RUNNABLE && coordinatorTask.getNodeAsObserved() != null) {
throw new IllegalStateException("Couldn't delete workers and work state while operation is in progress (coordinator "
+ "state is RUNNABLE and it is executing on " + coordinatorTask.getNodeAsObserved() + "): " + coordinatorTask);
}
List<Task> subtasks = coordinatorTask.listSubtasks(true, result);
taskManager.suspendAndDeleteTasks(TaskUtil.tasksToOids(subtasks), subtasksWaitTime, true, result);
List<ItemDelta<?, ?>> itemDeltas = prismContext.deltaFor(TaskType.class)
.item(TaskType.F_WORK_STATE).replace()
.asItemDeltas();
try {
taskManager.modifyTask(coordinatorTaskOid, itemDeltas, result);
} catch (ObjectAlreadyExistsException e) {
throw new IllegalStateException("Unexpected exception: " + e.getMessage(), e);
}
}
}
代码示例来源:origin: Evolveum/midpoint
throw new IllegalArgumentException("Task is not a coordinator task: " + coordinatorTask);
List<Task> currentWorkers = new ArrayList<>(coordinatorTask.listSubtasks(true, result));
Map<WorkerKey, WorkerTasksPerNodeConfigurationType> perNodeConfigurationMap = new HashMap<>();
MultiValuedMap<String, WorkerKey> shouldBeWorkers = createWorkerKeys(coordinatorTask, perNodeConfigurationMap, result);
代码示例来源:origin: Evolveum/midpoint
List<Task> workers = task.listSubtasks(true, opResult);
boolean clean = task.getWorkState() == null || Boolean.TRUE.equals(task.getWorkState().isAllWorkComplete());
taskManager.resumeTasks(TaskUtil.tasksToOids(task.listSubtasks(true, opResult)), opResult);
LOGGER.info("Worker tasks were successfully created for coordinator {}", task);
} catch (SchemaException | ObjectNotFoundException | ObjectAlreadyExistsException e) {
代码示例来源:origin: Evolveum/midpoint
private void fillInSubtasks(Task task, ClusterStatusInformation clusterStatusInformation, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException {
boolean retrieveNextRunStartTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RUN_START_TIMESTAMP, options);
boolean retrieveRetryTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RETRY_TIMESTAMP, options);
boolean retrieveNodeAsObserved = SelectorOptions.hasToLoadPath(TaskType.F_NODE_AS_OBSERVED, options);
List<Task> subtasks = task.listSubtasks(result);
for (Task subtask : subtasks) {
if (subtask.isPersistent()) {
addTransientTaskInformation(subtask.getTaskPrismObject(),
clusterStatusInformation,
retrieveNextRunStartTime,
retrieveRetryTime,
retrieveNodeAsObserved,
result);
fillInSubtasks(subtask, clusterStatusInformation, options, result);
}
TaskType subTaskType = subtask.getTaskPrismObject().asObjectable();
task.getTaskPrismObject().asObjectable().getSubtask().add(subTaskType);
}
}
代码示例来源:origin: Evolveum/midpoint
protected int getTotalItemsProcessed(String coordinatorTaskOid) {
OperationResult result = new OperationResult("getTotalItemsProcessed");
try {
Task coordinatorTask = taskManager.getTask(coordinatorTaskOid, result);
List<Task> tasks = coordinatorTask.listSubtasks(result);
int total = 0;
for (Task task : tasks) {
OperationStatsType opStat = task.getStoredOperationStats();
if (opStat == null) {
continue;
}
IterativeTaskInformationType iti = opStat.getIterativeTaskInformation();
if (iti == null) {
continue;
}
int count = iti.getTotalSuccessCount();
display("Task " + task + ": " + count + " items processed");
total += count;
}
return total;
} catch (Throwable t) {
throw new AssertionError("Unexpected exception", t);
}
}
代码示例来源:origin: Evolveum/midpoint
second = taskManager.getTask(second.getOid(), result);
display("Second task after completion", second);
List<Task> secondSubtasks = second.listSubtasks(result);
display("Subtasks of second task after completion", secondSubtasks);
assertEquals("Wrong # of second task's subtasks", 3, secondSubtasks.size());
third = taskManager.getTask(third.getOid(), result);
display("Third task after completion", third);
List<Task> thirdSubtasks = third.listSubtasks(result);
display("Subtasks of third task after completion", thirdSubtasks);
assertEquals("Wrong # of third task's subtasks", 2, thirdSubtasks.size());
代码示例来源:origin: Evolveum/midpoint
second = taskManager.getTask(second.getOid(), result);
display("Second task after completion", second);
List<Task> secondSubtasks = second.listSubtasks(result);
display("Subtasks of second task after completion", secondSubtasks);
assertEquals("Wrong # of second task's subtasks", 3, secondSubtasks.size());
third = taskManager.getTask(third.getOid(), result);
display("Third task after completion", third);
List<Task> thirdSubtasks = third.listSubtasks(result);
display("Subtasks of third task after completion", thirdSubtasks);
assertEquals("Wrong # of third task's subtasks", 2, thirdSubtasks.size());
代码示例来源:origin: Evolveum/midpoint
List<Task> workers = coordinatorTask.listSubtasks(true, result);
if (coordinatorTask.getWorkState() == null) {
return false;
代码示例来源:origin: Evolveum/midpoint
assertNotNull("Model context is not present in root task", taskModelContext);
List<Task> subtasks = rootTask.listSubtasks(result);
assertEquals("Incorrect number of subtasks", subtaskCount, subtasks.size());
内容来源于网络,如有侵权,请联系作者删除!