Search in sources :

Example 16 with StopWatch

use of core.framework.util.StopWatch in project core-ng-project by neowu.

the class Pool method createNewItem.

private PoolItem<T> createNewItem() {
    StopWatch watch = new StopWatch();
    size.incrementAndGet();
    try {
        return new PoolItem<>(factory.get());
    } catch (Throwable e) {
        size.getAndDecrement();
        throw e;
    } finally {
        logger.debug("create new resource, pool={}, size={}, elapsed={}", name, size.get(), watch.elapsedTime());
    }
}
Also used : StopWatch(core.framework.util.StopWatch)

Example 17 with StopWatch

use of core.framework.util.StopWatch in project core-ng-project by neowu.

the class TemplateManager method process.

public String process(String templatePath, Object model, String language) {
    StopWatch watch = new StopWatch();
    try {
        HTMLTemplate template = get(templatePath, model.getClass(), language);
        TemplateContext context = new TemplateContext(model, cdnManager);
        return template.process(context);
    } finally {
        logger.debug("process, templatePath={}, elapsedTime={}", templatePath, watch.elapsedTime());
    }
}
Also used : HTMLTemplate(core.framework.impl.template.HTMLTemplate) TemplateContext(core.framework.impl.template.TemplateContext) StopWatch(core.framework.util.StopWatch)

Example 18 with StopWatch

use of core.framework.util.StopWatch in project core-ng-project by neowu.

the class HTMLTemplateEngine method process.

public String process(String name, Object model) {
    StopWatch watch = new StopWatch();
    try {
        HTMLTemplate template = templates.get(name);
        if (template == null)
            throw Exceptions.error("template not found, name={}", name);
        TemplateContext context = new TemplateContext(model, cdnManager);
        return template.process(context);
    } finally {
        logger.debug("process, name={}, elapsedTime={}", name, watch.elapsedTime());
    }
}
Also used : HTMLTemplate(core.framework.impl.template.HTMLTemplate) TemplateContext(core.framework.impl.template.TemplateContext) StopWatch(core.framework.util.StopWatch)

Example 19 with StopWatch

use of core.framework.util.StopWatch in project core-ng-project by neowu.

the class DatabaseImpl method select.

@Override
public <T> List<T> select(String sql, Class<T> viewClass, Object... params) {
    StopWatch watch = new StopWatch();
    int returnedRows = 0;
    try {
        List<T> results = operation.select(sql, rowMapper(viewClass), params);
        returnedRows = results.size();
        checkTooManyRowsReturned(returnedRows);
        return results;
    } finally {
        long elapsedTime = watch.elapsedTime();
        ActionLogContext.track("db", elapsedTime, returnedRows, 0);
        logger.debug("select, sql={}, params={}, updatedRows={}, elapsedTime={}", sql, params, returnedRows, elapsedTime);
        checkSlowOperation(elapsedTime);
    }
}
Also used : StopWatch(core.framework.util.StopWatch)

Example 20 with StopWatch

use of core.framework.util.StopWatch in project core-ng-project by neowu.

the class DatabaseImpl method repository.

public <T> Repository<T> repository(Class<T> entityClass) {
    StopWatch watch = new StopWatch();
    try {
        new DatabaseClassValidator(entityClass).validateEntityClass();
        RowMapper<T> mapper = registerViewClass(entityClass);
        return new RepositoryImpl<>(this, entityClass, mapper);
    } finally {
        logger.info("register db entity, entityClass={}, elapsedTime={}", entityClass.getCanonicalName(), watch.elapsedTime());
    }
}
Also used : StopWatch(core.framework.util.StopWatch)

Aggregations

StopWatch (core.framework.util.StopWatch)79 IOException (java.io.IOException)21 UncheckedIOException (java.io.UncheckedIOException)21 SearchException (core.framework.search.SearchException)10 ElasticsearchException (org.elasticsearch.ElasticsearchException)10 ArrayList (java.util.ArrayList)6 HTMLTemplate (core.framework.impl.template.HTMLTemplate)4 BytesParam (core.framework.impl.log.filter.BytesParam)3 Map (java.util.Map)3 BsonDocument (org.bson.BsonDocument)3 BulkWriteOptions (com.mongodb.client.model.BulkWriteOptions)2 UpdateOptions (com.mongodb.client.model.UpdateOptions)2 DeleteResult (com.mongodb.client.result.DeleteResult)2 TemplateContext (core.framework.impl.template.TemplateContext)2 Headers (org.apache.kafka.common.header.Headers)2 Bson (org.bson.conversions.Bson)2 BulkRequestBuilder (org.elasticsearch.action.bulk.BulkRequestBuilder)2 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)2 Settings (org.elasticsearch.common.settings.Settings)2 MongoClient (com.mongodb.MongoClient)1