类org.hibernate.stat.CollectionStatistics源码实例Demo

下面列出了怎么用org.hibernate.stat.CollectionStatistics的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: keycloak   文件: HibernateStatsReporter.java
protected void logCollections(StringBuilder builder, String lineSep, Statistics stats) {
    builder.append("Important collections statistics: ").append(lineSep);
    for (String col : stats.getCollectionRoleNames()) {
        CollectionStatistics collectionStats = stats.getCollectionStatistics(col);
        if (collectionStats.getRecreateCount() > LIMIT || collectionStats.getUpdateCount() > LIMIT || collectionStats.getRemoveCount() > LIMIT ||
                collectionStats.getLoadCount() > LIMIT || collectionStats.getFetchCount() > LIMIT) {
            builder.append(col).append(" - ")
                    .append("recreated: ").append(collectionStats.getRecreateCount())
                    .append(", updated: ").append(collectionStats.getUpdateCount())
                    .append(", removed: ").append(collectionStats.getRemoveCount())
                    .append(", loaded: ").append(collectionStats.getLoadCount())
                    .append(", fetched: ").append(collectionStats.getFetchCount())
                    .append(lineSep);
        }
    }
    builder.append(lineSep);
}
 
源代码2 项目: cacheonix-core   文件: StatisticsService.java
/**
 * @see StatisticsServiceMBean#getCollectionStatistics(java.lang.String)
 */
public CollectionStatistics getCollectionStatistics(String role) {
	return stats.getCollectionStatistics(role);
}
 
源代码3 项目: pnc   文件: HibernateStatsUtils.java
/**
 * Get all the Hibernate collections statistics aggregated in a sorted Map
 * 
 * @param statistics
 * @return a sorted map containing all the Hibernate collections statistics
 */
public static SortedMap<String, Map<String, HibernateMetric>> getSecondLevelCacheCollectionsStats(
        Statistics statistics) {

    SortedMap<String, Map<String, HibernateMetric>> collectionsStatMap = new TreeMap<String, Map<String, HibernateMetric>>();

    if (statistics.isStatisticsEnabled()) {
        String[] collectionRoleNames = statistics.getCollectionRoleNames();
        Stream.of(collectionRoleNames).forEach(crN -> {
            CollectionStatistics cStats = statistics.getCollectionStatistics(crN);
            SortedMap<String, HibernateMetric> cStatMap = new TreeMap<String, HibernateMetric>();

            // Collection cache stats
            cStatMap.put(
                    "cache.region.name",
                    createHibernateMetricItem(
                            "cacheRegionName",
                            "The name of the region where this data is cached.",
                            cStats.getCacheRegionName()));

            cStatMap.put(
                    "cache.hit.count",
                    createHibernateMetricItem(
                            "cacheHitCount",
                            "The number of successful cache look-ups for this data from its configured cache region since the last Statistics clearing.",
                            cStats.getCacheHitCount()));
            cStatMap.put(
                    "cache.miss.count",
                    createHibernateMetricItem(
                            "cacheMissCount",
                            "The number of unsuccessful cache look-ups for this data from its configured cache region since the last Statistics clearing.",
                            cStats.getCacheMissCount()));
            double secondLvlCacheHitsRatio = (cStats.getCacheHitCount() + cStats.getCacheMissCount()) != 0
                    ? ((double) cStats.getCacheHitCount() / (cStats.getCacheHitCount() + cStats.getCacheMissCount())
                            * 100)
                    : -1;
            cStatMap.put(
                    "cache.hit.ratio",
                    createHibernateMetricItem(
                            "cacheHitRatio",
                            "The ratio of successful cache look-ups for this data from its configured cache region since the last Statistics clearing.",
                            df2.format(secondLvlCacheHitsRatio)));
            cStatMap.put(
                    "cache.put.count",
                    createHibernateMetricItem(
                            "cachePutCount",
                            "The number of times this data has been into its configured cache region since the last Statistics clearing.",
                            cStats.getCachePutCount()));

            // Collection stats
            cStatMap.put(
                    "fetch.count",
                    createHibernateMetricItem(
                            "fetchCount",
                            "Number of times (since last Statistics clearing) this collection has been fetched.",
                            cStats.getFetchCount()));
            cStatMap.put(
                    "recreate.count",
                    createHibernateMetricItem(
                            "recreateCount",
                            "Number of times (since last Statistics clearing) this collection has been recreated (rows potentially deleted and then rows (re-)inserted).",
                            cStats.getRecreateCount()));
            cStatMap.put(
                    "remove.count",
                    createHibernateMetricItem(
                            "removeCount",
                            "Number of times (since last Statistics clearing) this collection has been removed.",
                            cStats.getRemoveCount()));
            cStatMap.put(
                    "load.count",
                    createHibernateMetricItem(
                            "loadCount",
                            "Number of times (since last Statistics clearing) this collection has been loaded.",
                            cStats.getLoadCount()));
            cStatMap.put(
                    "update.count",
                    createHibernateMetricItem(
                            "updateCount",
                            "Number of times (since last Statistics clearing) this collection has been updated.",
                            cStats.getUpdateCount()));

            collectionsStatMap.put(COLLECTION_STATS_PREFIX + crN, cStatMap);
        });
    }

    return collectionsStatMap;
}
 
源代码4 项目: lemon   文件: StatisticsWrapper.java
public CollectionStatistics getCollectionStatistics(String role) {
    return null;
}
 
 类所在包
 类方法
 同包方法