Package org.jboss.cache

Examples of org.jboss.cache.RegionImpl


      assertEquals(9, algo.getEvictionQueue().getNumberOfNodes());
   }

   public void testEvictionQueueSortOrder2() throws Exception
   {
      RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
      EvictionRegionConfig config = region.getEvictionRegionConfig();

      ((LFUAlgorithmConfig) config.getEvictionAlgorithmConfig()).setMaxNodes(-1);
      ((LFUAlgorithmConfig) config.getEvictionAlgorithmConfig()).setMinNodes(10000);
      for (int i = 0; i < 10000; i++)
      {
         Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
         region.registerEvictionEvent(fqn, ADD_NODE_EVENT);
      }

      algo.process(region.getEvictionEventQueue());
      LFUQueue queue = (LFUQueue) algo.evictionQueue;

      long lastModifiedTimestamp = 0;
      for (NodeEntry ne : queue)
      {
         assertTrue(lastModifiedTimestamp <= ne.getModifiedTimeStamp());
         lastModifiedTimestamp = ne.getModifiedTimeStamp();
      }

      for (int i = 0; i < 10000; i++)
      {
         if ((i % 2) == 0)
         {
            Fqn fqn = Fqn.fromString("/a/b/" + Integer.toString(i));
            region.registerEvictionEvent(fqn, VISIT_NODE_EVENT);
         }
      }

      algo.process(region.getEvictionEventQueue());

      int count = 0;
      lastModifiedTimestamp = 0;
      for (NodeEntry ne : queue)
      {
View Full Code Here


   public void testEvictException() throws EvictionException
   {
      Fqn fqn1 = Fqn.fromString("/a/b/c");
      Fqn fqn2 = Fqn.fromString("/a/b/d");
      Fqn fqn3 = Fqn.fromString("/a/b/e");
      RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
      config.setMaxNodes(1);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());

      assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue().getNumberOfNodes());

      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());

      assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue().getNumberOfNodes());
   }
View Full Code Here

    */
   public void testMaxNode1() throws EvictionException
   {
      Fqn fqn1 = Fqn.fromString("/a/b/c");
      Fqn fqn2 = Fqn.fromString("/a/b/d");
      RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
      config.setMaxNodes(0);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());

      assertEquals("Queue size should be ", 2, algorithm.getEvictionQueue().getNumberOfNodes());
   }
View Full Code Here

   public void testMaxNode2() throws EvictionException
   {
      Fqn fqn1 = Fqn.fromString("/a/b/c");
      Fqn fqn2 = Fqn.fromString("/a/b/d");
      Fqn fqn3 = Fqn.fromString("/a/b/e");
      RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
      config.setMaxNodes(1);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());

      assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue().getNumberOfNodes());

      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);


      algorithm.process(region.getEvictionEventQueue());

      assertEquals("Queue size should be ", 1, algorithm.getEvictionQueue().getNumberOfNodes());
   }
View Full Code Here

    */
   public void testIdleTimeSeconds1() throws EvictionException
   {
      Fqn fqn1 = Fqn.fromString("/a/b/c");
      Fqn fqn2 = Fqn.fromString("/a/b/d");
      RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
      config.setMaxNodes(-1);
      config.setTimeToLive(-1);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());

      assertEquals("Queue size should be ", 2, algorithm.getEvictionQueue().getNumberOfNodes());
   }
View Full Code Here

   public void testIdleTimeSeconds2() throws EvictionException
   {
      Fqn fqn1 = Fqn.fromString("/a/b/c");
      Fqn fqn2 = Fqn.fromString("/a/b/d");
      Fqn fqn3 = Fqn.fromString("/a/b/e");
      RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
      config.setMaxNodes(0);
      config.setTimeToLive(1000);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());

      assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getNumberOfNodes());
      TestingUtil.sleepThread(1100);

      algorithm.process(region.getEvictionEventQueue());

      assertEquals("Queue size #2: ", 0, algorithm.getEvictionQueue().getNumberOfNodes());
   }
View Full Code Here

   public void testIdleTimeSeconds3() throws EvictionException
   {
      Fqn fqn1 = Fqn.fromString("/a/b/c");
      Fqn fqn2 = Fqn.fromString("/a/b/d");
      Fqn fqn3 = Fqn.fromString("/a/b/e");
      RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
      config.setMaxNodes(0);
      config.setTimeToLive(1000);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());

      assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getNumberOfNodes());
      TestingUtil.sleepThread(1100);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.VISIT_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());
      assertEquals("Queue size #2: ", 1, algorithm.getEvictionQueue().getNumberOfNodes());
   }
View Full Code Here

   public void testMaxAgeSeconds1() throws Exception
   {
      Fqn fqn1 = Fqn.fromString("/a/b/c");
      Fqn fqn2 = Fqn.fromString("/a/b/d");
      Fqn fqn3 = Fqn.fromString("/a/b/e");
      RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);
      config.setMaxNodes(-1);
      config.setTimeToLive(-1);
      config.setMaxAge(100);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());
      assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getNumberOfNodes());
      TestingUtil.sleepThread(110);
      algorithm.process(region.getEvictionEventQueue());
      assertEquals("Queue size #2: ", 0, algorithm.getEvictionQueue().getNumberOfNodes());
   }
View Full Code Here

   public void testMaxAgeSeconds2() throws EvictionException
   {
      Fqn fqn1 = Fqn.fromString("/a/b/c");
      Fqn fqn2 = Fqn.fromString("/a/b/d");
      Fqn fqn3 = Fqn.fromString("/a/b/e");
      RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);

      config.setMaxNodes(-1);
      config.setTimeToLive(-1);
      config.setMaxAge(100);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());
      assertEquals("Queue size #1: ", 3, algorithm.getEvictionQueue().getNumberOfNodes());
      TestingUtil.sleepThread(50);
      algorithm.process(region.getEvictionEventQueue());
      assertEquals("Queue size #2: ", 3, algorithm.getEvictionQueue().getNumberOfNodes());
      TestingUtil.sleepThread(60);
      algorithm.process(region.getEvictionEventQueue());
      assertEquals("Queue size #3: ", 0, algorithm.getEvictionQueue().getNumberOfNodes());
   }
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");
      Fqn fqn4 = Fqn.fromString("/a/b/f");
      RegionImpl region = (RegionImpl) regionManager.getRegion("/a/b", true);

      // Should have a maximum of 2 nodes.
      config.setMaxNodes(2);
      config.setTimeToLive(100);
      config.setMaxAge(300);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn4, EvictionEvent.Type.ADD_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());
      EvictionQueue eq = algorithm.getEvictionQueue();

      int numNodesInQueue = eq.getNumberOfNodes();
      assert 2 == numNodesInQueue : "Queue size #1: expected 2 but was " + numNodesInQueue;

      // make sure all nodes now expire
      TestingUtil.sleepThread(110);

      region.registerEvictionEvent(fqn3, EvictionEvent.Type.ADD_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());

      numNodesInQueue = eq.getNumberOfNodes();
      assert 1 == numNodesInQueue : "Queue size #2: expected 1 but was " + numNodesInQueue;

      TestingUtil.sleepThread(310);
      // visit the node now to prevent the idle time from doing the pruning - node still gets pruned but by
      // max age.
      region.registerEvictionEvent(fqn3, EvictionEvent.Type.VISIT_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());

      numNodesInQueue = eq.getNumberOfNodes();
      assert 0 == numNodesInQueue : "Queue size #3: expected 0 but was " + numNodesInQueue;
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.RegionImpl

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.