use of com.evolveum.midpoint.repo.cache.local.QueryKey in project midpoint by Evolveum.
the class GlobalQueryCache method dumpContent.
public void dumpContent() {
if (cache != null && LOGGER_CONTENT.isInfoEnabled()) {
cache.invokeAll(cache.keys(), e -> {
QueryKey key = e.getKey();
GlobalCacheQueryValue<?> value = e.getValue();
@NotNull SearchResultList<?> queryResult = value.getResult();
LOGGER_CONTENT.info("Cached query of {} ({} object(s), cached {} ms ago): {}: {}", key.getType().getSimpleName(), queryResult.size(), value.getAge(), key.getQuery(), queryResult);
return null;
});
}
}
use of com.evolveum.midpoint.repo.cache.local.QueryKey in project midpoint by Evolveum.
the class GlobalQueryCache method getStateInformation.
public Collection<SingleCacheStateInformationType> getStateInformation() {
Map<Class<?>, MutablePair<Integer, Integer>> counts = new HashMap<>();
AtomicInteger queries = new AtomicInteger(0);
AtomicInteger objects = new AtomicInteger(0);
if (cache != null) {
cache.invokeAll(cache.keys(), e -> {
QueryKey queryKey = e.getKey();
Class<?> objectType = queryKey.getType();
int resultingObjects = e.getValue().getResult().size();
MutablePair<Integer, Integer> value = counts.get(objectType);
if (value == null) {
value = new MutablePair<>(0, 0);
counts.put(objectType, value);
}
value.setLeft(value.getLeft() + 1);
value.setRight(value.getRight() + resultingObjects);
queries.incrementAndGet();
objects.addAndGet(resultingObjects);
return null;
});
SingleCacheStateInformationType info = new SingleCacheStateInformationType(prismContext).name(GlobalQueryCache.class.getName()).size(queries.get()).secondarySize(objects.get());
counts.forEach((type, pair) -> info.beginComponent().name(type.getSimpleName()).size(pair.getLeft()).secondarySize(pair.getRight()));
return Collections.singleton(info);
} else {
return Collections.emptySet();
}
}
use of com.evolveum.midpoint.repo.cache.local.QueryKey in project midpoint by Evolveum.
the class Invalidator method clearQueryResultsGlobally.
private <T extends ObjectType> void clearQueryResultsGlobally(Class<T> type, String oid, CacheInvalidationContext context) {
// TODO implement more efficiently
// Safe invalidation means we evict queries without looking at details of the change.
boolean safeIfUnknown = !context.isFromRemoteNode() || globalQueryCache.shouldDoSafeRemoteInvalidationFor(type);
ChangeDescription change = ChangeDescription.getFrom(type, oid, context, safeIfUnknown);
long start = System.currentTimeMillis();
AtomicInteger all = new AtomicInteger(0);
AtomicInteger removed = new AtomicInteger(0);
globalQueryCache.deleteMatching(entry -> {
QueryKey queryKey = entry.getKey();
all.incrementAndGet();
if (change.mayAffect(queryKey, entry.getValue().getResult(), matchingRuleRegistry)) {
LOGGER.trace("Removing (from global cache) query for type={}, change={}: {}", type, change, queryKey.getQuery());
removed.incrementAndGet();
return true;
} else {
return false;
}
});
LOGGER.trace("Removed (from global cache) {} (of {}) query result entries of type {} in {} ms", removed, all, type, System.currentTimeMillis() - start);
}
Aggregations