Package org.jboss.cache

Examples of org.jboss.cache.Region


      {
         cache = setupCache("configs/mixedPolicy-eviction.xml");
         regionManager = cache.getRegionManager();
         assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());

         Region region = regionManager.getRegion("/org/jboss/data", true);
         EvictionRegionConfig evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof FIFOAlgorithmConfig);
         assertEquals(5000, ((FIFOAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());

         region = regionManager.getRegion("/test", true);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/test/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof MRUAlgorithmConfig);
         assertEquals(10000, ((MRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());

         // test the default region. use a region name that isn't defined explicitly in conf file.
         region = regionManager.getRegion("/a/b/c", false);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.ROOT, region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
         assertEquals(-1, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());

         region = regionManager.getRegion("/maxAgeTest", false);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(8000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());
View Full Code Here


      {
         cache = setupCache("configs/local-lru-eviction.xml");
         regionManager = cache.getRegionManager();
         assertEquals(5000, cache.getConfiguration().getEvictionConfig().getWakeupInterval());

         Region region = regionManager.getRegion("/org/jboss/data", false);
         EvictionRegionConfig evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/org/jboss/data/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());

         region = regionManager.getRegion("/org/jboss/test/data", false);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/org/jboss/test/data/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(5, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(4000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());

         region = regionManager.getRegion("/test", true);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/test/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(4000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());

         region = regionManager.getRegion("/maxAgeTest", true);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.fromString("/maxAgeTest/"), region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(8000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
         assertEquals(10000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());

         // test the default region. use a region name that isn't defined explicitly in conf file.
         region = regionManager.getRegion("/a/b/c", false);
         evictionRegionConfig = region.getEvictionRegionConfig();
         assertEquals(Fqn.ROOT, region.getFqn());
         assertTrue(evictionRegionConfig.getEvictionAlgorithmConfig() instanceof LRUAlgorithmConfig);
         assertEquals(5000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxNodes());
         assertEquals(1000000, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getTimeToLive());
         assertEquals(-1, ((LRUAlgorithmConfig) evictionRegionConfig.getEvictionAlgorithmConfig()).getMaxAge());
View Full Code Here

      EvictionRegionConfig erc = new EvictionRegionConfig(fqn, config);
      c.getEvictionConfig().addEvictionRegionConfig(erc);
      CacheSPI mockCache = EasyMock.createNiceMock(CacheSPI.class);
      EasyMock.replay(mockCache);
      ((RegionManagerImpl) regionManager).injectDependencies(mockCache, c, null, null, null, new RegionRegistry());
      Region r = regionManager.getRegion(fqn, Region.Type.EVICTION, true);
      r.setEvictionRegionConfig(erc);

      ((RegionManagerImpl) regionManager).start();
      return (EvictionAlgorithm) TestingUtil.extractField(r, "evictionAlgorithm");
   }
View Full Code Here

   public void setUp() throws Exception
   {
      algorithm = new LRUAlgorithm();
      regionManager = new RegionManagerImpl();
      ((RegionManagerImpl) regionManager).injectDependencies(null, null, null, null, null, new RegionRegistry());
      Region r = regionManager.getRegion("/a/b", true);//.setEvictionPolicy(new DummyEvictionConfiguration());
      r.setEvictionRegionConfig(new EvictionRegionConfig(r.getFqn(), new LRUAlgorithmConfig()));
   }
View Full Code Here

   {
      Fqn fqn1 = Fqn.fromString("/a/b/c");
      Fqn fqn2 = Fqn.fromString("/a/b/d");
      Fqn fqn3 = Fqn.fromString("/a/b/e");

      Region region = regionManager.getRegion("/a/b", true);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);

      assertEquals("queue size ", 3, getQueueSize((RegionImpl) region));
      EvictionEvent node = takeLastEvent((RegionImpl) region);
      Fqn fqn = node.getFqn();
      assertEquals("DataNode retrieved should be FILO ", fqn, fqn1);
View Full Code Here

   {
      Fqn fqn1 = Fqn.fromString("/a/b/c");
      Fqn fqn2 = Fqn.fromString("/a/b/d");
      Fqn fqn3 = Fqn.fromString("/a/b/e");

      Region region = regionManager.getRegion("/a/b", true);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.REMOVE_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn3, EvictionEvent.Type.VISIT_NODE_EVENT);

      assertEquals("RemovedNode queue size ", 3, getQueueSize((RegionImpl) region));
      EvictionEvent.Type event = takeLastEvent((RegionImpl) region).getEventType();
      assertEquals("DataNode retrieved should be: ", EvictionEvent.Type.REMOVE_NODE_EVENT, event);
      takeLastEvent((RegionImpl) region);
View Full Code Here

   public void testMassivePutOnQueue()
   {
      Fqn fqn2 = Fqn.fromString("/a/b/d");

      Region region = regionManager.getRegion("/a/b", true);
      // This should succeed, alhtough it will produce warning over the threshold.
      for (int i = 0; i < EvictionConfig.EVENT_QUEUE_SIZE_DEFAULT - 1; i++)
      {
         region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
      }

   }
View Full Code Here

      final int recycleQueueCapacity = 10;

      /* override recycle queue capacity to make the test shorter */
      BaseEvictionAlgorithm algorithm = new MockEvictionAlgorithm(recycleQueueCapacity);

      Region region = regionManager.getRegion("/a/b/c", true);
      region.setEvictionRegionConfig(new EvictionRegionConfig(region.getFqn(), new MockEvictionAlgorithmConfig()));

      for (int i = 0; i < (recycleQueueCapacity + 1); i++)
      {
         Fqn fqn = Fqn.fromString("/a/b/c/" + Integer.toString(i + 1));
         region.registerEvictionEvent(fqn, EvictionEvent.Type.ADD_NODE_EVENT);
      }

      ExecutorService executor = Executors.newSingleThreadExecutor();
      Future<Void> future = executor.submit(new ProcessEvictionRegion((RegionImpl) region, algorithm));

View Full Code Here

      try
      {
         if (useRegionBasedMarshalling) // got to check again in case this meth is called directly
         {
            if (trace) log.trace("Writing region " + region + " to stream");
            Region r = null;
            if (region != null) r = regionManager.getRegion(region, false);
            if (r != null && r.getClassLoader() != null) toUse = r.getClassLoader();
            current.setContextClassLoader(toUse);
            marshallObject(region, out, refMap);
         }
         else
         {
View Full Code Here

         regionFqn = (Fqn) o;
      }

      if (trace) log.trace("Unmarshalled regionFqn " + regionFqn + " from stream");

      Region region = null;
      Object[] retValue = {null, null};

      if (regionFqn != null)
      {
         region = findRegion(regionFqn);
      }
      if (region == null)
      {
         if (log.isDebugEnabled())
            log.debug("Region does not exist for Fqn " + regionFqn + " - not using a context classloader.");
         retValue[0] = unmarshallObject(in, defaultClassLoader, refMap, false);
      }
      else
      {
         retValue[0] = unmarshallObject(in, region.getClassLoader(), refMap, true);
         retValue[1] = regionFqn;
      }
      if (trace) log.trace("Unmarshalled object " + retValue[0] + " with region " + retValue[1]);
      return retValue;
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.Region

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.