mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
initial ehcache support
This commit is contained in:
@@ -1,10 +1,20 @@
|
||||
package com.commafeed.backend;
|
||||
|
||||
import javax.ejb.Singleton;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.ejb.EntityManagerImpl;
|
||||
import org.hibernate.stat.Statistics;
|
||||
|
||||
@Singleton
|
||||
public class MetricsBean {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager em;
|
||||
|
||||
private Metric lastMinute = new Metric();
|
||||
private Metric thisMinute = new Metric();
|
||||
|
||||
@@ -61,6 +71,14 @@ public class MetricsBean {
|
||||
return lastHour;
|
||||
}
|
||||
|
||||
public String getCacheStats() {
|
||||
EntityManagerImpl impl = (EntityManagerImpl) em.getDelegate();
|
||||
Session session = impl.getSession();
|
||||
SessionFactory sessionFactory = session.getSessionFactory();
|
||||
Statistics statistics = sessionFactory.getStatistics();
|
||||
return statistics.toString();
|
||||
}
|
||||
|
||||
public static class Metric {
|
||||
private int feedsRefreshed;
|
||||
private int feedsUpdated;
|
||||
|
||||
Reference in New Issue
Block a user