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());
}
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();
}
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();
}
}
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();
}
}
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();
}
Aggregations