Package org.jboss.cache.lock

Examples of org.jboss.cache.lock.LockManager


   @Override
   protected void checkLocks()
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
      LockManager lm = cr.getComponent(LockManager.class);
      InvocationContextContainer icc = cr.getComponent(InvocationContextContainer.class);

      LockAssert.assertNotLocked(A, lm, icc);
      LockAssert.assertNotLocked(Fqn.ROOT, lm, icc);
      LockAssert.assertLocked(C, lm, icc);
View Full Code Here


   @Override
   protected void checkLocksDeep()
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
      LockManager lm = cr.getComponent(LockManager.class);
      InvocationContextContainer icc = cr.getComponent(InvocationContextContainer.class);

      LockAssert.assertNotLocked(A, lm, icc);
      LockAssert.assertNotLocked(Fqn.ROOT, lm, icc);
      LockAssert.assertNotLocked(A_B_D, lm, icc);
View Full Code Here

   @Override
   protected void assertNoLocks()
   {
      CacheSPI<Object, Object> cache = cacheTL.get();
      ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);
      LockManager lm = cr.getComponent(LockManager.class);
      InvocationContextContainer icc = cr.getComponent(InvocationContextContainer.class);
      LockAssert.assertNoLocks(lm, icc);
   }
View Full Code Here

      // Pause to give caches time to see each other
      TestingUtil.blockUntilViewsReceived(new CacheSPI[]{cache1, cache2}, 60000);
      createAndActivateRegion(cache2, A_B);
      assertEquals("Incorrect name for /a/b", JOE, cache2.get(A_B, "name"));

      LockManager lockManager = cache1.getComponentRegistry().getComponent(LockManager.class);
      assert  !lockManager.isLocked(A_B);
      cache1.getRegion(A, false).deactivate();
      assert  !lockManager.isLocked(A);
      assert  !lockManager.isLocked(A_B);
      createAndActivateRegion(cache1, A_B);
      assertEquals("Incorrect name for /a/b", JOE, cache1.get(A_B, "name"));
   }
View Full Code Here

      assert !TestingUtil.extractLockManager(cache).isLocked(cache.peek(fqn, true)) : "Node " + fqn + " is locked!!";
   }

   protected void assertLocked(Object owner, Fqn fqn, boolean write_locked)
   {
      LockManager lm = TestingUtil.extractLockManager(cache);
      NodeSPI<String, String> n = cache.peek(fqn, true);
      if (owner == null) owner = Thread.currentThread();
      assertTrue("node " + fqn + " is not locked", lm.isLocked(n));
      if (write_locked)
      {
         assertTrue("node " + fqn + " is not write-locked by owner " + owner, lm.ownsLock(fqn, LockType.WRITE, owner));
      }
      else
      {
         assertTrue("node " + fqn + " is not read-locked by owner " + owner, lm.ownsLock(fqn, LockType.READ, owner));
      }
   }
View Full Code Here

   @Override
   protected void assertLocked(Object owner, Fqn fqn, boolean write_locked)
   {
      if (write_locked)
      {
         LockManager lm = TestingUtil.extractLockManager(cache);
         NodeSPI<String, String> n = cache.peek(fqn, true);
         if (owner == null) owner = Thread.currentThread();
         assertTrue("node " + fqn + " is not locked", lm.isLocked(n));
         assertTrue("node " + fqn + " is not write-locked by owner " + owner, lm.ownsLock(fqn, LockType.WRITE, owner));
      }
   }
View Full Code Here

    * @param name
    * @return
    */
   public boolean isLocked(String name)
   {
      LockManager lm = ((CacheSPI<Serializable, Object>)cache).getComponentRegistry().getComponent(LockManager.class);
      return lm.isLocked(Fqn.fromRelativeFqn(PARAMETER_ROOT, Fqn.fromString(name)));
   }
View Full Code Here

    * @throws InterruptedException
    */
   public boolean lock(String name, LockType lockType)
   {

      LockManager lm = ((CacheSPI<Serializable, Object>)cache).getComponentRegistry().getComponent(LockManager.class);
      try
      {
         return lm.lock(Fqn.fromRelativeFqn(PARAMETER_ROOT, Fqn.fromString(name)), lockType, Integer.MAX_VALUE);
      }
      catch (InterruptedException e)
      {
         log.warn("An error occurs while tryning to lock the node " + name, e);
      }
View Full Code Here

    * Releases the lock passed in
    * @param name
    */
   public void unlock(String name)
   {
      LockManager lm = ((CacheSPI<Serializable, Object>)cache).getComponentRegistry().getComponent(LockManager.class);
      lm.unlock(Fqn.fromRelativeFqn(PARAMETER_ROOT, Fqn.fromString(name)), cache.getInvocationContext()
         .getGlobalTransaction());
   }
View Full Code Here

   @Override
   protected void assertLocked(Object owner, Fqn fqn, boolean write_locked)
   {
      if (write_locked)
      {
         LockManager lm = TestingUtil.extractLockManager(cache);
         NodeSPI<String, String> n = cache.peek(fqn, true);
         if (owner == null) owner = Thread.currentThread();
         assertTrue("node " + fqn + " is not locked", lm.isLocked(n));
         assertTrue("node " + fqn + " is not write-locked by owner " + owner, lm.ownsLock(fqn, LockType.WRITE, owner));
      }
   }
View Full Code Here

TOP

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

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.