Search in sources :

Example 1 with CacheInvalidationContext

use of com.evolveum.midpoint.CacheInvalidationContext in project midpoint by Evolveum.

the class Invalidator method invalidateCacheEntries.

public <T extends ObjectType> void invalidateCacheEntries(Class<T> type, String oid, Object additionalInfo, OperationResult parentResult) {
    OperationResult result = parentResult.subresult(CLASS_NAME_WITH_DOT + "invalidateCacheEntries").setMinor().addParam("type", type).addParam("oid", oid).addParam("additionalInfo", additionalInfo != null ? additionalInfo.getClass().getSimpleName() : "none").build();
    try {
        LocalObjectCache localObjectCache = getLocalObjectCache();
        if (localObjectCache != null) {
            localObjectCache.remove(oid);
        }
        LocalVersionCache localVersionCache = getLocalVersionCache();
        if (localVersionCache != null) {
            localVersionCache.remove(oid);
        }
        LocalQueryCache localQueryCache = getLocalQueryCache();
        if (localQueryCache != null) {
            clearQueryResultsLocally(localQueryCache, type, oid, additionalInfo, matchingRuleRegistry);
        }
        boolean clusterwide = TYPES_ALWAYS_INVALIDATED_CLUSTERWIDE.contains(type) || globalObjectCache.hasClusterwideInvalidationFor(type) || globalVersionCache.hasClusterwideInvalidationFor(type) || globalQueryCache.hasClusterwideInvalidationFor(type);
        cacheDispatcher.dispatchInvalidation(type, oid, clusterwide, new CacheInvalidationContext(false, new RepositoryCacheInvalidationDetails(additionalInfo)));
    } catch (Throwable t) {
        result.recordFatalError(t);
        // Really? We want the operation to proceed anyway. But OTOH we want to be sure devel team gets notified about this.
        throw t;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : LocalVersionCache(com.evolveum.midpoint.repo.cache.local.LocalVersionCache) LocalQueryCache(com.evolveum.midpoint.repo.cache.local.LocalQueryCache) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) LocalObjectCache(com.evolveum.midpoint.repo.cache.local.LocalObjectCache) CacheInvalidationContext(com.evolveum.midpoint.CacheInvalidationContext)

Example 2 with CacheInvalidationContext

use of com.evolveum.midpoint.CacheInvalidationContext in project midpoint by Evolveum.

the class ClusterRestController method executeClusterCacheInvalidationEvent.

@PostMapping(ClusterServiceConsts.EVENT_INVALIDATION + "{type}/{oid}")
public ResponseEntity<?> executeClusterCacheInvalidationEvent(@PathVariable("type") String type, @PathVariable("oid") String oid) {
    Task task = initRequest();
    OperationResult result = createSubresult(task, OPERATION_EXECUTE_CLUSTER_CACHE_INVALIDATION_EVENT);
    ResponseEntity<?> response;
    try {
        checkNodeAuthentication();
        Class<? extends ObjectType> clazz = type != null ? ObjectTypes.getClassFromRestType(type) : null;
        // clusterwide is false: we got this from another node so we don't need to redistribute it
        cacheDispatcher.dispatchInvalidation(clazz, oid, false, new CacheInvalidationContext(true, null));
        result.recordSuccess();
        response = createResponse(HttpStatus.OK, result);
    } catch (Throwable t) {
        response = handleException(result, t);
    }
    finishRequest(task, result);
    return response;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CacheInvalidationContext(com.evolveum.midpoint.CacheInvalidationContext)

Aggregations

CacheInvalidationContext (com.evolveum.midpoint.CacheInvalidationContext)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 LocalObjectCache (com.evolveum.midpoint.repo.cache.local.LocalObjectCache)1 LocalQueryCache (com.evolveum.midpoint.repo.cache.local.LocalQueryCache)1 LocalVersionCache (com.evolveum.midpoint.repo.cache.local.LocalVersionCache)1 Task (com.evolveum.midpoint.task.api.Task)1