Examples of EvictionWatcher


Examples of org.jboss.cache.util.internals.EvictionWatcher

   {
      Node node = cache.getRoot().addChild(Fqn.fromString("/base/"));
      node.setResident(true);
      cache.getRoot().setResident(true);

      EvictionWatcher ew = new EvictionWatcher(cache, Fqn.fromString("/base/1"));

      for (int i = 1; i < baseRegionMaxNodes + 2; i++)
      {
         Fqn f = Fqn.fromString("/base/" + i);
         cache.put(f, "key", "base" + i);
      }

      new EvictionController(cache).startEviction();
      assert ew.waitForEviction(30, TimeUnit.SECONDS);

      assertEquals(baseRegionMaxNodes, cache.getRoot().getChild(Fqn.fromString("/base")).getChildren().size());

   }
View Full Code Here

Examples of org.jboss.cache.util.internals.EvictionWatcher

   public void testNodeVisited() throws InterruptedException
   {
      String rootStr = "/org/jboss/test/data/";
      List<Fqn> fqnsToBeEvicted = new ArrayList<Fqn>();
      for (int i = 0; i < 5; i++) fqnsToBeEvicted.add(Fqn.fromString(rootStr + i));
      EvictionWatcher watcher = new EvictionWatcher(cache, fqnsToBeEvicted);

      for (int i = 0; i < 10; i++)
      {
         String str = rootStr + i;
         Fqn fqn = Fqn.fromString(str);
         try
         {
            cache.put(fqn, str, str);
         }
         catch (Exception e)
         {
            fail("Failed to insert data" + e);
            e.printStackTrace();
         }
      }

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

      EvictionController evictionController = new EvictionController(cache);
      evictionController.startEviction();
      try
      {
View Full Code Here

Examples of org.jboss.cache.util.internals.EvictionWatcher

      String rootStr = "/org/jboss/test/data/";
      LRUAlgorithmConfig cfg = (LRUAlgorithmConfig) cache3.getConfiguration().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgorithmConfig();
      cfg.setMaxAge(60, TimeUnit.SECONDS);
      cfg.setTimeToLive(360, TimeUnit.SECONDS);
      cfg.setMaxNodes(200);
      EvictionWatcher ew = new EvictionWatcher(cache1, Fqn.fromString(rootStr + 3));
      for (int i = 0; i < 10; i++)
      {
         String str = rootStr + i;
         Fqn fqn = Fqn.fromString(str);
         cache1.put(fqn, str, str);
      }

      assert ew.waitForEviction(30, TimeUnit.SECONDS);

      String val = (String) cache1.get(rootStr + "3", rootStr + "3");
      assertNull("DataNode should be evicted already ", val);
      val = (String) cache3.get(rootStr + "3", rootStr + "3");
      assertNotNull("DataNode should not be evicted here ", val);
View Full Code Here

Examples of org.jboss.cache.util.internals.EvictionWatcher

   {
      String rootStr = "/org/jboss/test/data/";
      LRUAlgorithmConfig cfg = (LRUAlgorithmConfig) cache3.getConfiguration().getEvictionConfig().getEvictionRegionConfig(rootStr).getEvictionAlgorithmConfig();
      cfg.setMaxAge(60, TimeUnit.SECONDS);
      cfg.setTimeToLive(360, TimeUnit.SECONDS);
      EvictionWatcher ew = new EvictionWatcher(cache1, Fqn.fromString(rootStr + 3));

      for (int i = 0; i < 10; i++)
      {
         String str = rootStr + i;
         Fqn fqn = Fqn.fromString(str);
         cache1.put(fqn, str, str);
      }

      String str = rootStr + "7";
      Fqn fqn = Fqn.fromString(str);
      cache1.get(fqn, str);

      assert ew.waitForEviction(30, TimeUnit.SECONDS);

      String val = (String) cache1.get(rootStr + "3", rootStr + "3");
      assertNull("DataNode should be empty ", val);
      val = (String) cache3.get(rootStr + "7", rootStr + "7");
      assertNotNull("DataNode should not be null", val);
View Full Code Here

Examples of org.jboss.cache.util.internals.EvictionWatcher

   public void testNodeVisited() throws InterruptedException
   {
      String rootStr = "/org/jboss/test/data/";
      List<Fqn> fqns = new ArrayList<Fqn>();
      for (int i = 0; i < 5; i++) fqns.add(Fqn.fromString(rootStr + i));
      EvictionWatcher ew = new EvictionWatcher(cache, fqns);
      for (int i = 0; i < 10; i++)
      {
         String str = rootStr + i;
         Fqn fqn = Fqn.fromString(str);
         try
         {
            cache.put(fqn, str, str);
         }
         catch (Exception e)
         {
            fail("Failed to insert data" + e);
            e.printStackTrace();
         }
      }

      assert ew.waitForEviction(30, TimeUnit.SECONDS);

      try
      {
         for (int i = 0; i < 5; i++)
         {
View Full Code Here

Examples of org.jboss.cache.util.internals.EvictionWatcher

    * @param fqnsToEvict fqns to watch for
    * @return true if evicted, false otherwise
    */
   public boolean waitForEviction(Cache cache, long timeToWait, TimeUnit unit, Fqn... fqnsToEvict) throws InterruptedException
   {
      return new EvictionWatcher(cache, fqnsToEvict).waitForEviction(timeToWait, unit);
   }
View Full Code Here

Examples of org.jboss.cache.util.internals.EvictionWatcher

   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));

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

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

      for (int i = 0; i < 20; i++)
      {
         String str = rootStr + Integer.toString(i);
         Fqn fqn = Fqn.fromString(str);
View Full Code Here

Examples of org.jboss.cache.util.internals.EvictionWatcher

   {
      Node node = cache.getRoot().addChild(Fqn.fromString("/base/"));
      node.setResident(true);
      cache.getRoot().setResident(true);

      EvictionWatcher ew = new EvictionWatcher(cache, Fqn.fromString("/base/1"));

      for (int i = 1; i < baseRegionMaxNodes + 2; i++)
      {
         Fqn f = Fqn.fromString("/base/" + i);
         cache.put(f, "key", "base" + i);
      }

      new EvictionController(cache).startEviction();
      assert ew.waitForEviction(30, TimeUnit.SECONDS);

      assertEquals(baseRegionMaxNodes, cache.getRoot().getChild(Fqn.fromString("/base")).getChildren().size());

   }
View Full Code Here

Examples of org.jboss.cache.util.internals.EvictionWatcher

      String testRootStr = "/test/";
      String lruRootStr = "/lru/";

      List<Fqn> toBeEvicted = new ArrayList<Fqn>();
      for (int i = 0; i < 20; i++) toBeEvicted.add(Fqn.fromString(lruRootStr + i));
      EvictionWatcher watcher = new EvictionWatcher(cache, toBeEvicted);
      for (int i = 0; i < 20; i++)
      {
         Fqn dflt = Fqn.fromString(dfltRootStr + i);
         Fqn test = Fqn.fromString(testRootStr + i);
         Fqn lru = Fqn.fromString(lruRootStr + i);
         cache.put(dflt, "key", "value");
         cache.put(test, "key", "value");
         cache.put(lru, "key", "value");
      }

      assert watcher.waitForEviction(30, TimeUnit.SECONDS);

      for (int i = 0; i < 20; i++)
      {
         Fqn dflt = Fqn.fromString(dfltRootStr + i);
         Fqn test = Fqn.fromString(testRootStr + i);
View Full Code Here

Examples of org.jboss.cache.util.internals.EvictionWatcher

      String testRootStr = "/test/";
      String lruRootStr = "/lru/";

      List<Fqn> toBeEvicted = new ArrayList<Fqn>();
      for (int i = 0; i < 20; i++) toBeEvicted.add(Fqn.fromString(lruRootStr + i));
      EvictionWatcher watcher = new EvictionWatcher(cache, toBeEvicted);
      for (int i = 0; i < 20; i++)
      {
         Fqn dflt = Fqn.fromString(dfltRootStr + i);
         Fqn test = Fqn.fromString(testRootStr + i);
         Fqn lru = Fqn.fromString(lruRootStr + i);
         cache.put(dflt, "key", "value");
         cache.put(test, "key", "value");
         cache.put(lru, "key", "value");
      }

      assert watcher.waitForEviction(30, TimeUnit.SECONDS);

      for (int i = 0; i < 20; i++)
      {
         Fqn dflt = Fqn.fromString(dfltRootStr + i);
         Fqn test = Fqn.fromString(testRootStr + i);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.