Search in sources :

Example 1 with QualifiedItemProcessingOutcomeType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.QualifiedItemProcessingOutcomeType in project midpoint by Evolveum.

the class SimpleMockActivityRun method runLocally.

@Override
@NotNull
protected ActivityRunResult runLocally(OperationResult result) throws SchemaException, ObjectNotFoundException, ObjectAlreadyExistsException {
    String message = activity.getWorkDefinition().getMessage();
    Operation operation = activityState.getLiveItemProcessingStatistics().recordOperationStart(new IterativeOperationStartInfo(new IterationItemInformation(message, null, null, null)));
    // to avoid wall clock time of 0 (failing throughput-assuming tests)
    MiscUtil.sleepCatchingInterruptedException(10);
    LOGGER.info("Message: {}", message);
    getRecorder().recordExecution(message);
    CommonMockActivityHelper helper = getActivityHandler().getMockHelper();
    helper.increaseExecutionCount(activityState, result);
    try {
        helper.failIfNeeded(this, activity.getWorkDefinition().getInitialFailures());
        QualifiedItemProcessingOutcomeType qualifiedOutcome = new QualifiedItemProcessingOutcomeType(getPrismContext()).outcome(ItemProcessingOutcomeType.SUCCESS);
        operation.done(qualifiedOutcome, null);
        incrementProgress(qualifiedOutcome);
    } catch (Exception e) {
        QualifiedItemProcessingOutcomeType qualifiedOutcome = new QualifiedItemProcessingOutcomeType(getPrismContext()).outcome(ItemProcessingOutcomeType.FAILURE);
        operation.done(qualifiedOutcome, e);
        incrementProgress(qualifiedOutcome);
        throw e;
    }
    return standardRunResult();
}
Also used : QualifiedItemProcessingOutcomeType(com.evolveum.midpoint.xml.ns._public.common.common_3.QualifiedItemProcessingOutcomeType) CommonMockActivityHelper(com.evolveum.midpoint.repo.common.tasks.handlers.CommonMockActivityHelper) IterativeOperationStartInfo(com.evolveum.midpoint.schema.statistics.IterativeOperationStartInfo) Operation(com.evolveum.midpoint.schema.statistics.Operation) IterationItemInformation(com.evolveum.midpoint.schema.statistics.IterationItemInformation) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with QualifiedItemProcessingOutcomeType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.QualifiedItemProcessingOutcomeType in project midpoint by Evolveum.

the class Operation method done.

default void done(ItemProcessingOutcomeType outcome, Throwable exception) {
    QualifiedItemProcessingOutcomeType qualifiedOutcome = new QualifiedItemProcessingOutcomeType(PrismContext.get()).outcome(outcome);
    done(qualifiedOutcome, exception);
}
Also used : QualifiedItemProcessingOutcomeType(com.evolveum.midpoint.xml.ns._public.common.common_3.QualifiedItemProcessingOutcomeType)

Example 3 with QualifiedItemProcessingOutcomeType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.QualifiedItemProcessingOutcomeType in project midpoint by Evolveum.

the class OutcomeKeyedCounterTypeUtil method incrementCounter.

/**
 * Increments counter corresponding to given outcome.
 */
public static int incrementCounter(List<OutcomeKeyedCounterType> counters, QualifiedItemProcessingOutcomeType outcome, PrismContext prismContext) {
    OutcomeKeyedCounterType counter = findOrCreateCounter(counters, outcome, prismContext);
    counter.setCount(or0(counter.getCount()) + 1);
    return counter.getCount();
}
Also used : OutcomeKeyedCounterType(com.evolveum.midpoint.xml.ns._public.common.common_3.OutcomeKeyedCounterType)

Example 4 with QualifiedItemProcessingOutcomeType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.QualifiedItemProcessingOutcomeType in project midpoint by Evolveum.

the class MockComponentActivityRun method runLocally.

@Override
@NotNull
protected ActivityRunResult runLocally(OperationResult result) throws CommonException {
    CompositeMockWorkDefinition workDef = activity.getWorkDefinition();
    int steps = workDef.getSteps();
    long delay = workDef.getDelay();
    LOGGER.info("Mock activity starting: id={}, steps={}, delay={}, sub-activity={}:\n{}", workDef.getMessage(), steps, delay, getMockSubActivity(), debugDumpLazily());
    String itemName = workDef.getMessage() + ":" + getMockSubActivity();
    Operation operation = activityState.getLiveItemProcessingStatistics().recordOperationStart(new IterativeOperationStartInfo(new IterationItemInformation(itemName, null, null, null)));
    RunningTask task = taskRun.getRunningTask();
    if (delay > 0) {
        LOGGER.trace("Sleeping for {} msecs", delay);
        MiscUtil.sleepWatchfully(System.currentTimeMillis() + delay, 100, task::canRun);
    }
    result.recordSuccess();
    getRecorder().recordExecution(itemName);
    QualifiedItemProcessingOutcomeType qualifiedOutcome = new QualifiedItemProcessingOutcomeType(getPrismContext()).outcome(ItemProcessingOutcomeType.SUCCESS);
    operation.done(qualifiedOutcome, null);
    incrementProgress(qualifiedOutcome);
    LOGGER.info("Mock activity finished: id={}, sub-activity={}:\n{}", workDef.getMessage(), getMockSubActivity(), debugDumpLazily());
    return standardRunResult();
}
Also used : QualifiedItemProcessingOutcomeType(com.evolveum.midpoint.xml.ns._public.common.common_3.QualifiedItemProcessingOutcomeType) RunningTask(com.evolveum.midpoint.task.api.RunningTask) IterativeOperationStartInfo(com.evolveum.midpoint.schema.statistics.IterativeOperationStartInfo) Operation(com.evolveum.midpoint.schema.statistics.Operation) IterationItemInformation(com.evolveum.midpoint.schema.statistics.IterationItemInformation) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

QualifiedItemProcessingOutcomeType (com.evolveum.midpoint.xml.ns._public.common.common_3.QualifiedItemProcessingOutcomeType)3 IterationItemInformation (com.evolveum.midpoint.schema.statistics.IterationItemInformation)2 IterativeOperationStartInfo (com.evolveum.midpoint.schema.statistics.IterativeOperationStartInfo)2 Operation (com.evolveum.midpoint.schema.statistics.Operation)2 NotNull (org.jetbrains.annotations.NotNull)2 CommonMockActivityHelper (com.evolveum.midpoint.repo.common.tasks.handlers.CommonMockActivityHelper)1 RunningTask (com.evolveum.midpoint.task.api.RunningTask)1 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)1 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 OutcomeKeyedCounterType (com.evolveum.midpoint.xml.ns._public.common.common_3.OutcomeKeyedCounterType)1