Package org.hibernate.cache.infinispan

Examples of org.hibernate.cache.infinispan.InfinispanRegionFactory


      p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.expiration.max_idle", "35000");
      p.setProperty("hibernate.cache.infinispan.collection.cfg", "mycollection-cache");
      p.setProperty("hibernate.cache.infinispan.collection.eviction.strategy", "LRU");
      p.setProperty("hibernate.cache.infinispan.collection.eviction.wake_up_interval", "3500");
      p.setProperty("hibernate.cache.infinispan.collection.eviction.max_entries", "25000");
      InfinispanRegionFactory factory = createRegionFactory(p);
      try {
         EmbeddedCacheManager manager = factory.getCacheManager();
         assertFalse(manager.getCacheManagerConfiguration()
               .globalJmxStatistics().enabled());
         assertNotNull(factory.getTypeOverrides().get(person));
         assertFalse(factory.getDefinedConfigurations().contains(person));
         assertNotNull(factory.getTypeOverrides().get(addresses));
         assertFalse(factory.getDefinedConfigurations().contains(addresses));
         AdvancedCache cache;

         EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion(person, p, null);
         assertNotNull(factory.getTypeOverrides().get(person));
         assertTrue(factory.getDefinedConfigurations().contains(person));
         assertNull(factory.getTypeOverrides().get(address));
         cache = region.getCache();
         Configuration cacheCfg = cache.getCacheConfiguration();
         assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
         assertEquals(2000, cacheCfg.expiration().wakeUpInterval());
         assertEquals(5000, cacheCfg.eviction().maxEntries());
         assertEquals(60000, cacheCfg.expiration().lifespan());
         assertEquals(30000, cacheCfg.expiration().maxIdle());
         assertFalse(cacheCfg.jmxStatistics().enabled());

         region = (EntityRegionImpl) factory.buildEntityRegion(address, p, null);
         assertNotNull(factory.getTypeOverrides().get(person));
         assertTrue(factory.getDefinedConfigurations().contains(person));
         assertNull(factory.getTypeOverrides().get(address));
         cache = region.getCache();
         cacheCfg = cache.getCacheConfiguration();
         assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
         assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
         assertEquals(20000, cacheCfg.eviction().maxEntries());
         assertFalse(cacheCfg.jmxStatistics().enabled());

         region = (EntityRegionImpl) factory.buildEntityRegion(car, p, null);
         assertNotNull(factory.getTypeOverrides().get(person));
         assertTrue(factory.getDefinedConfigurations().contains(person));
         assertNull(factory.getTypeOverrides().get(address));
         cache = region.getCache();
         cacheCfg = cache.getCacheConfiguration();
         assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
         assertEquals(3000, cacheCfg.expiration().wakeUpInterval());
         assertEquals(20000, cacheCfg.eviction().maxEntries());
         assertFalse(cacheCfg.jmxStatistics().enabled());

         CollectionRegionImpl collectionRegion = (CollectionRegionImpl)
               factory.buildCollectionRegion(addresses, p, null);
         assertNotNull(factory.getTypeOverrides().get(addresses));
         assertTrue(factory.getDefinedConfigurations().contains(person));
         assertNull(factory.getTypeOverrides().get(parts));
         cache = collectionRegion .getCache();
         cacheCfg = cache.getCacheConfiguration();
         assertEquals(EvictionStrategy.LIRS, cacheCfg.eviction().strategy());
         assertEquals(2500, cacheCfg.expiration().wakeUpInterval());
         assertEquals(5500, cacheCfg.eviction().maxEntries());
         assertEquals(65000, cacheCfg.expiration().lifespan());
         assertEquals(35000, cacheCfg.expiration().maxIdle());
         assertFalse(cacheCfg.jmxStatistics().enabled());

         collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, null);
         assertNotNull(factory.getTypeOverrides().get(addresses));
         assertTrue(factory.getDefinedConfigurations().contains(addresses));
         assertNull(factory.getTypeOverrides().get(parts));
         cache = collectionRegion.getCache();
         cacheCfg = cache.getCacheConfiguration();
         assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
         assertEquals(3500, cacheCfg.expiration().wakeUpInterval());
         assertEquals(25000, cacheCfg.eviction().maxEntries());
         assertFalse(cacheCfg.jmxStatistics().enabled());

         collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, null);
         assertNotNull(factory.getTypeOverrides().get(addresses));
         assertTrue(factory.getDefinedConfigurations().contains(addresses));
         assertNull(factory.getTypeOverrides().get(parts));
         cache = collectionRegion.getCache();
         cacheCfg = cache.getCacheConfiguration();
         assertEquals(EvictionStrategy.LRU, cacheCfg.eviction().strategy());
         assertEquals(3500, cacheCfg.expiration().wakeUpInterval());
         assertEquals(25000, cacheCfg.eviction().maxEntries());
         assertFalse(cacheCfg.jmxStatistics().enabled());
      } finally {
         factory.stop();
      }
   }
View Full Code Here


    getDoesNotBlockPutTest();
  }

  private void getDoesNotBlockPutTest() throws Exception {
    Configuration cfg = createConfiguration();
    InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
        new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
        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

    evictOrRemoveTest();
  }

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

    evictOrRemoveAllTest( "entity" );
  }

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

  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

  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

  }

  @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

      return regionFactory.getCacheManager().getCache("timestamps").getAdvancedCache();
   }

   public void testClearTimestampsRegionInIsolated() throws Exception {
      Configuration cfg = createConfiguration();
      InfinispanRegionFactory regionFactory = CacheTestUtil.startRegionFactory(
        new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
        cfg,
        getCacheTestSupport()
    );
      // Sleep a bit to avoid concurrent FLUSH problem
      avoidConcurrentFlush();

      Configuration cfg2 = createConfiguration();
      InfinispanRegionFactory regionFactory2 = CacheTestUtil.startRegionFactory(
        new ServiceRegistryBuilder().applySettings( cfg.getProperties() ).buildServiceRegistry(),
        cfg2,
        getCacheTestSupport()
    );
      // Sleep a bit to avoid concurrent FLUSH problem
      avoidConcurrentFlush();

      TimestampsRegionImpl region = (TimestampsRegionImpl) regionFactory.buildTimestampsRegion(getStandardRegionName(REGION_PREFIX), cfg.getProperties());
      TimestampsRegionImpl region2 = (TimestampsRegionImpl) regionFactory2.buildTimestampsRegion(getStandardRegionName(REGION_PREFIX), cfg2.getProperties());
//      QueryResultsRegion region2 = regionFactory2.buildQueryResultsRegion(getStandardRegionName(REGION_PREFIX), cfg2.getProperties());

//      ClassLoader cl = Thread.currentThread().getContextClassLoader();
//      Thread.currentThread().setContextClassLoader(cl.getParent());
//      log.info("TCCL is " + cl.getParent());
View Full Code Here

      Settings settings = cfg.buildSettings( serviceRegistry );
      Properties properties = cfg.getProperties();

      String factoryType = cfg.getProperty(Environment.CACHE_REGION_FACTORY);
      Class factoryClass = Thread.currentThread().getContextClassLoader().loadClass(factoryType);
      InfinispanRegionFactory regionFactory = (InfinispanRegionFactory) factoryClass.newInstance();
      regionFactory.start(settings, properties);
      return regionFactory;
   }
View Full Code Here

   public static InfinispanRegionFactory startRegionFactory(
       ServiceRegistry serviceRegistry,
       Configuration cfg,
       CacheTestSupport testSupport) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
      InfinispanRegionFactory factory = startRegionFactory( serviceRegistry, cfg );
      testSupport.registerFactory(factory);
      return factory;
   }
View Full Code Here

TOP

Related Classes of org.hibernate.cache.infinispan.InfinispanRegionFactory

Copyright © 2018 www.massapicom. 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.