org.hibernate.stat.SecondLevelCacheStatistics getStatistics( EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue( HibernateStatistics.PROVIDER_LABEL ); SessionFactory sessionFactory = entityManagerFactoryaccess.entityManagerFactory( scopedPersistenceUnitName ) .unwrap( SessionFactory.class ); if ( sessionFactory != null ) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics( scopedPersistenceUnitName + "." + pathAddress.getValue( HibernateStatistics.ENTITYCACHE ) ); } return null; }
org.hibernate.stat.SecondLevelCacheStatistics getStatistics(EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL); SessionFactory sessionFactory = entityManagerFactoryaccess.entityManagerFactory(scopedPersistenceUnitName).unwrap(SessionFactory.class); if (sessionFactory != null) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics(scopedPersistenceUnitName + "." + pathAddress.getValue(HibernateStatistics.ENTITYCACHE)); } return null; } private Operation getEntityCacheRegionName = new Operation() {
org.hibernate.stat.SecondLevelCacheStatistics getStatistics(EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL); SessionFactory sessionFactory = entityManagerFactoryaccess.entityManagerFactory(scopedPersistenceUnitName).unwrap(SessionFactory.class); if (sessionFactory != null) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics(scopedPersistenceUnitName + "." + pathAddress.getValue(HibernateStatistics.ENTITYCACHE)); } return null; } private Operation getEntityCacheRegionName = new Operation() {
org.hibernate.stat.SecondLevelCacheStatistics getStatistics(EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL); HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactoryaccess.entityManagerFactory(scopedPersistenceUnitName); if (entityManagerFactoryImpl == null) { return null; } SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics(scopedPersistenceUnitName + "." + pathAddress.getValue(HibernateStatistics.ENTITYCACHE)); } return null; } private Operation getEntityCacheRegionName = new Operation() {
org.hibernate.stat.SecondLevelCacheStatistics getStatistics(EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL); HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactoryaccess.entityManagerFactory(scopedPersistenceUnitName); if (entityManagerFactoryImpl == null) { return null; } SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics(scopedPersistenceUnitName + "." + pathAddress.getValue(HibernateStatistics.ENTITYCACHE)); } return null; } private Operation getEntityCacheRegionName = new Operation() {
@Test public void testLegacyStatsApi() { // these references need to be the prefixed name final String regionName = cachePrefix + '.' + localName; final Statistics stats = sessionFactory().getStatistics(); assertEquals( 2, stats.getSecondLevelCacheRegionNames().length ); final SecondLevelCacheStatistics secondLevelCacheStatistics = stats.getSecondLevelCacheStatistics( regionName ); assert secondLevelCacheStatistics != null; final NaturalIdCacheStatistics naturalIdCacheStatistics = stats.getNaturalIdCacheStatistics( regionName ); assert naturalIdCacheStatistics != null; final SecondLevelCacheStatistics dne = stats.getSecondLevelCacheStatistics( cachePrefix + ".does.not.exist" ); assert dne != null; }
/** * {@inheritDoc} */ public TabularData getCacheRegionStats() { List<CompositeData> list = new ArrayList<CompositeData>(); Statistics statistics = getStatistics(); for (String region : statistics.getSecondLevelCacheRegionNames()) { CacheRegionStats l2CacheStats = new CacheRegionStats(region, statistics.getSecondLevelCacheStatistics(region)); list.add(l2CacheStats.toCompositeData()); } TabularData td = CacheRegionStats.newTabularDataInstance(); td.putAll(list.toArray(new CompositeData[list.size()])); return td; }
/** * @see StatisticsServiceMBean#getSecondLevelCacheStatistics(java.lang.String) */ public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) { return stats.getSecondLevelCacheStatistics(regionName); } /**
/** * @see StatisticsServiceMBean#getSecondLevelCacheStatistics(java.lang.String) */ public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) { return stats.getSecondLevelCacheStatistics(regionName); } /**
/** * @see StatisticsServiceMBean#getSecondLevelCacheStatistics(java.lang.String) */ public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) { return stats.getSecondLevelCacheStatistics(regionName); } /**
/** * @see StatisticsServiceMBean#getSecondLevelCacheStatistics(java.lang.String) */ public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) { return stats.getSecondLevelCacheStatistics(regionName); } /**
public SecondLevelCacheStatistics getSecondLevelCacheStatistics() { return getStatistics().getSecondLevelCacheStatistics(currentSecondLevelCacheRegionName); } }
public SecondLevelCacheStatistics getSecondLevelCacheStatistics() { return getStatistics().getSecondLevelCacheStatistics(currentSecondLevelCacheRegionName); } }
private SecondLevelCacheStatistics getCacheStatistics(String regionName) { return emf.unwrap(SessionFactory.class).getStatistics() .getSecondLevelCacheStatistics(regionName); }
private boolean hasCacheRegion(PathElement element) { boolean result = false; final PersistenceUnitService puService = persistenceUnitRegistry.getPersistenceUnitService(puName); final Statistics stats = getStatistics(); if (stats != null && puService != null) { final String scopedPUName = puService.getScopedPersistenceUnitName(); final String unqualifiedRegionName = element.getValue(); final String qualifiedRegionName = scopedPUName + "." + unqualifiedRegionName; result = stats.getSecondLevelCacheStatistics(qualifiedRegionName) != null; } return result; }
org.hibernate.stat.SecondLevelCacheStatistics getStatistics(EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL); SessionFactory sessionFactory = entityManagerFactoryaccess.entityManagerFactory(scopedPersistenceUnitName).unwrap(SessionFactory.class); if (sessionFactory != null) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics(scopedPersistenceUnitName + "." + pathAddress.getValue(HibernateStatistics.ENTITYCACHE)); } return null; } private Operation getEntityCacheRegionName = new Operation() {
org.hibernate.stat.SecondLevelCacheStatistics getStatistics(EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL); HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactoryaccess.entityManagerFactory(scopedPersistenceUnitName); SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics(scopedPersistenceUnitName + "." + pathAddress.getValue(HibernateStatistics.ENTITYCACHE)); } return null; } private Operation getEntityCacheRegionName = new Operation() {
org.hibernate.stat.SecondLevelCacheStatistics getStatistics(EntityManagerFactoryAccess entityManagerFactoryaccess, PathAddress pathAddress) { String scopedPersistenceUnitName = pathAddress.getValue(HibernateStatistics.PROVIDER_LABEL); HibernateEntityManagerFactory entityManagerFactoryImpl = (HibernateEntityManagerFactory) entityManagerFactoryaccess.entityManagerFactory(scopedPersistenceUnitName); SessionFactory sessionFactory = entityManagerFactoryImpl.getSessionFactory(); if (sessionFactory != null) { // The entity class name is prefixed by the application scoped persistence unit name return sessionFactory.getStatistics().getSecondLevelCacheStatistics(scopedPersistenceUnitName + "." + pathAddress.getValue(HibernateStatistics.ENTITYCACHE)); } return null; } private Operation getEntityCacheRegionName = new Operation() {
private SecondLevelCacheStatistics getSecondLevelCacheStatistics(ModelNode operation) { final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)); final String puResourceName = address.getElement(address.size() - 2).getValue(); final String regionName = puResourceName + "." + address.getLastElement().getValue(); ManagementLookup stats = ManagementLookup.create(persistenceUnitRegistry, puResourceName); return stats == null ? null : stats.getStatistics().getSecondLevelCacheStatistics(regionName); }
private void addSecondLevelCacheStats(List<ApplicationStat> res, Statistics stats) { addCacheStat(res, "2Cache/total/", stats.getSecondLevelCacheHitCount(), stats.getSecondLevelCacheMissCount(), stats.getSecondLevelCachePutCount()); for (String cacheRegion : stats.getSecondLevelCacheRegionNames()) { SecondLevelCacheStatistics cStats = stats.getSecondLevelCacheStatistics(cacheRegion); addCacheStat(res, "2Cache/" + cacheRegion + "/", cStats.getHitCount(), cStats.getMissCount(), cStats.getPutCount()); addStat(res, "2Cache/" + cacheRegion + "/size", cStats.getElementCountInMemory(), "onDisk=" + cStats.getElementCountOnDisk() + ", memSize=" + cStats.getSizeInMemory()); } }