Package org.jboss.cache.lock

Examples of org.jboss.cache.lock.NodeLock


      Map nodeMap = w.getNodes();
      for (Iterator i = nodeMap.keySet().iterator(); i.hasNext();)
      {
         WorkspaceNode wn = (WorkspaceNode) nodeMap.get(i.next());
         NodeSPI n = wn.getNode();
         NodeLock lock = n.getLock();
         if (lock.isLocked())
         {
            actual.put(n.getFqn(), lock.isReadLocked() ? READ : WRITE);
         }
      }

      return super.invoke(ctx);
   }
View Full Code Here


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

      NodeSPI n = (NodeSPI) cache.getNode("/a");
      NodeLock lock = n.getLock();
      int num = lock.getReaderOwners().size();
      assertEquals(0, num);
      // make sure this is write locked.
      assertLocked(gtx, "/a", true);

      n = (NodeSPI) cache.getNode("/a/b");
      lock = n.getLock();
      num = lock.getReaderOwners().size();
      assertEquals(0, num);
      // make sure this is write locked.
      assertLocked(gtx, "/a/b", true);

      n = (NodeSPI) cache.getNode("/a/b/c");
      lock = n.getLock();
      num = lock.getReaderOwners().size();
      assertEquals(0, num);
      // make sure this is write locked.
      assertLocked(gtx, "/a/b/c", true);

      tx.rollback();
View Full Code Here

   }

   private void assertLocked(Object owner, String fqn, boolean write_locked)
   {
      NodeSPI<String, Comparable> n = cache.peek(Fqn.fromString(fqn), true);
      NodeLock lock = n.getLock();
      if (owner == null)
      {
         owner = Thread.currentThread();
      }
      assertTrue("node " + fqn + " is not locked", lock.isLocked());
      if (write_locked)
      {
         assertTrue("node " + fqn + " is not write-locked" + (lock.isReadLocked() ? " but is read-locked instead!" : "!"), lock.isWriteLocked());
      }
      else
      {
         assertTrue("node " + fqn + " is not read-locked" + (lock.isWriteLocked() ? " but is write-locked instead!" : "!"), lock.isReadLocked());
      }
      assertTrue("owner " + owner + "is not owner", lock.isOwner(owner));
   }
View Full Code Here

         // scan workspaces for this node
         assertNotNull("node " + fqn + " should be in transaction workspace", workspace.getNode(fqn));
      }
      else
      {
         NodeLock lock = n.getLock();
         assertTrue("node " + fqn + " is not locked", lock.isLocked());
         if (write_locked)
         {
            assertTrue("node " + fqn + " is not write-locked" + (lock.isReadLocked() ? " but is read-locked instead!" : "!"), lock.isWriteLocked());
         }
         else
         {
            assertTrue("node " + fqn + " is not read-locked" + (lock.isWriteLocked() ? " but is write-locked instead!" : "!"), lock.isReadLocked());
         }
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.lock.NodeLock

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.