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

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

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

Statistics.getSecondLevelCacheRegionNames介绍

[英]Get all second-level cache region names. Note: for backwards compatibility this method returns just the names of regions storing domain data, not query result regions
[中]获取所有二级缓存区域名称。注意:为了向后兼容,此方法只返回存储域数据的区域的名称,而不是查询结果区域

代码示例

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

json.put("CollectionRecreateCount", statistics.getCollectionRecreateCount());
json.put("StartTime", statistics.getStartTime());
json.put("SecondLevelCacheRegionNames", statistics.getSecondLevelCacheRegionNames());
json.put("SuccessfulTransactionCount", statistics.getSuccessfulTransactionCount());
json.put("TransactionCount", statistics.getTransactionCount());

代码示例来源: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

public String[] getSecondLevelCacheRegionNames() {
  return stats.getSecondLevelCacheRegionNames();
}

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

public String[] getSecondLevelCacheRegionNames() {
  return stats.getSecondLevelCacheRegionNames();
}

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

public String[] getSecondLevelCacheRegionNames() {
  return stats.getSecondLevelCacheRegionNames();
}

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

public String[] getSecondLevelCacheRegionNames() {
  return stats.getSecondLevelCacheRegionNames();
}

代码示例来源:origin: at.chrl/chrl-orm

public static String[] getCacheStatistics(final IHibernateConfig hconfig) {
  if (isNull(hconfig))
    throw new NullPointerException("Parameter hconfig is null");
  SessionFactory sf = HibernateService.getInstance().getSessionFactory(hconfig);
  if (isNull(sf))
    throw new NullPointerException("Could not obtain SessionFactory for Config: " + hconfig);
  final Statistics stats = sf.getStatistics();
  String[] header = new String[] { JVMInfoUtil.getInstance().printSection("Cache for: " + hconfig.toString()) };
  return Arrays.stream(stats.getSecondLevelCacheRegionNames()).reduce(header, (a, s) -> ArrayUtils.addAll(a, getCacheStatistics(sf, s)), ArrayUtils::addAll);
}

代码示例来源:origin: org.terracotta.modules/tim-hibernate-cache-provider-3.2

public Map<String, int[]> getRegionCacheSamples() {
 Map<String, int[]> result = new HashMap<String, int[]>();
 if (statistics instanceof SampledStatistics) {
  for (String name : statistics.getSecondLevelCacheRegionNames()) {
   SecondLevelCacheStatistics secondLevelCacheStatistics = statistics.getSecondLevelCacheStatistics(name);
   if (secondLevelCacheStatistics instanceof SampledSecondLevelCacheStatistics) {
    SampledSecondLevelCacheStatistics sampled = (SampledSecondLevelCacheStatistics) secondLevelCacheStatistics;
    result.put(name, new int[] { (int) sampled.getCacheHitMostRecentSample(),
      (int) sampled.getCacheMissMostRecentSample(), (int) sampled.getCachePutMostRecentSample() });
   }
  }
 }
 return result;
}

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

/**
 * {@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.apache.servicemix.bundles/org.apache.servicemix.bundles.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.sonatype.nexus.bundles/org.sonatype.nexus.bundles.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: hibernate/hibernate-tools

public int getChildCount(Object parent) {
  if(parent==stats) {
    return 4;
  } else if(parent==entities) {
    return stats.getEntityNames().length;
  } else if(parent==collections) {
    return stats.getCollectionRoleNames().length;
  } else if(parent==queries) {
    return stats.getQueries().length;
  } else if(parent==secondlevelcache) {
    return stats.getSecondLevelCacheRegionNames().length;
  } else if(parent instanceof CacheRegionStatistics) {
    return 0;
  }
  return 0;
}

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

public int getChildCount(Object parent) {
  if(parent==stats) {
    return 4;
  } else if(parent==entities) {
    return stats.getEntityNames().length;
  } else if(parent==collections) {
    return stats.getCollectionRoleNames().length;
  } else if(parent==queries) {
    return stats.getQueries().length;
  } else if(parent==secondlevelcache) {
    return stats.getSecondLevelCacheRegionNames().length;
  } else if(parent instanceof SecondLevelCacheStatistics) {
    /*SecondLevelCacheStatistics stats = (SecondLevelCacheStatistics) parent;
    return stats.getEntries().size();*/
  }
  return 0;
}

代码示例来源:origin: org.terracotta.modules/tim-hibernate-cache-provider-3.2

public TabularData getCacheRegionStats() {
 List<CompositeData> result = new ArrayList<CompositeData>();
 for (String region : statistics.getSecondLevelCacheRegionNames()) {
  CacheRegionStats l2CacheStats;
  if (statistics instanceof TerracottaStatistics) {
   l2CacheStats = new CacheRegionStats(region, statistics.getSecondLevelCacheStatistics(region),
                     ((TerracottaStatistics) statistics).getLatencyStatistics(region));
  } else {
   l2CacheStats = new CacheRegionStats(region, statistics.getSecondLevelCacheStatistics(region));
  }
  result.add(l2CacheStats.toCompositeData());
 }
 TabularData td = CacheRegionStats.newTabularDataInstance();
 td.putAll(result.toArray(new CompositeData[result.size()]));
 return td;
}

代码示例来源:origin: org.terracotta.modules/tim-hibernate-cache-provider-3.2

public void flushRegionCaches() {
 for (String region : statistics.getSecondLevelCacheRegionNames()) {
  lookupTerracottaHibernateCache(region).clear();
 }
 logger.info("All cache regions are evicted");
 sendNotification(CACHE_FLUSHED);
}

代码示例来源:origin: at.chrl/chrl-orm

public static String[] getCacheStatistics(final SessionFactory sessionFactory, final String cacheRegion) {
  if (isNull(sessionFactory))
    throw new NullPointerException("Parameter sessionFactory is null");
  if (isNull(cacheRegion))
    throw new NullPointerException("Parameter cacheRegion is null");
  if (cacheRegion.isEmpty())
    throw new IllegalArgumentException("Parameter cacheRegion is a empty String");
  final Statistics sfstats = sessionFactory.getStatistics();
  if (!ArrayUtils.contains(sfstats.getSecondLevelCacheRegionNames(), cacheRegion))
    throw new IllegalArgumentException("Cache Region" + cacheRegion + " is not managed by given SessionFactory");
  final SecondLevelCacheStatistics stats = sfstats.getSecondLevelCacheStatistics(cacheRegion);
  final NaturalIdCacheStatistics idstats = sfstats.getNaturalIdCacheStatistics(cacheRegion);
  return new String[] { "+ 2nd Level Cache Statistics: " + cacheRegion, "+", "+ # Puts: " + stats.getPutCount(), "+ # Hits: " + stats.getHitCount(), "+ # Misses: " + stats.getMissCount(), "+ Hit Ratio: " + ((double) stats.getHitCount()) / (stats.getHitCount() + stats.getMissCount()), "+ Size in Memory: " + stats.getSizeInMemory(), "+ Elements in Memory: " + stats.getElementCountInMemory(), "+ Elements on Disk: " + stats.getElementCountOnDisk(), "+", "+ ID # Puts: " + idstats.getPutCount(), "+ ID # Hits: " + idstats.getHitCount(), "+ ID # Misses: " + idstats.getMissCount(), "+ ID Hit Ratio: " + ((double) idstats.getHitCount()) / (idstats.getHitCount() + idstats.getMissCount()), "+ ID Size in Memory: " + idstats.getSizeInMemory(), "+ ID Elements in Memory: " + idstats.getElementCountInMemory(), "+ ID Execution Count: " + idstats.getExecutionCount(), "+ ID Avg Execution Time: " + idstats.getExecutionAvgTime() + "ms", "+ ID Max Execution Time: " + idstats.getExecutionMaxTime() + "ms", "+ ID Min Execution Time: " + idstats.getExecutionMinTime() + "ms", "+", "+" };
}

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

public Object getChild(Object parent, int index) {
  if(parent==stats) {
    switch(index) {
    case 0: return entities;
    case 1: return collections;
    case 2:	return queries;		
    case 3: return secondlevelcache;
    }
  } else if(parent==entities) {
    return stats.getEntityStatistics(stats.getEntityNames()[index]);
  } else if(parent==collections) {
    return stats.getCollectionStatistics(stats.getCollectionRoleNames()[index]);
  } else if(parent==queries) {
    return stats.getQueryStatistics(stats.getQueries()[index]);
  } else if(parent==secondlevelcache) {
    return stats.getSecondLevelCacheStatistics( stats.getSecondLevelCacheRegionNames()[index]);
  } else if(parent instanceof SecondLevelCacheStatistics) {
    SecondLevelCacheStatistics slcs = (SecondLevelCacheStatistics) parent;            
    return slcs.getEntries();
  }
  return null;
}

代码示例来源: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());
  }
}

代码示例来源:origin: riotfamily/riot

@Override
protected List<? extends StatsItem> getStats() {
  ArrayList<CacheRegionStatsItem> stats = Generics.newArrayList();
  String[] regions = sessionFactory.getStatistics().getSecondLevelCacheRegionNames();
  for (String region : regions) {
    CacheRegionStatsItem item = new CacheRegionStatsItem(region);
    SecondLevelCacheStatistics sl = sessionFactory.getStatistics().getSecondLevelCacheStatistics(region);
    item.setElementsInMemory(sl.getElementCountInMemory());
    item.setElementsOnDisk(sl.getElementCountOnDisk());
    item.setHitCount(sl.getHitCount());
    item.setMissCount(sl.getMissCount());
    item.setPutCount(sl.getPutCount());
    item.setKbInMemory(sl.getSizeInMemory() / 1024);
    stats.add(item);
  }
  return stats;
}

相关文章

Statistics类方法