Package org.jboss.cache.util.internals

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


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


               cache1.getRoot().getChild(Fqn.fromString("/org/jboss/data")).setResident(true); //so that it won't be counted for eviction
            }
         }
      }

      EvictionController ec1 = new EvictionController(cache1);
      ec1.startEviction();
      int childrenSize = cache1.getRoot().getChild(Fqn.fromString("/org/jboss/data")).getChildren().size();
      assert childrenSize == 5000 : "Expected 5000, saw " + childrenSize;

      c = UnitTestCacheConfigurationFactory.createConfiguration(CacheMode.REPL_SYNC, true);
      additionalConfiguration(c);
      final Cache<Object, Object> cache2 = new UnitTestCacheFactory<Object, Object>().createCache(c);
      caches.put("evict2", cache2);

      Node<Object, Object> parent;// = cache2.getRoot().getChild(Fqn.fromString("/org/jboss/test/data"));
      parent = cache2.getRoot().getChild(Fqn.fromString("/org/jboss/data"));
      Set children = parent.getChildren();
      //4999 because the root of the region will also be counted, as it is not resident
      assertTrue("Minimum number of base children transferred", children.size() >= 4999);

      // Sleep 2.5 secs so the nodes we are about to create in data won't
      // exceed the 4 sec TTL when eviction thread runs
      TestingUtil.sleepThread(2500);

      class Putter extends Thread
      {
         Cache<Object, Object> cache = null;
         boolean stopped = false;
         Exception ex = null;

         public void run()
         {
            int i = 25000;
            while (!stopped)
            {
               try
               {
                  cache.put(Fqn.fromString("/org/jboss/data/" + i), "key", "base" + i);
                  cache.put(Fqn.fromString("/org/jboss/test/data/" + i), "key", "data" + i);
                  i++;
               }
               catch (Exception e)
               {
                  ex = e;
               }
            }
         }
      }
      Putter p1 = new Putter();
      p1.cache = cache1;
      p1.start();
      Putter p2 = new Putter();
      p2.cache = cache2;
      p2.start();

      Random rnd = new Random();
      TestingUtil.sleepThread(rnd.nextInt(200));

      int maxCountBase = 0;
      int maxCountData = 0;
      boolean sawBaseDecrease = false;
      boolean sawDataDecrease = false;
      long start = System.currentTimeMillis();
      Node root = cache2.getRoot();
      while ((System.currentTimeMillis() - start) < 10000)
      {
         parent = root.getChild(Fqn.fromString("/org/jboss/test/data"));
         children = parent.getChildren();
         if (children != null)
         {
            int dataCount = children.size();
            if (dataCount < maxCountData)
            {
               System.out.println("data " + dataCount + " < " + maxCountData + " elapsed = " + (System.currentTimeMillis() - start));
               sawDataDecrease = true;
            }
            else
            {
               maxCountData = dataCount;
            }
         }

         parent = cache2.getRoot().getChild(Fqn.fromString("/org/jboss/data"));
         children = parent.getChildren();
         if (children != null)
         {
            int baseCount = children.size();
            if (baseCount < maxCountBase)
            {
               System.out.println("base " + baseCount + " < " + maxCountBase + " elapsed = " + (System.currentTimeMillis() - start));
               sawBaseDecrease = true;
            }
            else
            {
               maxCountBase = baseCount;
            }
         }

         if (sawDataDecrease && sawBaseDecrease)
         {
            break;
         }

         TestingUtil.sleepThread(50);
      }

      p1.stopped = true;
      p2.stopped = true;
      p1.join(1000);
      p2.join(1000);

      assertTrue("Saw data decrease", sawDataDecrease);
      assertTrue("Saw base decrease", sawBaseDecrease);
      assertNull("No exceptions in p1", p1.ex);
      assertNull("No exceptions in p2", p2.ex);

      EvictionController ec2 = new EvictionController(cache2);
      ec2.startEviction();

      parent = cache2.getRoot().getChild(Fqn.fromString("/org/jboss/test/data"));
      children = parent.getChildren();
      if (children != null)
      {
         System.out.println(children.size());
         assertTrue("Excess children evicted", children.size() <= 5);
      }
      parent = cache2.getRoot().getChild(Fqn.fromString("/org/jboss/data"));
      children = parent.getChildren();
      if (children != null)
      {
         System.out.println(children.size());
         assertTrue("Excess children evicted", children.size() <= 25000);
      }

      // Sleep more to let the eviction thread run again,
      // which will evict all data nodes due to their ttl of 4 secs
      ec2.evictRegionWithTimeToLive("/org/jboss/test/data");

      parent = cache2.getRoot().getChild(Fqn.fromString("/org/jboss/test/data"));
      if (parent != null)
      {
         children = parent.getChildren();
View Full Code Here

      assert cache0.exists(foo) : "Data should exist in data owner";
      assert cache1.exists(backupFoo) : "Buddy should have data";

      // Sleep long enough for eviction to run twice plus a bit
      new EvictionController(cache0).startEviction();
      new EvictionController(cache1).startEviction();

      // test that the data we're looking for has been evicted in both the data owner and the buddy.
      assert !cache0.exists(foo) : "Data should have evicted in data owner";
      assert !cache1.exists(backupFoo) : "Buddy should have data evicted";
View Full Code Here

      // test that the data exists in both the data owner and the buddy
      assert cache0.exists(foo) : "Data should exist in data owner";
      assert cache1.exists(backupFoo) : "Buddy should have data";

      // Kick eviction off!
      new EvictionController(cache0).startEviction();
      new EvictionController(cache1).startEviction();

      // test that the data we're looking for has been evicted in both the data owner and the buddy.
      assert !cache0.exists(foo) : "Data should have evicted in data owner";
      assert !cache1.exists(backupFoo) : "Buddy should have data evicted";
View Full Code Here

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

      new EvictionController(cache).startEviction();

      for (int i = 0; i < 5; i++)
      {
         Fqn f = Fqn.fromString(rootStr + i);
         assert null == cache.getNode(f) : f + " should be null";
View Full Code Here

      assert n != null;
      val = (String) n.get(rootStr + "7");
      assertNotNull("Node should not be empty ", val);
      retrieverThread.interrupt();
      retrieverThread.join();
      new EvictionController(cache).startEviction(true);
      assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString(rootStr + 7));
      val = (String) cache.get(rootStr + "7", rootStr + "7");
      System.out.println("-- val=" + val);
      assertNull("Node should be empty ", val);
   }
View Full Code Here

      Fqn fqn1 = Fqn.fromString(str1);
      String str2 = rootStr + "7/7";
      Fqn fqn2 = Fqn.fromString(str2);
      cache.get(fqn1, str1);// just to keep it fresh
      cache.get(fqn2, str2);// just to keep it fresh
      new EvictionController(cache).startEviction();
      cache.get(fqn1, str1);// just to keep it fresh
      cache.get(fqn2, str2);// just to keep it fresh
      new EvictionController(cache).startEviction();
      String val = (String) cache.get(rootStr + "7/7", rootStr + "7/7");
      assertNotNull("Node should not be empty ", val);
      cache.removeNode(fqn1);
      TestingUtil.sleepThread(wakeupIntervalMillis + 500);
      new EvictionController(cache).startEviction();
      val = (String) cache.get(rootStr + "7/7", rootStr + "7/7");
      assertNull("Node should be empty ", val);
   }
View Full Code Here

      {
         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

      cacheConfig.setCacheMode(Configuration.CacheMode.LOCAL);
      cache = (CacheSPI<Object, Object>) new UnitTestCacheFactory<Object, Object>().createCache(cacheConfig, false);
      cache.getConfiguration().getEvictionConfig().setWakeupInterval(1000);
      createNewRegion();
      cache.start();
      evController = new EvictionController(cache);
   }
View Full Code Here

     cache.getConfiguration().getEvictionConfig().setWakeupInterval(0);
     cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
     Object listener = new TestCacheListener();
     cache.getConfiguration().getCacheLoaderConfig().getFirstCacheLoaderConfig().setClassName(DummyInMemoryCacheLoader.class.getName());
     cache.start();
     ec = new EvictionController(cache);
     cache.getNotifier().addCacheListener(listener);
     t1_ex = t2_ex = null;
      isTrue = true;
   }
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.