org.hibernate.cache.spi.QueryResultsRegion Java Examples

The following examples show how to use org.hibernate.cache.spi.QueryResultsRegion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StatisticsImpl.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public CacheRegionStatisticsImpl getDomainDataRegionStatistics(String regionName) {
	if ( sessionFactory == null ) {
		return null;
	}

	return l2CacheStatsMap.computeIfAbsent(
			regionName,
			s -> {
				final Region region = sessionFactory.getCache().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 );
			}
	);
}
 
Example #2
Source File: RegionFactoryTemplate.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public QueryResultsRegion buildQueryResultsRegion(
		String regionName,
		SessionFactoryImplementor sessionFactory) {
	verifyStarted();
	return new QueryResultsRegionTemplate(
			regionName,
			this,
			createQueryResultsRegionStorageAccess( regionName, sessionFactory )
	);
}
 
Example #3
Source File: EnabledCaching.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public EnabledCaching(SessionFactoryImplementor sessionFactory) {
	this.sessionFactory = sessionFactory;

	this.regionFactory = getSessionFactory().getSessionFactoryOptions().getServiceRegistry().getService( RegionFactory.class );
	this.regionFactory.start( sessionFactory.getSessionFactoryOptions(), sessionFactory.getProperties() );

	if ( getSessionFactory().getSessionFactoryOptions().isQueryCacheEnabled() ) {
		final TimestampsRegion timestampsRegion = regionFactory.buildTimestampsRegion(
				RegionFactory.DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME,
				sessionFactory
		);
		timestampsCache = sessionFactory.getSessionFactoryOptions()
				.getTimestampsCacheFactory()
				.buildTimestampsCache( this, timestampsRegion );
		legacySecondLevelCacheNames.add( timestampsRegion.getName() );

		final QueryResultsRegion queryResultsRegion = regionFactory.buildQueryResultsRegion(
				RegionFactory.DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME,
				sessionFactory
		);
		regionsByName.put( queryResultsRegion.getName(), queryResultsRegion );
		defaultQueryResultsCache = new QueryResultsCacheImpl(
				queryResultsRegion,
				timestampsCache
		);
	}
	else {
		timestampsCache = new TimestampsCacheDisabledImpl();
		defaultQueryResultsCache = null;
	}
}
 
Example #4
Source File: EnabledCaching.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected QueryResultsCache makeQueryResultsRegionAccess(String regionName) {
	final QueryResultsRegion region = (QueryResultsRegion) regionsByName.computeIfAbsent(
			regionName,
			this::makeQueryResultsRegion
	);
	final QueryResultsCacheImpl regionAccess = new QueryResultsCacheImpl(
			region,
			timestampsCache
	);
	namedQueryResultsCacheMap.put( regionName, regionAccess );
	legacySecondLevelCacheNames.add( regionName );
	return regionAccess;
}
 
Example #5
Source File: EnabledCaching.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected QueryResultsRegion makeQueryResultsRegion(String regionName) {
	// make sure there is not an existing domain-data region with that name..
	final Region existing = regionsByName.get( regionName );
	if ( existing != null ) {
		if ( !QueryResultsRegion.class.isInstance( existing ) ) {
			throw new IllegalStateException( "Cannot store both domain-data and query-result-data in the same region [" + regionName );
		}

		throw new IllegalStateException( "Illegal call to create QueryResultsRegion - one already existed" );
	}

	return regionFactory.buildQueryResultsRegion( regionName, getSessionFactory() );
}
 
Example #6
Source File: HibernateRegionFactory.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties props)
    throws CacheException {
    return new HibernateQueryResultsRegion(this,
        regionName,
        accessStgyFactory.node(),
        accessStgyFactory.regionCache(regionName));
}
 
Example #7
Source File: HibernateRegionFactory.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties props)
    throws CacheException {
    return new HibernateQueryResultsRegion(this,
        regionName,
        accessStgyFactory.node(),
        accessStgyFactory.regionCache(regionName));
}
 
Example #8
Source File: RedissonRegionFactory.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Override
public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException {
    log.debug("Building query cache region: " + regionName);
    
    RMapCache<Object, Object> mapCache = getCache(regionName, properties, QUERY_DEF);
    return new RedissonQueryRegion(mapCache, ((Redisson)redisson).getConnectionManager(),this, properties, QUERY_DEF);
}
 
Example #9
Source File: QueryResultsCacheImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
QueryResultsCacheImpl(
		QueryResultsRegion cacheRegion,
		TimestampsCache timestampsCache) {
	this.cacheRegion = cacheRegion;
	this.timestampsCache = timestampsCache;
}
 
Example #10
Source File: QueryResultsCacheImpl.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public QueryResultsRegion getRegion() {
	return cacheRegion;
}
 
Example #11
Source File: NoCachingRegionFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public QueryResultsRegion buildQueryResultsRegion(
		String regionName, SessionFactoryImplementor sessionFactory) {
	throw new NoCacheRegionFactoryAvailableException();
}
 
Example #12
Source File: HibernateRegionFactory.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public QueryResultsRegion buildQueryResultsRegion(String regionName, SessionFactoryImplementor sessFactory) {
    return new IgniteQueryResultsRegion(this, regionName, accessStgyFactory.node(),
        accessStgyFactory.regionCache(regionName));
}