Package org.jboss.cache

Examples of org.jboss.cache.NodeSPI


   /**
    * Creates a new memory node in preparation for storage.
    */
   private NodeSPI createTempNode(Fqn fqn, TransactionContext transactionContext) throws Exception
   {
      NodeSPI n = createNodes(fqn, transactionContext);
      n.setDataLoaded(false);
      if (trace)
      {
         log.trace("createTempNode n " + n);
      }
      return n;
View Full Code Here


   private NodeSPI<?, ?> createNodes(Fqn fqn, TransactionContext transactionContext) throws Exception
   {
      Object[] results = dataContainer.createNodes(fqn);
      List<NodeSPI<?, ?>> createdNodes = (List<NodeSPI<?, ?>>) results[0];

      NodeSPI lastCreated = null;
      for (NodeSPI node : createdNodes)
      {
         node.setDataLoaded(false);
         if (transactionContext != null)
         {
            transactionContext.addDummyNodeCreatedByCacheLoader(node.getFqn());
         }
         lastCreated = node;
      }

      // mark the leaf node as data loaded since that is what we are doing in this interceptor.
      if (lastCreated != null) lastCreated.setDataLoaded(true);

      // regardless of whether the last node was created, return it.
      return (NodeSPI) results[1];
   }
View Full Code Here

      NodeSpiMock secondDeadNode = (NodeSpiMock) root.addChildDirect(fqnTransformer.getDeadBackupRoot(secondAddress));
      secondDeadNode.addChildDirect(Fqn.fromElements(0));


      expect(spiMock.getNode(fqn)).andReturn(null);
      NodeSPI buddyBackupRoot = (NodeSPI) root.getChild(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
      expect(containerMock.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN)).andReturn(buddyBackupRoot);

      control.checkOrder(false);
      expect(spiMock.getChildrenNames(firstDeadNode.getFqn())).andReturn(firstDeadNode.getChildrenNames());
      Object fqnElement = fqn.getLastElement();//this is only composed from one element
View Full Code Here

      assertTrue(cache.getRoot().hasChild(fqn));

      assertEquals(true, cache.removeNode(fqn));
      assertFalse(cache.getRoot().hasChild(fqn));
      // remove should REALLY remove though and not just mark as deleted/invalid.
      NodeSPI n = cache.peek(fqn, true, true);
      assert n == null;

      assertEquals(false, cache.removeNode(fqn));

      // remove should REALLY remove though and not just mark as deleted/invalid.
View Full Code Here

    * @param key
    */
   protected boolean exists(String fqn, String key)
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      NodeSPI n = cache.peek(Fqn.fromString(fqn), false, false);
      if (key == null) return n != null;
      return n != null && n.getKeysDirect().contains(key);
   }
View Full Code Here

      cache.evict(Fqn.fromString("/a/b/2"));
      // cache.evict(Fqn.fromString("/a/b/1"));
      cache.evict(Fqn.fromString("/a/b"));
      cache.evict(Fqn.fromString("/a"));

      NodeSPI n = cache.getNode("/a/b");
      assert !n.isChildrenLoaded();

      children = cache.getNode("/a/b").getChildrenNames();
      assertEquals(3, children.size());

      cache.evict(Fqn.fromString("/a/b/3"));
View Full Code Here

      c = null;
   }

   public void testRoot()
   {
      NodeSPI node = c.getRoot();
      assert ((NodeInvocationDelegate) node).getDelegationTarget() instanceof VersionedNode;
   }
View Full Code Here

   {
      Fqn A = Fqn.fromString("/a");
      Fqn B = Fqn.fromString("/b");
      Fqn A_B = Fqn.fromString("/a/b");

      NodeSPI nodeA, nodeB;

      cache.put(A, "k", "v");
      cache.put(A_B, "k", "v");

      nodeA = cache.getRoot().getChildDirect(A);// should work
      nodeB = cache.getRoot().getChildDirect(A_B);// should work

      assertEquals(A_B, nodeB.getFqn());

      nodeB = nodeA.getChildDirect(B);// should work
      assertEquals(A_B, nodeB.getFqn());
      assertEquals(true, cache.getRoot().removeChildDirect(A_B));// should work
      assertEquals(false, cache.getRoot().removeChildDirect(A_B));// should work

      cache.put(A_B, "k", "v");
      assertEquals(true, nodeA.removeChildDirect(B));// should work
      assertEquals(false, nodeA.removeChildDirect(B));// should work
      assertEquals(true, cache.getRoot().removeChildDirect(A.getLastElement()));
      assertEquals(false, cache.getRoot().removeChildDirect(A.getLastElement()));

      try
      {
         cache.getRoot().addChildDirect(A_B);// should fail
         fail("Should have failed");
      }
      catch (UnsupportedOperationException e)
      {
         // expected
      }
      nodeA = cache.getRoot().addChildDirect(A);// should work
      nodeA.addChildDirect(B);// should work
   }
View Full Code Here

      tx.begin();
      GlobalTransaction gtx = cache.getCurrentTransaction();
      cache.put("/a/b/c", null);
      cache.put("/a/b/c", null);

      NodeSPI n = cache.getNode("/a");
      assert !lockManager.isLocked(n, READ);
      // make sure this is write locked.
      assertLocked(gtx, "/a", true);

      n = cache.getNode("/a/b");
View Full Code Here

      cache.remove(f, "k1");

      assert loader.get(f).containsKey("_JBOSS_INTERNAL_OPTIMISTIC_DATA_VERSION");
      assert ((DefaultDataVersion) loader.get(f).get("_JBOSS_INTERNAL_OPTIMISTIC_DATA_VERSION")).getRawVersion() == 3;

      NodeSPI n = (NodeSPI) cache.getRoot().getChild(f);
      DataVersion dv = n.getVersion();

      assert dv instanceof DefaultDataVersion : "Should be an instance of DefaultDataVersion";

      assert ((DefaultDataVersion) dv).getRawVersion() == 3 : "Should have accurate data version";

      // now restart cache instance
      cache.stop();
      cache.start();

      assert cache.get(f, "k").equals("v") : "Value should have peristed";

      n = (NodeSPI) cache.getRoot().getChild(f);

      dv = n.getVersion();

      assert dv instanceof DefaultDataVersion : "Should be an instance of DefaultDataVersion";

      assert ((DefaultDataVersion) dv).getRawVersion() == 3 : "Version should have peristed";
      // make sure leakage doesn't occur into data map
      assert n.getData().size() == 1;
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.NodeSPI

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.