Package org.olat.core.util.coordinate

Examples of org.olat.core.util.coordinate.Locker


    LockImpl l3 = cm.findLock(asset);
    assertNull(l3);
   
   
    // ------------------ test the clusterlocker ----------------------   
    Locker cl = CoordinatorManager.getCoordinator().getLocker();
   
    // acquire
    LockResult res1 = cl.acquireLock(ores, ident, "abc");
    assertTrue(res1.isSuccess());
    DBFactory.getInstance().closeSession();
   
    // reacquire same identity (get from db)
    LockResult res11 = cl.acquireLock(ores, ident, "abc");
    long lock1Ac = res11.getLockAquiredTime();
    assertTrue(res11.isSuccess());
    DBFactory.getInstance().closeSession();

    // acquire by another identity must fail
    LockResult res2 = cl.acquireLock(ores, ident2, "abc");
    assertFalse(res2.isSuccess());
    DBFactory.getInstance().closeSession();

    // reacquire same identity
    LockResult res3 = cl.acquireLock(ores, ident, "abc");
    assertTrue(res3.isSuccess());
    DBFactory.getInstance().closeSession();

    // test the admin
    List<LockEntry> entries = cl.adminOnlyGetLockEntries();
    assertEquals(1, entries.size());
    LockEntry le = entries.get(0);
    // must be original owner
    assertEquals(le.getOwner().getName(), ident.getName());

    // release lock
    cl.releaseLock(res3);
    DBFactory.getInstance().closeSession();
    // test the admin
    entries = cl.adminOnlyGetLockEntries();
    assertEquals(0,entries.size());

    // make sure it is not locked anymore
    boolean lo = cl.isLocked(ores, "abc");
    assertFalse(lo);
   
   
   
   
View Full Code Here

TOP

Related Classes of org.olat.core.util.coordinate.Locker

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.