Search in sources :

Example 1 with ShadowedAsyncChange

use of com.evolveum.midpoint.provisioning.impl.shadows.ShadowedAsyncChange 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)

Aggregations

AsyncUpdateEvent (com.evolveum.midpoint.provisioning.api.AsyncUpdateEvent)1 AsyncUpdateEventHandler (com.evolveum.midpoint.provisioning.api.AsyncUpdateEventHandler)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 ResourceShadowCoordinates (com.evolveum.midpoint.schema.ResourceShadowCoordinates)1 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)1 InternalCounters (com.evolveum.midpoint.schema.internals.InternalCounters)1 InternalMonitor (com.evolveum.midpoint.schema.internals.InternalMonitor)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 com.evolveum.midpoint.util.exception (com.evolveum.midpoint.util.exception)1 LoggingUtils (com.evolveum.midpoint.util.logging.LoggingUtils)1 Trace (com.evolveum.midpoint.util.logging.Trace)1 TraceManager (com.evolveum.midpoint.util.logging.TraceManager)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Component (org.springframework.stereotype.Component)1