Package org.jboss.cache.loader

Examples of org.jboss.cache.loader.CacheLoader


   }

   public void testPutPassivation() throws Exception
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      CacheLoader loader = loaderTL.get();

      final Fqn NODE = Fqn.fromString("/test");
      final String KEY = "key";
      Object retval;
      cache.removeNode(NODE);// nothing to remove
      addDelay();
      retval = cache.put(NODE, KEY, 10);// put in memory
      assertNull(retval);
      retval = cache.put(NODE, KEY, 20);// put in memory
      addDelay();
      assertEquals(10, retval);// get from memory
      cache.evict(NODE, true);// passivate node
      addDelay();
      retval = cache.put(NODE, KEY, 30);// activate node then does put in memory
      assertFalse(loader.exists(NODE));
      assertEquals(20, retval);
   }
View Full Code Here


   }

   public void testPut2Passivation() throws Exception
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      CacheLoader loader = loaderTL.get();

      final Fqn NODE = Fqn.fromString("/a/b/c");
      final String KEY = "key";
      Object retval;
      cache.removeNode(NODE);// nothing to remove
      addDelay();
      retval = cache.put(NODE, KEY, 10);// put in memory
      assertNull(retval);
      addDelay();
      retval = cache.put(NODE, KEY, 20);// put in memory
      assertEquals(10, retval);
      cache.evict(NODE, true);// passivate node
      cache.evict(Fqn.fromString("/a/b"), true);// passivate parent node
      cache.evict(Fqn.fromString("/a"), true);// passivate parent node
      addDelay();
      assertTrue(loader.exists(Fqn.fromString("/a/b/c")));
      retval = cache.put(NODE, KEY, 30);// activate node, put in memory new value
      assertFalse(loader.exists(NODE));
      assertEquals(20, retval);
   }
View Full Code Here


   public void testSerializationPassivation() throws CacheException
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      CacheLoader loader = loaderTL.get();

      Fqn fqn = Fqn.fromString("/mypojo");
      SamplePojo pojo = new SamplePojo(39, "Hany");
      pojo.getHobbies().add("Running");
      pojo.getHobbies().add("Beerathlon");
      pojo.getHobbies().add("Triathlon");
      cache.put(fqn, 322649, pojo);// put in memory
      addDelay();
      assertNotNull(cache.get(fqn, 322649));// get from memory
      cache.evict(fqn, false);// passivate node
      try
      {
         assertTrue(loader.exists(fqn));
      }
      catch (Exception e)
      {
         fail(e.toString());
      }
      SamplePojo pojo2 = (SamplePojo) cache.get(fqn, 322649);// activate node
      try
      {
         assertFalse(loader.exists(fqn));
      }
      catch (Exception e)
      {
         fail(e.toString());
      }
View Full Code Here


   public void testPreloadingPassivation() throws Exception
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      CacheLoader loader = loaderTL.get();

      cache.removeNode(Fqn.ROOT);// remove nothing
      cache.put("1/2/3/4/5/d", "key", "val");// put in memory
      cache.evict(Fqn.fromString("1/2/3/4/5/d"));// passivate node
      System.out.println("-- checking for 1/2/3/4/5/d");
      addDelay();
      try
      {
         assertTrue(loader.exists(Fqn.fromString("1/2/3/4/5/d")));
      }
      catch (Exception e)
      {
         fail(e.toString());
      }
      cache.getNode("1/2/3/4/5/d");// get from loader but doesn't load attributes
      assertEquals(true, loader.exists(Fqn.fromString("1/2/3/4/5/d")));
      assert (exists("1/2/3/4/5/d"));
      System.out.println("-- 1/2/3/4/5/d exists");
      cache.get("1/2/3/4/5/d", "key");// activate node
      assertEquals(false, loader.exists(Fqn.fromString("1/2/3/4/5/d")));
   }
View Full Code Here


   public void testGetChildrenWithEvictionPassivation() throws Exception
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      CacheLoader loader = loaderTL.get();

      cache.put("/a/b/c/1", null);
      cache.put("/a/b/c/2", null);
      cache.put("/a/b/c/3", null);
      cache.evict(Fqn.fromString("/a/b/c/1"));// passivate node
      cache.evict(Fqn.fromString("/a/b/c/2"));// passivate node
      cache.evict(Fqn.fromString("/a/b/c/3"));// passivate node
      cache.evict(Fqn.fromString("/a/b/c"));// passivate node
      cache.evict(Fqn.fromString("/a/b"));// passivate node
      cache.evict(Fqn.fromString("/a"));// passivate node
      cache.evict(Fqn.fromString("/"));// passivate node
      addDelay();
      Set children = cache.getNode("/a/b/c").getChildrenNames();// load node children names
      assertNotNull(children);
      assertEquals(3, children.size());
      assertTrue(children.contains("1"));
      assertTrue(children.contains("2"));
      assertTrue(children.contains("3"));

      assertTrue(loader.exists(Fqn.fromString("/a/b/c")));

      cache.get("/a/b/c/1", "test");// load child
      cache.get("/a/b/c/2", "test");// load child
      cache.get("/a/b/c/3", "test");// load child
      cache.get("/a/b/c", "test");// load attributes

      assertFalse(loader.exists(Fqn.fromString("/a/b/c/1")));
      assertFalse(loader.exists(Fqn.fromString("/a/b/c/2")));
      assertFalse(loader.exists(Fqn.fromString("/a/b/c/3")));
      assertFalse(loader.exists(Fqn.fromString("/a/b/c")));
   }
View Full Code Here


   public void testGetChildren6Passivation() throws Exception
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      CacheLoader loader = loaderTL.get();

      cache.put("/a/1", null);// put node in memory
      cache.put("/a/2", null);// put node in memory
      cache.put("/a/3", null);// put node in memory
      cache.evict(Fqn.fromString("/a/1"));// passivate node
      cache.evict(Fqn.fromString("/a/2"));// passivate node
      cache.evict(Fqn.fromString("/a/3"));// passivate node
      cache.evict(Fqn.fromString("/a"));// passivate node
      assertTrue(loader.exists(Fqn.fromString("/a")));
      addDelay();
      assertNotNull(cache.getNode("/a"));// load node
      assertTrue(loader.exists(Fqn.fromString("/a")));// children haven't been loaded
      Set children = cache.getNode("/a").getChildrenNames();
      assertNotNull("No children were loaded", children);
      System.out.println("children: " + children);
      assertEquals("3 children weren't loaded", 3, children.size());
      cache.get("/a/1", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/1")));
      cache.get("/a/2", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/2")));
      cache.get("/a/3", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/3")));
      cache.get("/a", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a")));
   }
View Full Code Here

   }

   public void testGetChildren7Passivation() throws Exception
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      CacheLoader loader = loaderTL.get();

      cache.put("/a/1", null);
      cache.put("/a/2", null);
      cache.put("/a/3", null);
      cache.put("/a", "test", "test");
      cache.evict(Fqn.fromString("/a/1"));// passivate node
      cache.evict(Fqn.fromString("/a/2"));// passivate node
      cache.evict(Fqn.fromString("/a/3"));// passivate node
      cache.evict(Fqn.fromString("/a"));// passivate node
      assert !exists("/a");
      assertTrue(loader.exists(Fqn.fromString("/a")));
      addDelay();
      Object val = cache.get("/a", "test");// load node's attributes but not children
      assertEquals("attributes weren't loaded", "test", val);

      Set children = cache.getNode("/a").getChildrenNames();
      assertNotNull("No children were loaded", children);
      System.out.println("children: " + children);
      assertEquals("3 children weren't loaded", 3, children.size());
      cache.get("/a/1", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/1")));
      cache.get("/a/2", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/2")));
      cache.get("/a/3", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/3")));
      assertTrue(loader.exists(Fqn.fromString("/a")));
   }
View Full Code Here

   }

   public void testGetChildren8Passivation() throws Exception
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      CacheLoader loader = loaderTL.get();

      cache.put("/a/1", null);
      cache.put("/a/2", null);
      cache.put("/a/3", null);
      cache.evict(Fqn.fromString("/a/1"));// passivate node
      cache.evict(Fqn.fromString("/a/2"));// passivate node
      cache.evict(Fqn.fromString("/a/3"));// passivate node
      cache.evict(Fqn.fromString("/a"));// passivate node

      addDelay();
      assertNull(cache.get("/a", "test"));// load attributes only
      assertTrue(loader.exists(Fqn.fromString("/a")));// loaded attibutes but not children

      assertNull(cache.get("/a/1", "test"));// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/1")));// loaded attributes and has no children
      Set children = cache.getNode("/a").getChildrenNames();// load children names
      assertNotNull("No children were loaded", children);
      System.out.println("children: " + children);
      assertEquals("3 children weren't loaded", 3, children.size());
      assertTrue(loader.exists(Fqn.fromString("/a")));//loaded children but didn't initalizae them
   }
View Full Code Here

   }

   public void testGetChildren9Passivation() throws Exception
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      CacheLoader loader = loaderTL.get();

      cache.put("/a/1", null);
      cache.put("/a/2", null);
      cache.put("/a/3", null);
      cache.evict(Fqn.fromString("/a/1"));// passivate node
      cache.evict(Fqn.fromString("/a/2"));// passivate node
      cache.evict(Fqn.fromString("/a/3"));// passivate node
      cache.evict(Fqn.fromString("/a"));// passivate node
      assertTrue(loader.exists(Fqn.fromString("/a")));
      addDelay();

      cache.get("/a/1", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/1")));
      cache.get("/a/2", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/2")));
      cache.get("/a/3", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/3")));
      Set children = cache.getNode("/a").getChildrenNames();// get node's children names
      assertNotNull("No children were loaded", children);
      System.out.println("children: " + children);
      assertEquals("3 children weren't loaded", 3, children.size());
      assertNull(cache.get("/a", "test"));// load attributes and has no children by now, activation
      assertFalse(loader.exists(Fqn.fromString("/a")));

      cache.evict(Fqn.fromString("/a/1"));// passivate node
      cache.evict(Fqn.fromString("/a/2"));// passivate node
      cache.evict(Fqn.fromString("/a/3"));// passivate node
      cache.evict(Fqn.fromString("/a"));// passivate node
      assertTrue(loader.exists(Fqn.fromString("/a")));

      cache.get("/a/1", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/1")));
      cache.get("/a/2", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/2")));
      cache.get("/a/3", "test");// activate node
      assertFalse(loader.exists(Fqn.fromString("/a/3")));
      children = cache.getNode("/a").getChildrenNames();// get children names
      assertNotNull("No children were loaded", children);
      System.out.println("children: " + children);
      assertEquals("3 children weren't loaded", 3, children.size());
      assertNull(cache.get("/a", "test"));// load attributes and has no children by now, activation
      assertFalse(loader.exists(Fqn.fromString("/a")));
   }
View Full Code Here

      if (clm == null)
      {
         LOG.error("The CacheLoaderManager cannot be found");
         return;
      }
      CacheLoader currentCL = clm.getCacheLoader();
      if (currentCL == null)
      {
         LOG.error("The CacheLoader cannot be found");
         return;
      }
View Full Code Here

TOP

Related Classes of org.jboss.cache.loader.CacheLoader

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.