Search in sources :

Example 1 with CacheConfiguration

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;
    }
}
Also used : CacheConfiguration(com.evolveum.midpoint.util.caching.CacheConfiguration)

Example 2 with CacheConfiguration

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);
    }
}
Also used : CacheConfiguration(com.evolveum.midpoint.util.caching.CacheConfiguration)

Example 3 with CacheConfiguration

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;
}
Also used : AbstractSearchExpressionEvaluatorCache(com.evolveum.midpoint.model.common.expression.evaluator.caching.AbstractSearchExpressionEvaluatorCache) ArrayList(java.util.ArrayList) CacheType(com.evolveum.midpoint.schema.cache.CacheType) StatisticsLevel(com.evolveum.midpoint.util.caching.CacheConfiguration.StatisticsLevel) CacheConfiguration.getStatisticsLevel(com.evolveum.midpoint.util.caching.CacheConfiguration.getStatisticsLevel) CachePerformanceCollector(com.evolveum.midpoint.util.caching.CachePerformanceCollector) CacheConfiguration(com.evolveum.midpoint.util.caching.CacheConfiguration)

Example 4 with CacheConfiguration

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);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) CacheConfiguration(com.evolveum.midpoint.util.caching.CacheConfiguration) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with CacheConfiguration

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;
}
Also used : CacheConfiguration(com.evolveum.midpoint.util.caching.CacheConfiguration)

Aggregations

CacheConfiguration (com.evolveum.midpoint.util.caching.CacheConfiguration)6 AbstractSearchExpressionEvaluatorCache (com.evolveum.midpoint.model.common.expression.evaluator.caching.AbstractSearchExpressionEvaluatorCache)1 CacheType (com.evolveum.midpoint.schema.cache.CacheType)1 StatisticsLevel (com.evolveum.midpoint.util.caching.CacheConfiguration.StatisticsLevel)1 CacheConfiguration.getStatisticsLevel (com.evolveum.midpoint.util.caching.CacheConfiguration.getStatisticsLevel)1 CachePerformanceCollector (com.evolveum.midpoint.util.caching.CachePerformanceCollector)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 SystemException (com.evolveum.midpoint.util.exception.SystemException)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1