use of org.jgroups.blocks.locking.LockService in project JGroups by belaban.
the class LockServiceTest method testConcurrentLockRequestsFromDifferentMembers.
public void testConcurrentLockRequestsFromDifferentMembers() throws Exception {
int NUM = 10;
final CyclicBarrier barrier = new CyclicBarrier(NUM + 1);
TryLocker[] lockers = new TryLocker[NUM];
LockService[] services = { s1, s2, s3 };
for (int i = 0; i < lockers.length; i++) {
Lock mylock = services[i % services.length].getLock(LOCK);
lockers[i] = new TryLocker(mylock, barrier);
lockers[i].start();
}
barrier.await();
for (TryLocker locker : lockers) locker.join();
int num_acquired = 0;
for (TryLocker locker : lockers) {
if (locker.acquired) {
num_acquired++;
}
}
System.out.println("num_acquired = " + num_acquired);
assert num_acquired == 1 : "expected 1 but got " + num_acquired;
}
use of org.jgroups.blocks.locking.LockService in project JGroups by belaban.
the class LockService_JGRP_2234_Test method init.
@BeforeMethod
protected void init() throws Exception {
a = createChannel("A");
s1 = new LockService(a);
a.connect("LockServiceTest");
b = createChannel("B");
s2 = new LockService(b);
b.connect("LockServiceTest");
c = createChannel("C");
s3 = new LockService(c);
c.connect("LockServiceTest");
d = createChannel("D");
s4 = new LockService(d);
d.connect("LockServiceTest");
Util.waitUntilAllChannelsHaveSameView(10000, 1000, a, b, c, d);
}
Aggregations