Search in sources :

Example 16 with InfinispanRegionFactory

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

the class InfinispanRegionFactoryTestCase method testBuildTimestampsRegionWithCacheNameOverride.

@Test
public void testBuildTimestampsRegionWithCacheNameOverride() {
    final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
    final String myTimestampsCache = "mytimestamps-cache";
    Properties p = createProperties();
    p.setProperty(TIMESTAMPS_CACHE_RESOURCE_PROP, myTimestampsCache);
    InfinispanRegionFactory factory = createRegionFactory(p, (f, m) -> {
        ClusteringConfigurationBuilder builder = new ConfigurationBuilder().clustering().cacheMode(CacheMode.LOCAL);
        m.defineConfiguration(myTimestampsCache, builder.build());
    });
    try {
        TimestampsRegionImpl region = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
        assertTrue(isDefinedCache(factory, timestamps));
        // default timestamps cache is async replicated
        assertEquals(CacheMode.LOCAL, region.getCache().getCacheConfiguration().clustering().cacheMode());
    } finally {
        factory.stop();
    }
}
Also used : 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) ClusteringConfigurationBuilder(org.infinispan.configuration.cache.ClusteringConfigurationBuilder) Properties(java.util.Properties) Test(org.junit.Test)

Example 17 with InfinispanRegionFactory

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

the class InfinispanRegionFactoryTestCase method testDefaultPendingPutsCache.

@Test
public void testDefaultPendingPutsCache() {
    Properties p = createProperties();
    InfinispanRegionFactory factory = createRegionFactory(p);
    try {
        Configuration ppConfig = factory.getCacheManager().getCacheConfiguration(DEF_PENDING_PUTS_RESOURCE);
        assertTrue(ppConfig.isTemplate());
        assertFalse(ppConfig.clustering().cacheMode().isClustered());
        assertTrue(ppConfig.simpleCache());
        assertEquals(TransactionMode.NON_TRANSACTIONAL, ppConfig.transaction().transactionMode());
        assertEquals(60000, ppConfig.expiration().maxIdle());
        assertFalse(ppConfig.jmxStatistics().enabled());
        assertFalse(ppConfig.jmxStatistics().available());
    } finally {
        factory.stop();
    }
}
Also used : InfinispanRegionFactory(org.hibernate.cache.infinispan.InfinispanRegionFactory) Configuration(org.infinispan.configuration.cache.Configuration) Properties(java.util.Properties) Test(org.junit.Test)

Example 18 with InfinispanRegionFactory

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

the class InfinispanRegionFactoryTestCase method testDisableStatistics.

@Test
public void testDisableStatistics() {
    Properties p = createProperties();
    p.setProperty("hibernate.cache.infinispan.statistics", "false");
    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 {
        EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Address", p, MUTABLE_NON_VERSIONED);
        AdvancedCache cache = region.getCache();
        assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
        region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, MUTABLE_NON_VERSIONED);
        cache = region.getCache();
        assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
        final String query = "org.hibernate.cache.internal.StandardQueryCache";
        QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
        cache = queryRegion.getCache();
        assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
        final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache";
        ConfigurationBuilder builder = new ConfigurationBuilder();
        builder.clustering().stateTransfer().fetchInMemoryState(true);
        factory.getCacheManager().defineConfiguration("timestamps", builder.build());
        TimestampsRegionImpl timestampsRegion = (TimestampsRegionImpl) factory.buildTimestampsRegion(timestamps, p);
        cache = timestampsRegion.getCache();
        assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
        CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion("com.acme.Person.addresses", p, MUTABLE_NON_VERSIONED);
        cache = collectionRegion.getCache();
        assertFalse(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) Test(org.junit.Test)

Example 19 with InfinispanRegionFactory

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

the class AbstractEntityCollectionRegionTest method supportedAccessTypeTest.

private void supportedAccessTypeTest() throws Exception {
    StandardServiceRegistryBuilder ssrb = createStandardServiceRegistryBuilder();
    final StandardServiceRegistry registry = ssrb.build();
    try {
        InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(registry, getCacheTestSupport());
        supportedAccessTypeTest(regionFactory, CacheTestUtil.toProperties(ssrb.getSettings()));
    } finally {
        StandardServiceRegistryBuilder.destroy(registry);
    }
}
Also used : InfinispanRegionFactory(org.hibernate.cache.infinispan.InfinispanRegionFactory) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry)

Example 20 with InfinispanRegionFactory

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

the class AbstractEntityCollectionRegionTest method testIsTransactionAware.

@Test
public void testIsTransactionAware() throws Exception {
    StandardServiceRegistryBuilder ssrb = CacheTestUtil.buildBaselineStandardServiceRegistryBuilder("test", InfinispanRegionFactory.class, true, false, jtaPlatform);
    final StandardServiceRegistry registry = ssrb.build();
    try {
        Properties properties = CacheTestUtil.toProperties(ssrb.getSettings());
        InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(registry, getCacheTestSupport());
        TransactionalDataRegion region = (TransactionalDataRegion) createRegion(regionFactory, "test/test", properties, getCacheDataDescription());
        assertTrue("Region is transaction-aware", region.isTransactionAware());
        CacheTestUtil.stopRegionFactory(regionFactory, getCacheTestSupport());
    } finally {
        StandardServiceRegistryBuilder.destroy(registry);
    }
}
Also used : InfinispanRegionFactory(org.hibernate.cache.infinispan.InfinispanRegionFactory) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) TransactionalDataRegion(org.hibernate.cache.spi.TransactionalDataRegion) Properties(java.util.Properties) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) Test(org.junit.Test)

Aggregations

InfinispanRegionFactory (org.hibernate.cache.infinispan.InfinispanRegionFactory)20 Properties (java.util.Properties)16 Test (org.junit.Test)13 TimestampsRegionImpl (org.hibernate.cache.infinispan.timestamp.TimestampsRegionImpl)7 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)6 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)5 TestInfinispanRegionFactory (org.hibernate.test.cache.infinispan.util.TestInfinispanRegionFactory)5 Configuration (org.infinispan.configuration.cache.Configuration)5 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)5 AdvancedCache (org.infinispan.AdvancedCache)4 ClusteringConfigurationBuilder (org.infinispan.configuration.cache.ClusteringConfigurationBuilder)4 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)4 QueryResultsRegionImpl (org.hibernate.cache.infinispan.query.QueryResultsRegionImpl)3 TimeoutException (java.util.concurrent.TimeoutException)2 CollectionRegionImpl (org.hibernate.cache.infinispan.collection.CollectionRegionImpl)2 EntityRegionImpl (org.hibernate.cache.infinispan.entity.EntityRegionImpl)2 TransactionalDataRegion (org.hibernate.cache.spi.TransactionalDataRegion)2 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1