final HazelcastInstance keyOwner = nodeFactory.newHazelcastInstance();
warmUpPartitions(instance, keyOwner);
final String key = generateKeyOwnedBy(keyOwner);
final ILock lock = instance.getLock(key);
final ICondition condition = lock.newCondition(name);
final CountDownLatch awaitLatch = new CountDownLatch(size);
final CountDownLatch finalLatch = new CountDownLatch(size);
for (int i = 0; i < size; i++) {
new Thread(new Runnable() {
public void run() {
lock.lock();
try {
awaitLatch.countDown();
condition.await();
if (lock.isLockedByCurrentThread()) {
count.incrementAndGet();
}
} catch (InterruptedException ignored) {
} finally {
lock.unlock();
finalLatch.countDown();
}
}
}).start();
}
ILock lock1 = keyOwner.getLock(key);
ICondition condition1 = lock1.newCondition(name);
awaitLatch.await(1, TimeUnit.MINUTES);
lock1.lock();
condition1.signalAll();
lock1.unlock();
keyOwner.shutdown();
finalLatch.await(2, TimeUnit.MINUTES);
assertEquals(size, count.get());
}