Package org.jboss.cache.loader

Examples of org.jboss.cache.loader.CacheLoader


            false, true, true);// start

      // Pause to give caches time to see each other
      TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);

      CacheLoader loader = cache2.getCacheLoaderManager().getCacheLoader();

      assertNull("/a/b not transferred to loader", loader.get(A_B));

      assertNull("/a/b not transferred to cache", cache2.get(A_B, "person"));

      ClassLoader cl2 = getClassLoader();

      //      cache2.registerClassLoader(A, cl2);
      Region r = cache2.getRegion(A, true);
      r.registerContextClassLoader(cl2);

      r.activate();

      assertEquals("Correct state from loader for /a/b", ben.toString(), getUnmarshalled(loader.get(A_B).get("person")).toString());

      assertEquals("Correct state from cache for /a/b", ben.toString(), getUnmarshalled(cache2.get(A_B, "person")).toString());

   }
View Full Code Here


   {
      CacheSPI c1 = createCache("1", true, false, true, true);
      c1.put(A, "K", "V");

      assert c1.get(A, "K").equals("V");
      CacheLoader l1 = c1.getCacheLoaderManager().getCacheLoader();
      assert l1 != null;

      assert l1.exists(A);
      assert l1.get(A).get("K").equals("V");

      // test persistence
      c1.stop();

      assert l1.exists(A);
      assert l1.get(A).get("K").equals("V");

      Cache c2 = createCache("2", true, false, true, true);

      c2.put(B, "K", "V");

      assert c1.getConfiguration().isFetchInMemoryState();
      assert c1.getConfiguration().getCacheLoaderConfig().isFetchPersistentState();
      c1.start();

      assert c1.get(B, "K").equals("V");
      assert c1.get(A, "K") == null;
      assert !l1.exists(A);
   }
View Full Code Here


   public void testGetChildren10Passivation() 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();
      assertTrue(loader.exists(Fqn.fromString("/a")));
      assertNull(cache.get("/a", "test"));// load attributes from loader
      // don't remove from loader though since children may be present
      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");// passivate node
      assertFalse(loader.exists(Fqn.fromString("/a/3")));
      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());

      assertNull(cache.get("/a", "test"));// activate node
      assertFalse(loader.exists(Fqn.fromString("/a")));
   }
View Full Code Here


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

      Set<Object> keys;
      Fqn key = Fqn.fromString("/x/y/z/");
      cache.put(key, "keyA", "valA");
      cache.put(key, "keyB", "valB");
      cache.put(key, "keyC", "valC");
      addDelay();
      keys = cache.getNode(key).getKeys();
      assertEquals(3, keys.size());
      cache.getNode(key).clearData();
      cache.evict(key);// passivate node

      addDelay();
      keys = cache.getNode(key).getKeys();// activate node
      assertFalse(loader.exists(key));
      assertEquals(0, keys.size());
   }
View Full Code Here

   }

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

      Set<Object> keys;
      Fqn key = Fqn.fromString("/x/y/z/");
      cache.put(key, "keyA", "valA");
      cache.put(key, "keyB", "valB");
      cache.put(key, "keyC", "valC");
      keys = cache.getNode(key).getKeys();
      assertEquals(3, keys.size());
      cache.evict(key);// passivate node
      assertTrue(loader.exists(key));
      cache.getNode(key).clearData();
      keys = cache.getNode(key).getKeys();// activate node
      assertFalse(loader.exists(key));
      assertEquals(0, keys.size());
   }
View Full Code Here

   }

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

      final Fqn NODE = Fqn.fromString("/test");
      final String KEY = "key";
      Object retval = null;
      cache.removeNode(NODE);
      retval = cache.put(NODE, KEY, 10);
      assertNull(retval);

      cache.evict(NODE);// passivate node
      addDelay();
      assertTrue(loader.exists(NODE));
      assertEquals(10, loader.get(NODE).get(KEY));
      retval = cache.remove(NODE, KEY);// activate node
      assertEquals(10, retval);
      assertFalse(loader.exists(NODE));

      cache.evict(NODE);// passiave node
      addDelay();
      retval = cache.remove(NODE, KEY);// activate node
      assertFalse(loader.exists(NODE));
      assertNull(retval);
   }
View Full Code Here


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

      cache.put("/first/second", "key1", "val1");
      cache.put("/first/second/third", "key2", "val2");
      cache.evict(Fqn.fromString("/first/second"));// pasivate node to cache loader
      addDelay();
      assertTrue(loader.exists(Fqn.fromString("/first/second")));
      assert (exists("/first"));
      String val = (String) cache.get("/first/second", "key1");
      assertTrue(loader.exists(Fqn.fromString("/first/second")));
      assertEquals("val1", val);
      String val2 = (String) cache.get("/first/second/third", "key2");// activate node
      assertFalse(loader.exists(Fqn.fromString("/first/second/third")));
      assertEquals("val2", val2);
      assert (exists("/first/second/third"));
      assert (exists("/first/second"));
      assert (exists("/first"));
   }
View Full Code Here


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

      cache.put("/first/second/third", "key1", "val1");// stored in cache loader
      cache.evict(Fqn.fromString("/first/second/third"));// passivate node, note: it has no children
      addDelay();
      assertTrue(loader.exists(Fqn.fromString("/first/second/third")));
      assert (exists("/first/second"));
      assert (exists("/first"));
      String val = (String) cache.get("/first/second/third", "key1");// activate node
      assertFalse(loader.exists(Fqn.fromString("/first/second/third")));
      assertEquals("val1", val);
      assert (exists("/first/second/third"));
      assert (exists("/first/second"));
      assert (exists("/first"));
   }
View Full Code Here


   public void testEvictionWithGetChildrenNamesPassivation() 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
      assertTrue(loader.exists(Fqn.fromString("/a/1")));
      cache.evict(Fqn.fromString("/a/2"));// passivate node
      assertTrue(loader.exists(Fqn.fromString("/a/2")));
      cache.evict(Fqn.fromString("/a/3"));// passivate node
      assertTrue(loader.exists(Fqn.fromString("/a/3")));
      cache.evict(Fqn.fromString("/a"));// passivate node
      assertTrue(loader.exists(Fqn.fromString("/a")));
      addDelay();
      DummyTransactionManager mgr = DummyTransactionManager.getInstance();
      mgr.begin();
      mgr.getTransaction();
      Set<?> children = cache.getNode("/a").getChildrenNames();
View Full Code Here

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

      Fqn f = Fqn.fromString("/a");
      assert !cache.exists(f);
      assert !loader.exists(f);     
     
      Map<Object, Object> input = new HashMap();
      input.put("one", "one");
      input.put("two", "two");
      cache.put(f, input);
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.