Package org.jboss.cache

Examples of org.jboss.cache.RegionImpl


   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(-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 testMaxNode2() 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 ", 0, algorithm.getEvictionQueue().getNumberOfNodes());
   }
View Full Code Here

   public void testMaxNode3() 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(-1);
      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(-1);
      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(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

   {
      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(1000);
      config.setMaxAge(3000);
      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(1100);

      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(3100);
      // 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

   public void testCombo2() 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(2);
      config.setTimeToLive(1000);
      config.setMaxAge(3000);
      region.registerEvictionEvent(fqn1, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.ADD_NODE_EVENT);
      region.registerEvictionEvent(fqn2, EvictionEvent.Type.REMOVE_NODE_EVENT);

      algorithm.process(region.getEvictionEventQueue());

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

      // make sure existing events all time out
      TestingUtil.sleepThread(1100);
      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(3100);
      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.