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();
}
}
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;
}
Aggregations