Examples of InfinispanRegionFactory


Examples of org.hibernate.cache.infinispan.InfinispanRegionFactory

      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.eviction.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, null);
         AdvancedCache cache = region.getCache();
         assertFalse(factory.getTypeOverrides().get("entity").isExposeStatistics());
         assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());

         region = (EntityRegionImpl) factory.buildEntityRegion("com.acme.Person", p, null);
         cache = region.getCache();
         assertFalse(factory.getTypeOverrides().get("com.acme.Person").isExposeStatistics());
         assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());

         final String query = "org.hibernate.cache.internal.StandardQueryCache";
         QueryResultsRegionImpl queryRegion = (QueryResultsRegionImpl) factory.buildQueryResultsRegion(query, p);
         cache = queryRegion.getCache();
         assertFalse(factory.getTypeOverrides().get("query").isExposeStatistics());
         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(factory.getTypeOverrides().get("timestamps").isExposeStatistics());
         assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());

         CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
               factory.buildCollectionRegion("com.acme.Person.addresses", p, null);
         cache = collectionRegion.getCache();
         assertFalse(factory.getTypeOverrides().get("collection").isExposeStatistics());
         assertFalse(cache.getCacheConfiguration().jmxStatistics().enabled());
      } finally {
         factory.stop();
      }
   }
View Full Code Here

Examples of org.hibernate.cache.infinispan.InfinispanRegionFactory

   private InfinispanRegionFactory createRegionFactory(Properties p) {
      return createRegionFactory(null, p);
   }

   private InfinispanRegionFactory createRegionFactory(final EmbeddedCacheManager manager, Properties p) {
      final InfinispanRegionFactory factory = new SingleNodeTestCase.TestInfinispanRegionFactory() {

         @Override
         protected org.infinispan.transaction.lookup.TransactionManagerLookup createTransactionManagerLookup(Settings settings, Properties properties) {
            return new HibernateTransactionManagerLookup(null, null) {
               @Override
               public TransactionManager getTransactionManager() throws Exception {
                  AbstractJtaPlatform jta = new JBossStandAloneJtaPlatform();
                  jta.injectServices(ServiceRegistryBuilder.buildServiceRegistry());
                  return jta.getTransactionManager();
               }
            };
         }

         @Override
         protected EmbeddedCacheManager createCacheManager(Properties properties) throws CacheException {
            if (manager != null)
               return manager;
            else
               return super.createCacheManager(properties);
         }

      };

      factory.start(null, p);
      return factory;
   }
View Full Code Here

Examples of org.hibernate.cache.infinispan.InfinispanRegionFactory

    evictOrRemoveTest();
  }

  private void evictOrRemoveTest() throws Exception {
    Configuration cfg = createConfiguration();
    InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
        new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).build(),
        cfg,
        getCacheTestSupport()
    );
    boolean invalidation = false;
View Full Code Here

Examples of org.hibernate.cache.infinispan.InfinispanRegionFactory

    evictOrRemoveAllTest( "entity" );
  }

  private void evictOrRemoveAllTest(String configName) throws Exception {
    Configuration cfg = createConfiguration();
    InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
        new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).build(),
        cfg,
        getCacheTestSupport()
    );
    AdvancedCache localCache = getInfinispanCache( regionFactory );
View Full Code Here

Examples of org.hibernate.cache.infinispan.InfinispanRegionFactory

  private void supportedAccessTypeTest() throws Exception {
    Configuration cfg = CacheTestUtil.buildConfiguration( "test", InfinispanRegionFactory.class, true, false );
    String entityCfg = "entity";
    cfg.setProperty( InfinispanRegionFactory.ENTITY_CACHE_RESOURCE_PROP, entityCfg );
    InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
        ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ),
        cfg,
        getCacheTestSupport()
    );
    supportedAccessTypeTest( regionFactory, cfg.getProperties() );
View Full Code Here

Examples of org.hibernate.cache.infinispan.InfinispanRegionFactory

  protected abstract void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties);

  @Test
  public void testIsTransactionAware() throws Exception {
    Configuration cfg = CacheTestUtil.buildConfiguration( "test", InfinispanRegionFactory.class, true, false );
    InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
        ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ),
        cfg,
        getCacheTestSupport()
    );
    TransactionalDataRegion region = (TransactionalDataRegion) createRegion(
View Full Code Here

Examples of org.hibernate.cache.infinispan.InfinispanRegionFactory

  }

  @Test
  public void testGetCacheDataDescription() throws Exception {
    Configuration cfg = CacheTestUtil.buildConfiguration( "test", InfinispanRegionFactory.class, true, false );
    InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
        ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() ),
        cfg,
        getCacheTestSupport()
    );
    TransactionalDataRegion region = (TransactionalDataRegion) createRegion(
View Full Code Here

Examples of org.hibernate.cache.infinispan.InfinispanRegionFactory

    return CacheTestUtil.buildCustomQueryCacheConfiguration( "test", "replicated-query" );
  }

  private void putDoesNotBlockGetTest() throws Exception {
    Configuration cfg = createConfiguration();
    InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
        new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).build(),
        cfg,
        getCacheTestSupport()
    );

    // Sleep a bit to avoid concurrent FLUSH problem
    avoidConcurrentFlush();

    final QueryResultsRegion region = regionFactory.buildQueryResultsRegion(
        getStandardRegionName( REGION_PREFIX ),
        cfg.getProperties()
    );

    region.put( KEY, VALUE1 );
View Full Code Here

Examples of org.hibernate.cache.infinispan.InfinispanRegionFactory

    getDoesNotBlockPutTest();
  }

  private void getDoesNotBlockPutTest() throws Exception {
    Configuration cfg = createConfiguration();
    InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
        new StandardServiceRegistryBuilder().applySettings( cfg.getProperties() ).build(),
        cfg,
        getCacheTestSupport()
    );

    // Sleep a bit to avoid concurrent FLUSH problem
    avoidConcurrentFlush();

    final QueryResultsRegion region = regionFactory.buildQueryResultsRegion(
        getStandardRegionName( REGION_PREFIX ),
        cfg.getProperties()
    );

    region.put( KEY, VALUE1 );
View Full Code Here

Examples of org.hibernate.cache.infinispan.InfinispanRegionFactory

      p.setProperty("hibernate.cache.infinispan.query.cfg", "my-query-cache");
      p.setProperty("hibernate.cache.infinispan.query.eviction.strategy", "LIRS");
      p.setProperty("hibernate.cache.infinispan.query.eviction.wake_up_interval", "3000");
      p.setProperty("hibernate.cache.infinispan.query.eviction.max_entries", "10000");

      InfinispanRegionFactory factory = createRegionFactory(p);

      try {
         assertEquals("entity", factory.getTypeOverrides().get("entity").getCacheName());
         assertEquals("entity", factory.getTypeOverrides().get("collection").getCacheName());
         assertEquals("timestamps", factory.getTypeOverrides().get("timestamps").getCacheName());

         assertEquals("person-cache", factory.getTypeOverrides().get(person).getCacheName());
         assertEquals(EvictionStrategy.LRU, factory.getTypeOverrides().get(person).getEvictionStrategy());
         assertEquals(2000, factory.getTypeOverrides().get(person).getEvictionWakeUpInterval());
         assertEquals(5000, factory.getTypeOverrides().get(person).getEvictionMaxEntries());
         assertEquals(60000, factory.getTypeOverrides().get(person).getExpirationLifespan());
         assertEquals(30000, factory.getTypeOverrides().get(person).getExpirationMaxIdle());

         assertEquals("person-addresses-cache", factory.getTypeOverrides().get(addresses).getCacheName());
         assertEquals(120000, factory.getTypeOverrides().get(addresses).getExpirationLifespan());
         assertEquals(60000, factory.getTypeOverrides().get(addresses).getExpirationMaxIdle());

         assertEquals("my-query-cache", factory.getTypeOverrides().get("query").getCacheName());
         assertEquals(EvictionStrategy.LIRS, factory.getTypeOverrides().get("query").getEvictionStrategy());
         assertEquals(3000, factory.getTypeOverrides().get("query").getEvictionWakeUpInterval());
         assertEquals(10000, factory.getTypeOverrides().get("query").getEvictionMaxEntries());
      } finally {
         factory.stop();
      }
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.