Package org.infinispan.util.concurrent.locks

Examples of org.infinispan.util.concurrent.locks.LockManager


   /**
    * Verifies the cache doesn't contain any lock
    * @param cache
    */
   public static void assertNoLocks(Cache<?,?> cache) {
      LockManager lm = TestingUtil.extractLockManager(cache);
      for (Object key : cache.keySet()) assert !lm.isLocked(key);
   }
View Full Code Here


       */
      public int compareTo(ChangesContainer o)
      {
         // We use the lock manager to sort the key in order to be able
         // to use the lock stripping more details here https://issues.jboss.org/browse/ISPN-993
         LockManager lm = cache.getLockManager();
         int result = lm.getLockId(key) - lm.getLockId(o.getKey());
         return result == 0 ? historicalIndex - o.getHistoricalIndex() : result;
      }
View Full Code Here

      assert isNodeLocked(A_B_C_E);
   }

   protected void assertNoLocks() {
      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

   protected ThreadLocal<TransactionManager> tmTL = new ThreadLocal<TransactionManager>();
   protected ThreadLocal<TreeCache> treeCacheTL = new ThreadLocal<TreeCache>();

   protected void checkLocks() {
      Cache<Object, Object> cache = cacheTL.get();
      LockManager lm = TestingUtil.extractLockManager(cache);
      assert !TreeStructureSupport.isLocked(lm, A);
      assert !TreeStructureSupport.isLocked(lm, Fqn.ROOT);
      assert TreeStructureSupport.isLocked(lm, C);
      assert TreeStructureSupport.isLocked(lm, A_B);
      assert TreeStructureSupport.isLocked(lm, A_B_C);
View Full Code Here

      assert TreeStructureSupport.isLocked(lm, A_B_C);
   }

   protected void checkLocksDeep() {
      Cache<Object, Object> cache = cacheTL.get();
      LockManager lm = TestingUtil.extractLockManager(cache);
      assert !TreeStructureSupport.isLocked(lm, A);
      assert !TreeStructureSupport.isLocked(lm, Fqn.ROOT);
      assert !TreeStructureSupport.isLocked(lm, A_B_D);

      assert TreeStructureSupport.isLocked(lm, C);
View Full Code Here

      assert TreeStructureSupport.isLocked(lm, A_B_C_E);
   }

   protected void assertNoLocks() {
      Cache<Object, Object> cache = cacheTL.get();
      LockManager lm = TestingUtil.extractLockManager(cache);
      for (Object key : cache.keySet()) assert !lm.isLocked(key);
   }
View Full Code Here

   protected void assertLocked(Cache cache, Object key) {
      assert checkLocked(cache, key) : "expected key '" + key + "' to be locked on cache " + cache + ", but it is not";
   }

   protected boolean checkLocked(Cache cache, Object key) {
      LockManager lockManager = TestingUtil.extractLockManager(cache);
      return lockManager.isLocked(key);
   }
View Full Code Here

      asserLocked(c2, false, k1, k2);
      checkOwnership(k1, k2, "new_value1", "new_value2");
   }

   void asserLocked(Cache c, boolean isLocked, Object... keys) {
      LockManager lm = TestingUtil.extractComponent(c, LockManager.class);
      for (Object key : keys) {
         assert isLocked == lm.isLocked(key) : " expecting key '" + key + "' to be " + (isLocked ? " locked " :
               "not locked + \n Lock owner is:" + lm.getOwner(key));
      }
   }
View Full Code Here

      MagicKey k2 = new MagicKey("k2", c2); // maps on to c2 and c3

      init(k1, k2);

      TransactionManager tm4 = getTransactionManager(c4);
      LockManager lockManager4 = TestingUtil.extractComponent(c4, LockManager.class);

      tm4.begin();
      Object ret = c4.putIfAbsent(k1, "new_value");
      if (testRetVals) assert "value1".equals(ret) : "Was expecting value1 but was " + ret;
      ret = c4.putIfAbsent(k2, "new_value");
      if (testRetVals) assert "value2".equals(ret) : "Was expecting value2 but was " + ret;

      assert c4.get(k1).equals("value1");
      assert c4.get(k2).equals("value2");

      assert lockManager4.isLocked(k1);
      assert lockManager4.isLocked(k2);

      tm4.rollback();

      assert !lockManager4.isLocked(k1);
      assert !lockManager4.isLocked(k2);

      assert c2.get(k1).equals("value1");
      assert c2.get(k2).equals("value2");

      assertIsInContainerImmortal(c1, k1);
View Full Code Here

      if (!exceptions.isEmpty()) throw exceptions.get(0);
      assertNoLocks();
   }

   private void assertNoLocks() {
      LockManager lm = TestingUtil.extractLockManager(cache);
      LockAssert.assertNoLocks(
            lm, TestingUtil.extractComponentRegistry(cache).getComponent(InvocationContextContainer.class)
      );

      LockContainer lc = (LockContainer) TestingUtil.extractField(lm, "lockContainer");
View Full Code Here

TOP

Related Classes of org.infinispan.util.concurrent.locks.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.