HHH-14662 Remove unnecessary statuful lambda instances from StatisticsImpl
This commit is contained in:
parent
3443541f6c
commit
40ed10e9fa
|
@ -224,7 +224,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service, Manageabl
|
||||||
public EntityStatisticsImpl getEntityStatistics(String entityName) {
|
public EntityStatisticsImpl getEntityStatistics(String entityName) {
|
||||||
return entityStatsMap.getOrCompute(
|
return entityStatsMap.getOrCompute(
|
||||||
entityName,
|
entityName,
|
||||||
s -> new EntityStatisticsImpl( metamodel.entityPersister( s ) )
|
this::instantiateEntityStatistics
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service, Manageabl
|
||||||
public CollectionStatisticsImpl getCollectionStatistics(String role) {
|
public CollectionStatisticsImpl getCollectionStatistics(String role) {
|
||||||
return collectionStatsMap.getOrCompute(
|
return collectionStatsMap.getOrCompute(
|
||||||
role,
|
role,
|
||||||
s -> new CollectionStatisticsImpl( metamodel.collectionPersister( s ) )
|
this::instantiateCollectionStatistics
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,13 +416,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service, Manageabl
|
||||||
public NaturalIdStatisticsImpl getNaturalIdStatistics(String rootEntityName) {
|
public NaturalIdStatisticsImpl getNaturalIdStatistics(String rootEntityName) {
|
||||||
return naturalIdQueryStatsMap.getOrCompute(
|
return naturalIdQueryStatsMap.getOrCompute(
|
||||||
rootEntityName,
|
rootEntityName,
|
||||||
s -> {
|
this::instantiateNaturalStatistics
|
||||||
final EntityPersister entityDescriptor = metamodel.entityPersister( s );
|
|
||||||
if ( !entityDescriptor.hasNaturalIdentifier() ) {
|
|
||||||
throw new IllegalArgumentException( "Given entity [" + s + "] does not define natural-id" );
|
|
||||||
}
|
|
||||||
return new NaturalIdStatisticsImpl( entityDescriptor );
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,10 +425,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service, Manageabl
|
||||||
final String key = cache.unqualifyRegionName( regionName );
|
final String key = cache.unqualifyRegionName( regionName );
|
||||||
return deprecatedNaturalIdStatsMap.getOrCompute(
|
return deprecatedNaturalIdStatsMap.getOrCompute(
|
||||||
key,
|
key,
|
||||||
unqualifiedRegionName -> new DeprecatedNaturalIdCacheStatisticsImpl(
|
this::instantiateDeprecatedNaturalIdCacheStatistics
|
||||||
unqualifiedRegionName,
|
|
||||||
cache.getNaturalIdAccessesInRegion( unqualifiedRegionName )
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,21 +554,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service, Manageabl
|
||||||
public CacheRegionStatisticsImpl getDomainDataRegionStatistics(String regionName) {
|
public CacheRegionStatisticsImpl getDomainDataRegionStatistics(String regionName) {
|
||||||
return l2CacheStatsMap.getOrCompute(
|
return l2CacheStatsMap.getOrCompute(
|
||||||
regionName,
|
regionName,
|
||||||
s -> {
|
this::instantiateCacheRegionStatistics
|
||||||
final Region region = cache.getRegion( s );
|
|
||||||
|
|
||||||
if ( region == null ) {
|
|
||||||
throw new IllegalArgumentException( "Unknown cache region : " + s );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( region instanceof QueryResultsRegion ) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Region name [" + s + "] referred to a query result region, not a domain data region"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new CacheRegionStatisticsImpl( region );
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,22 +585,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service, Manageabl
|
||||||
|
|
||||||
return l2CacheStatsMap.getOrCompute(
|
return l2CacheStatsMap.getOrCompute(
|
||||||
regionName,
|
regionName,
|
||||||
s -> {
|
this::createCacheRegionStatistics
|
||||||
Region region = cache.getRegion( s );
|
|
||||||
|
|
||||||
if ( region == null ) {
|
|
||||||
|
|
||||||
if ( ! queryCacheEnabled ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is the pre-5.3 behavior. and since this is a pre-5.3 method it should behave consistently
|
|
||||||
// NOTE that this method is deprecated
|
|
||||||
region = cache.getQueryResultsCache( s ).getRegion();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new CacheRegionStatisticsImpl( region );
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -690,7 +652,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service, Manageabl
|
||||||
public QueryStatisticsImpl getQueryStatistics(String queryString) {
|
public QueryStatisticsImpl getQueryStatistics(String queryString) {
|
||||||
return queryStatsMap.getOrCompute(
|
return queryStatsMap.getOrCompute(
|
||||||
queryString,
|
queryString,
|
||||||
s -> new QueryStatisticsImpl( s )
|
QueryStatisticsImpl::new
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,7 +787,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service, Manageabl
|
||||||
private CacheRegionStatisticsImpl getQueryRegionStats(String regionName) {
|
private CacheRegionStatisticsImpl getQueryRegionStats(String regionName) {
|
||||||
return l2CacheStatsMap.getOrCompute(
|
return l2CacheStatsMap.getOrCompute(
|
||||||
regionName,
|
regionName,
|
||||||
s -> new CacheRegionStatisticsImpl( cache.getQueryResultsCache( regionName ).getRegion() )
|
this::instantiateCacheRegionStatsForQueryResults
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,4 +960,64 @@ public class StatisticsImpl implements StatisticsImplementor, Service, Manageabl
|
||||||
.append( ']' )
|
.append( ']' )
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EntityStatisticsImpl instantiateEntityStatistics(final String entityName) {
|
||||||
|
return new EntityStatisticsImpl( metamodel.entityPersister( entityName ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private CollectionStatisticsImpl instantiateCollectionStatistics(final String role) {
|
||||||
|
return new CollectionStatisticsImpl( metamodel.collectionPersister( role ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private NaturalIdStatisticsImpl instantiateNaturalStatistics(final String entityName) {
|
||||||
|
final EntityPersister entityDescriptor = metamodel.entityPersister( entityName );
|
||||||
|
if ( !entityDescriptor.hasNaturalIdentifier() ) {
|
||||||
|
throw new IllegalArgumentException( "Given entity [" + entityName + "] does not define natural-id" );
|
||||||
|
}
|
||||||
|
return new NaturalIdStatisticsImpl( entityDescriptor );
|
||||||
|
}
|
||||||
|
|
||||||
|
private DeprecatedNaturalIdCacheStatisticsImpl instantiateDeprecatedNaturalIdCacheStatistics(final String unqualifiedRegionName) {
|
||||||
|
return new DeprecatedNaturalIdCacheStatisticsImpl(
|
||||||
|
unqualifiedRegionName,
|
||||||
|
cache.getNaturalIdAccessesInRegion( unqualifiedRegionName )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CacheRegionStatisticsImpl instantiateCacheRegionStatistics(final String regionName) {
|
||||||
|
final Region region = cache.getRegion( regionName );
|
||||||
|
|
||||||
|
if ( region == null ) {
|
||||||
|
throw new IllegalArgumentException( "Unknown cache region : " + regionName );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( region instanceof QueryResultsRegion ) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
"Region name [" + regionName + "] referred to a query result region, not a domain data region"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CacheRegionStatisticsImpl( region );
|
||||||
|
}
|
||||||
|
|
||||||
|
private CacheRegionStatisticsImpl instantiateCacheRegionStatsForQueryResults(final String regionName) {
|
||||||
|
return new CacheRegionStatisticsImpl( cache.getQueryResultsCache( regionName ).getRegion() );
|
||||||
|
}
|
||||||
|
|
||||||
|
private CacheRegionStatisticsImpl createCacheRegionStatistics(final String regionName) {
|
||||||
|
Region region = cache.getRegion( regionName );
|
||||||
|
|
||||||
|
if ( region == null ) {
|
||||||
|
|
||||||
|
if ( !queryCacheEnabled ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is the pre-5.3 behavior. and since this is a pre-5.3 method it should behave consistently
|
||||||
|
// NOTE that this method is deprecated
|
||||||
|
region = cache.getQueryResultsCache( regionName ).getRegion();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new CacheRegionStatisticsImpl( region );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue