use of com.evolveum.midpoint.schema.util.task.ActivityPath in project midpoint by Evolveum.
the class ReleaseBucketsOperation method computeReleaseModifications.
@NotNull
private Collection<ItemDelta<?, ?>> computeReleaseModifications(@NotNull TaskType task) {
assert workerTaskOid != null;
List<WorkBucketType> bucketsToRelease = new ArrayList<>();
List<WorkBucketType> currentBuckets = BucketingUtil.getBuckets(task.getActivityState(), activityPath);
if (sequentialNumber != null) {
WorkBucketType bucket = BucketingUtil.findBucketByNumberRequired(currentBuckets, sequentialNumber);
checkBucketReadyOrDelegated(bucket);
bucketsToRelease.add(bucket);
} else {
currentBuckets.stream().filter(b -> BucketingUtil.isDelegatedTo(b, workerTaskOid)).forEach(bucketsToRelease::add);
}
LOGGER.trace("Releasing buckets {} in {} (delegated to {})", bucketsToRelease, task, workerTaskOid);
ItemPath statePath = ActivityStateUtil.getStateItemPath(task.getActivityState(), activityPath);
return bucketsStateChangeDeltas(statePath, bucketsToRelease, WorkBucketStateType.READY, null);
}
use of com.evolveum.midpoint.schema.util.task.ActivityPath in project midpoint by Evolveum.
the class ActivityState method getParentActivityState.
// endregion
// region Navigation
/**
* Returns the state of the _parent activity_, e.g. operations completion sub-activity -> reconciliation activity.
*
* Note: the caller must know the work state type name. This can be resolved somehow in the future, e.g. by requiring
* that the work state already exists.
*/
@NotNull
public ActivityState getParentActivityState(@NotNull QName workStateTypeName, OperationResult result) throws SchemaException, ObjectNotFoundException {
ActivityPath activityPath = getActivityPath();
argCheck(!activityPath.isEmpty(), "Root activity has no parent");
return getActivityStateUpwards(activityPath.allExceptLast(), getTask(), workStateTypeName, beans, result);
}
use of com.evolveum.midpoint.schema.util.task.ActivityPath in project midpoint by Evolveum.
the class NodeDownCleaner method releaseAllBucketsOfWorker.
/**
* We don't want this task to hold its buckets forever. So let's release them.
*
* (There's a slight risk if the task is restarted in the meanwhile, i.e. before learning that node is down and this
* moment. But let us live with this risk for now.)
*/
private void releaseAllBucketsOfWorker(OperationResult result) throws ObjectNotFoundException, SchemaException {
TaskActivityStateType state = task.getActivitiesStateOrClone();
if (state == null || state.getTaskRole() != TaskRoleType.WORKER) {
return;
}
if (parent == null) {
LOGGER.warn("No parent for worker {} (root {}) ?", task, root);
return;
}
ActivityPath activityPath = ActivityPath.fromBean(Objects.requireNonNull(state.getLocalRoot(), "No local root in " + task));
LOGGER.info("Returning all buckets from {} (coordinator {})", task, parent);
beans.bucketingManager.releaseAllWorkBucketsFromWorker(parent.getOid(), task.getOid(), activityPath, null, result);
}
use of com.evolveum.midpoint.schema.util.task.ActivityPath in project midpoint by Evolveum.
the class TestWorkerTasks method test140UpdateWorkerTasks.
/**
* Checks if worker tasks are correctly updated by the reconciliation.
*
* Scenario:
*
* 1. four worker tasks are created and started
* 2. some workers are broken: #2 is renamed, #3 is renamed + made scavenger, #4 is made scavenger
* 3. reconciliation is started, fixing the things
*/
@Test
public void test140UpdateWorkerTasks() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
assumeNoExtraClusterNodes(result);
when("starting worker tasks");
Task root = taskAdd(TASK_140_WORKERS_UPDATE, result);
try {
waitForChildrenBeRunning(root, 4, result);
then("starting worker tasks");
String w1correct = "Worker DefaultNode:1 for root activity in task-140";
String w2correct = "Worker DefaultNode:2 for root activity in task-140";
String w3correct = "Worker DefaultNode:3 for root activity in task-140";
String w4correct = "Worker DefaultNode:4 for root activity in task-140";
assertFourWorkers(root, "after starting worker", w1correct, w2correct, w3correct, w4correct, true, false, false, false, DN, DN, DN, DN, 4, result);
// ---------------------------------------------------------------------------------------- rename worker explicitly
when("change workers explicitly");
List<? extends Task> subtasks = root.listSubtasks(result);
assertThat(subtasks).as("subtasks").hasSize(4);
Task w2 = findTaskByName(subtasks, w2correct);
Task w3 = findTaskByName(subtasks, w3correct);
Task w4 = findTaskByName(subtasks, w4correct);
String w2broken = "Broken 2";
String w3broken = "Broken 3";
w2.setName(w2broken);
w2.flushPendingModifications(result);
w3.setName(w3broken);
setScavenger(w3, true);
w3.flushPendingModifications(result);
setScavenger(w4, true);
w4.flushPendingModifications(result);
then("change workers explicitly");
assertFourWorkers(root, "after changing workers", w1correct, w2broken, w3broken, w4correct, true, false, true, true, DN, DN, DN, DN, 4, result);
// ---------------------------------------------------------------------------------------- reconcile workers
when("reconcile workers");
Map<ActivityPath, WorkersReconciliationResultType> resultMap = activityManager.reconcileWorkers(root.getOid(), result);
then("reconcile workers");
assertFourWorkers(root, "after reconciliation", w1correct, w2correct, w3correct, w4correct, true, false, false, false, DN, DN, DN, DN, 4, result);
assertReconResult("after reconciliation", resultMap, 1, 1, 2, 0, 0, 0);
} finally {
taskManager.suspendTaskTree(root.getOid(), TaskManager.WAIT_INDEFINITELY, result);
taskManager.deleteTaskTree(root.getOid(), result);
}
}
Aggregations