use of com.evolveum.midpoint.util.caching.CacheConfiguration in project midpoint by Evolveum.
the class GlobalObjectCache method getNextVersionCheckTime.
public Long getNextVersionCheckTime(@NotNull Class<? extends ObjectType> type) {
CacheConfiguration cacheConfiguration = getConfiguration();
CacheConfiguration.CacheObjectTypeConfiguration typeConfiguration = cacheConfiguration.getForObjectType(type);
if (typeConfiguration != null && typeConfiguration.supportsCaching()) {
return System.currentTimeMillis() + getTimeToCheckVersion(typeConfiguration, cacheConfiguration);
} else {
return null;
}
}
use of com.evolveum.midpoint.util.caching.CacheConfiguration in project midpoint by Evolveum.
the class CacheUpdater method storeObjectToVersionGlobal.
private <T extends ObjectType> void storeObjectToVersionGlobal(PrismObject<T> object) {
CacheConfiguration cacheConfiguration = globalVersionCache.getConfiguration();
Class<? extends ObjectType> type = object.asObjectable().getClass();
if (cacheConfiguration != null && cacheConfiguration.supportsObjectType(type)) {
globalVersionCache.put(object);
}
}
use of com.evolveum.midpoint.util.caching.CacheConfiguration in project midpoint by Evolveum.
the class AbstractSearchExpressionEvaluator method executeSearchUsingCache.
private <O extends ObjectType> List<V> executeSearchUsingCache(Class<O> targetTypeClass, final QName targetTypeQName, ObjectQuery query, List<ItemDelta<V, D>> additionalAttributeDeltas, final ExpressionEvaluationContext params, String contextDescription, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException {
CachePerformanceCollector collector = CachePerformanceCollector.INSTANCE;
Class<?> cacheClass = getCacheClass();
CacheType cacheType = getCacheType();
CacheConfiguration cacheConfiguration = cacheType != null ? cacheConfigurationManager.getConfiguration(cacheType) : null;
CacheConfiguration.CacheObjectTypeConfiguration cacheObjectTypeConfiguration = cacheConfiguration != null ? cacheConfiguration.getForObjectType(targetTypeClass) : null;
StatisticsLevel statisticsLevel = getStatisticsLevel(cacheObjectTypeConfiguration, cacheConfiguration);
boolean traceMiss = CacheConfiguration.getTraceMiss(cacheObjectTypeConfiguration, cacheConfiguration);
boolean tracePass = CacheConfiguration.getTracePass(cacheObjectTypeConfiguration, cacheConfiguration);
ObjectSearchStrategyType searchStrategy = getSearchStrategy();
AbstractSearchExpressionEvaluatorCache cache = getCache();
if (cache == null) {
if (cacheClass != null) {
log("Cache: NULL {} ({})", false, query, targetTypeClass.getSimpleName());
collector.registerNotAvailable(cacheClass, targetTypeClass, statisticsLevel);
}
return executeSearch(null, targetTypeClass, targetTypeQName, query, searchStrategy, additionalAttributeDeltas, params, contextDescription, task, result);
}
assert cacheClass != null && cacheType != null;
if (!cache.supportsObjectType(targetTypeClass)) {
log("Cache: PASS {} ({})", tracePass, query, targetTypeClass.getSimpleName());
cache.registerPass();
collector.registerPass(cacheClass, targetTypeClass, statisticsLevel);
return executeSearch(null, targetTypeClass, targetTypeQName, query, searchStrategy, additionalAttributeDeltas, params, contextDescription, task, result);
}
// noinspection unchecked
List<V> list = cache.getQueryResult(targetTypeClass, query, searchStrategy, params, prismContext);
if (list != null) {
cache.registerHit();
collector.registerHit(cacheClass, targetTypeClass, statisticsLevel);
log("Cache: HIT {} ({})", false, query, targetTypeClass.getSimpleName());
return CloneUtil.clone(list);
}
cache.registerMiss();
collector.registerMiss(cacheClass, targetTypeClass, statisticsLevel);
log("Cache: MISS {} ({})", traceMiss, query, targetTypeClass.getSimpleName());
List<PrismObject> rawResult = new ArrayList<>();
List<V> freshList = executeSearch(rawResult, targetTypeClass, targetTypeQName, query, searchStrategy, additionalAttributeDeltas, params, contextDescription, task, result);
if (!freshList.isEmpty()) {
// we don't want to cache negative results (e.g. if used with focal objects it might mean that they would be attempted to create multiple times)
// noinspection unchecked
cache.putQueryResult(targetTypeClass, query, searchStrategy, params, freshList, rawResult, prismContext);
}
return freshList;
}
use of com.evolveum.midpoint.util.caching.CacheConfiguration in project midpoint by Evolveum.
the class CacheConfigurationManager method compileConfigurations.
@NotNull
private Map<CacheType, CacheConfiguration> compileConfigurations(@Nullable CachingConfigurationType configuration, Collection<String> profiles) {
try {
List<CachingProfileType> relevantProfiles = getRelevantProfiles(configuration, profiles);
Map<CacheType, CacheConfiguration> rv = new HashMap<>();
addProfile(rv, defaultCachingProfile);
for (CachingProfileType profile : relevantProfiles) {
addProfile(rv, profile);
}
if (configuration != null && Boolean.TRUE.equals(configuration.isTraceConfiguration())) {
LOGGER.info("Compiled configurations (profiles = {}):", profiles);
for (Map.Entry<CacheType, CacheConfiguration> entry : rv.entrySet()) {
LOGGER.info(" {}:\n{}", entry.getKey(), entry.getValue().debugDump(2));
}
}
return rv;
} catch (SchemaException e) {
// benefit.
throw new SystemException("Couldn't compile cache configuration: " + e.getMessage(), e);
}
}
use of com.evolveum.midpoint.util.caching.CacheConfiguration in project midpoint by Evolveum.
the class CacheConfigurationManager method parseSettings.
private CacheConfiguration parseSettings(CacheSettingsType settings) throws SchemaException {
CacheConfiguration rv = new CacheConfiguration();
mergeSettings(rv, settings);
return rv;
}
Aggregations