Search in sources :

Example 26 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class CollectionDatasourceImpl method loadData.

/**
 * Load data from middleware into {@link #data} field.
 * <p>In case of error sets {@link #dataLoadError} field to the exception object.</p>
 * @param params    datasource parameters, as described in {@link CollectionDatasource#refresh(java.util.Map)}
 */
protected void loadData(Map<String, Object> params) {
    Security security = AppBeans.get(Security.NAME);
    if (!security.isEntityOpPermitted(metaClass, EntityOp.READ)) {
        return;
    }
    String tag = getLoggingTag("CDS");
    StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));
    if (needLoading()) {
        LoadContext context = beforeLoadData(params);
        if (context == null) {
            return;
        }
        try {
            final Collection<T> entities = dataSupplier.loadList(context);
            afterLoadData(params, context, entities);
        } catch (Throwable e) {
            dataLoadError = e;
        }
    }
    sw.stop();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 27 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class ValueCollectionDatasourceImpl method loadData.

@Override
protected void loadData(Map<String, Object> params) {
    String tag = getLoggingTag("VDS");
    StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));
    delegate.loadData(params);
    sw.stop();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 28 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class AbstractMessages method searchFiles.

protected String searchFiles(String pack, String key, Locale locale, Locale truncatedLocale, Set<String> passedPacks) {
    StopWatch stopWatch = new Slf4JStopWatch("Messages.searchFiles");
    try {
        String cacheKey = makeCacheKey(pack, key, locale, truncatedLocale);
        String msg = strCache.get(cacheKey);
        if (msg != null)
            return msg;
        log.trace("searchFiles: {}", cacheKey);
        String packPath = confDir + "/" + pack.replaceAll("\\.", "/");
        while (packPath != null && !packPath.equals(confDir)) {
            Properties properties = loadPropertiesFromFile(packPath, locale, truncatedLocale);
            if (properties != PROPERTIES_NOT_FOUND) {
                msg = getMessageFromProperties(pack, key, locale, truncatedLocale, properties, passedPacks);
                if (msg != null)
                    return msg;
            }
            // not found, keep searching
            int pos = packPath.lastIndexOf("/");
            if (pos < 0)
                packPath = null;
            else
                packPath = packPath.substring(0, pos);
        }
        return null;
    } finally {
        stopWatch.stop();
    }
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 29 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class AbstractMessages method searchClasspath.

protected String searchClasspath(String pack, String key, Locale locale, Locale truncatedLocale, Set<String> passedPacks) {
    StopWatch stopWatch = new Slf4JStopWatch("Messages.searchClasspath");
    try {
        String cacheKey = makeCacheKey(pack, key, locale, truncatedLocale);
        String msg = strCache.get(cacheKey);
        if (msg != null)
            return msg;
        log.trace("searchClasspath: {}", cacheKey);
        String packPath = "/" + pack.replaceAll("\\.", "/");
        while (packPath != null) {
            Properties properties = loadPropertiesFromResource(packPath, locale, truncatedLocale);
            if (properties != PROPERTIES_NOT_FOUND) {
                msg = getMessageFromProperties(pack, key, locale, truncatedLocale, properties, passedPacks);
                if (msg != null)
                    return msg;
            }
            // not found, keep searching
            int pos = packPath.lastIndexOf("/");
            if (pos < 0)
                packPath = null;
            else
                packPath = packPath.substring(0, pos);
        }
        return null;
    } finally {
        stopWatch.stop();
    }
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 30 with StopWatch

use of org.perf4j.StopWatch in project cuba by cuba-platform.

the class MetadataLoader method replaceExtendedMetaClasses.

protected void replaceExtendedMetaClasses() {
    StopWatch sw = new Slf4JStopWatch("Metadata.replaceExtendedMetaClasses");
    for (MetaModel model : session.getModels()) {
        MetaModelImpl modelImpl = (MetaModelImpl) model;
        List<Pair<MetaClass, MetaClass>> replaceMap = new ArrayList<>();
        for (MetaClass metaClass : modelImpl.getClasses()) {
            MetaClass effectiveMetaClass = session.getClass(extendedEntities.getEffectiveClass(metaClass));
            if (effectiveMetaClass != metaClass) {
                replaceMap.add(new Pair<>(metaClass, effectiveMetaClass));
            }
            for (MetaProperty metaProperty : metaClass.getOwnProperties()) {
                MetaPropertyImpl propertyImpl = (MetaPropertyImpl) metaProperty;
                // replace domain
                Class effectiveDomainClass = extendedEntities.getEffectiveClass(metaProperty.getDomain());
                MetaClass effectiveDomainMeta = session.getClass(effectiveDomainClass);
                if (metaProperty.getDomain() != effectiveDomainMeta) {
                    propertyImpl.setDomain(effectiveDomainMeta);
                }
                if (metaProperty.getRange().isClass()) {
                    // replace range class
                    ClassRange range = (ClassRange) metaProperty.getRange();
                    Class effectiveRangeClass = extendedEntities.getEffectiveClass(range.asClass());
                    MetaClass effectiveRangeMeta = session.getClass(effectiveRangeClass);
                    if (effectiveRangeMeta != range.asClass()) {
                        ClassRange newRange = new ClassRange(effectiveRangeMeta);
                        newRange.setCardinality(range.getCardinality());
                        newRange.setOrdered(range.isOrdered());
                        ((MetaPropertyImpl) metaProperty).setRange(newRange);
                    }
                }
            }
        }
        for (Pair<MetaClass, MetaClass> replace : replaceMap) {
            MetaClass replacedMetaClass = replace.getFirst();
            extendedEntities.registerReplacedMetaClass(replacedMetaClass);
            MetaClassImpl effectiveMetaClass = (MetaClassImpl) replace.getSecond();
            modelImpl.registerClass(replacedMetaClass.getName(), replacedMetaClass.getJavaClass(), effectiveMetaClass);
        }
    }
    sw.stop();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) MetaModel(com.haulmont.chile.core.model.MetaModel) MetaClass(com.haulmont.chile.core.model.MetaClass) MetaClass(com.haulmont.chile.core.model.MetaClass) MetaProperty(com.haulmont.chile.core.model.MetaProperty) Pair(com.haulmont.bali.datastruct.Pair)

Aggregations

StopWatch (org.perf4j.StopWatch)41 Slf4JStopWatch (org.perf4j.slf4j.Slf4JStopWatch)41 UIPerformanceLogger (com.haulmont.cuba.gui.logging.UIPerformanceLogger)17 Element (org.dom4j.Element)4 Transaction (com.haulmont.cuba.core.Transaction)3 Test (org.testng.annotations.Test)3 Node (com.haulmont.bali.datastruct.Node)2 MetaClass (com.haulmont.chile.core.model.MetaClass)2 AppFolder (com.haulmont.cuba.core.entity.AppFolder)2 ComponentLoader (com.haulmont.cuba.gui.xml.layout.ComponentLoader)2 ComponentLoaderContext (com.haulmont.cuba.gui.xml.layout.loaders.ComponentLoaderContext)2 SearchFolder (com.haulmont.cuba.security.entity.SearchFolder)2 Binding (groovy.lang.Binding)2 IOException (java.io.IOException)2 KryoException (com.esotericsoftware.kryo.KryoException)1 Pair (com.haulmont.bali.datastruct.Pair)1 Tree (com.haulmont.bali.datastruct.Tree)1 MetaModel (com.haulmont.chile.core.model.MetaModel)1 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 EntityManager (com.haulmont.cuba.core.EntityManager)1