org.hibernate.stat.Statistics.getSecondLevelCacheStatistics()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中org.hibernate.stat.Statistics.getSecondLevelCacheStatistics()方法的一些代码示例,展示了Statistics.getSecondLevelCacheStatistics()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Statistics.getSecondLevelCacheStatistics()方法的具体详情如下:
包路径:org.hibernate.stat.Statistics
类名称:Statistics
方法名:getSecondLevelCacheStatistics

Statistics.getSecondLevelCacheStatistics介绍

[英]Second-level cache statistics per region
[中]每个区域的二级缓存统计信息

代码示例

代码示例来源:origin: hibernate/hibernate-orm

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;
}

代码示例来源:origin: wildfly/wildfly

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() {

代码示例来源:origin: wildfly/wildfly

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() {

代码示例来源:origin: wildfly/wildfly

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() {

代码示例来源:origin: wildfly/wildfly

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() {

代码示例来源:origin: hibernate/hibernate-orm

@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;
}

代码示例来源:origin: net.sf.ehcache/ehcache

/**
 * {@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;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

/**
 * @see StatisticsServiceMBean#getSecondLevelCacheStatistics(java.lang.String)
 */
public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) {
  return stats.getSecondLevelCacheStatistics(regionName);
}
/**

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

/**
 * @see StatisticsServiceMBean#getSecondLevelCacheStatistics(java.lang.String)
 */
public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) {
  return stats.getSecondLevelCacheStatistics(regionName);
}
/**

代码示例来源:origin: hibernate/hibernate

/**
 * @see StatisticsServiceMBean#getSecondLevelCacheStatistics(java.lang.String)
 */
public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) {
  return stats.getSecondLevelCacheStatistics(regionName);
}
/**

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

/**
 * @see StatisticsServiceMBean#getSecondLevelCacheStatistics(java.lang.String)
 */
public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName) {
  return stats.getSecondLevelCacheStatistics(regionName);
}
/**

代码示例来源:origin: org.apache.tapestry/tapestry-hibernate

public SecondLevelCacheStatistics getSecondLevelCacheStatistics()
  {
    return getStatistics().getSecondLevelCacheStatistics(currentSecondLevelCacheRegionName);
  }
}

代码示例来源:origin: apache/tapestry-5

public SecondLevelCacheStatistics getSecondLevelCacheStatistics()
  {
    return getStatistics().getSecondLevelCacheStatistics(currentSecondLevelCacheRegionName);
  }
}

代码示例来源:origin: infinispan/infinispan-simple-tutorials

private SecondLevelCacheStatistics getCacheStatistics(String regionName) {
 return emf.unwrap(SessionFactory.class).getStatistics()
   .getSecondLevelCacheStatistics(regionName);
}

代码示例来源:origin: org.jboss.as/jboss-as-jpa-hibernate4

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;
}

代码示例来源:origin: org.jboss.eap/jipijapa-hibernate5

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() {

代码示例来源:origin: org.jipijapa/jipijapa-hibernate4-1

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() {

代码示例来源:origin: org.jipijapa/jipijapa-hibernate4-3

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() {

代码示例来源:origin: org.jboss.as/jboss-as-jpa-hibernate4

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

代码示例来源:origin: com.springsource.insight/insight-repo

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

相关文章

Statistics类方法