Package org.jboss.cache.util.internals

Examples of org.jboss.cache.util.internals.EvictionController$Signaller


   public void testEviction2() throws Exception
   {
      List<Fqn> fqnsThatShouldBeEvicted = new ArrayList<Fqn>();
      for (int i = 10; i < 20; i++) fqnsThatShouldBeEvicted.add(Fqn.fromString("/org/jboss/data/" + i));

      EvictionController evictionController = new EvictionController(cache);
      String rootStr = "/org/jboss/data/";
      for (int i = 0; i < 20; i++)
      {
         String str = rootStr + Integer.toString(i);
         Fqn fqn = Fqn.fromString(str);//"/org/jboss/data/i";
         cache.put(fqn, i, str);
         for (int k = 0; k < i; k++)
         {
            cache.put(fqn, k, str);
         }
      }

      evictionController.startEviction();

      for (int i = 0; i < 20; i++)
      {
         String str = rootStr + Integer.toString(i);
         Fqn fqn = Fqn.fromString(str);
         Node node = cache.getNode(fqn);
         if (i > 9)
         {
            assertNull("Testing at " + i, node);
         }
         else
         {
            assertEquals(1 + i, node.getData().size());
         }
      }

      for (int i = 0; i < 17; i++)
      {
         cache.put("/org/jboss/data/3", 100 + i, "value");
      }

      Node node = cache.getNode("/org/jboss/data/3");
      assertEquals(21, node.getData().size());

      evictionController.startEviction();
      TestingUtil.sleepThread(200); // small grace period

      assertNull(cache.getNode("/org/jboss/data/3"));
   }
View Full Code Here


         {
            fail("Failed to insert data" + e);
            e.printStackTrace();
         }
      }
      EvictionController evictionController = new EvictionController(cache);
      evictionController.startEviction();

      try
      {
         String val = (String) cache.get(rootStr + "3", rootStr + "3");
         assertNull("DataNode should be empty ", val);
View Full Code Here

         String str = rootStr + i;
         Fqn fqn = Fqn.fromString(str);
         cache.put(fqn, str, str);
      }

      EvictionController evictionController = new EvictionController(cache);
      evictionController.startEviction();
      // wait a few secs for eviction to complete
      TestingUtil.sleepThread(500);
      assertEquals("Number of nodes", maxNodes + 2, cache.getNumberOfNodes());
      for (int i = 0; i < maxNodes; i++)
      {
View Full Code Here

         }
      }

      assert watcher.waitForEviction(30, TimeUnit.SECONDS) : "Eviction event not received!";

      EvictionController evictionController = new EvictionController(cache);
      evictionController.startEviction();
      try
      {
         for (int i = 0; i < 5; i++)
         {
            String str = rootStr + Integer.toString(i);
View Full Code Here

            fail("Failed to insert data" + e);
            e.printStackTrace();
         }
      }

      EvictionController evictionController = new EvictionController(cache);
      evictionController.startEviction();

      String str1 = rootStr + "7";
      Fqn fqn1 = Fqn.fromString(str1);
      String str2 = rootStr + "7/7";
      Fqn fqn2 = Fqn.fromString(str2);
      try
      {
         assertNotNull(cache.get(fqn2, str2));
         assertNotNull(cache.get(fqn1, str1));
         cache.removeNode(fqn2);
         evictionController.startEviction();
         assertNull(cache.get(fqn2, str2));
         assertNotNull(cache.get(fqn1, str1));
         cache.removeNode(fqn1);
         evictionController.startEviction();
         assertNull(cache.get(fqn1, str1));
         assertNull(cache.get(fqn2, str2));

         String str3 = rootStr + "5/5";
         String str4 = rootStr + "5";
         Fqn fqn3 = Fqn.fromString(str3);
         Fqn fqn4 = Fqn.fromString(str4);
         assertNotNull(cache.get(fqn3, str3));
         assertNotNull(cache.get(fqn4, str4));

         evictionController.startEviction();

         // remove the node above fqn4 /org/jboss/test/5 will cascade the delete into /org/jboss/test/5/5
         cache.removeNode(fqn4);

         evictionController.startEviction();
         assertNull(cache.get(fqn3, str3));
         assertNull(cache.get(fqn4, str4));
      }
      catch (Exception e)
      {
View Full Code Here

         cache.put("/a/b/1", "a", "b");
         cache.put("/a/b/2", "a", "b");
         cache.put("/a/b/3", "a", "b");

         new EvictionController(cache).startEviction();

         assert cache.getNode("/a/b/1") == null;
         assert cache.getNode("/a/b/2") != null;
         assert cache.getNode("/a/b/3") != null;
      }
View Full Code Here

   public void testEvictionOccurence() throws Exception
   {
      cache.put("/timeBased/test", "key", "value");
      assertTrue(cache.exists("/timeBased/test"));
      TestingUtil.sleepThread(1);
      new EvictionController(cache).startEviction();
//      assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString("/timeBased/test"));
      assertTrue(!cache.exists("/timeBased/test"));
   }
View Full Code Here

      // in case any waiting threads in subclasses are waiting for the cache to be initialised
      cacheInitialisedLatch.countDown();

      assert cache.get(fqn, "k") != null : "Node should be in the cache";

      new EvictionController(cache).startEviction();

      assert cache.get(fqn, "k") != null : "Node should still be in cache due to a minTTL of 3 secs";

      // the last cache.get() would have updated the last modified tstamp so we need to wait at least 3 secs (+1 sec maybe for the eviction thread)
      // to make sure this is evicted.
      new EvictionController(cache).startEviction(true);
      assert waitForEviction(cache, 5, TimeUnit.SECONDS, fqn);

      assert cache.get(fqn, "k") == null : "Node should have been evicted";
   }
View Full Code Here

      String str = rootStr + "0";
      Fqn fqn = Fqn.fromString(str);
      cache1.put(str, str, str);
//      assert waitForEviction(cache1, 30, TimeUnit.SECONDS, fqn) : "Eviction event not received!";
      new EvictionController(cache1).startEviction();
      Object node = cache1.peek(fqn, false);
      assertNull("Node should be evicted already ", node);
      assertEquals("Eviction counter ", 1, listener.getCounter());
      String val = (String) cache3.get(str, str);
      assertNotNull("DataNode should not be evicted here ", val);
View Full Code Here

      try
      {
         log.info("update 1 from future to past");
         cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future);
         TestingUtil.sleepThread(200);
         new EvictionController(cache).startEviction();
         assertNotNull(cache.getNode(fqn1));
         cache.put(fqn1, ExpirationAlgorithmConfig.EXPIRATION_KEY, future + 250);
         TestingUtil.sleepThread(500);
         new EvictionController(cache).startEviction();
         assertNotNull(cache.getNode(fqn1));
         TestingUtil.sleepThread(100);
         new EvictionController(cache).startEviction();
         assertNull(cache.getNode(fqn1));
      }
      finally
      {
         cache.removeNode(Fqn.ROOT);
View Full Code Here

TOP

Related Classes of org.jboss.cache.util.internals.EvictionController$Signaller

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.