Package org.jboss.cache

Examples of org.jboss.cache.Node


   }

   public void testLazyLoadingOnNodeGetChildren() throws Exception
   {
      cache.getTransactionManager().begin();
      Node node = cache.getRoot().getChild(parent);
      assert node.getChildren().size() == 1 : "Node should have 1 child";
      WorkspaceNode n = getWorkspaceNode(parent);
      assert n.isChildrenLoaded() : "Should have loaded children";
      cache.getTransactionManager().commit();
   }
View Full Code Here


   public void testLazyLoadingOnNodeAddChild() throws Exception
   {
      Fqn newChild = Fqn.fromString("/newchild");
      cache.getTransactionManager().begin();
      Node node = cache.getRoot().getChild(parent);
      node.addChild(newChild);
      assert node.hasChild(newChild) : "Node should have added child";
      WorkspaceNode n = getWorkspaceNode(parent);
      assert !n.isChildrenLoaded() : "Should not have loaded children";
      cache.getTransactionManager().commit();
   }
View Full Code Here

   }

   public void testLazyLoadingOnNodeRemoveChild() throws Exception
   {
      cache.getTransactionManager().begin();
      Node node = cache.getRoot().getChild(parent);
      node.removeChild(child.getLastElement());
      assert !node.hasChild(child.getLastElement()) : "Node should have removed child";
      WorkspaceNode n = getWorkspaceNode(parent);
      assert !n.isChildrenLoaded() : "Should not have loaded children";
      cache.getTransactionManager().commit();
   }
View Full Code Here

      assertDataLoaded(child);
      cache.get(child, "foo2"); // does not exist, will trigger a load
      assertDataLoaded(child);

      // should not load
      Node node = cache.getRoot().getChild(parent);
      assertDataLoaded(child);
      assertDataNotLoaded(parent);

      // needs to load children at this stage in case there are other children that have been evicted.
      Set children = node.getChildren(); //getchildrennames /parent
      assertEquals(1, children.size());
      assertDataLoaded(child);
      cache.get(child, "foo"); //get /parent/child
      assertDataLoaded(child);
View Full Code Here

      // evict the parent
      cache.evict(parent, false);
      assertNull(cache.peek(parent, false));

      // now get node.
      Node n = cache.getRoot().getChild(parent);
      assertNotNull(n);
      assertDataNotLoaded(parent);

      verify(mockCacheLoader);
   }
View Full Code Here

      // evict the parent
      cache.evict(parent, false);
      assertNull(cache.peek(parent, false));

      // now get node.
      Node n = cache.getRoot().getChild(parent);
      assertNotNull(n);
      assertDataNotLoaded(parent);

      // should not load node but should change isDataLoaded to true
      // will trigger a removedata() though
      n.clearData();

      assertDataLoaded(parent);
      verify(mockCacheLoader);
   }
View Full Code Here

      retrieverThread.setDaemon(true);
      retrieverThread.start();
      assert waitForEviction(cache, 30, TimeUnit.SECONDS, Fqn.fromString(rootStr + 3));
      String val = (String) cache.get(rootStr + "3", rootStr + "3");
      assertNull("Node should be empty ", val);
      Node n = cache.getNode(fqn7);
      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));
View Full Code Here

      assertNull("Node should be empty ", val);
   }

   public void testOvereviction() throws Exception
   {
      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++)
View Full Code Here

   }


   public Entry get(String uri, MediaType accept)
   {
      Node parent = cache.getRoot().getChild(Fqn.fromElements(uri));
      if (parent == null) return null;

      for (Object obj : parent.getChildren())
      {
         Node leaf = (Node) obj;
         CacheEntry entry = (CacheEntry) leaf.get("entry");
         if (entry == null) continue;
         if (accept.isCompatible(entry.getMediaType()))
         {
            return entry;
         }
View Full Code Here

   public Entry add(String uri, MediaType mediaType, CacheControl cc, MultivaluedMap<String, Object> headers, byte[] entity, String etag)
   {
      // there's a race condition here with a concurrent get() method above.  Too bad JBoss Cache doesn't have a way to create
      // a node before hand then insert it
      CacheEntry cacheEntry = new CacheEntry(headers, entity, cc.getMaxAge(), etag, mediaType);
      Node parent = cache.getRoot().addChild(Fqn.fromElements(uri));
      Node leaf = parent.addChild(Fqn.fromElements(mediaType.toString()));
      leaf.put("entry", cacheEntry);
      leaf.put(ExpirationAlgorithmConfig.EXPIRATION_KEY, (cc.getMaxAge() * 1000) + System.currentTimeMillis());
      return cacheEntry;
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.Node

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.