Search in sources :

Example 1 with AsyncUpdateEventHandler

use of com.evolveum.midpoint.provisioning.api.AsyncUpdateEventHandler in project midpoint by Evolveum.

the class AsyncUpdater method processAsynchronousUpdates.

public void processAsynchronousUpdates(ResourceShadowCoordinates shadowCoordinates, AsyncUpdateEventHandler handler, Task callerTask, OperationResult callerResult) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, ExpressionEvaluationException {
    InternalMonitor.recordCount(InternalCounters.PROVISIONING_ALL_EXT_OPERATION_COUNT);
    ProvisioningContext globalContext = ctxFactory.createForCoordinates(shadowCoordinates, callerTask, callerResult);
    // This is a bit of hack to propagate information about async update channel to upper layers
    // e.g. to implement MID-5853. TODO fix this hack
    globalContext.setChannelOverride(SchemaConstants.CHANNEL_ASYNC_UPDATE_URI);
    IndividualEventsAcknowledgeGate<AsyncUpdateEvent> acknowledgeGate = new IndividualEventsAcknowledgeGate<>();
    ResourceObjectAsyncChangeListener listener = (resourceObjectChange, lTask, lResult) -> {
        ShadowedAsyncChange change = new ShadowedAsyncChange(resourceObjectChange, changeProcessingBeans);
        change.initialize(lTask, lResult);
        AsyncUpdateEvent event = new AsyncUpdateEventImpl(change) {

            @Override
            public void acknowledge(boolean release, OperationResult result) {
                LOGGER.trace("Acknowledgement (release={}) sent for {}", release, this);
                change.acknowledge(release, result);
                acknowledgeGate.acknowledgeIssuedEvent(this);
            }
        };
        acknowledgeGate.registerIssuedEvent(event);
        try {
            handler.handle(event, lResult);
        } catch (Throwable t) {
            LoggingUtils.logUnexpectedException(LOGGER, "Got unexpected exception while handling an async update event", t);
            acknowledgeGate.acknowledgeIssuedEvent(event);
        }
    };
    resourceObjectConverter.listenForAsynchronousUpdates(globalContext, listener, callerResult);
    // There may be some events in processing - for example, if the async update task is suspended while
    // receiving a lot of events.
    acknowledgeGate.waitForIssuedEventsAcknowledge(callerResult);
}
Also used : ProvisioningContext(com.evolveum.midpoint.provisioning.impl.ProvisioningContext) ProvisioningContextFactory(com.evolveum.midpoint.provisioning.impl.ProvisioningContextFactory) ShadowedAsyncChange(com.evolveum.midpoint.provisioning.impl.shadows.ShadowedAsyncChange) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Autowired(org.springframework.beans.factory.annotation.Autowired) ResourceObjectAsyncChangeListener(com.evolveum.midpoint.provisioning.impl.resourceobjects.ResourceObjectAsyncChangeListener) Trace(com.evolveum.midpoint.util.logging.Trace) InternalMonitor(com.evolveum.midpoint.schema.internals.InternalMonitor) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) Task(com.evolveum.midpoint.task.api.Task) LoggingUtils(com.evolveum.midpoint.util.logging.LoggingUtils) ProvisioningContext(com.evolveum.midpoint.provisioning.impl.ProvisioningContext) Component(org.springframework.stereotype.Component) ResourceObjectConverter(com.evolveum.midpoint.provisioning.impl.resourceobjects.ResourceObjectConverter) ResourceShadowCoordinates(com.evolveum.midpoint.schema.ResourceShadowCoordinates) AsyncUpdateEvent(com.evolveum.midpoint.provisioning.api.AsyncUpdateEvent) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) AsyncUpdateEventHandler(com.evolveum.midpoint.provisioning.api.AsyncUpdateEventHandler) InternalCounters(com.evolveum.midpoint.schema.internals.InternalCounters) ResourceObjectAsyncChangeListener(com.evolveum.midpoint.provisioning.impl.resourceobjects.ResourceObjectAsyncChangeListener) ShadowedAsyncChange(com.evolveum.midpoint.provisioning.impl.shadows.ShadowedAsyncChange) AsyncUpdateEvent(com.evolveum.midpoint.provisioning.api.AsyncUpdateEvent) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 2 with AsyncUpdateEventHandler

use of com.evolveum.midpoint.provisioning.api.AsyncUpdateEventHandler in project midpoint by Evolveum.

the class AsyncUpdateActivityRun method iterateOverItemsInBucket.

@Override
public void iterateOverItemsInBucket(OperationResult opResult) throws CommunicationException, ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException {
    AsyncUpdateEventHandler handler = (event, hResult) -> {
        SyncItemProcessingRequest<AsyncUpdateEvent> request = new SyncItemProcessingRequest<>(event, this);
        return coordinator.submit(request, hResult);
    };
    RunningTask runningTask = getRunningTask();
    ModelImplUtils.clearRequestee(runningTask);
    getModelBeans().provisioningService.processAsynchronousUpdates(resourceObjectClass.getCoords(), handler, runningTask, opResult);
}
Also used : ItemProcessingRequest(com.evolveum.midpoint.repo.common.activity.run.processing.ItemProcessingRequest) ActivityRunException(com.evolveum.midpoint.repo.common.activity.run.ActivityRunException) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) com.evolveum.midpoint.repo.common.activity.run(com.evolveum.midpoint.repo.common.activity.run) RunningTask(com.evolveum.midpoint.task.api.RunningTask) ModelBeans(com.evolveum.midpoint.model.impl.ModelBeans) ResourceObjectClass(com.evolveum.midpoint.model.impl.sync.tasks.ResourceObjectClass) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) com.evolveum.midpoint.util.exception(com.evolveum.midpoint.util.exception) ResourceObjectShadowChangeDescription(com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription) ModelImplUtils(com.evolveum.midpoint.model.impl.util.ModelImplUtils) SyncItemProcessingRequest(com.evolveum.midpoint.model.impl.sync.tasks.SyncItemProcessingRequest) NotNull(org.jetbrains.annotations.NotNull) AsyncUpdateEvent(com.evolveum.midpoint.provisioning.api.AsyncUpdateEvent) AsyncUpdateEventHandler(com.evolveum.midpoint.provisioning.api.AsyncUpdateEventHandler) SyncItemProcessingRequest(com.evolveum.midpoint.model.impl.sync.tasks.SyncItemProcessingRequest) RunningTask(com.evolveum.midpoint.task.api.RunningTask) AsyncUpdateEventHandler(com.evolveum.midpoint.provisioning.api.AsyncUpdateEventHandler)

Aggregations

AsyncUpdateEvent (com.evolveum.midpoint.provisioning.api.AsyncUpdateEvent)2 AsyncUpdateEventHandler (com.evolveum.midpoint.provisioning.api.AsyncUpdateEventHandler)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 com.evolveum.midpoint.util.exception (com.evolveum.midpoint.util.exception)2 ModelBeans (com.evolveum.midpoint.model.impl.ModelBeans)1 ResourceObjectClass (com.evolveum.midpoint.model.impl.sync.tasks.ResourceObjectClass)1 SyncItemProcessingRequest (com.evolveum.midpoint.model.impl.sync.tasks.SyncItemProcessingRequest)1 ModelImplUtils (com.evolveum.midpoint.model.impl.util.ModelImplUtils)1 ResourceObjectShadowChangeDescription (com.evolveum.midpoint.provisioning.api.ResourceObjectShadowChangeDescription)1 ProvisioningContext (com.evolveum.midpoint.provisioning.impl.ProvisioningContext)1 ProvisioningContextFactory (com.evolveum.midpoint.provisioning.impl.ProvisioningContextFactory)1 ResourceObjectAsyncChangeListener (com.evolveum.midpoint.provisioning.impl.resourceobjects.ResourceObjectAsyncChangeListener)1 ResourceObjectConverter (com.evolveum.midpoint.provisioning.impl.resourceobjects.ResourceObjectConverter)1 ShadowedAsyncChange (com.evolveum.midpoint.provisioning.impl.shadows.ShadowedAsyncChange)1 com.evolveum.midpoint.repo.common.activity.run (com.evolveum.midpoint.repo.common.activity.run)1 ActivityRunException (com.evolveum.midpoint.repo.common.activity.run.ActivityRunException)1 ItemProcessingRequest (com.evolveum.midpoint.repo.common.activity.run.processing.ItemProcessingRequest)1 ResourceShadowCoordinates (com.evolveum.midpoint.schema.ResourceShadowCoordinates)1 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)1 InternalCounters (com.evolveum.midpoint.schema.internals.InternalCounters)1