Package org.hibernate.cache

Examples of org.hibernate.cache.GeneralDataRegion


        boolean invalidation = CacheHelper.isClusteredInvalidation(localCache);
       
        // Sleep a bit to avoid concurrent FLUSH problem
        avoidConcurrentFlush();
       
        GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
       
        cfg = createConfiguration(configName);
        regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
       
        GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
       
        assertNull("local is clean", localRegion.get(KEY));
        assertNull("remote is clean", remoteRegion.get(KEY));
       
        localRegion.put(KEY, VALUE1);
        assertEquals(VALUE1, localRegion.get(KEY));
       
        // allow async propagation
        sleep(250);
        Object expected = invalidation ? null : VALUE1;
        assertEquals(expected, remoteRegion.get(KEY));
       
        localRegion.evict(KEY);
       
        assertEquals(null, localRegion.get(KEY));
       
        assertEquals(null, remoteRegion.get(KEY));
    }
View Full Code Here


        boolean invalidation = CacheHelper.isClusteredInvalidation(localCache);
       
        // Sleep a bit to avoid concurrent FLUSH problem
        avoidConcurrentFlush();
   
        GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
       
        cfg = createConfiguration(configName);
        regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
        Cache remoteCache = getJBossCache(regionFactory);
       
        // Sleep a bit to avoid concurrent FLUSH problem
        avoidConcurrentFlush();
   
        GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
        Fqn regionFqn = getRegionFqn(getStandardRegionName(REGION_PREFIX), REGION_PREFIX);
       
        Node regionRoot = localCache.getRoot().getChild(regionFqn);
        assertFalse(regionRoot == null);
        assertEquals("No children in " + regionRoot, 0, getValidChildrenCount(regionRoot));
        assertTrue(regionRoot.isResident());
       
        if (optimistic) {
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
        }
   
        regionRoot = remoteCache.getRoot().getChild(regionFqn);
        assertFalse(regionRoot == null);
        assertEquals(0, getValidChildrenCount(regionRoot));
        assertTrue(regionRoot.isResident());
       
        if (optimistic) {
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
        }
       
        assertNull("local is clean", localRegion.get(KEY));
        assertNull("remote is clean", remoteRegion.get(KEY));
       
        localRegion.put(KEY, VALUE1);
        assertEquals(VALUE1, localRegion.get(KEY));    
       
        // Allow async propagation
        sleep(250);
       
        remoteRegion.put(KEY, VALUE1);
        assertEquals(VALUE1, remoteRegion.get(KEY));    
       
        // Allow async propagation
        sleep(250);
       
        if (optimistic) {
            regionRoot = localCache.getRoot().getChild(regionFqn);
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
            regionRoot = remoteCache.getRoot().getChild(regionFqn);
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
        }
       
        localRegion.evictAll();
       
        // This should re-establish the region root node
        assertNull(localRegion.get(KEY));
       
        regionRoot = localCache.getRoot().getChild(regionFqn);
        assertFalse(regionRoot == null);
        assertEquals(0, getValidChildrenCount(regionRoot));
        assertTrue(regionRoot.isValid());
        assertTrue(regionRoot.isResident());

        // Re-establishing the region root on the local node doesn't
        // propagate it to other nodes. Do a get on the remote node to re-establish
        assertEquals(null, remoteRegion.get(KEY));
       
        regionRoot = remoteCache.getRoot().getChild(regionFqn);
        assertFalse(regionRoot == null);
        assertEquals(0, getValidChildrenCount(regionRoot));
        assertTrue(regionRoot.isValid());
        assertTrue(regionRoot.isResident());
       
        assertEquals("local is clean", null, localRegion.get(KEY));
        assertEquals("remote is clean", null, remoteRegion.get(KEY));
    }
View Full Code Here

        boolean invalidation = CacheHelper.isClusteredInvalidation(localCache);
       
        // Sleep a bit to avoid concurrent FLUSH problem
        avoidConcurrentFlush();
       
        GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
       
        cfg = createConfiguration(configName);
        regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
       
        GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
       
        assertNull("local is clean", localRegion.get(KEY));
        assertNull("remote is clean", remoteRegion.get(KEY));
       
        localRegion.put(KEY, VALUE1);
        assertEquals(VALUE1, localRegion.get(KEY));
       
        // allow async propagation
        sleep(250);
        Object expected = invalidation ? null : VALUE1;
        assertEquals(expected, remoteRegion.get(KEY));
       
        localRegion.evict(KEY);
       
        assertEquals(null, localRegion.get(KEY));
       
        assertEquals(null, remoteRegion.get(KEY));
    }
View Full Code Here

        boolean invalidation = CacheHelper.isClusteredInvalidation(localCache);
       
        // Sleep a bit to avoid concurrent FLUSH problem
        avoidConcurrentFlush();
   
        GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
       
        cfg = createConfiguration(configName);
        regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
        Cache remoteCache = getJBossCache(regionFactory);
       
        // Sleep a bit to avoid concurrent FLUSH problem
        avoidConcurrentFlush();
   
        GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
        Fqn regionFqn = getRegionFqn(getStandardRegionName(REGION_PREFIX), REGION_PREFIX);
       
        Node regionRoot = localCache.getRoot().getChild(regionFqn);
        assertFalse(regionRoot == null);
        assertEquals("No children in " + regionRoot, 0, getValidChildrenCount(regionRoot));
        assertTrue(regionRoot.isResident());
       
        if (optimistic) {
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
        }
   
        regionRoot = remoteCache.getRoot().getChild(regionFqn);
        assertFalse(regionRoot == null);
        assertEquals(0, getValidChildrenCount(regionRoot));
        assertTrue(regionRoot.isResident());
       
        if (optimistic) {
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
        }
       
        assertNull("local is clean", localRegion.get(KEY));
        assertNull("remote is clean", remoteRegion.get(KEY));
       
        localRegion.put(KEY, VALUE1);
        assertEquals(VALUE1, localRegion.get(KEY));    
       
        // Allow async propagation
        sleep(250);
       
        remoteRegion.put(KEY, VALUE1);
        assertEquals(VALUE1, remoteRegion.get(KEY));    
       
        // Allow async propagation
        sleep(250);
       
        if (optimistic) {
            regionRoot = localCache.getRoot().getChild(regionFqn);
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
            regionRoot = remoteCache.getRoot().getChild(regionFqn);
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
        }
       
        localRegion.evictAll();
       
        // This should re-establish the region root node
        assertNull(localRegion.get(KEY));
       
        regionRoot = localCache.getRoot().getChild(regionFqn);
        assertFalse(regionRoot == null);
        assertEquals(0, getValidChildrenCount(regionRoot));
        assertTrue(regionRoot.isValid());
        assertTrue(regionRoot.isResident());

        // Re-establishing the region root on the local node doesn't
        // propagate it to other nodes. Do a get on the remote node to re-establish
        assertEquals(null, remoteRegion.get(KEY));
       
        regionRoot = remoteCache.getRoot().getChild(regionFqn);
        assertFalse(regionRoot == null);
        assertEquals(0, getValidChildrenCount(regionRoot));
        assertTrue(regionRoot.isValid());
        assertTrue(regionRoot.isResident());
       
        assertEquals("local is clean", null, localRegion.get(KEY));
        assertEquals("remote is clean", null, remoteRegion.get(KEY));
    }
View Full Code Here

      boolean invalidation = localCache.isClusteredInvalidation();

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

      GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory,
               getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);

      cfg = createConfiguration();
      regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());

      GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory,
               getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);

      assertNull("local is clean", localRegion.get(KEY));
      assertNull("remote is clean", remoteRegion.get(KEY));

      localRegion.put(KEY, VALUE1);
      assertEquals(VALUE1, localRegion.get(KEY));

      // allow async propagation
      sleep(250);
      Object expected = invalidation ? null : VALUE1;
      assertEquals(expected, remoteRegion.get(KEY));

      localRegion.evict(KEY);

      // allow async propagation
      sleep(250);
      assertEquals(null, localRegion.get(KEY));
      assertEquals(null, remoteRegion.get(KEY));
   }
View Full Code Here

      CacheAdapter localCache = getInfinispanCache(regionFactory);

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

      GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory,
               getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);

      cfg = createConfiguration();
      regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
      CacheAdapter remoteCache = getInfinispanCache(regionFactory);

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

      GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory,
               getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);

      Set keys = localCache.keySet();
      assertEquals("No valid children in " + keys, 0, getValidKeyCount(keys));

      keys = remoteCache.keySet();
      assertEquals("No valid children in " + keys, 0, getValidKeyCount(keys));

      assertNull("local is clean", localRegion.get(KEY));
      assertNull("remote is clean", remoteRegion.get(KEY));

      localRegion.put(KEY, VALUE1);
      assertEquals(VALUE1, localRegion.get(KEY));

      // Allow async propagation
      sleep(250);

      remoteRegion.put(KEY, VALUE1);
      assertEquals(VALUE1, remoteRegion.get(KEY));

      // Allow async propagation
      sleep(250);

      localRegion.evictAll();

      // allow async propagation
      sleep(250);
      // This should re-establish the region root node in the optimistic case
      assertNull(localRegion.get(KEY));
      assertEquals("No valid children in " + keys, 0, getValidKeyCount(localCache.keySet()));

      // Re-establishing the region root on the local node doesn't
      // propagate it to other nodes. Do a get on the remote node to re-establish
      // This only adds a node in the case of optimistic locking
      assertEquals(null, remoteRegion.get(KEY));
      assertEquals("No valid children in " + keys, 0, getValidKeyCount(remoteCache.keySet()));

      assertEquals("local is clean", null, localRegion.get(KEY));
      assertEquals("remote is clean", null, remoteRegion.get(KEY));
   }
View Full Code Here

        boolean invalidation = CacheHelper.isClusteredInvalidation(localCache);
       
        // Sleep a bit to avoid concurrent FLUSH problem
        avoidConcurrentFlush();
       
        GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
       
        cfg = createConfiguration(configName);
        regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
       
        GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
       
        assertNull("local is clean", localRegion.get(KEY));
        assertNull("remote is clean", remoteRegion.get(KEY));
       
        localRegion.put(KEY, VALUE1);
        assertEquals(VALUE1, localRegion.get(KEY));
       
        // allow async propagation
        sleep(250);
        Object expected = invalidation ? null : VALUE1;
        assertEquals(expected, remoteRegion.get(KEY));
       
        localRegion.evict(KEY);
       
        assertEquals(null, localRegion.get(KEY));
       
        assertEquals(null, remoteRegion.get(KEY));
    }
View Full Code Here

        boolean invalidation = CacheHelper.isClusteredInvalidation(localCache);
       
        // Sleep a bit to avoid concurrent FLUSH problem
        avoidConcurrentFlush();
   
        GeneralDataRegion localRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
       
        cfg = createConfiguration(configName);
        regionFactory = CacheTestUtil.startRegionFactory(cfg, getCacheTestSupport());
        Cache remoteCache = getJBossCache(regionFactory);
       
        // Sleep a bit to avoid concurrent FLUSH problem
        avoidConcurrentFlush();
   
        GeneralDataRegion remoteRegion = (GeneralDataRegion) createRegion(regionFactory, getStandardRegionName(REGION_PREFIX), cfg.getProperties(), null);
        Fqn regionFqn = getRegionFqn(getStandardRegionName(REGION_PREFIX), REGION_PREFIX);
       
        Node regionRoot = localCache.getRoot().getChild(regionFqn);
        assertFalse(regionRoot == null);
        Set children = regionRoot.getChildrenNames();
        assertEquals("No children in " + children, 0, children.size());
        assertTrue(regionRoot.isResident());
       
        if (optimistic) {
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
        }
   
        regionRoot = remoteCache.getRoot().getChild(regionFqn);
        assertFalse(regionRoot == null);
        assertEquals(0, regionRoot.getChildrenNames().size());
        assertTrue(regionRoot.isResident());
       
        if (optimistic) {
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
        }
       
        assertNull("local is clean", localRegion.get(KEY));
        assertNull("remote is clean", remoteRegion.get(KEY));
       
        localRegion.put(KEY, VALUE1);
        assertEquals(VALUE1, localRegion.get(KEY));    
       
        // Allow async propagation
        sleep(250);
       
        remoteRegion.put(KEY, VALUE1);
        assertEquals(VALUE1, remoteRegion.get(KEY));    
       
        // Allow async propagation
        sleep(250);
       
        if (optimistic) {
            regionRoot = localCache.getRoot().getChild(regionFqn);
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
            regionRoot = remoteCache.getRoot().getChild(regionFqn);
            assertEquals(NonLockingDataVersion.class, ((NodeSPI) regionRoot).getVersion().getClass());
        }
       
        localRegion.evictAll();
       
        // This should re-establish the region root node in the optimistic case
        assertNull(localRegion.get(KEY));
       
        regionRoot = localCache.getRoot().getChild(regionFqn);
        if (optimistic) {
           assertFalse(regionRoot == null);
           assertEquals(0, regionRoot.getChildrenNames().size());
           assertTrue(regionRoot.isValid());
           assertTrue(regionRoot.isResident());
        }
        else {
            assertTrue("region root is removed", regionRoot == null || !regionRoot.isValid());
        }

        // Re-establishing the region root on the local node doesn't
        // propagate it to other nodes. Do a get on the remote node to re-establish
        // This only adds a node in the case of optimistic locking
        assertEquals(null, remoteRegion.get(KEY));
       
        regionRoot = remoteCache.getRoot().getChild(regionFqn);
        if (optimistic) {
            assertFalse(regionRoot == null);
            assertEquals(0, regionRoot.getChildrenNames().size());
            assertTrue(regionRoot.isValid());
            assertTrue(regionRoot.isResident());
        }
        else {
            assertTrue("region root is removed", regionRoot == null || !regionRoot.isValid());
        }
       
        assertEquals("local is clean", null, localRegion.get(KEY));
        assertEquals("remote is clean", null, remoteRegion.get(KEY));
    }
View Full Code Here

TOP

Related Classes of org.hibernate.cache.GeneralDataRegion

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.