Search in sources :

Example 31 with StopWatch

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

the class EmailSender method sendEmail.

@Override
public void sendEmail(SendingMessage sendingMessage) throws MessagingException {
    MimeMessage msg = createMimeMessage(sendingMessage);
    StopWatch sw = new Slf4JStopWatch("EmailSender.send");
    mailSender.send(msg);
    sw.stop();
    log.info("Email '{}' to '{}' has been sent successfully", msg.getSubject(), sendingMessage.getAddress());
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 32 with StopWatch

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

the class Scheduling method calculateNextCronDate.

protected long calculateNextCronDate(ScheduledTask task, long date, long currentDate, long frame) {
    StopWatch sw = new Slf4JStopWatch("Cron next date calculations");
    CronSequenceGenerator cronSequenceGenerator = new CronSequenceGenerator(task.getCron(), getCurrentTimeZone());
    // if last start = 0 (task never has run) or to far in the past, we use (NOW - FRAME) timestamp for pivot time
    // this approach should work fine cause cron works with absolute time
    long pivotPreviousTime = Math.max(date, currentDate - frame);
    Date currentStart = null;
    Date nextDate = cronSequenceGenerator.next(new Date(pivotPreviousTime));
    while (nextDate.getTime() < currentDate) {
        // if next date is in past try to find next date nearest to now
        currentStart = nextDate;
        nextDate = cronSequenceGenerator.next(nextDate);
    }
    if (currentStart == null) {
        currentStart = nextDate;
    }
    log.trace("{}\n now={} frame={} currentStart={} lastStart={} cron={}", task, currentDate, frame, currentStart, task.getCron());
    sw.stop();
    return currentStart.getTime();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) CronSequenceGenerator(org.springframework.scheduling.support.CronSequenceGenerator) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 33 with StopWatch

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

the class ClusterManager method internalSend.

protected void internalSend(Serializable message, boolean sync) {
    StopWatch sw = new Slf4JStopWatch(String.format("sendClusterMessage(%s)", message.getClass().getSimpleName()));
    try {
        byte[] bytes = SerializationSupport.serialize(message);
        log.debug("Sending message: {}: {} ({} bytes)", message.getClass(), message, bytes.length);
        MessageStat stat = messagesStat.get(message.getClass().getName());
        if (stat != null) {
            stat.updateSent(bytes.length);
        }
        Message msg = new Message(null, null, bytes);
        if (sync) {
            msg.setFlag(Message.Flag.RSVP);
        }
        try {
            channel.send(msg);
        } catch (Exception e) {
            log.error("Error sending message", e);
        }
    } finally {
        sw.stop();
    }
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 34 with StopWatch

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

the class PerformanceLogInterceptor method aroundInvoke.

@SuppressWarnings({ "UnusedDeclaration", "UnnecessaryLocalVariable" })
private Object aroundInvoke(ProceedingJoinPoint ctx) throws Throwable {
    StopWatch stopWatch = new Slf4JStopWatch(ctx.getSignature().toShortString());
    try {
        stopWatch.start();
        Object res = ctx.proceed();
        return res;
    } finally {
        stopWatch.stop();
    }
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch)

Example 35 with StopWatch

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

the class JmxInstancesDatasource method loadData.

@Override
protected void loadData(Map<String, Object> params) {
    String tag = getLoggingTag("CDS");
    StopWatch sw = new Slf4JStopWatch(tag, LoggerFactory.getLogger(UIPerformanceLogger.class));
    detachListener(data.values());
    data.clear();
    for (JmxInstance jmxInstance : jmxControlAPI.getInstances()) {
        data.put(jmxInstance.getId(), jmxInstance);
        attachListener(jmxInstance);
    }
    sw.stop();
}
Also used : Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) UIPerformanceLogger(com.haulmont.cuba.gui.logging.UIPerformanceLogger) StopWatch(org.perf4j.StopWatch) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) JmxInstance(com.haulmont.cuba.core.entity.JmxInstance)

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