Search in sources :

Example 1 with TimestampsRegionImpl

use of org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl in project hibernate-orm by hibernate.

the class InfinispanRegionFactory method buildTimestampsRegion.

@Override
public TimestampsRegion buildTimestampsRegion(String regionName, Map<String, Object> configValues) {
    if (log.isDebugEnabled()) {
        log.debug("Building timestamps cache region [" + regionName + "]");
    }
    final AdvancedCache cache = getCache(regionName, DataType.TIMESTAMPS, null);
    final TimestampsRegionImpl region = createTimestampsRegion(cache, regionName);
    startRegion(region);
    return region;
}
Also used : TimestampsRegionImpl(org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl) ClusteredTimestampsRegionImpl(org.hibernate.cache.infinispan.timestamp.ClusteredTimestampsRegionImpl) AdvancedCache(org.infinispan.AdvancedCache)

Example 2 with TimestampsRegionImpl

use of org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl in project hibernate-orm by hibernate.

the class InfinispanRegionFactoryTestCase method testBuildTimestampsRegionWithNoneEvictionOverride.

@Test
public void testBuildTimestampsRegionWithNoneEvictionOverride() {
    final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
    final String timestampsNoEviction = "timestamps-no-eviction";
    Properties p = createProperties();
    p.setProperty("hibernate.cache.infinispan.timestamps.cfg", timestampsNoEviction);
    p.setProperty("hibernate.cache.infinispan.timestamps.eviction.strategy", "NONE");
    p.setProperty("hibernate.cache.infinispan.timestamps.eviction.max_entries", "0");
    p.setProperty("hibernate.cache.infinispan.timestamps.expiration.wake_up_interval", "3000");
    InfinispanRegionFactory factory = createRegionFactory(p);
    try {
        TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
        assertTrue(isDefinedCache(factory, timestamps));
        assertEquals(3000, region.getCache().getCacheConfiguration().expiration().wakeUpInterval());
    } finally {
        factory.stop();
    }
}
Also used : TimestampsRegionImpl(org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl) InfinispanRegionFactory(org.hibernate.cache.infinispan.InfinispanRegionFactory) Properties(java.util.Properties) Test(org.junit.Test)

Example 3 with TimestampsRegionImpl

use of org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl in project hibernate-orm by hibernate.

the class InfinispanRegionFactoryTestCase method testEnableStatistics.

@Test
public void testEnableStatistics() {
    Properties p = createProperties();
    p.setProperty("hibernate.cache.infinispan.statistics", "true");
    p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.lifespan", "60000");
    p.setProperty("hibernate.cache.infinispan.com.acme.Person.expiration.max_idle", "30000");
    p.setProperty("hibernate.cache.infinispan.entity.cfg", "myentity-cache");
    p.setProperty("hibernate.cache.infinispan.entity.eviction.strategy", "FIFO");
    p.setProperty("hibernate.cache.infinispan.entity.expiration.wake_up_interval", "3000");
    p.setProperty("hibernate.cache.infinispan.entity.eviction.max_entries", "10000");
    InfinispanRegionFactory factory = createRegionFactory(p);
    try {
        EmbeddedCacheManager manager = factory.getCacheManager();
        assertTrue(manager.getCacheManagerConfiguration().globalJmxStatistics().enabled());
        EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, MUTABLE_NON_VERSIONED);
        AdvancedCache cache = region.getCache();
        assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
        region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, MUTABLE_NON_VERSIONED);
        cache = region.getCache();
        assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
        final String query = "org.hibernate.cache.internal.StandardQueryCache";
        QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
        cache = queryRegion.getCache();
        assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
        final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
        ConfigurationBuilder builder = new ConfigurationBuilder();
        builder.clustering().stateTransfer().fetchInMemoryState(true);
        manager.defineConfiguration("timestamps", builder.build());
        TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
        cache = timestampsRegion.getCache();
        assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
        CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion("com.acme.Person.addresses", p, MUTABLE_NON_VERSIONED);
        cache = collectionRegion.getCache();
        assertTrue(cache.getCacheConfiguration().jmxStatistics().enabled());
    } finally {
        factory.stop();
    }
}
Also used : QueryResultsRegionImpl(org.hibernate.cache.infinispan.query.QueryResultsRegionImpl) TimestampsRegionImpl(org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) InfinispanRegionFactory(org.hibernate.cache.infinispan.InfinispanRegionFactory) EntityRegionImpl(org.hibernate.cache.infinispan.entity.EntityRegionImpl) CollectionRegionImpl(org.hibernate.cache.infinispan.collection.CollectionRegionImpl) AdvancedCache(org.infinispan.AdvancedCache) Properties(java.util.Properties) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) Test(org.junit.Test)

Example 4 with TimestampsRegionImpl

use of org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl in project hibernate-orm by hibernate.

the class InfinispanRegionFactoryTestCase method testBuildDefaultTimestampsRegion.

@Test
public void testBuildDefaultTimestampsRegion() {
    final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
    Properties p = createProperties();
    InfinispanRegionFactory factory = createRegionFactory(p);
    try {
        assertTrue(isDefinedCache(factory, DEF_TIMESTAMPS_RESOURCE));
        TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
        AdvancedCache cache = region.getCache();
        assertEquals(timestamps, cache.getName());
        Configuration cacheCfg = cache.getCacheConfiguration();
        assertEquals(EvictionStrategy.NONE, cacheCfg.eviction().strategy());
        assertEquals(CacheMode.REPL_ASYNC, cacheCfg.clustering().cacheMode());
        assertFalse(cacheCfg.jmxStatistics().enabled());
    } finally {
        factory.stop();
    }
}
Also used : TimestampsRegionImpl(org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl) InfinispanRegionFactory(org.hibernate.cache.infinispan.InfinispanRegionFactory) Configuration(org.infinispan.configuration.cache.Configuration) AdvancedCache(org.infinispan.AdvancedCache) Properties(java.util.Properties) Test(org.junit.Test)

Example 5 with TimestampsRegionImpl

use of org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl in project hibernate-orm by hibernate.

the class InfinispanRegionFactoryTestCase method testTimestampValidation.

@Test(expected = CacheException.class)
public void testTimestampValidation() {
    final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
    Properties p = createProperties();
    InputStream configStream = FileLookupFactory.newInstance().lookupFile(InfinispanRegionFactory.DEF_INFINISPAN_CONFIG_RESOURCE, getClass().getClassLoader());
    ConfigurationBuilderHolder cbh = new ParserRegistry().parse(configStream);
    DefaultCacheManager manager = new DefaultCacheManager(cbh, true);
    ConfigurationBuilder builder = new ConfigurationBuilder();
    builder.clustering().cacheMode(CacheMode.INVALIDATION_SYNC);
    manager.defineConfiguration(DEF_TIMESTAMPS_RESOURCE, builder.build());
    try {
        InfinispanRegionFactory factory = createRegionFactory(manager, p, null);
        factory.start(CacheTestUtil.sfOptionsForStart(), p);
        TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
        fail("Should have failed saying that invalidation is not allowed for timestamp caches.");
    } finally {
        TestingUtil.killCacheManagers(manager);
    }
}
Also used : TimestampsRegionImpl(org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl) DefaultCacheManager(org.infinispan.manager.DefaultCacheManager) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ConfigurationBuilderHolder(org.infinispan.configuration.parsing.ConfigurationBuilderHolder) InfinispanRegionFactory(org.hibernate.cache.infinispan.InfinispanRegionFactory) InputStream(java.io.InputStream) ParserRegistry(org.infinispan.configuration.parsing.ParserRegistry) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

TimestampsRegionImpl (org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl)9 Properties (java.util.Properties)8 InfinispanRegionFactory (org.hibernate.cache.infinispan.InfinispanRegionFactory)7 Test (org.junit.Test)7 AdvancedCache (org.infinispan.AdvancedCache)5 ClusteringConfigurationBuilder (org.infinispan.configuration.cache.ClusteringConfigurationBuilder)5 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)5 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)5 CollectionRegionImpl (org.hibernate.cache.infinispan.collection.CollectionRegionImpl)2 EntityRegionImpl (org.hibernate.cache.infinispan.entity.EntityRegionImpl)2 QueryResultsRegionImpl (org.hibernate.cache.infinispan.query.QueryResultsRegionImpl)2 Configuration (org.infinispan.configuration.cache.Configuration)2 InputStream (java.io.InputStream)1 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)1 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)1 ClusteredTimestampsRegionImpl (org.hibernate.cache.infinispan.timestamp.ClusteredTimestampsRegionImpl)1 Account (org.hibernate.test.cache.infinispan.functional.entities.Account)1 AccountHolder (org.hibernate.test.cache.infinispan.functional.entities.AccountHolder)1 TestInfinispanRegionFactory (org.hibernate.test.cache.infinispan.util.TestInfinispanRegionFactory)1 ConfigurationBuilderHolder (org.infinispan.configuration.parsing.ConfigurationBuilderHolder)1