Package org.jboss.cache

Examples of org.jboss.cache.Node


   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      Node<Object, Object>  rootNode = cache.getRoot();

      // creates a Node<Object, Object> with fqn /a/b/c
      Node childA = rootNode.addChild(A);
      childA.addChild(B).addChild(C);

      rootNode.getChild(A).put("key", "value");
      rootNode.getChild(A).getChild(B).put("key", "value");
      rootNode.getChild(A).getChild(B).getChild(C).put("key", "value");
View Full Code Here


      root1.addChild(fqn);
      delay();
      // cache1 should still have this
      assertTrue(root1.hasChild(fqn));
      // cache 2 should not
      Node node2 = root2.getChild(fqn);
      assertTrue("Should be null", node2 == null || (isInvalidation && !node2.isValid()));

      // now try again with passing the default options
      root1.removeChild(fqn);
      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(false);
      root1.addChild(fqn);
      delay();
      // cache1 should still have this
      assertTrue(root1.hasChild(fqn));
      // cache 2 should as well
      if (!isInvalidation)
      {
         assertTrue(root2.hasChild(fqn));
      }
      else
      {
         assertTrue("Should be null", node2 == null || !node2.isValid());
      }
   }
View Full Code Here

      // re-fetch nodeC
      nodeC = cache.getNode(Fqn.fromRelativeFqn(nodeB.getFqn(), C));

      log.info("POST MOVE " + cache);
      log.info("HC " + nodeC + " " + System.identityHashCode(nodeC));
      Node x = cache.getRoot().getChild(Fqn.fromString("b/c"));
      log.info("HC " + x + " " + System.identityHashCode(x));
      /*
         /a
         /b/c
      */
 
View Full Code Here

      CacheSPI<Object, Object> cache = cacheTL.get();
      Node<Object, Object> rootNode = cache.getRoot();

      final Fqn FQN_X = Fqn.fromString("/x");
      // set up the initial structure.
      Node aNode = rootNode.addChild(A);
      Node xNode = aNode.addChild(FQN_X);
      assertEquals(aNode.getChildren().size(), 1);
      cache.move(xNode.getFqn(), aNode.getFqn());
      assertEquals(aNode.getChildren().size(), 1);

      assert 0 == cache.getNumberOfLocksHeld();
   }
View Full Code Here

      {
         cache.put("/a/1", null);
         cache.put("/a/2", null);
         cache.put("/a/3", null);

         Node n = cache.getNode("/a");
         assertNotNull(n);

         Set children = n.getChildrenNames();
         assertNotNull(children);
         assertEquals(3, children.size());
      }
      catch (Exception e)
      {
View Full Code Here

      CacheSPI<String, String> cache1 = cache1TL.get();
      CacheSPI<String, String> cache2 = cache2TL.get();
      NodeSPI<String, String> root1 = root1TL.get();
      NodeSPI<String, String> root2 = root2TL.get();
     
      Node node1 = root1.addChild(fqn);
      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      node1.put(key, "value");
      delay();
      // cache1 should still have this
      assertEquals("value", cache1.get(fqn, key));

      // cache 2 should not
      assertNull("Should be null", cache2.get(fqn, key));

      // now try again with passing the default options
      cache1.getInvocationContext().getOptionOverrides().reset();
      node1.put(key, "value");
      delay();
      // cache1 should still have this
      assertEquals("value", cache1.get(fqn, key));

      // cache 2 should as well
      if (!isInvalidation)
      {
         assertEquals("value", cache2.get(fqn, key));
      }
      else
      {
         assertNull("should be invalidated", cache2.get(fqn, key));
      }

      // now cache2
      cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      Node node2 = root2.addChild(fqn);
      cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      node2.put(key, "value2");
      delay();
      assertEquals("value2", cache2.get(fqn, key));
      assertEquals("value", cache1.get(fqn, key));

      cache2.getInvocationContext().getOptionOverrides().reset();
      node2.put(key, "value2");
      delay();
      assertEquals("value2", cache2.get(fqn, key));
      if (!isInvalidation)
      {
         assertEquals("value2", cache1.get(fqn, key));
View Full Code Here

      NodeSPI<String, String> root2 = root2TL.get();

      Map<String, String> map = new HashMap<String, String>();
      map.put(key, "value");

      Node node1 = root1.addChild(fqn);
      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      node1.putAll(map);
      delay();
      // cache1 should still have this
      assertEquals("value", cache1.get(fqn, key));
      // cache 2 should not
      assertNull("Should be null", cache2.get(fqn, key));

      // now try again with passing the default options
      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(false);
      node1.putAll(map);
      delay();
      // cache1 should still have this
      assertEquals("value", cache1.get(fqn, key));
      // cache 2 should as well
      if (!isInvalidation)
      {
         assertEquals("value", cache2.get(fqn, key));
      }
      else
      {
         assertNull("should be invalidated", cache2.get(fqn, key));
      }

      // now cache2
      cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      Node node2 = root2.addChild(fqn);
      map.put(key, "value2");
      cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      node2.putAll(map);
      delay();
      assertEquals("value2", cache2.get(fqn, key));
      assertEquals("value", cache1.get(fqn, key));

      cache2.getInvocationContext().getOptionOverrides().reset();
      node2.put(key, "value2");
      delay();
      assertEquals("value2", cache2.get(fqn, key));
      if (!isInvalidation)
      {
         assertEquals("value2", cache1.get(fqn, key));
View Full Code Here

      CacheSPI<String, String> cache2 = cache2TL.get();
      NodeSPI<String, String> root1 = root1TL.get();
      NodeSPI<String, String> root2 = root2TL.get();

      // put some stuff in the cache first
      Node node1 = root1.addChild(fqn);
      cache1.getInvocationContext().setOptionOverrides(null);
      node1.put(key, "value");
      delay();
      assertEquals("value", cache1.get(fqn, key));
      if (isInvalidation)
      {
         assertNull("Should be null", cache2.get(fqn, key));
      }
      else
      {
         assertEquals("value", cache2.get(fqn, key));
      }

      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      node1.remove(key);
      delay();

      // should be removed in cache1
      assertNull("should be null", cache1.get(fqn, key));
      // Not in cache2
      if (isInvalidation)
      {
         assertNull("Should be null", cache2.get(fqn, key));
      }
      else
      {
         assertEquals("value", cache2.get(fqn, key));
      }

      // replace cache entries
      node1.put(key, "value");
      delay();
      assertEquals("value", cache1.get(fqn, key));
      if (isInvalidation)
      {
         assertNull("Should be null", cache2.get(fqn, key));
      }
      else
      {
         assertEquals("value", cache2.get(fqn, key));
      }

      // now try again with passing the default options
      cache1.getInvocationContext().getOptionOverrides().reset();
      node1.remove(key);
      delay();

      // both should be null
      assertNull("should be null", cache1.get(fqn, key));
      assertNull("should be null", cache2.get(fqn, key));
View Full Code Here

      CacheSPI<String, String> cache1 = cache1TL.get();
      CacheSPI<String, String> cache2 = cache2TL.get();
      NodeSPI<String, String> root1 = root1TL.get();
      NodeSPI<String, String> root2 = root2TL.get();

      Node node1 = root1.addChild(fqn);
      TransactionManager mgr = cache1.getTransactionManager();
      mgr.begin();
      cache1.getInvocationContext().getOptionOverrides().reset();
      node1.put(key, "value1");
      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      node1.put(key, "value2");
      mgr.commit();
      delay();
      // cache1 should still have this
      assertEquals("value2", cache1.get(fqn, key));

      if (!isInvalidation)
      {
         assertEquals("value1", cache2.get(fqn, key));
      }
      else
      {
         assertNull(cache2.get(fqn, key));
      }

      // now try again with passing the default options
      mgr.begin();
      cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      node1.put(key, "value3");
      cache1.getInvocationContext().getOptionOverrides().reset();
      node1.put(key, "value");
      mgr.commit();
      delay();
      // cache1 should still have this
      assertEquals("value", cache1.get(fqn, key));

      // cache 2 should as well
      if (!isInvalidation)
      {
         assertEquals("value", cache2.get(fqn, key));
      }
      else
      {
         assertNull("should be invalidated", cache2.get(fqn, key));
      }

      // now cache2
      Node node2 = root2.addChild(fqn);
      mgr = cache2.getTransactionManager();
      mgr.begin();
      cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(false);
      node2.put(key, "value3");
      cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      node2.put(key, "value2");
      mgr.commit();
      delay();

      assertEquals("value2", cache2.get(fqn, key));

      if (!isInvalidation)
      {
         assertEquals("value3", cache1.get(fqn, key));
      }
      else
      {
         assertNull(cache1.get(fqn, key));
      }

      mgr.begin();
      cache2.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
      node2.put(key, "value2");
      cache2.getInvocationContext().getOptionOverrides().reset();
      node2.put(key, "value4");
      mgr.commit();
      delay();
      assertEquals("value4", cache2.get(fqn, key));
      if (!isInvalidation)
      {
View Full Code Here

         cleanBeanRegion();
         region.activate();
      }
     
      // JBCACHE-1349 -- ensure root node exists
      Node regionRoot = cache.getNode(cacheNode);
      if (regionRoot == null)
      {
         regionRoot = cache.getRoot().addChild(cacheNode);
      }
      regionRoot.setResident(true);
     
      log.debug("started(): created region: " +region + " for ejb: " + ejbContainer.getEjbName());
     
      // register to listen for cache events
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.