Search in sources :

Example 1 with ActivityDistributionDefinition

use of com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition in project midpoint by Evolveum.

the class TestBucketingStatic method assertNarrowedQuery.

private void assertNarrowedQuery(Task task, WorkBucketType bucket, ObjectQuery expectedQuery) throws SchemaException {
    ActivityDistributionDefinition distributionDefinition = getDistributionDefinition(task);
    ObjectQuery narrowedQuery = bucketingManager.narrowQueryForWorkBucket(UserType.class, null, distributionDefinition, null, bucket);
    displayDumpable("narrowed query", narrowedQuery);
    PrismAsserts.assertQueriesEquivalent("Wrong narrowed query", expectedQuery, narrowedQuery);
}
Also used : ActivityDistributionDefinition(com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Example 2 with ActivityDistributionDefinition

use of com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition in project midpoint by Evolveum.

the class GetBucketOperation method determineBucketsToGet.

private int determineBucketsToGet() {
    ActivityDistributionDefinition def = options.getDistributionDefinition();
    if (def == null || def.getBuckets() == null || def.getBuckets().getSampling() == null) {
        return 1;
    }
    BucketsSamplingDefinitionType sampling = def.getBuckets().getSampling();
    var regular = sampling.getRegular();
    var random = sampling.getRandom();
    argCheck(regular == null || random == null, "Both regular and random sampling is selected");
    int interval;
    if (regular != null) {
        argCheck(regular.getInterval() == null || regular.getSampleSize() == null, "Both interval and sample size are configured");
        if (regular.getInterval() != null) {
            interval = regular.getInterval();
            argCheck(interval > 0, "Specified sampling interval is less than 1: %s", interval);
        } else if (regular.getSampleSize() != null) {
            int numberOfBuckets = getNumberOfBucketsForSampling();
            interval = Math.max(1, numberOfBuckets / regular.getSampleSize());
        } else {
            throw new IllegalArgumentException("Regular sampling is selected but not configured");
        }
    } else if (random != null) {
        double probability;
        if (random.getSampleSize() != null) {
            probability = (double) random.getSampleSize() / getNumberOfBucketsForSampling();
        } else if (random.getProbability() != null) {
            probability = random.getProbability();
            argCheck(probability >= 0 && probability <= 1, "Probability is not in [0;1] interval: %s", probability);
        } else {
            throw new IllegalArgumentException("Random sampling is selected but not configured");
        }
        interval = getIntervalForProbability(probability);
    } else {
        throw new IllegalArgumentException("Sampling is selected but neither regular nor random variant is set");
    }
    // todo
    LOGGER.info("Using sampling interval of {}", interval);
    stateCheck(interval > 0, "Computed interval is less than 1: %s", interval);
    return interval;
}
Also used : ActivityDistributionDefinition(com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition)

Example 3 with ActivityDistributionDefinition

use of com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition in project midpoint by Evolveum.

the class WorkersReconciliation method initialize.

private void initialize() throws SchemaException {
    activity = beans.activityManager.getActivity(rootTask, activityPath);
    ActivityDistributionDefinition distributionDefinition = activity.getDistributionDefinition();
    // We will eventually remove this constraint, to be able to convert distributed to non-distributed tasks.
    workersDefinitionBean = distributionDefinition.getWorkers();
    argCheck(workersDefinitionBean != null, "Activity %s in %s (%s) has no workers defined", activityPath, rootTask, coordinatorTask);
    coordinatorActivityState = ActivityStateUtil.getActivityState(coordinatorTask.getActivitiesStateOrClone(), activityPath);
    if (coordinatorActivityState != null) {
        argCheck(BucketingUtil.isCoordinator(coordinatorActivityState), "Activity %s in %s (%s) is not a coordinator", activityPath, rootTask, coordinatorTask);
    }
}
Also used : ActivityDistributionDefinition(com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition)

Example 4 with ActivityDistributionDefinition

use of com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition in project midpoint by Evolveum.

the class GetBucketOperation method getInitialDelay.

private long getInitialDelay() {
    ActivityDistributionDefinition distribution = options.getDistributionDefinition();
    WorkAllocationDefinitionType allocation = distribution != null ? distribution.getBuckets().getAllocation() : null;
    return allocation != null && allocation.getWorkAllocationInitialDelay() != null ? allocation.getWorkAllocationInitialDelay() : // TODO workStateManager.getConfiguration().getWorkAllocationInitialDelay();
    0;
}
Also used : ActivityDistributionDefinition(com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition)

Aggregations

ActivityDistributionDefinition (com.evolveum.midpoint.repo.common.activity.definition.ActivityDistributionDefinition)4 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1