private void testTwoDistributedLocks(DistributedLock lock1, DistributedLock lock2) throws Exception {
    // first lock should succeed
    assertTrue(lock1.tryLock());
    // second lock should fail since the lock is acquired by first lock
    assertFalse(lock2.tryLock());
    lock1.unlock();
    // second lock should succeed since the first lock released the lock
    assertTrue(lock2.tryLock());
    lock2.unlock();

    assertTrue(lock1.tryLock());
    assertFalse(lock2.tryLock());
    Thread.sleep(distributedLockLeaseTimeout + 500);
    // After lease timeout, the lock is free to acquire again even if it's not unlock
    assertTrue(lock2.tryLock());

    lock1.unlock();
    lock2.unlock();
    lock1.close();
    lock2.close();
  }
Test two distributed locks
@param lock1
@param lock2
@throws Exception
ambry-clustermap/src/test/java/com/github/ambry/clustermap/HelixParticipantTest.java