@Override public long getElementCountOnDisk() { long count = 0; HashSet<Region> processedRegions = null; for ( NaturalIdDataAccess accessStrategy : accessStrategies ) { final DomainDataRegion region = accessStrategy.getRegion(); if ( ExtendedStatisticsSupport.class.isInstance( region ) ) { } if ( region instanceof ExtendedStatisticsSupport ) { if ( processedRegions == null ) { processedRegions = new HashSet<>(); } if ( processedRegions.add( region ) ) { count += ( (ExtendedStatisticsSupport) region ).getElementCountOnDisk(); } } } if ( count == 0 ) { return NO_EXTENDED_STAT_SUPPORT_RETURN; } return count; }
@Override public long getElementCountInMemory() { long count = 0; HashSet<Region> processedRegions = null; for ( NaturalIdDataAccess accessStrategy : accessStrategies ) { final DomainDataRegion region = accessStrategy.getRegion(); if ( ExtendedStatisticsSupport.class.isInstance( region ) ) { } if ( region instanceof ExtendedStatisticsSupport ) { if ( processedRegions == null ) { processedRegions = new HashSet<>(); } if ( processedRegions.add( region ) ) { count += ( (ExtendedStatisticsSupport) region ).getElementCountInMemory(); } } } if ( count == 0 ) { return NO_EXTENDED_STAT_SUPPORT_RETURN; } return count; }
@Override public long getSizeInMemory() { long count = 0; HashSet<Region> processedRegions = null; for ( NaturalIdDataAccess accessStrategy : accessStrategies ) { final DomainDataRegion region = accessStrategy.getRegion(); if ( ExtendedStatisticsSupport.class.isInstance( region ) ) { } if ( region instanceof ExtendedStatisticsSupport ) { if ( processedRegions == null ) { processedRegions = new HashSet<>(); } if ( processedRegions.add( region ) ) { count += ( (ExtendedStatisticsSupport) region ).getElementCountOnDisk(); } } } if ( count == 0 ) { return NO_EXTENDED_STAT_SUPPORT_RETURN; } return count; }
NaturalIdStatisticsImpl(EntityPersister rootEntityDescriptor) { super( () -> rootEntityDescriptor.getNaturalIdCacheAccessStrategy() != null ? rootEntityDescriptor.getNaturalIdCacheAccessStrategy().getRegion() : null ); this.rootEntityName = rootEntityDescriptor.getRootEntityName(); final ReadWriteLock lock = new ReentrantReadWriteLock(); this.readLock = lock.readLock(); this.writeLock = lock.writeLock(); }
@Override public void naturalIdQueryExecuted(String rootEntityName, long time) { naturalIdQueryExecutionCount.increment(); boolean isLongestQuery; //noinspection StatementWithEmptyBody for ( long old = naturalIdQueryExecutionMaxTime.get(); ( isLongestQuery = time > old ) && ( !naturalIdQueryExecutionMaxTime.compareAndSet( old, time ) ); old = naturalIdQueryExecutionMaxTime.get() ) { // nothing to do here given the odd loop structure... } if ( isLongestQuery ) { naturalIdQueryExecutionMaxTimeEntity = rootEntityName; } final EntityPersister rootEntityPersister = sessionFactory.getMetamodel().entityPersister( rootEntityName ); getNaturalIdStatistics( rootEntityName ).queryExecuted( time ); if ( rootEntityPersister.hasNaturalIdCache() ) { final String naturalIdRegionName = rootEntityPersister.getNaturalIdCacheAccessStrategy() .getRegion() .getName(); getNaturalIdCacheStatistics( qualify( naturalIdRegionName ) ).queryExecuted( time ); if ( isLongestQuery ) { naturalIdQueryExecutionMaxTimeRegion = naturalIdRegionName; } } }
factory.getStatistics().naturalIdCacheHit( StatsHelper.INSTANCE.getRootEntityRole( persister ), naturalIdCacheAccessStrategy.getRegion().getName() ); factory.getStatistics().naturalIdCacheMiss( StatsHelper.INSTANCE.getRootEntityRole( persister ), naturalIdCacheAccessStrategy.getRegion().getName() );
factory.getStatistics().naturalIdCachePut( StatsHelper.INSTANCE.getRootEntityRole( persister ), naturalIdCacheAccessStrategy.getRegion().getName() ); factory.getStatistics().naturalIdCachePut( StatsHelper.INSTANCE.getRootEntityRole( persister ), naturalIdCacheAccessStrategy.getRegion().getName() ); factory.getStatistics().naturalIdCachePut( StatsHelper.INSTANCE.getRootEntityRole( persister ), naturalIdCacheAccessStrategy.getRegion().getName() );
NaturalIdStatisticsImpl(EntityTypeDescriptor rootEntityDescriptor) { super( () -> rootEntityDescriptor.getHierarchy().getNaturalIdDescriptor().getCacheAccess() != null ? rootEntityDescriptor.getHierarchy().getNaturalIdDescriptor().getCacheAccess().getRegion() : null ); this.rootEntityName = rootEntityDescriptor.getEntityName(); final ReadWriteLock lock = new ReentrantReadWriteLock(); this.readLock = lock.readLock(); this.writeLock = lock.writeLock(); }
@Override public void naturalIdQueryExecuted(String rootEntityName, long time) { naturalIdQueryExecutionCount.increment(); boolean isLongestQuery; //noinspection StatementWithEmptyBody for ( long old = naturalIdQueryExecutionMaxTime.get(); ( isLongestQuery = time > old ) && ( !naturalIdQueryExecutionMaxTime.compareAndSet( old, time ) ); old = naturalIdQueryExecutionMaxTime.get() ) { // nothing to do here given the odd loop structure... } if ( isLongestQuery ) { naturalIdQueryExecutionMaxTimeEntity = rootEntityName; } final EntityTypeDescriptor rootEntityDescriptor = sessionFactory.getMetamodel().findEntityDescriptor( rootEntityName ); getNaturalIdStatistics( rootEntityName ).queryExecuted( time ); final String naturalIdRegionName = rootEntityDescriptor.getHierarchy().getNaturalIdDescriptor().getCacheAccess() .getRegion() .getName(); if ( isLongestQuery ) { naturalIdQueryExecutionMaxTimeRegion = naturalIdRegionName; } }
factory.getStatistics().naturalIdCachePut( descriptor.getNavigableRole(), cacheAccess.getRegion().getName() ); factory.getStatistics().naturalIdCachePut( descriptor.getNavigableRole(), cacheAccess.getRegion().getName() ); factory.getStatistics().naturalIdCachePut( descriptor.getNavigableRole(), cacheAccess.getRegion().getName() ); factory.getStatistics().naturalIdCachePut( descriptor.getNavigableRole(), cacheAccess.getRegion().getName() ); factory.getStatistics().naturalIdCachePut( descriptor.getNavigableRole(), cacheAccess.getRegion().getName() );