本文整理了Java中com.evolveum.midpoint.task.api.Task.getWorkManagement()
方法的一些代码示例,展示了Task.getWorkManagement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.getWorkManagement()
方法的具体详情如下:
包路径:com.evolveum.midpoint.task.api.Task
类名称:Task
方法名:getWorkManagement
暂无
代码示例来源:origin: Evolveum/midpoint
public boolean isStandalone() {
if (workerTask.getWorkManagement() == null) {
return true;
}
TaskKindType kind = workerTask.getWorkManagement().getTaskKind();
return kind == null || kind == TaskKindType.STANDALONE;
}
代码示例来源:origin: Evolveum/midpoint
public TaskWorkManagementType getWorkStateConfiguration() {
return isStandalone() ? workerTask.getWorkManagement() : coordinatorTask.getWorkManagement();
}
}
代码示例来源:origin: Evolveum/midpoint
private Task getCoordinatorTask(Task workerTask, OperationResult result) throws SchemaException, ObjectNotFoundException {
Task parent = workerTask.getParentTask(result);
if (parent == null) {
throw new IllegalStateException("No coordinator task for worker task " + workerTask);
}
TaskWorkManagementType wsConfig = parent.getWorkManagement();
if (wsConfig == null || wsConfig.getTaskKind() != TaskKindType.COORDINATOR) {
throw new IllegalStateException("Coordinator task for worker task " + workerTask + " is not marked as such: " + parent);
}
return parent;
}
代码示例来源:origin: Evolveum/midpoint
private TaskPartitionsDefinition createPartitionsDefinition(Task masterTask) {
if (masterTask.getWorkManagement() == null || masterTask.getWorkManagement().getPartitions() == null) {
throw new IllegalStateException("No partitions definition in task " + masterTask);
}
return new StaticTaskPartitionsDefinition(masterTask.getWorkManagement().getPartitions(),
prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class));
}
}
代码示例来源:origin: Evolveum/midpoint
private void setOrCheckTaskKind(Task task, OperationResult opResult)
throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
TaskKindType taskKind = task.getWorkManagement() != null ? task.getWorkManagement().getTaskKind() : null;
if (taskKind == null) {
ItemDelta<?, ?> itemDelta = prismContext.deltaFor(TaskType.class)
.item(TaskType.F_WORK_MANAGEMENT, TaskWorkManagementType.F_TASK_KIND)
.replace(TaskKindType.COORDINATOR)
.asItemDelta();
task.addModificationImmediate(itemDelta, opResult);
} else if (taskKind != TaskKindType.COORDINATOR) {
throw new IllegalStateException("Task has incompatible task kind; expected " + TaskKindType.COORDINATOR +
" but having: " + task.getWorkManagement() + " in " + task);
}
}
代码示例来源:origin: Evolveum/midpoint
private void setOrCheckTaskKind(Task masterTask, OperationResult opResult)
throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
TaskKindType taskKind = masterTask.getWorkManagement() != null ? masterTask.getWorkManagement().getTaskKind() : null;
if (taskKind == null) {
ItemDelta<?, ?> itemDelta = getPrismContext().deltaFor(TaskType.class)
.item(TaskType.F_WORK_MANAGEMENT, TaskWorkManagementType.F_TASK_KIND)
.replace(TaskKindType.PARTITIONED_MASTER)
.asItemDelta();
masterTask.addModificationImmediate(itemDelta, opResult);
} else if (taskKind != TaskKindType.PARTITIONED_MASTER) {
throw new IllegalStateException("Partitioned task has incompatible task kind: " + masterTask.getWorkManagement() + " in " + masterTask);
}
}
代码示例来源:origin: Evolveum/midpoint
private void executeInitialDelayForMultiNode(Context ctx) throws InterruptedException {
long delay = (long) (Math.random() * getInitialDelay(ctx.coordinatorTask.getWorkManagement()));
if (delay != 0) {
// temporary info level logging
LOGGER.info("executeInitialDelayForMultiNode: waiting {} ms in {}", delay, ctx.workerTask);
dynamicSleep(delay, ctx.canRunSupplier);
}
}
}
代码示例来源:origin: Evolveum/midpoint
private TaskPartitionsDefinition createPartitionsDefinition(Task masterTask) {
TaskPartitionsDefinitionType definitionInTask = masterTask.getWorkManagement() != null ?
masterTask.getWorkManagement().getPartitions() : null;
TaskPartitionsDefinitionType partitionsDefinition = definitionInTask != null ?
definitionInTask.clone() : new TaskPartitionsDefinitionType();
partitionsDefinition.setCount(3);
partitionsDefinition.setCopyMasterExtension(true);
return new StaticTaskPartitionsDefinition(partitionsDefinition,
prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class));
}
}
代码示例来源:origin: Evolveum/midpoint
private TaskPartitionsDefinition createPartitionsDefinition(Task masterTask) {
TaskPartitionsDefinitionType definitionInTask = masterTask.getWorkManagement() != null ?
masterTask.getWorkManagement().getPartitions() : null;
TaskPartitionsDefinitionType partitionsDefinition = definitionInTask != null ?
definitionInTask.clone() : new TaskPartitionsDefinitionType();
partitionsDefinition.setCount(2);
partitionsDefinition.setDurablePartitions(true);
partitionsDefinition.setCopyMasterExtension(true);
return new StaticTaskPartitionsDefinition(partitionsDefinition,
prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class));
}
}
代码示例来源:origin: Evolveum/midpoint
private Context createContext(String workerTaskOid, Supplier<Boolean> canRun,
OperationResult result) throws SchemaException, ObjectNotFoundException {
Context ctx = new Context(canRun);
ctx.workerTask = taskManager.getTask(workerTaskOid, result);
TaskWorkManagementType wsConfig = ctx.workerTask.getWorkManagement();
if (wsConfig != null && wsConfig.getTaskKind() != null && wsConfig.getTaskKind() != TaskKindType.WORKER &&
wsConfig.getTaskKind() != TaskKindType.STANDALONE) {
throw new IllegalStateException("Wrong task kind for worker task " + ctx.workerTask + ": " + wsConfig.getTaskKind());
}
if (wsConfig != null && wsConfig.getTaskKind() == TaskKindType.WORKER) {
ctx.coordinatorTask = getCoordinatorTask(ctx.workerTask, result);
}
return ctx;
}
代码示例来源:origin: Evolveum/midpoint
private WorkBucketType getWorkBucketStandalone(Context ctx, OperationResult result)
throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
WorkSegmentationStrategy workStateStrategy = strategyFactory.createStrategy(ctx.workerTask.getWorkManagement());
setOrUpdateEstimatedNumberOfBuckets(ctx.workerTask, workStateStrategy, result);
TaskWorkStateType workState = getWorkStateOrNew(ctx.workerTask.getTaskPrismObject());
GetBucketResult response = workStateStrategy.getBucket(workState);
LOGGER.trace("getWorkBucketStandalone: workStateStrategy returned {} for standalone task {}", response, ctx.workerTask);
if (response instanceof FoundExisting) {
throw new AssertionError("Found unallocated buckets in standalone worker task on a second pass: " + ctx.workerTask);
} else if (response instanceof NewBuckets) {
NewBuckets newBucketsResponse = (NewBuckets) response;
repositoryService.modifyObject(TaskType.class, ctx.workerTask.getOid(),
bucketsAddDeltas(newBucketsResponse.newBuckets), null, result);
return newBucketsResponse.newBuckets.get(newBucketsResponse.selected);
} else if (response instanceof NothingFound) {
if (!((NothingFound) response).definite) {
throw new AssertionError("Unexpected 'indefinite' answer when looking for next bucket in a standalone task: " + ctx.workerTask);
}
markWorkComplete(ctx.workerTask, result);
return null;
} else {
throw new AssertionError(response);
}
}
代码示例来源:origin: Evolveum/midpoint
private MultiValuedMap<String, WorkerKey> createWorkerKeys(Task task,
Map<WorkerKey, WorkerTasksPerNodeConfigurationType> perNodeConfigurationMap,
OperationResult opResult)
throws SchemaException {
TaskWorkManagementType wsCfg = task.getWorkManagement();
WorkersManagementType workersCfg = wsCfg.getWorkers();
if (workersCfg == null) {
throw new IllegalStateException("Workers configuration is missing: " + task);
}
MultiValuedMap<String, WorkerKey> rv = new ArrayListValuedHashMap<>();
for (WorkerTasksPerNodeConfigurationType perNodeConfig : getWorkersPerNode(workersCfg)) {
for (String nodeIdentifier : getNodeIdentifiers(perNodeConfig, opResult)) {
int count = defaultIfNull(perNodeConfig.getCount(), 1);
for (int index = 1; index <= count; index++) {
WorkerKey key = createWorkerKey(nodeIdentifier, index, perNodeConfig, workersCfg, task);
rv.put(key.group, key);
perNodeConfigurationMap.put(key, perNodeConfig);
}
}
}
return rv;
}
代码示例来源:origin: Evolveum/midpoint
private TaskPartitionsDefinition createPartitioningDefinition(Task masterTask) {
TaskPartitionsDefinitionType definitionInTask = masterTask.getWorkManagement() != null ?
masterTask.getWorkManagement().getPartitions() : null;
TaskPartitionsDefinitionType partitionsDefinition = definitionInTask != null ?
definitionInTask.clone() : new TaskPartitionsDefinitionType();
partitionsDefinition.setCount(3);
partitionsDefinition.setCopyMasterExtension(true);
return new StaticTaskPartitionsDefinition(partitionsDefinition,
prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class));
}
}
代码示例来源:origin: Evolveum/midpoint
long start = System.currentTimeMillis();
int globalAttempt = 0; // just for statistics
TaskWorkManagementType workManagement = ctx.coordinatorTask.getWorkManagement();
WorkSegmentationStrategy workStateStrategy = strategyFactory.createStrategy(workManagement);
setOrUpdateEstimatedNumberOfBuckets(ctx.coordinatorTask, workStateStrategy, result);
代码示例来源:origin: Evolveum/midpoint
TaskWorkManagementType wsCfg = coordinatorTask.getWorkManagement();
WorkersManagementType workersCfg = wsCfg.getWorkers();
内容来源于网络,如有侵权,请联系作者删除!