ZKClientService zkClient1 = createZKClient(); ZKClientService zkClient2 = createZKClient(); try { final Lock[] locks = new Lock[] {
@Test (timeout = 20000) public void testLockInterrupt() throws InterruptedException { ZKClientService zkClient = createZKClient(); try { final ReentrantDistributedLock lock = new ReentrantDistributedLock(zkClient, "/interrupt");
@Test (timeout = 20000) public void testMultiThreads() throws InterruptedException { ZKClientService zkClient = createZKClient(); try {
@Test (timeout = 200000) public void testLockInterruptMultiClients() throws InterruptedException { ZKClientService zkClient1 = createZKClient(); ZKClientService zkClient2 = createZKClient(); try { final ReentrantDistributedLock lock1 = new ReentrantDistributedLock(zkClient1, "/multiInterrupt");
ZKClientService zkClient1 = createZKClient(); ZKClientService zkClient2 = createZKClient(); try {
@Test (timeout = 20000) public void testTryLockMultiClients() throws InterruptedException { ZKClientService zkClient1 = createZKClient(); ZKClientService zkClient2 = createZKClient(); try { final ReentrantDistributedLock lock1 = new ReentrantDistributedLock(zkClient1, "/multiTrylock");
@Test (timeout = 20000) public void testTryLock() throws InterruptedException { ZKClientService zkClient = createZKClient(); try { final ReentrantDistributedLock lock = new ReentrantDistributedLock(zkClient, "/trylock");
@Test (timeout = 20000) public void testReentrant() { // Test the lock is reentrant from the same thread ZKClientService zkClient = createZKClient(); try { ReentrantDistributedLock lock = new ReentrantDistributedLock(zkClient, "reentrant"); lock.lock(); try { try { lock.lock(); } finally { lock.unlock(); } } finally { lock.unlock(); } } finally { zkClient.stopAndWait(); } }